Decompiled source of Living Traps v1.0.2

LivingTraps.dll

Decompiled a week ago
using System;
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 System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using LivingTraps;
using LivingTraps.NetcodePatcher;
using Living_Traps;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[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: AssemblyCompany("bcs4313")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a suspicious looking pill that is very good for you")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cd9e2c801759e115bb3ab98ef537ed8ed3634744")]
[assembly: AssemblyProduct("LivingTraps")]
[assembly: AssemblyTitle("LivingTraps")]
[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;
		}
	}
}
public class TRAPAICORE : EnemyAI
{
	public enum State
	{
		SearchingForPlayer,
		StickingInFrontOfPlayer
	}

	protected PlayerControllerB mostRecentPlayer = null;

	protected GrabbableObject[] source;

	protected int sourcecycle = 75;

	public bool isRootSpawn = true;

	public string selectedType = "";

	protected float stamina = 0f;

	protected bool recovering = false;

	public int provokePoints = 0;

	private float nextDestTime = 0f;

	public Transform turnCompass;

	public Transform attackArea;

	protected float timeSinceHittingLocalPlayer;

	protected float timeSinceNewRandPos;

	protected Vector3 positionRandomness;

	protected Vector3 StalkPos;

	protected Random enemyRandom;

	protected bool isDeadAnimationDone;

	public override void OnDestroy()
	{
		((EnemyAI)this).OnDestroy();
		Debug.Log((object)"Living Trap: Destroyed Self");
	}

	public void setHalo(bool active)
	{
		Transform val = ((Component)this).transform.Find("Halo");
		if (Object.op_Implicit((Object)(object)val))
		{
			((Component)val).gameObject.SetActive(active);
		}
		else
		{
			Debug.LogError((object)"MOAI: failed to find Halo!");
		}
	}

	public PlayerControllerB moaiGetNearestPlayer()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
		PlayerControllerB result = null;
		float num = 1E+09f;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if (Object.op_Implicit((Object)(object)val) && !val.isPlayerDead && val.isPlayerControlled && Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) < num)
			{
				num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				result = val;
			}
		}
		return result;
	}

	public void baseInit()
	{
		//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)
		Debug.Log((object)"Living Trap: BaseInit");
		source = Object.FindObjectsOfType<GrabbableObject>();
		mostRecentPlayer = moaiGetNearestPlayer();
		timeSinceHittingLocalPlayer = 0f;
		timeSinceNewRandPos = 0f;
		positionRandomness = new Vector3(0f, 0f, 0f);
		enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
		isDeadAnimationDone = false;
		base.currentBehaviourStateIndex = 0;
		if (((NetworkBehaviour)RoundManager.Instance).IsHost)
		{
			awaken();
		}
	}

	public async void awaken()
	{
		Debug.Log((object)"Living Trap: Awaken");
		((EnemyAI)this).StopSearch(base.currentSearch, true);
		nextDestTime = Time.time + 0.5f;
		await Task.Delay(2000);
		if (!isRootSpawn)
		{
			return;
		}
		int groupNum = Plugin.rnd.Next(0, Plugin.groupSize.Value);
		for (int i = 0; i < groupNum; i++)
		{
			GameObject dupe = Object.Instantiate<GameObject>(base.enemyType.enemyPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation);
			if (Object.op_Implicit((Object)(object)dupe.GetComponent<NetworkObject>()))
			{
				dupe.GetComponent<NetworkObject>().Spawn(false);
			}
			dupe.GetComponent<LivingTrapAI>().isRootSpawn = false;
			dupe.GetComponent<LivingTrapAI>().selectedType = selectedType;
		}
	}

	public void baseUpdate()
	{
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		if (base.isEnemyDead && base.enemyHP > 0)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
			stopAllSound();
			base.isEnemyDead = true;
			base.enemyHP = 0;
		}
		if (base.isEnemyDead)
		{
			if (!isDeadAnimationDone)
			{
				isDeadAnimationDone = true;
				stopAllSound();
				base.creatureVoice.PlayOneShot(base.dieSFX);
			}
			return;
		}
		if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isPlayerDead)
		{
			base.targetPlayer = null;
		}
		base.movingTowardsTargetPlayer = (Object)(object)base.targetPlayer != (Object)null;
		timeSinceHittingLocalPlayer += Time.deltaTime;
		timeSinceNewRandPos += Time.deltaTime;
		if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false))
		{
			turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
		}
		if (base.stunNormalizedTimer > 0f)
		{
			base.agent.speed = 0f;
		}
	}

	public void baseAIInterval()
	{
		if (sourcecycle > 0)
		{
			sourcecycle--;
		}
		else
		{
			source = Object.FindObjectsOfType<GrabbableObject>();
			sourcecycle = 75;
		}
		if (stamina <= 0f)
		{
			recovering = true;
		}
		else if (stamina > 60f)
		{
			recovering = false;
		}
		if (sourcecycle % 5 == 0 && stamina < 120f)
		{
			stamina += 3f;
		}
		if ((Object)(object)base.targetPlayer != (Object)null)
		{
			mostRecentPlayer = base.targetPlayer;
		}
	}

	public void baseSearchingForPlayer()
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		base.agent.speed = 3f * Plugin.moaiGlobalSpeed.Value;
		if (FoundClosestPlayerInRange(28f, needLineOfSight: true) || provokePoints > 0)
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
		}
		else if (nextDestTime < Time.time)
		{
			nextDestTime = (float)((double)Time.time + 6.0 * Plugin.rnd.NextDouble());
			((EnemyAI)this).SetDestinationToPosition(GetRandomNavMeshPosition(((Component)this).transform.position, 25f), false);
		}
	}

	public static Vector3 GetRandomNavMeshPosition(Vector3 center, float range)
	{
		//IL_0006: 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_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_0017: 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_005e: 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)
		//IL_003a: 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_0063: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val2 = default(NavMeshHit);
		for (int i = 0; i < 30; i++)
		{
			Vector3 val = center + Random.insideUnitSphere * range;
			val.y = center.y;
			if (NavMesh.SamplePosition(val, ref val2, 3f, -1))
			{
				return ((NavMeshHit)(ref val2)).position;
			}
		}
		Debug.LogWarning((object)"Failed to find random NavMesh position.");
		return center;
	}

	public void baseStickingInFrontOfPlayer(float maxRange = 22f)
	{
		base.agent.speed = 5.3f * Plugin.moaiGlobalSpeed.Value;
		stamina -= 1.5f;
		if (!FoundClosestPlayerInRange(maxRange, needLineOfSight: false) && !FoundClosestPlayerInRange(maxRange + 6f, needLineOfSight: true) && provokePoints <= 0)
		{
			base.targetPlayer = null;
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}
		else
		{
			StickingInFrontOfPlayer();
		}
	}

	public Vector3 objNavPos(GrabbableObject objTarget)
	{
		//IL_001e: 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_0014: 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_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)
		if (!Object.op_Implicit((Object)(object)objTarget))
		{
			return Vector3.zero;
		}
		NavMeshHit val = default(NavMeshHit);
		if (NavMesh.SamplePosition(((Component)objTarget).transform.position, ref val, 5f, -1))
		{
			return ((NavMeshHit)(ref val)).position;
		}
		return Vector3.zero;
	}

	public bool FoundClosestPlayerInRange(float r, bool needLineOfSight)
	{
		if (recovering)
		{
			return false;
		}
		moaiTargetClosestPlayer(r, needLineOfSight);
		if ((Object)(object)base.targetPlayer == (Object)null)
		{
			return false;
		}
		return (Object)(object)base.targetPlayer != (Object)null;
	}

	public bool moaiTargetClosestPlayer(float range, bool requireLineOfSight)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: 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)
		if (recovering)
		{
			return false;
		}
		base.mostOptimalDistance = range;
		PlayerControllerB targetPlayer = base.targetPlayer;
		base.targetPlayer = null;
		for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
		{
			if (((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], false, false) && (!requireLineOfSight || ((EnemyAI)this).CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position, 100f, 80, -1f, (Transform)null)))
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
		}
		if ((Object)(object)base.targetPlayer != (Object)null && (Object)(object)targetPlayer != (Object)null)
		{
			base.targetPlayer = targetPlayer;
		}
		return (Object)(object)base.targetPlayer != (Object)null;
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
	}

	private void StickingInFrontOfPlayer()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner)
		{
			StalkPos = ((Component)base.targetPlayer).transform.position;
			((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
		}
	}

	public override void OnCollideWithEnemy(Collider other, EnemyAI collidedEnemy = null)
	{
		if (!(timeSinceHittingLocalPlayer < 0.5f) && !collidedEnemy.isEnemyDead && !base.isEnemyDead && (!((Object)((Component)collidedEnemy).gameObject).name.ToLower().Contains("moai") || ((Component)((Component)this).transform.Find("Halo")).gameObject.activeSelf != ((Component)((Component)collidedEnemy).transform.Find("Halo")).gameObject.activeSelf))
		{
			timeSinceHittingLocalPlayer = 0f;
			collidedEnemy.HitEnemy(1, (PlayerControllerB)null, true, -1);
		}
	}

	public override void OnCollideWithPlayer(Collider other)
	{
		//IL_00b1: 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_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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)
		if (timeSinceHittingLocalPlayer < 0.5f)
		{
			return;
		}
		PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		timeSinceHittingLocalPlayer = 0f;
		if (!Object.op_Implicit((Object)(object)((Component)this).transform.Find("Halo")) || !((Component)((Component)this).transform.Find("Halo")).gameObject.activeSelf)
		{
			if (val.health < 30)
			{
				val.KillPlayer(val.velocityLastFrame, true, (CauseOfDeath)6, 0, default(Vector3));
			}
			else
			{
				val.DamagePlayer(30, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			}
		}
		else if (((Component)((Component)this).transform.Find("Halo")).gameObject.activeSelf && val.health <= 90)
		{
			val.DamagePlayer(-10, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}
	}

	public virtual void playSoundId(string id)
	{
	}

	public void stopAllSound()
	{
		base.creatureSFX.Stop();
		base.creatureVoice.Stop();
	}

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

	protected internal override string __getTypeName()
	{
		return "TRAPAICORE";
	}
}
namespace LivingTraps
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("LivingTraps", "Living Traps", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class Assets
		{
			public static AssetBundle MainAssetBundle;

			public static void PopulateAssets()
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "livingtrapbundle"));
				if ((Object)(object)MainAssetBundle == (Object)null)
				{
					Logger.LogError((object)"Failed to load custom assets.");
				}
			}
		}

		public static Harmony _harmony;

		public static ManualLogSource Logger;

		public static Random rnd = new Random();

		public static float rawSpawnMultiplier = 0f;

		public static EnemyType LivingTrap;

		public static TerminalNode LivingTrapTerminalNode;

		public static TerminalKeyword LivingTrapTerminalKeyword;

		public static ConfigEntry<int> rarity;

		public static ConfigEntry<float> moaiGlobalSpeed;

		public static ConfigEntry<string> trapOptions;

		public static ConfigEntry<int> groupSize;

		public static void LogDebug(string text)
		{
			Logger.LogInfo((object)text);
		}

		public static void LogProduction(string text)
		{
			Logger.LogInfo((object)text);
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			bindVars();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | 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);
					}
				}
			}
			Random.InitState((int)DateTime.Now.Ticks);
			Debug.Log((object)("LivingTrap ENEMY BUNDLE: " + ((object)Assets.MainAssetBundle).ToString()));
			LivingTrap = Assets.MainAssetBundle.LoadAsset<EnemyType>("LivingTrap");
			LivingTrapTerminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("LivingTrapTN");
			LivingTrapTerminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("LivingTrapTK");
			Debug.Log((object)("LT" + (object)LivingTrap));
			Debug.Log((object)("LT TN" + (object)LivingTrapTerminalNode));
			Debug.Log((object)("LT TK" + (object)LivingTrapTerminalKeyword));
			NetworkPrefabs.RegisterNetworkPrefab(LivingTrap.enemyPrefab);
			Enemies.RegisterEnemy(LivingTrap, rarity.Value, (LevelTypes)(-1), (SpawnType)1, LivingTrapTerminalNode, LivingTrapTerminalKeyword);
			Logger.LogInfo((object)"Plugin Living Traps is loaded!");
		}

		public static string ScaleAllIntegers(string input, float multiplier)
		{
			return Regex.Replace(input, "\\d+", delegate(Match match)
			{
				int num = int.Parse(match.Value);
				return ((int)Math.Round((float)num * multiplier)).ToString();
			});
		}

		public void bindVars()
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00b9: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//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_00d1: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//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_00e9: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			rarity = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Enemy Spawnrate", 20, "Essentially the enemy 'rarity.' A higher value means a higher spawnrate.");
			moaiGlobalSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Modifiers", "Enemy Speed Multiplier", 1f, "Changes the speed of all living traps.");
			trapOptions = ((BaseUnityPlugin)this).Config.Bind<string>("Spawning", "Trap spawn options.", "TurretContainer,mine,spike", "Comma separated list of trap spawns. If you enter a modded option, it must somewhat match the gameobject/prefab name in the SpawnableMapObjects definition (if you know what this means that is). for simplicity, you can try throwing in basic names to see if the mod picks it up. Even a small piece of the trap's name would work.");
			groupSize = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Group Size Range", 1, "The max group spawn size for trap spawns. Traps will spawn in groups (3 spike traps, 3 mines, etc.) of 1 to this size.");
			ConfigEntry<float> obj = moaiGlobalSpeed;
			FloatSliderOptions val = new FloatSliderOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = 5f;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(obj, val);
			TextInputFieldConfigItem val3 = new TextInputFieldConfigItem(trapOptions, new TextInputFieldOptions
			{
				RequiresRestart = false
			});
			IntInputFieldConfigItem val4 = new IntInputFieldConfigItem(rarity, new IntInputFieldOptions
			{
				RequiresRestart = false
			});
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
		}
	}
}
namespace Living_Traps
{
	internal class LivingTrapAI : TRAPAICORE
	{
		private GameObject hostTrap;

		private float retryTime = 0f;

		public override void Start()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"LivingTrap: Spawned in!");
			baseInit();
			GameObject trap = getTrap(pickTrap());
			if ((Object)(object)trap == (Object)null)
			{
				Debug.LogError((object)("Trap prefab could not be loaded. Path ID = " + (object)trap));
			}
			else if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				hostTrap = Object.Instantiate<GameObject>(trap, ((Component)this).transform.position, ((Component)this).transform.rotation);
				hostTrap.GetComponent<NetworkObject>().Spawn(false);
				((EnemyAI)this).thisNetworkObject = hostTrap.GetComponent<NetworkObject>();
			}
		}

		public override void Update()
		{
			//IL_009b: 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)
			if (!Object.op_Implicit((Object)(object)hostTrap) && ((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			if (!Object.op_Implicit((Object)(object)hostTrap))
			{
				Debug.Log((object)"Living Trap: Host trap missing! Will not sync transform of trap!");
				if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					requestTrapObjectServerRpc();
				}
				return;
			}
			((EnemyAI)this).Update();
			baseUpdate();
			if (Object.op_Implicit((Object)(object)hostTrap))
			{
				hostTrap.transform.position = ((Component)this).transform.position;
				hostTrap.transform.rotation = ((Component)this).transform.rotation;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void requestTrapObjectServerRpc()
		{
			//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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2314795623u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2314795623u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && Time.time > retryTime)
			{
				retryTime = Time.time + 0.2f;
				NetworkObject component = hostTrap.GetComponent<NetworkObject>();
				if (Object.op_Implicit((Object)(object)hostTrap) && Object.op_Implicit((Object)(object)component) && component.IsSpawned)
				{
					setTrapObjectClientRpc(component.NetworkObjectId);
				}
				else
				{
					Debug.Log((object)"Living Traps: Can't send trap information to clients, awaiting for net synchronization.");
				}
			}
		}

		[ClientRpc]
		public void setTrapObjectClientRpc(ulong uid)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2025391493u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, uid);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2025391493u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			NetworkObject[] array = Object.FindObjectsOfType<NetworkObject>();
			NetworkObject[] array2 = array;
			foreach (NetworkObject val3 in array2)
			{
				if (val3.NetworkObjectId == uid)
				{
					hostTrap = ((Component)val3).gameObject;
				}
			}
		}

		public override void DoAIInterval()
		{
			if (!((EnemyAI)this).isEnemyDead)
			{
				((EnemyAI)this).DoAIInterval();
				baseAIInterval();
				((EnemyAI)this).agent.acceleration = 8f * Plugin.moaiGlobalSpeed.Value;
				switch (((EnemyAI)this).currentBehaviourStateIndex)
				{
				case 0:
					baseSearchingForPlayer();
					break;
				case 1:
					baseStickingInFrontOfPlayer();
					break;
				default:
					Debug.Log((object)"This Behavior State doesn't exist!");
					break;
				}
			}
		}

		public string pickTrap()
		{
			if (!selectedType.Equals(""))
			{
				return selectedType;
			}
			string[] array = (from s in Plugin.trapOptions.Value.Split(",")
				select s.Trim()).ToArray();
			return selectedType = array[Plugin.rnd.Next(0, array.Length)];
		}

		public static GameObject getTrap(string hazardName)
		{
			SelectableLevel[] array = Resources.FindObjectsOfTypeAll<SelectableLevel>();
			SelectableLevel[] array2 = array;
			foreach (SelectableLevel val in array2)
			{
				if (val.spawnableMapObjects == null)
				{
					continue;
				}
				SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects;
				foreach (SpawnableMapObject val2 in spawnableMapObjects)
				{
					if (((Object)val2.prefabToSpawn).name.ToLower().Contains(hazardName.ToLower()))
					{
						return val2.prefabToSpawn;
					}
				}
			}
			return null;
		}

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LivingTrapAI()
		{
			//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(2314795623u, new RpcReceiveHandler(__rpc_handler_2314795623));
			NetworkManager.__rpc_func_table.Add(2025391493u, new RpcReceiveHandler(__rpc_handler_2025391493));
		}

		private static void __rpc_handler_2314795623(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)1;
				((LivingTrapAI)(object)target).requestTrapObjectServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2025391493(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong trapObjectClientRpc = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref trapObjectClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LivingTrapAI)(object)target).setTrapObjectClientRpc(trapObjectClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LivingTrapAI";
		}
	}
}
namespace EasterIsland
{
	internal class ConfigModel
	{
		public static ConfigEntry<float> moaiGlobalSize;

		public static ConfigEntry<float> moaiGlobalMusicVol;

		public static ConfigEntry<float> moaiGlobalRarity;

		public static ConfigEntry<float> moaiGlobalSpeed;

		public static void setupConfig()
		{
			//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)
			//IL_0016: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0028: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_007e: 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_008e: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00a0: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			ConfigEntry<float> obj = moaiGlobalSize;
			FloatSliderOptions val = new FloatSliderOptions();
			((BaseRangeOptions<float>)val).Min = 0.05f;
			((BaseRangeOptions<float>)val).Max = 5f;
			FloatSliderConfigItem val2 = new FloatSliderConfigItem(obj, val);
			ConfigEntry<float> obj2 = moaiGlobalMusicVol;
			FloatSliderOptions val3 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val3).Min = 0f;
			((BaseRangeOptions<float>)val3).Max = 2f;
			FloatSliderConfigItem val4 = new FloatSliderConfigItem(obj2, val3);
			ConfigEntry<float> obj3 = moaiGlobalRarity;
			FloatSliderOptions val5 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val5).Min = 0f;
			((BaseRangeOptions<float>)val5).Max = 10f;
			FloatSliderConfigItem val6 = new FloatSliderConfigItem(obj3, val5);
			ConfigEntry<float> obj4 = moaiGlobalSpeed;
			FloatSliderOptions val7 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val7).Min = 0f;
			((BaseRangeOptions<float>)val7).Max = 5f;
			FloatSliderConfigItem val8 = new FloatSliderConfigItem(obj4, val7);
		}
	}
}
namespace LivingTraps.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}