Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FarmGrid TT v1.1.2
plugins\TeflonTed.FarmGrid.dll
Decompiled 19 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("TeflonTed.FarmGrid")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Teflon Ted's Farm Grid — snap cultivator planting to optimally spaced rows")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+aa3557958a7656958068f9c07e5ebb364e91eab7")] [assembly: AssemblyProduct("TeflonTed.FarmGrid")] [assembly: AssemblyTitle("TeflonTed.FarmGrid")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [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 TeflonTed.FarmGrid { [BepInPlugin("com.teflonted.valheim.farmgrid", "Teflon Ted's Farm Grid", "1.1.2")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.teflonted.valheim.farmgrid"; public const string PluginName = "Teflon Ted's Farm Grid"; public const string PluginVersion = "1.1.2"; private void Awake() { Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.teflonted.valheim.farmgrid"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Teflon Ted's Farm Grid 1.1.2 loaded"); } private void OnDestroy() { FarmGrid.DestroyFarmGrid(); } } internal static class FarmGrid { private sealed class PlantObject { internal Vector3 Position; internal readonly float Growth; internal readonly int Id; internal PlantObject(Vector3 position, float growth, int id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Position = position; Growth = growth; Id = id; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPriority(0)] private static class ZNetScene_Awake_Patch { private static void Postfix() { SetupPlantCache(); } } [HarmonyPatch(typeof(Player), "SetupPlacementGhost")] private static class Player_SetupPlacementGhost_Patch { private static void Postfix() { ResetCache(); SetGhostPlant(); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private static class Player_UpdatePlacementGhost_Patch { private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } ItemData rightItem = ((Humanoid)__instance).GetRightItem(); if (rightItem?.m_shared == null || rightItem.m_shared.m_name != "$item_cultivator") { HideFarmGrid(); ResetCache(); return; } if (_ghost == null) { SetGhostPlant(); } if (_ghost == null) { HideFarmGrid(); } else { ApplySnap(); } } } private const float ExtraSpacing = 0.1f; private const int GridSections = 2; private const float GridYOffset = 0.1f; private static readonly Color GridColor = new Color(0f, 1f, 0f, 0.35f); private static readonly string[] PlantLayers = new string[6] { "Default", "Default_small", "item", "piece", "piece_nonsolid", "static_solid" }; private static readonly Dictionary<string, float> VanillaDefaults = new Dictionary<string, float> { { "BlueberryBush", 0.5f }, { "CloudberryBush", 0.5f }, { "RaspberryBush", 0.5f }, { "Pickable_Dandelion", 0.5f }, { "Pickable_Fiddlehead", 0.5f }, { "Pickable_Mushroom", 0.5f }, { "Pickable_Mushroom_blue", 0.5f }, { "Pickable_Mushroom_yellow", 0.5f }, { "Pickable_SmokePuff", 0.5f }, { "Pickable_Thistle", 0.5f } }; private static readonly Dictionary<string, float> PlantSizes = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase); private static int _plantMask; private static Vector3 _snapPoint = Vector3.zero; private static GameObject[] _farmGrid; private static bool _farmGridVisible; private static PlantObject _ghost; private static Vector3 _ghostPos; private static Material _lineMaterial; private static bool _freeDraw = true; internal static void SetupPlantCache() { if ((Object)(object)ZNetScene.instance == (Object)null) { return; } PlantSizes.Clear(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } Plant component = prefab.GetComponent<Plant>(); if ((Object)(object)component == (Object)null || PlantSizes.ContainsKey(((Object)component).name)) { continue; } PlantSizes[((Object)component).name] = component.m_growRadius; if (component.m_grownPrefabs == null) { continue; } GameObject[] grownPrefabs = component.m_grownPrefabs; foreach (GameObject val in grownPrefabs) { if ((Object)(object)val != (Object)null && !PlantSizes.ContainsKey(((Object)val).name)) { PlantSizes[((Object)val).name] = component.m_growRadius; } } } foreach (KeyValuePair<string, float> vanillaDefault in VanillaDefaults) { if (!PlantSizes.ContainsKey(vanillaDefault.Key)) { PlantSizes[vanillaDefault.Key] = vanillaDefault.Value; } } _plantMask = LayerMask.GetMask(PlantLayers); if (_plantMask == 0) { _plantMask = -1; } } private static float Spacing(float growth) { return growth * 2f + 0.1f; } private static float SearchRadius(PlantObject plant) { return Spacing(plant.Growth) * 3f; } private static float EffectiveGrowth(float growRadius, Component host) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, growRadius); if ((Object)(object)host == (Object)null) { return num; } Collider[] componentsInChildren = host.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && val.enabled) { Bounds bounds = val.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; num = Mathf.Max(new float[3] { num, extents.x, extents.z }); } } return num; } private static string PrefabName(string name) { if (string.IsNullOrEmpty(name)) { return string.Empty; } int num = name.IndexOfAny(new char[2] { '(', ' ' }); if (num < 0) { return name; } return name.Substring(0, num); } private static bool TryGetSize(string prefab, out float size) { string key = PrefabName(prefab); if (PlantSizes.TryGetValue(key, out size)) { return true; } size = 0f; return false; } private static bool TryGetPlant(Collider collider, out PlantObject plant) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) plant = null; if ((Object)(object)collider == (Object)null) { return false; } Plant val = ((Component)collider).GetComponentInParent<Plant>() ?? ((Component)collider).GetComponentInChildren<Plant>(true); Vector3 position; int instanceID; Component host; float size; if ((Object)(object)val != (Object)null) { string prefab = PrefabName(((Object)((Component)val).gameObject).name); position = ((Component)val).transform.position; instanceID = ((Object)val).GetInstanceID(); host = (Component)(object)val; if (!TryGetSize(prefab, out size)) { size = Mathf.Max(0f, val.m_growRadius); } } else { Transform val2 = (((Object)(object)((Component)collider).transform.root != (Object)null) ? ((Component)collider).transform.root : ((Component)collider).transform); if (!TryGetSize(PrefabName(((Object)val2).name), out size)) { return false; } position = val2.position; instanceID = ((Object)val2).GetInstanceID(); host = (Component)(object)val2; } plant = new PlantObject(position, EffectiveGrowth(size, host), instanceID); return true; } private static List<PlantObject> FindNearby(Vector3 position, float radius) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Collider[] s_pieceColliders = Piece.s_pieceColliders; int count = Physics.OverlapSphereNonAlloc(position, radius, s_pieceColliders, _plantMask); IOrderedEnumerable<Collider> orderedEnumerable = s_pieceColliders.Take(count).OrderBy(delegate(Collider c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = ((Component)c).transform.position - (_ghost?.Position ?? position); return ((Vector3)(ref val2)).sqrMagnitude; }); List<PlantObject> list = new List<PlantObject>(); HashSet<int> hashSet = new HashSet<int>(); foreach (Collider item in orderedEnumerable) { if (!TryGetPlant(item, out var plant)) { continue; } if (_ghost != null) { Vector3 val = plant.Position - _ghost.Position; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { continue; } } if (hashSet.Add(plant.Id)) { list.Add(plant); if (list.Count >= 24) { break; } } } return list; } private static bool Overlaps(Vector3 pos, List<PlantObject> others, float growth) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < others.Count; i++) { Vector3 val = pos - others[i].Position; if (((Vector3)(ref val)).magnitude <= growth + others[i].Growth) { return true; } } return false; } private static float GroundY(Vector3 pos) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZoneSystem.instance != (Object)null)) { return pos.y; } return ZoneSystem.instance.GetGroundHeight(pos); } private static void DrawFreeGrid(PlantObject root) { //IL_0005: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = _ghost.Position - root.Position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.forward; } else { ((Vector3)(ref val)).Normalize(); } _freeDraw = true; float num = Spacing(Mathf.Max(_ghost.Growth, root.Growth)); _snapPoint = root.Position + val * num; _snapPoint.y = GroundY(_snapPoint); Player.m_localPlayer.m_placementGhost.transform.position = _snapPoint; DrawLines(_snapPoint, val, num); } private static void DrawFixedGrid(List<PlantObject> others) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (!TryGridDir(others, out var gridDir, out var root) || root == null) { DrawFreeGrid(others[0]); return; } _freeDraw = false; float cell = Spacing(Mathf.Max(_ghost.Growth, root.Growth)); List<Vector3> list = GridCandidates(_ghost.Position, root.Position, gridDir, cell); _snapPoint = list[0]; for (int i = 0; i < list.Count; i++) { if (!Overlaps(list[i], others, _ghost.Growth)) { _snapPoint = list[i]; break; } } _snapPoint.y = GroundY(_snapPoint); Player.m_localPlayer.m_placementGhost.transform.position = _snapPoint; DrawLines(_snapPoint, gridDir, cell); } private static List<Vector3> GridCandidates(Vector3 ghostPos, Vector3 rootPos, Vector3 gridDir, float cell) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(gridDir.z, 0f, 0f - gridDir.x); for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { if (i != 0 || j != 0) { list.Add(rootPos + gridDir * ((float)i * cell) + val * ((float)j * cell)); } } } return list.OrderBy(delegate(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Vector3 val2 = p - ghostPos; return ((Vector3)(ref val2)).sqrMagnitude; }).ToList(); } private static bool TryGridDir(List<PlantObject> plants, out Vector3 gridDir, out PlantObject root) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) root = plants[0]; gridDir = Vector3.zero; int num = Mathf.Min(2, plants.Count); for (int i = 0; i < num; i++) { root = plants[i]; for (int j = 1; j < plants.Count; j++) { if (i != j) { Vector3 val = root.Position - plants[j].Position; val.y = 0f; float num2 = Spacing(Mathf.Max(Mathf.Max(root.Growth, plants[j].Growth), _ghost.Growth)); float num3 = ((Vector3)(ref val)).magnitude - num2; if (num3 > -0.01f && num3 < 0.01f * num2) { gridDir = ((Vector3)(ref val)).normalized; return true; } } } } root = null; return false; } internal static bool ApplySnap() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if (_ghost == null || (Object)(object)Player.m_localPlayer == (Object)null) { HideFarmGrid(); ResetCache(); return false; } GameObject placementGhost = Player.m_localPlayer.m_placementGhost; if ((Object)(object)placementGhost == (Object)null) { HideFarmGrid(); ResetCache(); return false; } Vector3 val = _ghostPos - placementGhost.transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (((!_farmGridVisible || _freeDraw) && sqrMagnitude < 0.0001f) || (_farmGridVisible && !_freeDraw && sqrMagnitude < 0.02f)) { if (_snapPoint != Vector3.zero) { placementGhost.transform.position = _snapPoint; } return true; } _snapPoint = Vector3.zero; _ghost.Position = placementGhost.transform.position; _ghostPos = _ghost.Position; List<PlantObject> list = FindNearby(_ghost.Position, SearchRadius(_ghost)); if (list.Count < 1) { HideFarmGrid(); return true; } if (list.Count == 1) { DrawFreeGrid(list[0]); } else { DrawFixedGrid(list); } return true; } internal static void SetGhostPlant() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer?.m_placementGhost == (Object)null) { return; } if (TryGetPlant(localPlayer.m_placementGhost.GetComponentInChildren<Collider>(), out var plant)) { plant.Position = localPlayer.m_placementGhost.transform.position; _ghost = plant; _ghostPos = plant.Position; return; } Plant val = localPlayer.m_placementGhost.GetComponent<Plant>() ?? localPlayer.m_placementGhost.GetComponentInChildren<Plant>(true); if ((Object)(object)val != (Object)null) { float growRadius = Mathf.Max(0f, val.m_growRadius); if (TryGetSize(PrefabName(((Object)((Component)val).gameObject).name), out var size)) { growRadius = size; } _ghost = new PlantObject(localPlayer.m_placementGhost.transform.position, EffectiveGrowth(growRadius, (Component)(object)val), ((Object)val).GetInstanceID()); _ghostPos = _ghost.Position; } } internal static void ResetCache() { //IL_0006: 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) _ghost = null; _snapPoint = Vector3.zero; _freeDraw = true; } private static void DrawLines(Vector3 pos, Vector3 gridDir, float cell) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) EnsureFarmGrid(); if (_farmGrid != null && !((Object)(object)_farmGrid[0] == (Object)null)) { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(gridDir.z, 0f, 0f - gridDir.x); for (int i = -2; i <= 2; i++) { DrawSegment(_farmGrid[i + 2], pos + gridDir * ((float)i * cell), val, cell); DrawSegment(_farmGrid[i + 2 + 5], pos + val * ((float)i * cell), gridDir, cell); } _farmGridVisible = true; } } private static void DrawSegment(GameObject lineObj, Vector3 position, Vector3 along, float cell) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) LineRenderer component = lineObj.GetComponent<LineRenderer>(); component.widthMultiplier = 0.015f; ((Renderer)component).enabled = true; for (int i = -2; i <= 2; i++) { Vector3 val = position + along * ((float)i * cell); val.y = GroundY(val) + 0.1f; component.SetPosition(i + 2, val); } } private static void EnsureFarmGrid() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown int num = 10; if (_farmGrid != null && _farmGrid.Length == num && (Object)(object)_farmGrid[0] != (Object)null) { return; } DestroyFarmGrid(); if ((Object)(object)_lineMaterial == (Object)null) { _lineMaterial = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && ((Object)m).name == "Default-Line")); if ((Object)(object)_lineMaterial == (Object)null) { Shader val = Shader.Find("Sprites/Default"); if ((Object)(object)val != (Object)null) { _lineMaterial = new Material(val); } } } _farmGrid = (GameObject[])(object)new GameObject[num]; for (int num2 = 0; num2 < num; num2++) { GameObject val2 = new GameObject("TeflonTed_FarmGridLine"); LineRenderer val3 = val2.AddComponent<LineRenderer>(); if ((Object)(object)_lineMaterial != (Object)null) { ((Renderer)val3).sharedMaterial = _lineMaterial; } val3.useWorldSpace = true; val3.startColor = GridColor; val3.endColor = GridColor; val3.positionCount = 5; ((Renderer)val3).enabled = false; _farmGrid[num2] = val2; } } private static void HideFarmGrid() { if (!_farmGridVisible || _farmGrid == null || (Object)(object)_farmGrid[0] == (Object)null) { return; } for (int i = 0; i < _farmGrid.Length; i++) { if ((Object)(object)_farmGrid[i] != (Object)null) { ((Renderer)_farmGrid[i].GetComponent<LineRenderer>()).enabled = false; } } _farmGridVisible = false; _freeDraw = true; } internal static void DestroyFarmGrid() { if (_farmGrid == null) { return; } for (int i = 0; i < _farmGrid.Length; i++) { if ((Object)(object)_farmGrid[i] != (Object)null) { Object.Destroy((Object)(object)_farmGrid[i]); } } _farmGrid = null; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }