Decompiled source of Moonswept v0.5.8

Moonswept.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Moonswept.NetcodePatcher;
using Moonswept.Utils.Attributes;
using Moonswept.Utils.ContentBases;
using On;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("MMHOOK_Assembly-CSharp")]
[assembly: AssemblyCompany("Moonswept")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1d3649cb4d9e4d6dddd0e9e7131d642dd60f40bd")]
[assembly: AssemblyProduct("Moonswept")]
[assembly: AssemblyTitle("Moonswept")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 Moonswept
{
	public class Cleaner : GenericBase<Cleaner>
	{
		public EnemyType enemy;

		public TerminalNode tNode;

		public TerminalKeyword tKeyword;

		public GameObject fogPrefab;

		public override void Initialize()
		{
			//IL_009c: 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)
			//IL_00c5: Expected O, but got Unknown
			base.Initialize();
			enemy = Main.assets.LoadAsset<EnemyType>("Cleaner.asset");
			tNode = Main.assets.LoadAsset<TerminalNode>("CleanerTN.asset");
			tKeyword = Main.assets.LoadAsset<TerminalKeyword>("CleanerTK.asset");
			NetworkPrefabs.RegisterNetworkPrefab(Main.assets.LoadAsset<GameObject>("Cleaner.prefab"));
			Enemies.RegisterEnemy(enemy, Main.config.Bind<int>("TZP Cleaner", "Weight", 75, "Spawn weight. Higher is more common.").Value, Main.config.Bind<LevelTypes>("TZP Cleaner", "Spawn Locations", (LevelTypes)(-1), "The moons this enemy can spawn on.").Value, (SpawnType)0, tNode, tKeyword);
			StartOfRound.Awake += new hook_Awake(KillYourself);
		}

		private void KillYourself(orig_Awake orig, StartOfRound self)
		{
			orig.Invoke(self);
		}
	}
	public class CleanerAI : EnemyAI
	{
		public enum BehaviourState
		{
			Wander,
			Retreat,
			DispenseGas
		}

		public Transform modelRoot;

		public AnimationCurve movement;

		public float rotationSpeed;

		private float movementStopwatch = 0f;

		private Transform currentTargetNode;

		private Vector3 initialPos;

		private float stopwatch = 0f;

		public GameObject fogPrefab;

		private float stopwatch2 = 0f;

		public override void Start()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			((EnemyAI)this).Update();
			((Component)modelRoot).transform.Rotate(new Vector3(0f, rotationSpeed, 0f) * Time.fixedDeltaTime);
			movementStopwatch += Time.fixedDeltaTime;
			if (movementStopwatch >= 4f)
			{
				movementStopwatch = 0f;
			}
			((Component)modelRoot).transform.localPosition = new Vector3(0f, 2.24f + movement.Evaluate(movementStopwatch), 0f);
		}

		public override void DoAIInterval()
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead)
			{
			}
			stopwatch2 += base.AIIntervalTime;
			if (stopwatch2 >= 0.5f)
			{
				stopwatch2 = 0f;
				SpawnFogClientRpc();
			}
			switch ((BehaviourState)base.currentBehaviourStateIndex)
			{
			case BehaviourState.Wander:
				base.agent.speed = 2f;
				break;
			case BehaviourState.Retreat:
			{
				base.agent.speed = 14f;
				float num = Vector3.Distance(initialPos, currentTargetNode.position);
				float num2 = Vector3.Distance(((Component)this).transform.position, currentTargetNode.position);
				if (num2 / num <= 0.4f)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(currentTargetNode.position, false);
				}
				break;
			}
			case BehaviourState.DispenseGas:
				base.agent.speed = 0f;
				if (stopwatch <= 0f)
				{
					SpawnFogClientRpc();
				}
				stopwatch += base.AIIntervalTime;
				if (stopwatch >= 2f)
				{
					base.currentBehaviourStateIndex = 0;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				break;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			//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)
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			((EnemyAI)this).SwitchToBehaviourState(1);
			initialPos = ((Component)this).transform.position;
			currentTargetNode = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, false, 0, false, 50, false);
			base.enemyHP -= force;
			if (base.enemyHP <= 0)
			{
				((EnemyAI)this).KillEnemyClientRpc(true);
			}
		}

		[ClientRpc]
		public void SpawnFogClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(897430802u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 897430802u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					Object.Instantiate<GameObject>(fogPrefab, ((Component)modelRoot).transform.position, Quaternion.identity);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CleanerAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(897430802u, new RpcReceiveHandler(__rpc_handler_897430802));
		}

		private static void __rpc_handler_897430802(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CleanerAI)(object)target).SpawnFogClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "CleanerAI";
		}
	}
	public class TZPFogZone : MonoBehaviour
	{
		public SphereCollider collider;

		public float destroyAfter;

		private float stopwatch;

		public void FixedUpdate()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			Bounds bounds = ((Collider)collider).bounds;
			if (((Bounds)(ref bounds)).Contains(localPlayerController.playerEye.position))
			{
				localPlayerController.increasingDrunknessThisFrame = true;
				localPlayerController.drunknessInertia = Mathf.Clamp(localPlayerController.drunknessInertia + Time.fixedDeltaTime / 1f * localPlayerController.drunknessSpeed, 0.1f, 4.5f);
			}
			stopwatch += Time.fixedDeltaTime;
			if (stopwatch >= 1.5f)
			{
				((Component)this).GetComponentInChildren<ParticleSystem>().Stop();
			}
			if (stopwatch >= destroyAfter)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class MobileTurret : GenericBase<MobileTurret>
	{
		public EnemyType enemy;

		public TerminalNode tNode;

		public TerminalKeyword tKeyword;

		public override void Initialize()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			base.Initialize();
			enemy = Main.assets.LoadAsset<EnemyType>("WalkerTurret.asset");
			tNode = Main.assets.LoadAsset<TerminalNode>("WalkerTurretTN.asset");
			tKeyword = Main.assets.LoadAsset<TerminalKeyword>("WalkerTurretTK.asset");
			NetworkPrefabs.RegisterNetworkPrefab(Main.assets.LoadAsset<GameObject>("WalkerTurret.prefab"));
			Enemies.RegisterEnemy(enemy, Main.config.Bind<int>("Mobile Turret", "Weight", 50, "Spawn weight. Higher is more common.").Value, Main.config.Bind<LevelTypes>("Mobile Turret", "Spawn Locations", (LevelTypes)(-1), "The moons this enemy can spawn on.").Value, (SpawnType)0, tNode, tKeyword);
		}
	}
	public class MobileTurretAI : EnemyAI
	{
		public enum BehaviourState
		{
			Patrolling,
			Chasing,
			LockingOn,
			Firing
		}

		public Transform aimTarget;

		public Transform muzzle;

		public ParticleSystem gunshots;

		private Vector3 targetLastSeenAt;

		private float lockOnTimer = 0f;

		private float firingTimer = 0f;

		private float firingDelay = 0f;

		private bool isDoingGunshots;

		public AudioSource source;

		public AudioSource seePlayerSource;

		public override void Start()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_0061: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.stunNormalizedTimer >= 0f)
			{
				base.agent.speed = 0f;
			}
			if (base.currentBehaviourStateIndex != 3 && Object.op_Implicit((Object)(object)base.targetPlayer))
			{
				aimTarget.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(0f, aimTarget.eulerAngles.y, 0f), 4f * Time.fixedDeltaTime);
			}
			if (!isDoingGunshots)
			{
				return;
			}
			firingDelay += Time.fixedDeltaTime;
			if (firingDelay >= 0.21f)
			{
				firingDelay = 0f;
				if ((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(35f, 60, -1) == (Object)(object)GameNetworkManager.Instance.localPlayerController)
				{
					GameNetworkManager.Instance.localPlayerController.DamagePlayer(15, true, true, (CauseOfDeath)7, 0, false, default(Vector3));
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 2f;
				if (((EnemyAI)this).TargetClosestPlayer(10f, false, 70f))
				{
					if (Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) > 10f)
					{
						base.targetPlayer = null;
						break;
					}
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					((EnemyAI)this).SwitchToBehaviourState(1);
				}
				break;
			case 2:
				base.agent.speed = 0f;
				lockOnTimer += base.AIIntervalTime;
				if (lockOnTimer >= 1f)
				{
					lockOnTimer = 0f;
					StartGunshotsClientRpc();
					((EnemyAI)this).SwitchToBehaviourState(3);
				}
				break;
			case 1:
				base.agent.speed = 2f;
				if (targetLastSeenAt != Vector3.zero)
				{
					((EnemyAI)this).SetDestinationToPosition(targetLastSeenAt, false);
				}
				if (Object.op_Implicit((Object)(object)base.targetPlayer))
				{
					targetLastSeenAt = ((Component)base.targetPlayer).transform.position;
					if (Vector3.Distance(targetLastSeenAt, ((Component)this).transform.position) < 10f)
					{
						lockOnTimer = 0f;
						((EnemyAI)this).SwitchToBehaviourState(2);
						if (!seePlayerSource.isPlaying)
						{
							seePlayerSource.Play();
						}
					}
					if (!((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 90f, 60, -1f, (Transform)null))
					{
						base.targetPlayer = null;
					}
				}
				else if (targetLastSeenAt == Vector3.zero || Vector3.Distance(targetLastSeenAt, ((Component)this).transform.position) < 3f)
				{
					targetLastSeenAt = Vector3.zero;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
				break;
			case 3:
				base.agent.speed = 0f;
				firingTimer += base.AIIntervalTime;
				if (firingTimer >= 2f)
				{
					firingTimer = 0f;
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					((EnemyAI)this).SwitchToBehaviourState(1);
					StopGunshotsClientRpc();
				}
				break;
			}
		}

		[ClientRpc]
		public void StartGunshotsClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2562756128u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2562756128u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					gunshots.Play();
					source.Play();
					isDoingGunshots = true;
					firingDelay = 0f;
				}
			}
		}

		[ClientRpc]
		public void StopGunshotsClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1641717521u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1641717521u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					gunshots.Stop();
					source.Stop();
					isDoingGunshots = false;
					firingDelay = 0f;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_MobileTurretAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2562756128u, new RpcReceiveHandler(__rpc_handler_2562756128));
			NetworkManager.__rpc_func_table.Add(1641717521u, new RpcReceiveHandler(__rpc_handler_1641717521));
		}

		private static void __rpc_handler_2562756128(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MobileTurretAI)(object)target).StartGunshotsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1641717521(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((MobileTurretAI)(object)target).StopGunshotsClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "MobileTurretAI";
		}
	}
	[BepInPlugin("MoonsweptTeam.Moonswept", "Moonswept", "0.5.0")]
	public class Main : BaseUnityPlugin
	{
		public static ConfigFile config;

		public static AssetBundle assets;

		private void Awake()
		{
			config = ((BaseUnityPlugin)this).Config;
			assets = AssetBundle.LoadFromFile(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) + "/moonswept");
			InitializeNetworkBehaviours();
			ContentScanner.ScanTypes(Assembly.GetExecutingAssembly(), delegate(GenericBase x)
			{
				x.Initialize();
			});
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Moonswept";

		public const string PLUGIN_NAME = "Moonswept";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Moonswept.Utils.Helpers
{
	public class Utils
	{
		public static Vector3 FindLookRotation(GameObject self, GameObject target)
		{
			//IL_0007: 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_0017: 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_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_0027: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target.transform.position - self.transform.position;
			return ((Vector3)(ref val)).normalized;
		}
	}
	public class StopwatchArray
	{
		private Dictionary<string, float> watches;

		public float this[string key]
		{
			get
			{
				if (!watches.ContainsKey(key))
				{
					watches.Add(key, 0f);
				}
				return watches[key];
			}
			set
			{
				if (!watches.ContainsKey(key))
				{
					watches.Add(key, 0f);
				}
				watches[key] = value;
			}
		}

		public float this[Enum key]
		{
			get
			{
				return this[key.ToString()];
			}
			set
			{
				this[key.ToString()] = value;
			}
		}

		public float this[int key]
		{
			get
			{
				return this[key.ToString()];
			}
			set
			{
				this[key.ToString()] = value;
			}
		}

		public StopwatchArray()
		{
			watches = new Dictionary<string, float>();
		}
	}
}
namespace Moonswept.Utils.Extensions.Unity
{
	public static class UnityExtensions
	{
		public static void RemoveComponent<T>(this GameObject self) where T : Component
		{
			Object.Destroy((Object)(object)self.GetComponent<T>());
		}

		public static void RemoveComponents<T>(this GameObject self) where T : Component
		{
			T[] components = self.GetComponents<T>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
		}

		public static void RemoveComponent<T>(this Component self) where T : Component
		{
			Object.Destroy((Object)(object)self.GetComponent<T>());
		}

		public static void RemoveComponents<T>(this Component self) where T : Component
		{
			T[] components = self.GetComponents<T>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
		}

		public static T AddComponent<T>(this Component self) where T : Component
		{
			return self.gameObject.AddComponent<T>();
		}

		public static Sprite MakeSprite(this Texture2D self)
		{
			//IL_0015: 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)
			return Sprite.Create(new Rect(0f, 0f, 512f, 512f), new Vector2(256f, 256f), 1f, self);
		}
	}
}
namespace Moonswept.Utils.Extensions.Text
{
	public static class StringExtensions
	{
		public static string RemoveUnsafeCharacters(this string str)
		{
			string[] array = new string[17]
			{
				"\n", "'", " ", "!", "`", "&", "-", ")", "(", "{",
				"}", "|", "@", "<", ">", ".", "\\"
			};
			string text = str;
			string[] array2 = array;
			foreach (string oldValue in array2)
			{
				text = text.Replace(oldValue, "");
			}
			return text;
		}

		public static string RemoveUnsafeCharacters(this string str, string[] unsafeChars)
		{
			string text = str;
			foreach (string oldValue in unsafeChars)
			{
				text = text.Replace(oldValue, "");
			}
			return text;
		}
	}
}
namespace Moonswept.Utils.Extensions.Enumeration
{
	public static class EnumeratorExtensions
	{
		public static T GetRandom<T>(this IEnumerable<T> self)
		{
			return self.ElementAt(Random.Range(0, self.Count()));
		}

		public static T GetRandom<T>(this IEnumerable<T> self, Func<T, bool> predicate)
		{
			try
			{
				return self.Where(predicate).ElementAt(Random.Range(0, self.Count()));
			}
			catch
			{
				return default(T);
			}
		}
	}
}
namespace Moonswept.Utils.ContentBases
{
	public static class ContentScanner
	{
		public static void ScanTypes<T>(Assembly assembly, Action<T> action)
		{
			IEnumerable<Type> enumerable = from x in assembly.GetTypes()
				where !x.IsAbstract && x.IsSubclassOf(typeof(T))
				select x;
			foreach (Type item in enumerable)
			{
				T obj = (T)Activator.CreateInstance(item);
				action(obj);
			}
		}
	}
	public abstract class GenericBase<T> : GenericBase where T : GenericBase<T>
	{
		public static T Instance { get; private set; }

		public GenericBase()
		{
			if (Instance == null)
			{
				Instance = this as T;
			}
		}
	}
	public abstract class GenericBase
	{
		public ConfigFile config;

		public virtual void Initialize()
		{
			config = Main.config;
			PostCreation();
		}

		public virtual void PostCreation()
		{
		}
	}
}
namespace Moonswept.Utils.Attributes
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
	public class AutoRunAttribute : Attribute
	{
	}
	internal sealed class AutoRunCollector
	{
		public static void HandleAutoRun()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				TypeInfo typeInfo = type.GetTypeInfo();
				MethodInfo[] methods = typeInfo.GetMethods((BindingFlags)(-1));
				foreach (MethodInfo methodInfo in methods)
				{
					AutoRunAttribute customAttribute = methodInfo.GetCustomAttribute<AutoRunAttribute>();
					if (customAttribute != null && methodInfo.IsStatic)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
	public class ConfigFieldAttribute : Attribute
	{
		public string name;

		public string desc;

		public object defaultValue;

		public ConfigFieldAttribute(string name, string desc, object defaultValue)
		{
			this.name = name;
			this.desc = desc;
			this.defaultValue = defaultValue;
		}
	}
	[AttributeUsage(AttributeTargets.Class)]
	public class ConfigSectionAttribute : Attribute
	{
		public string name;

		public ConfigSectionAttribute(string name)
		{
			this.name = name;
		}
	}
	public class ConfigManager
	{
		public static void HandleConfigAttributes(Assembly assembly, ConfigFile config)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			Type[] types = assembly.GetTypes();
			foreach (Type type in types)
			{
				TypeInfo typeInfo = type.GetTypeInfo();
				ConfigSectionAttribute customAttribute = typeInfo.GetCustomAttribute<ConfigSectionAttribute>();
				if (customAttribute == null)
				{
					continue;
				}
				FieldInfo[] fields = typeInfo.GetFields();
				foreach (FieldInfo fieldInfo in fields)
				{
					if (!fieldInfo.IsStatic)
					{
						continue;
					}
					Type fieldType = fieldInfo.FieldType;
					ConfigFieldAttribute customAttribute2 = fieldInfo.GetCustomAttribute<ConfigFieldAttribute>();
					if (customAttribute2 != null)
					{
						MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
							where x.Name == "Bind"
							select x).First();
						methodInfo = methodInfo.MakeGenericMethod(fieldType);
						ConfigEntryBase val = (ConfigEntryBase)methodInfo.Invoke(config, new object[3]
						{
							(object)new ConfigDefinition(customAttribute.name, customAttribute2.name),
							customAttribute2.defaultValue,
							(object)new ConfigDescription(customAttribute2.desc, (AcceptableValueBase)null, Array.Empty<object>())
						});
						fieldInfo.SetValue(null, val.BoxedValue);
					}
				}
			}
		}
	}
}
namespace Moonswept.Utils.AddressableUtils
{
	public static class RuntimePrefabManager
	{
		internal static GameObject PrefabParent;

		[AutoRun]
		internal static void Setup()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			PrefabParent = new GameObject("MoonsweptPrefabParent");
			PrefabParent.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)PrefabParent);
		}

		public static GameObject CreatePrefab(this GameObject gameObject, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(gameObject, PrefabParent.transform);
			((Object)val).name = name;
			if (Object.op_Implicit((Object)(object)val.GetComponent<NetworkObject>()))
			{
				MakeNetworkPrefab(val);
			}
			return val;
		}

		public static void MakeNetworkPrefab(GameObject gameObject)
		{
			NetworkObject component = gameObject.GetComponent<NetworkObject>();
			NetworkManager.Singleton.AddNetworkPrefab(gameObject);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace Moonswept.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}