Decompiled source of UnrealTentacle v1.0.3

DreWulff-UnrealTentacle.dll

Decompiled a week ago
#define DEBUG
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnrealTentacle.Configuration;

[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("DreWulff-UnrealTentacle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d43f629584467684bccf593b6876411668b5fe44")]
[assembly: AssemblyProduct("UnrealTentacle")]
[assembly: AssemblyTitle("DreWulff-UnrealTentacle")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[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 static class RarityParser
{
	public static void Parse(string raw, out Dictionary<LevelTypes, int> levelRarities, out Dictionary<string, int> customRarities)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		levelRarities = new Dictionary<LevelTypes, int>();
		customRarities = new Dictionary<string, int>();
		if (string.IsNullOrWhiteSpace(raw))
		{
			return;
		}
		string[] array = raw.Split(',');
		string[] array2 = array;
		foreach (string text in array2)
		{
			string[] array3 = text.Split(':');
			if (array3.Length != 2)
			{
				continue;
			}
			string text2 = array3[0].Trim();
			if (int.TryParse(array3[1].Trim(), out var result))
			{
				if (Enum.TryParse<LevelTypes>(text2, ignoreCase: true, out LevelTypes result2))
				{
					levelRarities[result2] = result;
				}
				else
				{
					customRarities[text2] = result;
				}
			}
		}
	}
}
namespace UnrealTentacle
{
	[RequireComponent(typeof(Rigidbody))]
	internal class UnrealTentacleAI : EnemyAI
	{
		private enum State
		{
			ROAMING,
			ASLEEP,
			ATTACK
		}

		[SerializeField]
		private Transform baseTentacleBone;

		[SerializeField]
		private Transform tentacleBone;

		[SerializeField]
		private Transform tentacleTip;

		[SerializeField]
		private GameObject barbProjectile;

		[SerializeField]
		private float barbSpeed;

		[SerializeField]
		private float searchRoofTimer;

		[SerializeField]
		private SpotVerifier spotVerifier;

		private Vector3 projectedPosition;

		private float searchRandomFactor;

		[SerializeField]
		private float range;

		private bool spottedPlayer = false;

		private bool spawned = false;

		private float lookAroundTimer;

		private List<PlayerControllerB> closePlayers = new List<PlayerControllerB>();

		private List<PlayerControllerB> onSightPlayers = new List<PlayerControllerB>();

		private Vector3 targetPlayerPosition;

		[Tooltip("Cooldown for damage instances.")]
		[SerializeField]
		private float damageCooldown;

		[Tooltip("Damage done to the player when hit while close.")]
		[SerializeField]
		private int stingDamage;

		[Tooltip("Damage done to the player when hit by the projectile.")]
		[SerializeField]
		private int barbDamage;

		[SerializeField]
		private GameObject mapDotObj;

		[SerializeField]
		private GameObject colliderObj;

		[SerializeField]
		private GameObject modelObj;

		[SerializeField]
		private GameObject scanNodeObj;

		[SerializeField]
		private int copiesToBeSpawned = 3;

		private float timeSinceDamagingPlayer;

		private float timeOfDeath;

		private Vector3 deadStartingPosition;

		private Vector3 deadTargetPosition;

		private bool onCeiling = false;

		[HideInInspector]
		public Rigidbody rb;

		public void StartAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			DoAnimationClientRpc("Attack");
		}

		private void AttackUpdate()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)null)
			{
				SyncTargetPlayerServerRpc();
				targetPlayerPosition = ((Component)base.targetPlayer).transform.position;
			}
			RotateTowardsPlayer(targetPlayerPosition);
		}

		private void AttackAI()
		{
			if (!TargetClosestPlayer())
			{
				Sleep();
			}
		}

		public void ShootProjectile()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)null)
			{
				ShootProjectile(((Component)base.targetPlayer).transform.position);
			}
		}

		public void ShootProjectile(Vector3 target)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00c2: 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)
			TentacleProjectile component = Object.Instantiate<GameObject>(barbProjectile, ((Component)tentacleTip).transform.position, ((Component)tentacleTip).transform.rotation, RoundManager.Instance.mapPropsContainer.transform).GetComponent<TentacleProjectile>();
			Vector3 val = target + new Vector3(0f, 2f, 0f) - tentacleTip.position;
			component.StartTrajectory(((Vector3)(ref val)).normalized * barbSpeed);
			NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
			component2.Spawn(false);
			val = target + new Vector3(0f, 2f, 0f) - tentacleTip.position;
			component.SyncVelocity(((Vector3)(ref val)).normalized * barbSpeed);
		}

		private void RotateTowardsPlayer(Vector3 target)
		{
			//IL_0007: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			tentacleBone.LookAt(target);
			if (((Component)this).transform.eulerAngles.z == 180f)
			{
				tentacleBone.eulerAngles = new Vector3(tentacleBone.eulerAngles.x - 45f, tentacleBone.eulerAngles.y, tentacleBone.localScale.z + 180f);
			}
		}

		private void StartRoam()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			base.inSpecialAnimation = false;
			searchRandomFactor = Random.Range(0f, searchRoofTimer / 2f);
			DisableScanNodeClientRpc();
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		private void RoamAI()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)this).transform.position, -Physics.gravity);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 20f, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && ((RaycastHit)(ref val2)).distance < 15f && ((RaycastHit)(ref val2)).distance > 2f && searchRoofTimer <= searchRandomFactor)
			{
				projectedPosition = ((RaycastHit)(ref val2)).point;
				((Component)spotVerifier).transform.position = projectedPosition;
				if (spotVerifier.collisionCounter <= 0)
				{
					ValidateSpotClientRpc();
				}
			}
			if (searchRoofTimer <= 0f)
			{
				StartSleep();
				return;
			}
			base.agent.speed = 500f;
			searchRoofTimer -= base.AIIntervalTime;
		}

		[ClientRpc]
		public void ValidateSpotClientRpc()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			StartSleep();
			((Component)this).transform.position = projectedPosition - new Vector3(0f, 0.05f, 0f);
			((Component)this).transform.eulerAngles = new Vector3(180f, (float)Random.Range(0, 360), 0f);
		}

		[ClientRpc]
		private void DisableScanNodeClientRpc()
		{
			((Behaviour)base.agent).enabled = true;
			scanNodeObj.SetActive(false);
		}

		public void StartSleep()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			for (int i = 1; i < copiesToBeSpawned; i++)
			{
				SpawnCopy();
			}
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			base.inSpecialAnimation = false;
			base.agent.speed = 0f;
			((Behaviour)base.agent).enabled = false;
			spottedPlayer = false;
			base.moveTowardsDestination = false;
			ReEnableEnemyClientRpc();
			SetSleepSpeedClientRpc(1f);
		}

		public void Sleep()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			spottedPlayer = false;
			lookAroundTimer = Random.Range(10, 20);
			spawned = true;
			DoAnimationClientRpc("Idle");
		}

		public void SleepAI()
		{
			if (TargetClosestPlayer() && !spottedPlayer)
			{
				spottedPlayer = true;
				DoAnimationClientRpc("Alert");
			}
			if (lookAroundTimer > 0f)
			{
				lookAroundTimer -= base.AIIntervalTime;
				return;
			}
			DoAnimationClientRpc("LookAround");
			lookAroundTimer = Random.Range(10, 20);
		}

		[ClientRpc]
		private void ReEnableEnemyClientRpc()
		{
			modelObj.SetActive(true);
			mapDotObj.SetActive(true);
			scanNodeObj.SetActive(true);
			colliderObj.SetActive(true);
		}

		private bool TargetClosestPlayer()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance && CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) && base.tempDist < range)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				return true;
			}
			return false;
		}

		public bool CheckLineOfSightForPosition(Vector3 objectPosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (Physics.Linecast(base.eye.position, objectPosition, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return false;
			}
			return true;
		}

		[ServerRpc]
		public void SyncTargetPlayerServerRpc()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)base.targetPlayer == (Object)null))
			{
				ReceiveTargetPlayerClientRpc(((Component)base.targetPlayer).transform.position);
			}
		}

		[ClientRpc]
		public void ReceiveTargetPlayerClientRpc(Vector3 target)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner)
			{
				targetPlayerPosition = target;
			}
		}

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			float num = Random.Range(0.8f, 1f);
			((Component)((Component)this).gameObject.transform).transform.localScale = num * ((Component)((Component)this).gameObject.transform).transform.localScale;
			rb = ((Component)this).gameObject.GetComponent<Rigidbody>();
			timeSinceDamagingPlayer = damageCooldown;
			LogIfDebugBuild("Unreal Tentacle Spawned");
			StartRoam();
		}

		public override void Update()
		{
			if (!base.isEnemyDead)
			{
				((EnemyAI)this).Update();
			}
		}

		public void LateUpdate()
		{
			//IL_0037: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (base.isEnemyDead)
			{
				if (timeOfDeath < 1f)
				{
					timeOfDeath += Time.deltaTime;
					Transform transform = ((Component)this).transform;
					Vector3 val = deadStartingPosition;
					Vector3 val2 = deadTargetPosition;
					float num = timeOfDeath * 10f;
					Vector3 val3 = deadTargetPosition - deadStartingPosition;
					transform.position = Vector3.Lerp(val, val2, num / ((Vector3)(ref val3)).magnitude);
				}
			}
			else
			{
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					break;
				case 1:
					break;
				case 2:
					AttackUpdate();
					break;
				}
			}
		}

		public override void DoAIInterval()
		{
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			((EnemyAI)this).DoAIInterval();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				RoamAI();
				break;
			case 1:
				if (spawned)
				{
					SleepAI();
				}
				break;
			case 2:
				AttackAI();
				break;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
				else if (base.enemyHP > 0)
				{
					DoAnimationServerRpc("Stun");
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			SetDeathPositionClientRpc();
		}

		[ServerRpc]
		public void DoAnimationServerRpc(string animationName)
		{
			DoAnimationClientRpc(animationName);
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			base.creatureAnimator.SetTrigger(animationName);
		}

		[ClientRpc]
		public void SetSleepSpeedClientRpc(float value)
		{
			base.creatureAnimator.SetFloat("AnimationSpeed", value);
		}

		[ClientRpc]
		public void SetDeathPositionClientRpc()
		{
			//IL_0008: 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_001a: 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_002f: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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)
			deadStartingPosition = ((Component)this).transform.position;
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(base.eye.position, Vector3.down);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Linecast(base.eye.position, base.eye.position + Vector3.down * 20f, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				deadTargetPosition = ((RaycastHit)(ref val2)).point + new Vector3(0f, 0.2f, 0f);
			}
			timeOfDeath = 0f;
		}

		public void SpawnCopy()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner)
			{
				UnrealTentacleAI component = Object.Instantiate<GameObject>(base.enemyType.enemyPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, RoundManager.Instance.mapPropsContainer.transform).GetComponent<UnrealTentacleAI>();
				NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
				component2.Spawn(false);
				component.DontSpawnCopiesClientRpc();
			}
		}

		[ClientRpc]
		private void DontSpawnCopiesClientRpc()
		{
			copiesToBeSpawned = 0;
		}
	}
	[BepInPlugin("DreWulff-UnrealTentacle", "UnrealTentacle", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "unreal-tentacle-assets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("NaliTentacle");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("NaliTentacleTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("NaliTentacleTK");
			GameObject val4 = ModAssets.LoadAsset<GameObject>("Barb");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4);
			RarityParser.Parse(BoundConfig.Rarity.Value, out Dictionary<LevelTypes, int> levelRarities, out Dictionary<string, int> customRarities);
			Enemies.RegisterEnemy(val, levelRarities, customRarities, val2, val3);
			Logger.LogInfo((object)"Plugin DreWulff-UnrealTentacle is loaded!");
		}

		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.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);
					}
				}
			}
		}
	}
	internal class SpotVerifier : MonoBehaviour
	{
		[HideInInspector]
		public int collisionCounter = 0;

		private void OnTriggerEnter(Collider other)
		{
			if ((StartOfRound.Instance.collidersAndRoomMaskAndDefault & (1 << ((Component)other).gameObject.layer)) != 0)
			{
				collisionCounter++;
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if ((StartOfRound.Instance.collidersAndRoomMaskAndDefault & (1 << ((Component)other).gameObject.layer)) != 0)
			{
				collisionCounter--;
			}
		}
	}
	internal class TentacleAnimationEvents : MonoBehaviour
	{
		[SerializeField]
		private UnrealTentacleAI mainAI;

		public void EndSpawn()
		{
			mainAI.Sleep();
		}

		public void StartAttack()
		{
			mainAI.StartAttack();
		}

		public void Shoot()
		{
			mainAI.ShootProjectile();
		}

		public void EndStun()
		{
			mainAI.DoAnimationClientRpc("Alert");
		}
	}
	internal class TentacleProjectile : NetworkBehaviour
	{
		[SerializeField]
		private int damage = 20;

		private Rigidbody rb;

		private float TTL;

		private void Awake()
		{
			TTL = 3f;
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		private void Update()
		{
			if (TTL < 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				TTL -= Time.deltaTime;
			}
		}

		public void StartTrajectory(Vector3 speed)
		{
			//IL_0007: 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_001f: 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)
			rb.velocity = speed;
			((Component)this).transform.LookAt(((Component)this).transform.position + speed);
			((Component)this).transform.Rotate(-90f, 0f, 0f);
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_0029: 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)
			if (((Component)other).gameObject.CompareTag("Player"))
			{
				((Component)other).GetComponent<PlayerControllerB>().DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if ((0x100B08u & (uint)(1 << ((Component)other).gameObject.layer)) != 0)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		[ClientRpc]
		private void StartTrajectoryClientRpc(Vector3 speed)
		{
			//IL_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsOwner)
			{
				rb.velocity = speed;
				((Component)this).transform.LookAt(((Component)this).transform.position + speed);
				((Component)this).transform.Rotate(-90f, 0f, 0f);
			}
		}

		public void SyncVelocity(Vector3 velocity)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			StartTrajectoryClientRpc(velocity);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DreWulff-UnrealTentacle";

		public const string PLUGIN_NAME = "UnrealTentacle";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace UnrealTentacle.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<string> Rarity;

		public PluginConfig(ConfigFile cfg)
		{
			Rarity = cfg.Bind<string>("Spawning", "Rarity", "All:15,6 Mazon:200,Halation:100,Vow:100,46 Infernis:200", "Spawn weights per moon.\nFormat: Key:Weight,Key:Weight\nKeys can be LevelTypes (All, Modded, ExperimentationLevel, etc)\nor custom moon names (Junic, Infernis, etc).");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}