Decompiled source of HoardingBugTowers v0.3.0

HoardingBugTowers.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("HoardingBugTowers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+78a029a2c817b5a1ba84a591a8458549ff35bbf1")]
[assembly: AssemblyProduct("HoardingBugTowers")]
[assembly: AssemblyTitle("HoardingBugTowers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 HoardingBugTowers
{
	[HarmonyPatch]
	internal static class HoardingBugBestiaryPatch
	{
		private const string BestiaryText = "Sigurd's danger level: 0%\n\nScientific name: Linepithema-crassus\n\nHoarding bugs (of the order Hymenoptera) are large, social insects. While often found living alone, they have been found to share their nests with members of their own species. They measure a height of 3 feet on average, with bulbous bodies. The thinness of their fluid and blood and the material of their carapaces contributes to their low weight, making them capable of flight with their membranous wings. It also makes their bodies somewhat transparent.\n\nHoarding bugs were given their name due to their territorial nature. Once they have chosen a place as their nest, they will seek to adorn it with any object they can find and will protect these objects as a part of the nest. Hoarding bugs are not so dangerous alone as they are in large hives. However, if left alone, hoarding bugs are surprisingly neutral and pose little danger. wWe love the stupid cuddle bugs.!! - tjhis has been a note from the indomitable Sigurd\n\n/ ????\n\nDATE: TOMORROW, Latest Sandicans Scienced discovery:\n\nIt's like a hierarchy. The top of the stack is like the alpha. wolf pack type shit.\nAWOOOOOOOoooo I feel it deep within, it’s just beneath the skkin i must confess tgat i feeel like a monsterrrr\n\nWe have also found a recorded copy of an old cartoon named we bare bears .\n\t-sincerely Nupor of The Sandicans";

		private static bool applied;

		private static MethodBase? TargetMethod()
		{
			Type type = AccessTools.TypeByName("Terminal");
			if (!(type == null))
			{
				return AccessTools.Method(type, "Start", (Type[])null, (Type[])null);
			}
			return null;
		}

		[HarmonyPostfix]
		private static void TerminalStartPostfix(object __instance)
		{
			Apply(__instance);
		}

		private static void Apply(object terminal)
		{
			if (applied)
			{
				return;
			}
			Type type = AccessTools.TypeByName("TerminalNode");
			if (type == null)
			{
				return;
			}
			FieldInfo fieldInfo = AccessTools.Field(type, "creatureName");
			FieldInfo fieldInfo2 = AccessTools.Field(type, "displayText");
			if (!(fieldInfo == null) && !(fieldInfo2 == null))
			{
				object obj = AccessTools.Field(terminal.GetType(), "terminalNodes")?.GetValue(terminal);
				if ((!(((obj == null) ? null : AccessTools.Field(obj.GetType(), "allTerminalNodes"))?.GetValue(obj) is IEnumerable nodes) || !ApplyToNodes(nodes, fieldInfo, fieldInfo2)) && !ApplyToNodes(Resources.FindObjectsOfTypeAll(type), fieldInfo, fieldInfo2))
				{
					HoardingBugTowersPlugin.Log.LogWarning((object)"Could not find the hoarding bug TerminalNode; bestiary text was not changed.");
				}
			}
		}

		private static bool ApplyToNodes(IEnumerable nodes, FieldInfo creatureName, FieldInfo displayText)
		{
			foreach (object node in nodes)
			{
				if (node != null && creatureName.GetValue(node) is string text && text.IndexOf("hoard", StringComparison.OrdinalIgnoreCase) >= 0 && text.IndexOf("bug", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					displayText.SetValue(node, "Sigurd's danger level: 0%\n\nScientific name: Linepithema-crassus\n\nHoarding bugs (of the order Hymenoptera) are large, social insects. While often found living alone, they have been found to share their nests with members of their own species. They measure a height of 3 feet on average, with bulbous bodies. The thinness of their fluid and blood and the material of their carapaces contributes to their low weight, making them capable of flight with their membranous wings. It also makes their bodies somewhat transparent.\n\nHoarding bugs were given their name due to their territorial nature. Once they have chosen a place as their nest, they will seek to adorn it with any object they can find and will protect these objects as a part of the nest. Hoarding bugs are not so dangerous alone as they are in large hives. However, if left alone, hoarding bugs are surprisingly neutral and pose little danger. wWe love the stupid cuddle bugs.!! - tjhis has been a note from the indomitable Sigurd\n\n/ ????\n\nDATE: TOMORROW, Latest Sandicans Scienced discovery:\n\nIt's like a hierarchy. The top of the stack is like the alpha. wolf pack type shit.\nAWOOOOOOOoooo I feel it deep within, it’s just beneath the skkin i must confess tgat i feeel like a monsterrrr\n\nWe have also found a recorded copy of an old cartoon named we bare bears .\n\t-sincerely Nupor of The Sandicans");
					applied = true;
					HoardingBugTowersPlugin.Log.LogInfo((object)"Updated the hoarding bug Terminal bestiary entry.");
					return true;
				}
			}
			return false;
		}
	}
	[BepInPlugin("com.flintchips.hoardingbugtowers", "Hoarding Bug Towers", "0.3.0")]
	public sealed class HoardingBugTowersPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.flintchips.hoardingbugtowers";

		public const string PluginName = "Hoarding Bug Towers";

		public const string PluginVersion = "0.3.0";

		internal const float StackChance = 0.2f;

		internal const float TripleChance = 0.25f;

		internal const float StackHeight = 1.3f;

		internal const float MinStackSeconds = 1f;

		internal const float MaxStackSeconds = 22f;

		internal const float FollowSmoothTime = 0.22f;

		internal const float DismountSmoothTime = 0.35f;

		internal const float DismountNudgeDistance = 0.8f;

		internal const float AggroNudgeUp = 0.18f;

		internal const float GuardRadius = 20f;

		internal const float CrowdedStackChance = 0.35f;

		internal const int CrowdedBugCount = 3;

		internal const float CrowdedRadius = 5f;

		internal const float ScrambleStackSeconds = 3.5f;

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("com.flintchips.hoardingbugtowers").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Hoarding Bug Towers 0.3.0 loaded.");
		}
	}
	[HarmonyPatch]
	internal static class HoarderBugPatch
	{
		private static FieldInfo? nestPositionField;

		private static readonly Dictionary<int, float> NextAttemptByBug = new Dictionary<int, float>();

		private static readonly List<Component> BugSnapshot = new List<Component>();

		private static float nextSnapshot;

		private static MethodBase? TargetMethod()
		{
			Type type = AccessTools.TypeByName("HoarderBugAI");
			if (!(type == null))
			{
				return AccessTools.Method(type, "Update", (Type[])null, (Type[])null);
			}
			return null;
		}

		[HarmonyPostfix]
		private static void UpdatePostfix(Component __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if (NextAttemptByBug.TryGetValue(instanceID, out var value) && Time.time < value)
			{
				return;
			}
			NextAttemptByBug[instanceID] = Time.time + 2f;
			if (Time.time >= nextSnapshot)
			{
				nextSnapshot = Time.time + 2f;
				BugSnapshot.Clear();
				Object[] array = Object.FindObjectsOfType(((object)__instance).GetType());
				foreach (Object obj in array)
				{
					Component val = (Component)(object)((obj is Component) ? obj : null);
					if (val != null)
					{
						BugSnapshot.Add(val);
					}
				}
			}
			TryCreateStack(__instance, BugSnapshot);
		}

		internal static void TryCreateStack(Component lower, List<Component> nearbyBugsList)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)lower.GetComponent<BugTowerMember>() != (Object)null || (Object)(object)lower.GetComponent<BugTowerBase>() != (Object)null)
			{
				return;
			}
			List<Component> list = new List<Component>();
			int num = 0;
			foreach (Component nearbyBugs in nearbyBugsList)
			{
				if (!((Object)(object)nearbyBugs == (Object)(object)lower) && !((Object)(object)nearbyBugs.GetComponent<BugTowerMember>() != (Object)null) && !((Object)(object)nearbyBugs.GetComponent<BugTowerBase>() != (Object)null))
				{
					float num2 = Vector3.Distance(nearbyBugs.transform.position, lower.transform.position);
					if (num2 <= 5f)
					{
						num++;
					}
					if (!(num2 > 2.2f))
					{
						list.Add(nearbyBugs);
					}
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			bool guarding = IsGuardingNest(lower);
			bool flag = !guarding && num >= 3;
			if (!guarding && !flag)
			{
				return;
			}
			float num3 = (flag ? 0.35f : 0.2f);
			if (Random.value > num3)
			{
				return;
			}
			list.RemoveAll((Component candidate) => (!guarding) ? IsGuardingNest(candidate) : (!IsGuardingNest(candidate)));
			if (list.Count == 0)
			{
				return;
			}
			List<Component> list2 = new List<Component>
			{
				lower,
				list[Random.Range(0, list.Count)]
			};
			if (Random.value < 0.25f)
			{
				foreach (Component item in list)
				{
					if ((Object)(object)item != (Object)(object)list2[1] && Vector3.Distance(item.transform.position, lower.transform.position) <= 2.2f)
					{
						list2.Add(item);
						break;
					}
				}
			}
			float num4 = (flag ? Math.Max(0.5f, 3.5f) : Math.Max(1f, 22f));
			float num5 = (flag ? 0.5f : 1f);
			float endTime = Time.time + Random.Range(num5, num4);
			BugTowerBase bugTowerBase = lower.gameObject.AddComponent<BugTowerBase>();
			bugTowerBase.Initialize(list2.Count - 1);
			for (int num6 = 1; num6 < list2.Count; num6++)
			{
				list2[num6].gameObject.AddComponent<BugTowerMember>().Attach(lower, bugTowerBase, num6, endTime);
			}
		}

		private static bool IsGuardingNest(Component bug)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			if ((object)nestPositionField == null)
			{
				nestPositionField = AccessTools.Field(((object)bug).GetType(), "nestPosition");
			}
			if (!(nestPositionField?.GetValue(bug) is Vector3 val))
			{
				return false;
			}
			return Vector3.Distance(bug.transform.position, val) <= 20f;
		}
	}
	internal sealed class BugTowerBase : MonoBehaviour
	{
		private int riders;

		internal void Initialize(int count)
		{
			riders = count;
		}

		internal void RiderLeft()
		{
			riders--;
			if (riders <= 0)
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
	internal sealed class BugTowerMember : MonoBehaviour
	{
		private Component? lower;

		private BugTowerBase? towerBase;

		private int level;

		private float releaseAt;

		private NavMeshAgent? agent;

		private Vector3 followVelocity;

		private Collider[] solidColliders = Array.Empty<Collider>();

		private bool dismounting;

		private Vector3 dismountTarget;

		private Vector3 dismountNudgeTarget;

		private Vector3 dismountVelocity;

		private bool nudgingToDismount;

		private FieldInfo? inChaseField;

		private FieldInfo? angryAtPlayerField;

		private bool aggroHovering;

		private float hoverHeight;

		private bool leftTower;

		internal void Attach(Component bottom, BugTowerBase activeBase, int towerLevel, float endTime)
		{
			lower = bottom;
			towerBase = activeBase;
			level = towerLevel;
			releaseAt = endTime;
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			if ((Object)(object)agent != (Object)null)
			{
				agent.isStopped = true;
				agent.updatePosition = false;
				agent.updateRotation = false;
			}
			solidColliders = ((Component)this).GetComponentsInChildren<Collider>(true);
			Collider[] array = solidColliders;
			foreach (Collider val in array)
			{
				if (!val.isTrigger)
				{
					val.enabled = false;
				}
			}
		}

		private void LateUpdate()
		{
			//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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (!IsServer())
			{
				Object.Destroy((Object)(object)this);
			}
			else if (dismounting)
			{
				UpdateDismount();
			}
			else if (aggroHovering)
			{
				if (IsAngry())
				{
					UpdateAggroHover();
				}
				else
				{
					BeginDismount();
				}
			}
			else if (IsAngry())
			{
				BeginAggroHover();
			}
			else if ((Object)(object)lower == (Object)null || Time.time >= releaseAt)
			{
				BeginDismount();
			}
			else
			{
				Vector3 val = lower.transform.position + Vector3.up * (1.3f * (float)level);
				((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, val, ref followVelocity, Math.Max(0.01f, 0.22f));
				((Component)this).transform.rotation = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f);
			}
		}

		private bool IsAngry()
		{
			Component component = ((Component)this).GetComponent("HoarderBugAI");
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			if ((object)inChaseField == null)
			{
				inChaseField = AccessTools.Field(((object)component).GetType(), "inChase");
			}
			if ((object)angryAtPlayerField == null)
			{
				angryAtPlayerField = AccessTools.Field(((object)component).GetType(), "angryAtPlayer");
			}
			object obj = inChaseField?.GetValue(component);
			if (!(obj is bool) || !(bool)obj)
			{
				return angryAtPlayerField?.GetValue(component) != null;
			}
			return true;
		}

		private void BeginDismount()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			//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)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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)
			dismounting = true;
			NotifyTowerLeft();
			Vector2 val = Random.insideUnitCircle;
			if (((Vector2)(ref val)).sqrMagnitude < 0.001f)
			{
				val = Vector2.right;
			}
			((Vector2)(ref val)).Normalize();
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position + new Vector3(val.x, 0f, val.y) * 0.8f, ref val2, 5f, -1))
			{
				dismountTarget = ((NavMeshHit)(ref val2)).position;
			}
			else if ((Object)(object)lower != (Object)null && NavMesh.SamplePosition(lower.transform.position, ref val2, 5f, -1))
			{
				dismountTarget = ((NavMeshHit)(ref val2)).position;
			}
			else
			{
				dismountTarget = ((Component)this).transform.position;
			}
			dismountNudgeTarget = new Vector3(dismountTarget.x, ((Component)this).transform.position.y, dismountTarget.z);
			nudgingToDismount = Vector3.SqrMagnitude(dismountNudgeTarget - ((Component)this).transform.position) > 0.0025f;
		}

		private void BeginAggroHover()
		{
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			aggroHovering = true;
			lower = null;
			NotifyTowerLeft();
			Transform transform = ((Component)this).transform;
			transform.position += Vector3.up * 0.18f;
			if ((Object)(object)agent != (Object)null)
			{
				agent.isStopped = false;
				hoverHeight = Mathf.Clamp(((Component)this).transform.position.y - agent.nextPosition.y, 0.18f, 1.48f);
			}
			else
			{
				hoverHeight = 1.3f;
			}
		}

		private void UpdateAggroHover()
		{
			//IL_0015: 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)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			if (!((Object)(object)agent == (Object)null))
			{
				Vector3 val = agent.nextPosition + Vector3.up * hoverHeight;
				((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, val, ref followVelocity, 0.08f);
			}
		}

		private void UpdateDismount()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_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_00e4: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (nudgingToDismount)
			{
				((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, dismountNudgeTarget, ref dismountVelocity, Math.Max(0.01f, 0.175f));
				if (Vector3.SqrMagnitude(((Component)this).transform.position - dismountNudgeTarget) > 0.0025f)
				{
					return;
				}
				((Component)this).transform.position = dismountNudgeTarget;
				dismountVelocity = Vector3.zero;
				nudgingToDismount = false;
			}
			((Component)this).transform.position = Vector3.SmoothDamp(((Component)this).transform.position, dismountTarget, ref dismountVelocity, Math.Max(0.01f, 0.35f));
			if (!(Vector3.SqrMagnitude(((Component)this).transform.position - dismountTarget) > 0.0025f))
			{
				((Component)this).transform.position = dismountTarget;
				ReleaseToNavigation();
			}
		}

		private void ReleaseToNavigation()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)agent != (Object)null)
			{
				if (agent.isOnNavMesh)
				{
					agent.Warp(dismountTarget);
				}
				agent.updatePosition = true;
				agent.updateRotation = true;
				if (agent.isOnNavMesh)
				{
					agent.isStopped = false;
				}
			}
			Collider[] array = solidColliders;
			foreach (Collider val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.enabled = true;
				}
			}
			Object.Destroy((Object)(object)this);
		}

		private void NotifyTowerLeft()
		{
			if (!leftTower)
			{
				leftTower = true;
				if ((Object)(object)towerBase != (Object)null)
				{
					towerBase.RiderLeft();
				}
			}
		}

		private void OnDestroy()
		{
			NotifyTowerLeft();
		}

		private static bool IsServer()
		{
			if ((Object)(object)NetworkManager.Singleton != (Object)null)
			{
				return NetworkManager.Singleton.IsServer;
			}
			return false;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "HoardingBugTowers";

		public const string PLUGIN_NAME = "HoardingBugTowers";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}