using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("PoVPlanterFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PoVPlanterFix")] [assembly: AssemblyTitle("PoVPlanterFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PoVPlanterFix { [BepInPlugin("groshyr.povplanterfix", "PoVPlanterFix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "groshyr.povplanterfix"; private const string PovGuid = "treextr.pathofvalheiman"; private const string OdinArchitectGuid = "Raelaziel.OdinArchitect"; private const string SoilName = "oa_soil"; private static readonly Collider[] Hits = (Collider[])(object)new Collider[64]; private static readonly Collider[] Near = (Collider[])(object)new Collider[128]; private static readonly RaycastHit[] Down = (RaycastHit[])(object)new RaycastHit[16]; private static int _soilMask; private static int _spaceMask; private void Awake() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0218: Expected O, but got Unknown _soilMask = LayerMask.GetMask(new string[5] { "piece", "piece_nonsolid", "terrain", "static_solid", "Default" }); _spaceMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" }); Type type = AccessTools.TypeByName("PassiveTree.MassPlant"); Type type2 = AccessTools.TypeByName("PassiveTree.Farming"); MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "Ground", new Type[2] { typeof(Vector3), typeof(Vector3).MakeByRefType() }, (Type[])null) : null); MethodInfo item = ((type != null) ? AccessTools.Method(type, "Free", new Type[2] { typeof(Plant), typeof(Vector3) }, (Type[])null) : null); MethodInfo item2 = ((type2 != null) ? AccessTools.Method(type2, "Room", new Type[3] { typeof(Plant), typeof(Vector3), typeof(float) }, (Type[])null) : null); Harmony val = new Harmony("groshyr.povplanterfix"); List list = new List(); if (methodInfo != null) { val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "GroundOnSoil", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); list.Add("mass planting on soil"); } (MethodInfo, string)[] array = new(MethodInfo, string)[2] { (item, "mass planting space"), (item2, "dense planting space") }; for (int i = 0; i < array.Length; i++) { var (methodInfo2, item3) = array[i]; if (methodInfo2 != null) { val.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "ClearPlanter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "RestorePlanter", (Type[])null), (HarmonyMethod)null); list.Add(item3); } } if (list.Count < 3) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Path of Valheiman's planting code was not all found (PoV changed?); only patched: " + string.Join(", ", list))); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Path of Valheiman's farming perks work in OdinArchitect planters: " + string.Join(", ", list))); } private static Piece PlanterAt(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapBoxNonAlloc(point, new Vector3(0.05f, 0.12f, 0.05f), Hits, Quaternion.identity, _soilMask, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if ((Object)(object)Hits[i] != (Object)null && ((Object)Hits[i]).name == "oa_soil") { return ((Component)Hits[i]).GetComponentInParent(); } } return null; } private static void GroundOnSoil(Vector3 at, ref Vector3 ground, ref bool __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) int num = Physics.RaycastNonAlloc(at + Vector3.up * 4f, Vector3.down, Down, 12f, -1, (QueryTriggerInteraction)1); RaycastHit val = default(RaycastHit); bool flag = false; for (int i = 0; i < num; i++) { if ((Object)(object)((RaycastHit)(ref Down[i])).collider != (Object)null && ((Object)((RaycastHit)(ref Down[i])).collider).name == "oa_soil" && (!flag || ((RaycastHit)(ref Down[i])).distance < ((RaycastHit)(ref val)).distance)) { val = Down[i]; flag = true; } } if (flag && (!__result || !(ground.y > ((RaycastHit)(ref val)).point.y + 0.05f))) { ground = ((RaycastHit)(ref val)).point; __result = Vector3.Angle(((RaycastHit)(ref val)).normal, Vector3.up) < 25f; } } private static void ClearPlanter(Plant plant, Vector3 at, out List __state) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) __state = null; if ((Object)(object)plant == (Object)null || (Object)(object)PlanterAt(at) == (Object)null) { return; } __state = new List(); int num = Physics.OverlapSphereNonAlloc(at, Mathf.Max(plant.m_growRadius, 0.2f) + 0.5f, Near, _spaceMask); for (int i = 0; i < num; i++) { Collider val = Near[i]; if (!((Object)(object)val == (Object)null) && val.enabled && !val.isTrigger && !((Component)val).transform.IsChildOf(((Component)plant).transform) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent() != (Object)null)) { val.enabled = false; __state.Add(val); } } } private static void RestorePlanter(List __state) { if (__state == null) { return; } foreach (Collider item in __state) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } } } }