Decompiled source of TheGiantSpecimens v2.2.1

plugins/TheGiantSpecimens/TheGiantSpecimens.dll

Decompiled 3 months ago
using System;
using System.Collections;
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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DigitalRuby.ThunderAndLightning;
using GameNetcodeStuff;
using GiantSpecimens.Colours;
using GiantSpecimens.Configs;
using GiantSpecimens.Dependency;
using GiantSpecimens.Patches;
using GiantSpecimens.StormScript;
using GiantSpecimens.src;
using HarmonyLib;
using LethalLib.Modules;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using MoreShipUpgrades.API;
using On.GameNetcodeStuff;
using TheGiantSpecimens.NetcodePatcher;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("MoreShipUpgrades")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TheGiantSpecimens")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Giant Enemies for Lethal Company.")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: AssemblyInformationalVersion("2.2.1+4b176fbbab64312092708aee3e1a1d62daf1dd64")]
[assembly: AssemblyProduct("TheGiantSpecimens")]
[assembly: AssemblyTitle("TheGiantSpecimens")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
		NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<NetworkBehaviourReference>();
		NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<NetworkBehaviourReference>();
	}
}
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 GiantSpecimens
{
	[BepInPlugin("TheGiantSpecimens", "TheGiantSpecimens", "2.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Harmony _harmony = new Harmony("TheGiantSpecimens");

		public static EnemyType PinkGiant;

		public static EnemyType StellarSovereign;

		public static EnemyType DriftGiant;

		public static Item RedWoodPlushie;

		public static Item Whistle;

		public static Item RedWoodHeart;

		public static Item DriftwoodSample;

		internal static ManualLogSource Logger;

		public static CauseOfDeath RupturedEardrums = EnumUtils.Create<CauseOfDeath>("RupturedEardrums");

		public static CauseOfDeath InternalBleed = EnumUtils.Create<CauseOfDeath>("InternalBleed");

		public static CauseOfDeath Thwomped = EnumUtils.Create<CauseOfDeath>("Thwomped");

		public static ThreatType DriftwoodGiant = EnumUtils.Create<ThreatType>("DriftwoodGiant");

		public static Dictionary<string, Item> samplePrefabs = new Dictionary<string, Item>();

		public static bool LGULoaded;

		private static PluginInfo LGU;

		public static GiantSpecimensConfig ModConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			if (LobbyCompatibilityChecker.Enabled)
			{
				LobbyCompatibilityChecker.Init();
			}
			ModConfig = new GiantSpecimensConfig(((BaseUnityPlugin)this).Config);
			GiantPatches.Init();
			Assets.PopulateAssets();
			GiantSpecimensScrap();
			GiantSpecimensEnemies();
			Logger.LogInfo((object)"Plugin TheGiantSpecimens is loaded!");
			InitializeNetworkBehaviours();
			_harmony.PatchAll(typeof(StartOfRoundPatcher));
		}

		internal static void GiantSpecimensScrap()
		{
			Whistle = Assets.MainAssetBundle.LoadAsset<Item>("WhistleObj");
			Utilities.FixMixerGroups(Whistle.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(Whistle.spawnPrefab);
			TerminalNode terminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("wlTerminalNode");
			RegisterShopItemWithConfig(GiantSpecimensConfig.ConfigWhistleEnabled.Value, GiantSpecimensConfig.ConfigWhistleScrapEnabled.Value, Whistle, terminalNode, GiantSpecimensConfig.ConfigWhistleCost.Value, GiantSpecimensConfig.ConfigWhistleRarity.Value);
			RedWoodPlushie = Assets.MainAssetBundle.LoadAsset<Item>("RedWoodPlushieObj");
			Utilities.FixMixerGroups(RedWoodPlushie.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(RedWoodPlushie.spawnPrefab);
			RegisterScrapWithConfig(GiantSpecimensConfig.ConfigRedwoodPlushieEnabled.Value, GiantSpecimensConfig.ConfigRedwoodPlushieRarity.Value, RedWoodPlushie);
			RedWoodHeart = Assets.MainAssetBundle.LoadAsset<Item>("RedwoodHeartObj");
			Utilities.FixMixerGroups(RedWoodHeart.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(RedWoodHeart.spawnPrefab);
			DriftwoodSample = Assets.MainAssetBundle.LoadAsset<Item>("DriftWoodGiantSample");
			Utilities.FixMixerGroups(DriftwoodSample.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(DriftwoodSample.spawnPrefab);
			samplePrefabs.Add("RedWoodGiant", RedWoodHeart);
			samplePrefabs.Add("DriftWoodGiant", DriftwoodSample);
		}

		internal static void GiantSpecimensEnemies()
		{
			PinkGiant = Assets.MainAssetBundle.LoadAsset<EnemyType>("PinkGiantObj");
			PinkGiant.PowerLevel = GiantSpecimensConfig.ConfigRedwoodGiantPower.Value;
			TerminalNode terminalNode = Assets.MainAssetBundle.LoadAsset<TerminalNode>("PinkGiantTN");
			TerminalKeyword terminalKeyword = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("PinkGiantTK");
			NetworkPrefabs.RegisterNetworkPrefab(PinkGiant.enemyPrefab);
			RegisterEnemyWithConfig(GiantSpecimensConfig.ConfigRedWoodEnabled.Value, GiantSpecimensConfig.ConfigRedWoodRarity.Value, PinkGiant, terminalNode, terminalKeyword);
			DriftGiant = Assets.MainAssetBundle.LoadAsset<EnemyType>("DriftwoodGiantObj");
			DriftGiant.PowerLevel = GiantSpecimensConfig.ConfigDriftwoodGiantPower.Value;
			TerminalNode terminalNode2 = Assets.MainAssetBundle.LoadAsset<TerminalNode>("DriftwoodGiantTN");
			TerminalKeyword terminalKeyword2 = Assets.MainAssetBundle.LoadAsset<TerminalKeyword>("DriftwoodGiantTK");
			NetworkPrefabs.RegisterNetworkPrefab(DriftGiant.enemyPrefab);
			RegisterEnemyWithConfig(GiantSpecimensConfig.ConfigDriftWoodEnabled.Value, GiantSpecimensConfig.ConfigDriftWoodRarity.Value, DriftGiant, terminalNode2, terminalKeyword2);
		}

		internal static void RunLGUCompatibility()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.malco.lethalcompany.moreshipupgrades", out LGU))
			{
				return;
			}
			LGULoaded = true;
			Logger.LogInfo((object)$"MNC = {LGU}");
			if (GiantSpecimensConfig.ConfigDriftwoodHeartEnabled.Value)
			{
				samplePrefabs.TryGetValue("DriftWoodGiant", out var value);
				if ((Object)(object)value != (Object)null)
				{
					RegisterLGUSample(value, "DriftWoodGiant", 2, registerNetworkPrefab: false, grabbableToEnemies: true);
				}
				else
				{
					Logger.LogInfo((object)"Error registering Driftwood Giant Sample!");
				}
			}
			if (GiantSpecimensConfig.ConfigRedwoodHeartEnabled.Value)
			{
				samplePrefabs.TryGetValue("RedWoodGiant", out var value2);
				if ((Object)(object)value2 != (Object)null)
				{
					RegisterLGUSample(value2, "RedWoodGiant", 3, registerNetworkPrefab: false, grabbableToEnemies: true);
				}
				else
				{
					Logger.LogInfo((object)"Error registering Redwood Giant Sample!");
				}
			}
		}

		private void InitializeNetworkBehaviours()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array = methods;
				foreach (MethodInfo methodInfo in array)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}

		private static void RegisterEnemyWithConfig(bool enabled, string configMoonRarity, EnemyType enemy, TerminalNode terminalNode, TerminalKeyword terminalKeyword)
		{
			if (enabled)
			{
				var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
				Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword);
			}
			else
			{
				Enemies.RegisterEnemy(enemy, 0, (LevelTypes)(-1), terminalNode, terminalKeyword);
			}
		}

		private static void RegisterScrapWithConfig(bool enabled, string configMoonRarity, Item scrap)
		{
			if (enabled)
			{
				var (dictionary, dictionary2) = ConfigParsing(configMoonRarity);
				Items.RegisterScrap(scrap, dictionary, dictionary2);
			}
			else
			{
				Items.RegisterScrap(scrap, 0, (LevelTypes)(-1));
			}
		}

		private static void RegisterShopItemWithConfig(bool enabledShopItem, bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity)
		{
			if (enabledShopItem)
			{
				Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost);
			}
			if (enabledScrap)
			{
				RegisterScrapWithConfig(enabled: true, configMoonRarity, item);
			}
		}

		private static void RegisterLGUSample(Item sample, string monster, int level, bool registerNetworkPrefab, bool grabbableToEnemies, double weight = 50.0)
		{
			if (LGULoaded)
			{
				Type typeFromHandle = typeof(HunterSamples);
				MethodInfo method = typeFromHandle.GetMethod("RegisterSample", new Type[6]
				{
					typeof(Item),
					typeof(string),
					typeof(int),
					typeof(bool),
					typeof(bool),
					typeof(double)
				});
				method.Invoke(null, new object[6] { sample, monster, level, registerNetworkPrefab, grabbableToEnemies, weight });
			}
		}

		private static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
			foreach (string item in from s in configMoonRarity.Split(',')
				select s.Trim())
			{
				string[] array = item.Split(':');
				if (array.Length != 2)
				{
					continue;
				}
				string text = array[0];
				if (int.TryParse(array[1], out var result))
				{
					if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2))
					{
						dictionary[result2] = result;
						Logger.LogInfo((object)$"Registered spawn rate for level type {result2} to {result}");
					}
					else
					{
						dictionary2[text] = result;
						Logger.LogInfo((object)$"Registered spawn rate for custom level type {text} to {result}");
					}
				}
			}
			return (dictionary, dictionary2);
		}
	}
	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, "giantspecimensassetsll"));
			if ((Object)(object)MainAssetBundle == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to load custom assets.");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TheGiantSpecimens";

		public const string PLUGIN_NAME = "TheGiantSpecimens";

		public const string PLUGIN_VERSION = "2.2.1";
	}
}
namespace GiantSpecimens.StormScript
{
	public class StormyWeatherScript
	{
		public static void LogIfDebugBuild(string text)
		{
		}

		public static void SpawnLightningBolt(Vector3 strikePosition)
		{
			//IL_0035: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 85);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)random.Next(-32, 32), 0f, (float)random.Next(-32, 32));
			Vector3 val2 = strikePosition + Vector3.up * 160f + val;
			StormyWeather val3 = Object.FindObjectOfType<StormyWeather>(true);
			if ((Object)(object)val3 == (Object)null)
			{
				LogIfDebugBuild("StormyWeather not found");
				return;
			}
			LogIfDebugBuild($"{val2} -> {strikePosition}");
			LightningBoltPrefabScript val4 = Object.Instantiate<LightningBoltPrefabScript>(val3.targetedThunder);
			((Behaviour)val4).enabled = true;
			if ((Object)(object)val4 == (Object)null)
			{
				LogIfDebugBuild("localLightningBoltPrefabScript not found");
				return;
			}
			((LightningBoltPrefabScriptBase)val4).GlowWidthMultiplier = 2.5f;
			((LightningBoltPrefabScriptBase)val4).DurationRange = new RangeOfFloats
			{
				Minimum = 0.6f,
				Maximum = 1.2f
			};
			((LightningBoltPrefabScriptBase)val4).TrunkWidthRange = new RangeOfFloats
			{
				Minimum = 0.6f,
				Maximum = 1.2f
			};
			((LightningBoltScript)val4).Camera = GameNetworkManager.Instance.localPlayerController.gameplayCamera;
			val4.Source.transform.position = val2;
			val4.Destination.transform.position = strikePosition;
			((LightningBoltPrefabScriptBase)val4).AutomaticModeSeconds = 0.2f;
			((LightningBoltPrefabScriptBase)val4).Generations = 8;
			MonoBehaviour val5 = (MonoBehaviour)(object)val4;
			val5.StartCoroutine(ChangeLightningColor(val4));
			((LightningBoltPrefabScriptBase)val4).CreateLightningBoltsNow();
			AudioSource val6 = Object.Instantiate<AudioSource>(val3.targetedStrikeAudio);
			((Component)val6).transform.position = strikePosition + Vector3.up * 0.5f;
			((Behaviour)val6).enabled = true;
			val6.volume /= 4f;
			val3.PlayThunderEffects(strikePosition, val6);
		}

		private static IEnumerator ChangeLightningColor(LightningBoltPrefabScript boltScript)
		{
			float duration = 1f;
			float timer = 0f;
			while (timer < duration)
			{
				float num = timer / duration;
				((LightningBoltScript)boltScript).GlowTintColor = Color.Lerp(new Color(0.8f, 0f, 0f, 0.25f), Color.blue, num);
				((LightningBoltScript)boltScript).LightningTintColor = Color.Lerp(new Color(0.7f, 0f, 0f, 0.25f), Color.cyan, num);
				((LightningBoltScript)boltScript).MainTrunkTintColor = Color.Lerp(new Color(0.6f, 0f, 0f, 0.25f), Color.white, num);
				timer += Time.deltaTime;
				yield return null;
			}
		}
	}
}
namespace GiantSpecimens.Patches
{
	public static class GiantPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_PlayerHitGroundEffects <0>__PlayerControllerB_PlayerHitGroundEffects;
		}

		public static bool thrownByGiant;

		public static bool grabbedByGiant;

		public static PlayerControllerB playerControllerB;

		public static bool addedToDebug;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerControllerB_PlayerHitGroundEffects;
			if (obj == null)
			{
				hook_PlayerHitGroundEffects val = PlayerControllerB_PlayerHitGroundEffects;
				<>O.<0>__PlayerControllerB_PlayerHitGroundEffects = val;
				obj = (object)val;
			}
			PlayerControllerB.PlayerHitGroundEffects += (hook_PlayerHitGroundEffects)obj;
		}

		private static void PlayerControllerB_PlayerHitGroundEffects(orig_PlayerHitGroundEffects orig, PlayerControllerB self)
		{
			if ((Object)(object)playerControllerB != (Object)null && thrownByGiant && (Object)(object)self != (Object)null && (Object)(object)self == (Object)(object)playerControllerB && self.fallValueUncapped < -39f)
			{
				self.fallValueUncapped = -39f;
				thrownByGiant = false;
				((Component)self).GetComponent<Rigidbody>().isKinematic = true;
			}
			if (grabbedByGiant && (Object)(object)self != (Object)null)
			{
				self.fallValue = 0f;
				self.fallValueUncapped = 0f;
			}
			orig.Invoke(self);
		}
	}
}
namespace GiantSpecimens.src
{
	internal class GiantSpecimensUtils : NetworkBehaviour
	{
		private static int seed;

		private static Random random;

		internal static GiantSpecimensUtils Instance { get; set; }

		private void Awake()
		{
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnScrapServerRpc(string itemName, Vector3 position)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1936775984u, val, (RpcDelivery)0);
				bool flag = itemName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(itemName, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1936775984u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				Plugin.Logger.LogInfo((object)"StartOfRound null");
				return;
			}
			if (random == null)
			{
				Plugin.Logger.LogInfo((object)"Initializing random");
				seed = StartOfRound.Instance.randomMapSeed;
				random = new Random(seed + 85);
			}
			if (itemName.Length == 0)
			{
				Plugin.Logger.LogInfo((object)"itemName is empty");
				return;
			}
			Plugin.samplePrefabs.TryGetValue(itemName, out var value);
			if ((Object)(object)value == (Object)null)
			{
				Plugin.Logger.LogInfo((object)("Could not get Item " + itemName));
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(value.spawnPrefab, position + Vector3.up, Quaternion.identity);
			int num = random.Next(value.minValue, value.maxValue);
			ScanNodeProperties componentInChildren = val3.gameObject.GetComponentInChildren<ScanNodeProperties>();
			componentInChildren.scrapValue = num;
			componentInChildren.subText = $"Value: ${num}";
			val3.GetComponent<GrabbableObject>().scrapValue = num;
			val3.GetComponent<NetworkObject>().Spawn(false);
			UpdateScanNodeClientRpc(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>()), num);
		}

		[ClientRpc]
		public void UpdateScanNodeClientRpc(NetworkObjectReference go, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(46640521u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 46640521u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				NetworkObject val3 = default(NetworkObject);
				((NetworkObjectReference)(ref go)).TryGet(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 != (Object)null)
				{
					ScanNodeProperties componentInChildren = ((Component)val3).GetComponentInChildren<ScanNodeProperties>();
					componentInChildren.scrapValue = value;
					componentInChildren.subText = $"Value: ${value}";
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_GiantSpecimensUtils()
		{
			//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(1936775984u, new RpcReceiveHandler(__rpc_handler_1936775984));
			NetworkManager.__rpc_func_table.Add(46640521u, new RpcReceiveHandler(__rpc_handler_46640521));
		}

		private static void __rpc_handler_1936775984(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string itemName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref itemName, false);
				}
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GiantSpecimensUtils)(object)target).SpawnScrapServerRpc(itemName, position);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_46640521(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference go = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref go, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((GiantSpecimensUtils)(object)target).UpdateScanNodeClientRpc(go, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "GiantSpecimensUtils";
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatcher
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void RegisterScraps()
		{
			foreach (Item value in Plugin.samplePrefabs.Values)
			{
				if (!StartOfRound.Instance.allItemsList.itemsList.Contains(value))
				{
					StartOfRound.Instance.allItemsList.itemsList.Add(value);
				}
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void StartOfRound_Start(ref StartOfRound __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(WaitForNetworkObject(__instance, CreateNetworkManager));
		}

		private static IEnumerator WaitForNetworkObject(StartOfRound __instance, Action<StartOfRound> action)
		{
			while (!((NetworkBehaviour)__instance).NetworkObject.IsSpawned)
			{
				yield return null;
			}
			action(__instance);
		}

		private static void CreateNetworkManager(StartOfRound __instance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			Plugin.Logger.LogInfo((object)$"IsServer: {((NetworkBehaviour)__instance).IsServer}");
			if (((NetworkBehaviour)__instance).IsServer)
			{
				if ((Object)(object)GiantSpecimensUtils.Instance == (Object)null)
				{
					GameObject val = new GameObject("GiantSpecimensUtils")
					{
						hideFlags = (HideFlags)61
					};
					val.AddComponent<GiantSpecimensUtils>();
					val.AddComponent<NetworkObject>();
					val.GetComponent<NetworkObject>().GlobalObjectIdHash = 4004522770u;
					val.GetComponent<NetworkObject>().Spawn(false);
					Plugin.Logger.LogInfo((object)"Created GiantSpecimensUtils.");
				}
				else
				{
					Plugin.Logger.LogWarning((object)"GiantSpecimensUtils already exists?");
				}
			}
		}

		[HarmonyPatch("OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable(StartOfRound __instance)
		{
			GiantSpecimensUtils.Instance = null;
		}
	}
}
namespace GiantSpecimens.Configs
{
	public class GiantSpecimensConfig
	{
		public static ConfigEntry<int> ConfigMultiplierForestkeeper { get; private set; }

		public static ConfigEntry<float> ConfigSpeedRedWood { get; private set; }

		public static ConfigEntry<float> ConfigShipDistanceRedWood { get; private set; }

		public static ConfigEntry<float> ConfigForestDistanceRedWood { get; private set; }

		public static ConfigEntry<string> ConfigColourHexcode { get; private set; }

		public static ConfigEntry<bool> ConfigRedWoodEnabled { get; private set; }

		public static ConfigEntry<string> ConfigRedWoodRarity { get; private set; }

		public static ConfigEntry<bool> ConfigRedwoodPlushieEnabled { get; private set; }

		public static ConfigEntry<string> ConfigRedwoodPlushieRarity { get; private set; }

		public static ConfigEntry<int> ConfigWhistleCost { get; private set; }

		public static ConfigEntry<bool> ConfigWhistleEnabled { get; private set; }

		public static ConfigEntry<string> ConfigWhistleRarity { get; private set; }

		public static ConfigEntry<bool> ConfigWhistleScrapEnabled { get; private set; }

		public static ConfigEntry<bool> ConfigDriftWoodEnabled { get; private set; }

		public static ConfigEntry<string> ConfigDriftWoodRarity { get; private set; }

		public static ConfigEntry<bool> ConfigDriftWoodPlushieEnabled { get; private set; }

		public static ConfigEntry<string> ConfigDriftWoodPlushieRarity { get; private set; }

		public static ConfigEntry<int> ConfigMultiplierDriftwood { get; private set; }

		public static ConfigEntry<bool> ConfigZeusMode { get; private set; }

		public static ConfigEntry<bool> ConfigEatOldBirds { get; private set; }

		public static ConfigEntry<float> ConfigScreamRange { get; private set; }

		public static ConfigEntry<bool> ConfigDriftwoodHeartEnabled { get; private set; }

		public static ConfigEntry<bool> ConfigRedwoodHeartEnabled { get; private set; }

		public static ConfigEntry<float> ConfigRedwoodGiantPower { get; private set; }

		public static ConfigEntry<float> ConfigDriftwoodGiantPower { get; private set; }

		public GiantSpecimensConfig(ConfigFile configFile)
		{
			ConfigRedwoodGiantPower = configFile.Bind<float>("Enemy Options", "Redwood Giant | Enemy Power", 1f, "Config the enemy power of the Redwood Giant");
			ConfigDriftwoodGiantPower = configFile.Bind<float>("Enemy Options", "DriftWood Giant | Enemy Power", 1f, "Config the enemy power of the Driftwood Giant");
			ConfigDriftwoodHeartEnabled = configFile.Bind<bool>("Scrap Options", "DriftWood Giant | Heart", true, "Enables/Disables the Heart (Currently looks like an LGU Sample) from spawning on death.");
			ConfigRedwoodHeartEnabled = configFile.Bind<bool>("Scrap Options", "RedWood Giant | Heart", true, "Enables/Disables the Heart from spawning on death.");
			ConfigRedwoodPlushieEnabled = configFile.Bind<bool>("Scrap Options", "RedWood Giant | Plushie", true, "Enables/Disables the Plushie from appearing ingame.");
			ConfigZeusMode = configFile.Bind<bool>("Enemy Options", "RedWood Giant | Zeus Mode", false, "Enables/Disables the Zeus mode.");
			ConfigEatOldBirds = configFile.Bind<bool>("Enemy Options", "RedWood Giant | Eating Palette", true, "Enables/Disables the eating of old birds.");
			ConfigScreamRange = configFile.Bind<float>("Enemy Options", "DriftWood Giant | Scream Range", 20f, "Configure the range of the scream of the Driftwood Giant");
			ConfigMultiplierForestkeeper = configFile.Bind<int>("Enemy Options", "ForestKeeper Multiplier", 2, "Multiplier in Forest Keeper spawnrate after the RedWood Giant spawns.");
			ConfigMultiplierDriftwood = configFile.Bind<int>("Enemy Options", "Driftwood Multiplier", 2, "Multiplier in Driftwood spawnrate after the RedWood Giant spawns");
			ConfigRedWoodEnabled = configFile.Bind<bool>("Enemy Options", "RedWood Giant | Enabled", true, "Enables/Disables the spawning of the RedWood Giant (sets rarity to 0 if false on all moons)");
			ConfigRedWoodRarity = configFile.Bind<string>("Enemy Options", "RedWood Giant | Spawn Weight.", "Modded:100,ExperimentationLevel:50,AssuranceLevel:100,VowLevel:200,OffenseLevel:100,MarchLevel:200,RendLevel:200,DineLevel:100,TitanLevel:200,Adamance:100,Embrion:150,Artifice:200,Auralis:150", "Spawn Weight of the RedWood Giant in all moons, Feel free to add to it any moon, just follow the format (also needs LLL installed for LE moons to work with this config).");
			ConfigSpeedRedWood = configFile.Bind<float>("Enemy Options", "RedWood Giant Speed", 2f, "Default walking speed of the RedWood Giant, (Chase speed is 4*Walking Speed) I recommend 1.5 to 3.");
			ConfigShipDistanceRedWood = configFile.Bind<float>("Enemy Options", "RedWood Giant Targetting Range | Ship", 10f, "Distance of the Forest Keeper to the ship that stops the RedWoodGiant from chasing them, I recommend 0 to 15f (values are completely untested).");
			ConfigForestDistanceRedWood = configFile.Bind<float>("Enemy Options", "RedWood Giant Targetting Range | Forest Keeper", 50f, "Distance from which the RedWood Giant is able to see the Forest Keeper, I recommend 30f or more.");
			ConfigColourHexcode = configFile.Bind<string>("Enemy Options", "RedWood Giant | Footstep Colour", "#808080", "Decides what the default colour of the footsteps is using a hexcode, default is grey (Invalid hexcodes will default to Grey), keep blank to use Modded set colours set by me for different moons, don't forget to include the hashtag in config.");
			ConfigWhistleRarity = configFile.Bind<string>("Scrap Options", "Whistle Scrap | Rarity", "Modded:5,ExperimentationLevel:5,AssuranceLevel:5,VowLevel:5,OffenseLevel:5,MarchLevel:5,RendLevel:5,DineLevel:5,TitanLevel:5,Adamance:5,Embrion:5,Artifice:5", "Rarity of Whistle scrap appearing on every moon (set to Modded:0,Vanilla:0 if you'd like for it to not spawn).");
			ConfigRedwoodPlushieRarity = configFile.Bind<string>("Scrap Options", "RedWood Giant Scrap | Rarity", "Modded:5,ExperimentationLevel:5,AssuranceLevel:5,VowLevel:5,OffenseLevel:5,MarchLevel:5,RendLevel:5,DineLevel:5,TitanLevel:5,Adamance:5,Embrion:5,Artifice:5", "Rarity of redwood plushie appearing on every moon (set to Modded:0,Vanilla:0 if you'd like for it to not spawn).");
			ConfigWhistleEnabled = configFile.Bind<bool>("Shop Options", "Whistle Item | Enabled", true, "Enables/Disables the whistle showing up in shop");
			ConfigWhistleScrapEnabled = configFile.Bind<bool>("Scrap Options", "Whistle Scrap | Enabled", true, "Enables/Disables the whistle showing up");
			ConfigWhistleCost = configFile.Bind<int>("Shop Options", "Whistle Item | Cost", 111, "Cost of Whistle");
			ConfigDriftWoodEnabled = configFile.Bind<bool>("Enemy Options", "Driftwood | Enabled", true, "Enables/Disables the spawning of the driftwood (sets rarity to 0 if false on all moons)");
			ConfigDriftWoodRarity = configFile.Bind<string>("Enemy Options", "Driftwood | Rarity", "Modded:100,ExperimentationLevel:75,AssuranceLevel:50,VowLevel:150,OffenseLevel:50,MarchLevel:175,RendLevel:125,DineLevel:125,TitanLevel:150,Adamance:100,Embrion:150,Artifice:200", "Rarity of driftwood appearing on every moon");
			ConfigDriftWoodPlushieRarity = configFile.Bind<string>("Scrap Options", "Driftwood Scrap | Rarity", "Modded:5,ExperimentationLevel:5,AssuranceLevel:5,VowLevel:5,OffenseLevel:5,MarchLevel:5,RendLevel:5,DineLevel:5,TitanLevel:5,Adamance:5,Embrion:5,Artifice:5", "Rarity of driftwood plushie appearing on every moon (set to Modded:0,Vanilla:0 if you'd like for it to not spawn).");
			ClearUnusedEntries(configFile);
			Plugin.Logger.LogInfo((object)"Setting up config for Giant Specimen plugin...");
		}

		private void ClearUnusedEntries(ConfigFile configFile)
		{
			PropertyInfo property = ((object)configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(configFile, null);
			dictionary.Clear();
			configFile.Save();
		}
	}
}
namespace GiantSpecimens.Scrap
{
	public class RedwoodHeart : GrabbableObject
	{
		public AudioSource heartSound;

		public AudioClip[] heartBeatClips;

		public Material heartMaterial;

		private void LogIfDebugBuild(string text)
		{
		}

		public override void Start()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_004c: Expected O, but got Unknown
			((GrabbableObject)this).Start();
			Transform val = ((Component)this).transform.Find("Body");
			if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<MeshRenderer>() != (Object)null)
			{
				MeshRenderer component = ((Component)val).GetComponent<MeshRenderer>();
				Material val2 = new Material(((Renderer)((Component)val).GetComponent<MeshRenderer>()).material);
				Material val3 = val2;
				((Renderer)component).material = val2;
				heartMaterial = val3;
			}
			else
			{
				LogIfDebugBuild("Body or MeshRenderer component not found, material not cloned.");
			}
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			LogIfDebugBuild("Giant Heart Item Activated");
			((MonoBehaviour)this).StartCoroutine(GlowAnimation());
		}

		private IEnumerator GlowAnimation()
		{
			float initialTime = 0f;
			float duration1 = 5f;
			Color startColor = Color.red;
			Color endColor = new Color(1f, 0.71f, 1f, 1f);
			while (initialTime < duration1)
			{
				Color color = Color.Lerp(startColor, endColor, initialTime / duration1);
				heartMaterial.color = color;
				initialTime += Time.deltaTime;
				yield return null;
			}
		}

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

		protected internal override string __getTypeName()
		{
			return "RedwoodHeart";
		}
	}
	public class DriftwoodHeart : GrabbableObject
	{
		public AudioSource heartSound;

		public AudioClip[] heartBeatClips;

		private void LogIfDebugBuild(string text)
		{
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			((Component)this).GetComponentInChildren<ParticleSystem>().Stop();
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			LogIfDebugBuild("Driftwood heart discarded");
			((Component)this).GetComponentInChildren<ParticleSystem>().Stop();
			((Component)this).GetComponentInChildren<ParticleSystem>().Clear();
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			LogIfDebugBuild("Driftwood heart pocketed");
			((Component)this).GetComponentInChildren<ParticleSystem>().Stop();
			((Component)this).GetComponentInChildren<ParticleSystem>().Clear();
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			LogIfDebugBuild("Driftwood heart grabbed");
			((Component)this).GetComponentInChildren<ParticleSystem>().Play();
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			LogIfDebugBuild("Driftwood heart equipped");
			((Component)this).GetComponentInChildren<ParticleSystem>().Play();
		}

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

		protected internal override string __getTypeName()
		{
			return "DriftwoodHeart";
		}
	}
	public class RedwoodPlushieScrap : GrabbableObject
	{
		[SerializeField]
		public AudioSource plushiePlayer;

		[SerializeField]
		public AudioClip[] plushieSounds;

		[SerializeField]
		public float maxLoudness;

		[SerializeField]
		public float minLoudness;

		[SerializeField]
		public float minPitch;

		[SerializeField]
		public float maxPitch;

		private Random noisemakerRandom;

		public Animator triggerAnimator;

		[NonSerialized]
		public AudioClip soundToPlay;

		private void LogIfDebugBuild(string text)
		{
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			int num = noisemakerRandom.Next(0, plushieSounds.Length);
			float volume = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
			float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
			plushiePlayer.pitch = pitch;
			soundToPlay = plushieSounds[num];
			PlayPlushiePlayer(volume);
			if ((Object)(object)base.playerHeldBy != (Object)null)
			{
				Animator obj = triggerAnimator;
				if (obj != null)
				{
					obj.SetTrigger("startSqueeze");
				}
			}
		}

		public void PlayPlushiePlayer(float volume)
		{
			plushiePlayer.PlayOneShot(soundToPlay, volume);
			if (((NetworkBehaviour)this).IsHost)
			{
				PlayPlushiePlayerClientRpc(volume);
			}
			else
			{
				PlayPlushiePlayerServerRpc(volume);
			}
		}

		[ServerRpc]
		public void PlayPlushiePlayerServerRpc(float volume)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Invalid comparison between Unknown and I4
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(897526911u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volume, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 897526911u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviour)this).IsHost)
			{
				PlayPlushiePlayerClientRpc(volume);
			}
		}

		[ClientRpc]
		public void PlayPlushiePlayerClientRpc(float volume)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_007d: 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_0097: 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(2117604191u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref volume, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2117604191u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsHost)
				{
					plushiePlayer.PlayOneShot(soundToPlay, volume);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_RedwoodPlushieScrap()
		{
			//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(897526911u, new RpcReceiveHandler(__rpc_handler_897526911));
			NetworkManager.__rpc_func_table.Add(2117604191u, new RpcReceiveHandler(__rpc_handler_2117604191));
		}

		private static void __rpc_handler_897526911(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				float volume = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volume, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RedwoodPlushieScrap)(object)target).PlayPlushiePlayerServerRpc(volume);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2117604191(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float volume = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref volume, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((RedwoodPlushieScrap)(object)target).PlayPlushiePlayerClientRpc(volume);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RedwoodPlushieScrap";
		}
	}
	public class WhistleItem : GrabbableObject
	{
		[SerializeField]
		public AudioSource whistlePlayer;

		[SerializeField]
		public AudioClip[] whistleSounds;

		[SerializeField]
		public float maxLoudness;

		[SerializeField]
		public float minLoudness;

		[SerializeField]
		public float minPitch;

		[SerializeField]
		public float maxPitch;

		private Random noisemakerRandom;

		public Animator triggerAnimator;

		[NonSerialized]
		public int count;

		private void LogIfDebugBuild(string text)
		{
		}

		public override void Start()
		{
			((GrabbableObject)this).Start();
			count = 0;
			noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			int num = noisemakerRandom.Next(0, whistleSounds.Length);
			float num2 = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
			float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
			whistlePlayer.pitch = pitch;
			whistlePlayer.PlayOneShot(whistleSounds[num], num2);
			if ((Object)(object)triggerAnimator != (Object)null)
			{
				triggerAnimator.SetTrigger("playAnim");
			}
			if ((Object)(object)base.playerHeldBy != (Object)null && FlagClosestRedWoodGiantInRange(75f))
			{
				LogIfDebugBuild("Run.");
			}
		}

		private bool FlagClosestRedWoodGiantInRange(float range)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (spawnedEnemy.enemyType.enemyName == "RedWoodGiant")
				{
					float num = Vector3.Distance(((Component)base.playerHeldBy).transform.position, ((Component)spawnedEnemy).transform.position);
					if (num < range && !base.playerHeldBy.isInsideFactory)
					{
						spawnedEnemy.SetDestinationToPosition(((Component)base.playerHeldBy).transform.position, false);
						count++;
					}
				}
			}
			if (count > 0)
			{
				LogIfDebugBuild("You are being chased by " + count + " Redwood Giants :)");
				count = 0;
				return true;
			}
			return false;
		}

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

		protected internal override string __getTypeName()
		{
			return "WhistleItem";
		}
	}
}
namespace GiantSpecimens.Enemy
{
	internal class DriftwoodGiantAI : EnemyAI, IVisibleThreat
	{
		private enum State
		{
			SpawnAnimation,
			IdleAnimation,
			SearchingForPrey,
			RunningToPrey,
			SlashingPrey,
			EatingPrey,
			PlayingWithPrey,
			Scream,
			Stunned,
			RunningAway
		}

		public Collider grabArea;

		public Material handsMaterial;

		public AnimationClip spawnAnimation;

		public AnimationClip screamAnimation;

		public AnimationClip throwAnimation;

		public AnimationClip slashAnimation;

		public ChainIKConstraint RightShoulder;

		public AudioSource MouthVoice;

		public AudioClip[] stompSounds;

		public AudioClip eatenSound;

		public AudioClip screamSound;

		public AudioClip spawnSound;

		public AudioClip stunSound;

		public AudioClip throwSound;

		public AudioClip slashSound;

		public AudioClip[] hitSound;

		public AudioClip[] walkSounds;

		[NonSerialized]
		private NetworkVariable<NetworkBehaviourReference> _playerNetVar = new NetworkVariable<NetworkBehaviourReference>(default(NetworkBehaviourReference), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		[NonSerialized]
		public string levelName;

		[NonSerialized]
		public float screamRange;

		[NonSerialized]
		public string[] enemyTargetWhitelist;

		[NonSerialized]
		public EnemyAI targetEnemy;

		[NonSerialized]
		public bool targettingEnemy;

		[NonSerialized]
		public Material newHandsMaterial;

		[NonSerialized]
		public float seeableDistance = 50f;

		[NonSerialized]
		public float slashingRange = 6f;

		[NonSerialized]
		public Vector3 playerPositionBeforeGrab;

		[NonSerialized]
		public Vector3 enemyPositionBeforeDeath;

		[NonSerialized]
		public bool currentlyGrabbed;

		[NonSerialized]
		public int previousStateIndex;

		[NonSerialized]
		public int nextStateIndex;

		[NonSerialized]
		public float rangeOfSight = 50f;

		[NonSerialized]
		public string nextAnimationName = "";

		[NonSerialized]
		public bool testBuild;

		[NonSerialized]
		public int numberOfFeedings;

		[NonSerialized]
		public LineRenderer line;

		[NonSerialized]
		public float awarenessLevel;

		[NonSerialized]
		public float maxAwarenessLevel = 100f;

		[NonSerialized]
		public float awarenessDecreaseRate = 2.5f;

		[NonSerialized]
		public float awarenessIncreaseRate = 5f;

		[NonSerialized]
		public float awarenessIncreaseMultiplier = 6f;

		[NonSerialized]
		public bool canSlash = true;

		[NonSerialized]
		public Collider shipBoundaries;

		[NonSerialized]
		public bool isScared;

		[NonSerialized]
		public bool isScaredFromOldBird;

		[NonSerialized]
		public bool isScaredFromRedwood;

		[NonSerialized]
		public EnemyAI ScaryThing;

		public PlayerControllerB DriftwoodTargetPlayer
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				return (PlayerControllerB)NetworkBehaviourReference.op_Implicit(_playerNetVar.Value);
			}
			set
			{
				//IL_0022: 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 ((Object)(object)value == (Object)null)
				{
					_playerNetVar.Value = NetworkBehaviourReference.op_Implicit((NetworkBehaviour)null);
				}
				else
				{
					_playerNetVar.Value = new NetworkBehaviourReference((NetworkBehaviour)(object)value);
				}
			}
		}

		ThreatType IVisibleThreat.type => (ThreatType)4;

		int IVisibleThreat.SendSpecialBehaviour(int id)
		{
			return 0;
		}

		int IVisibleThreat.GetThreatLevel(Vector3 seenByPosition)
		{
			return 18;
		}

		int IVisibleThreat.GetInterestLevel()
		{
			return 0;
		}

		Transform IVisibleThreat.GetThreatLookTransform()
		{
			return base.eye;
		}

		Transform IVisibleThreat.GetThreatTransform()
		{
			return ((Component)this).transform;
		}

		Vector3 IVisibleThreat.GetThreatVelocity()
		{
			//IL_0014: 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)
			if (((NetworkBehaviour)this).IsOwner)
			{
				return base.agent.velocity;
			}
			return Vector3.zero;
		}

		float IVisibleThreat.GetVisibility()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return 0f;
			}
			Vector3 velocity = base.agent.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0f)
			{
				return 1f;
			}
			return 0.75f;
		}

		private void LogIfDebugBuild(string text)
		{
		}

		public void AdjustMaterialColor(Material material, float redAdjustment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0015: 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_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			Color color = material.color;
			float num = Mathf.Clamp01(color.r + redAdjustment);
			float num2 = Mathf.Clamp01(color.g - redAdjustment);
			float num3 = Mathf.Clamp01(color.b - redAdjustment);
			material.color = new Color(num, num2, num3, color.a);
			Debug.Log((object)$"Adjusted Color: {material.color}");
		}

		public override void Start()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			((EnemyAI)this).Start();
			shipBoundaries = StartOfRound.Instance.shipBounds;
			screamRange = GiantSpecimensConfig.ConfigScreamRange.Value;
			SkinnedMeshRenderer component = ((Component)((Component)this).transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)component != (Object)null)
			{
				Material val = null;
				for (int i = 0; i < ((Renderer)component).materials.Length; i++)
				{
					if (((Object)((Renderer)component).materials[i]).name.Contains("DW-Hands"))
					{
						val = ((Renderer)component).materials[i];
						break;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					newHandsMaterial = new Material(val);
					((Renderer)component).materials = ((Renderer)component).materials.Select((Material m) => (!((Object)m).name.Contains("DW-Hands")) ? m : newHandsMaterial).ToArray();
				}
				else
				{
					LogIfDebugBuild("Material not found");
				}
			}
			else
			{
				LogIfDebugBuild("Renderer not found");
			}
			levelName = ((Object)RoundManager.Instance.currentLevel).name;
			LogIfDebugBuild(levelName);
			SpawnableEnemyWithRarity val2 = RoundManager.Instance.currentLevel.OutsideEnemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("DriftWoodGiant"));
			if (val2 != null)
			{
				LogIfDebugBuild(val2.rarity.ToString());
			}
			LogIfDebugBuild("DriftWood Giant Enemy Spawned");
			_ = testBuild;
			enemyTargetWhitelist = new string[8] { "Baboon hawk", "Butler", "Centipede", "Crawler", "Hoarding bug", "Masked", "Mouthdog", "Nutcracker" };
			base.creatureVoice.PlayOneShot(spawnSound);
			((MonoBehaviour)this).StartCoroutine(SpawnAnimationCooldown());
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
		}

		public override void Update()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (!base.isEnemyDead)
			{
				if (base.stunNormalizedTimer > 0f && base.currentBehaviourStateIndex != 8)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					previousStateIndex = base.currentBehaviourStateIndex;
					nextStateIndex = 2;
					nextAnimationName = "startWalk";
					DoAnimationClientRpc("startStun");
					((MonoBehaviour)this).StartCoroutine(StunPause());
					((EnemyAI)this).SwitchToBehaviourClientRpc(8);
				}
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && DWHasLineOfSightToPosition(((Component)GameNetworkManager.Instance.localPlayerController).transform.position))
				{
					DriftwoodGiantSeePlayerEffect();
				}
				if (base.currentBehaviourStateIndex == 2)
				{
					UpdateAwareness();
				}
				if ((Object)(object)DriftwoodTargetPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController && currentlyGrabbed)
				{
					((Component)GameNetworkManager.Instance.localPlayerController).transform.position = ((Component)grabArea).transform.position;
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			if (testBuild)
			{
				((MonoBehaviour)this).StartCoroutine(DrawPath(line, base.agent));
			}
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 0f;
				break;
			case 1:
				base.agent.speed = 0f;
				break;
			case 2:
				base.agent.speed = 7f;
				if (DetectScaryThings())
				{
					RunFarAway();
				}
				if (FindClosestTargetEnemyInRange(rangeOfSight))
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					previousStateIndex = base.currentBehaviourStateIndex;
					nextStateIndex = 3;
					nextAnimationName = "startChase";
					DoAnimationClientRpc("startScream");
					((EnemyAI)this).SwitchToBehaviourClientRpc(7);
					targettingEnemy = true;
				}
				else if (FindClosestPlayerInRange(rangeOfSight) && awarenessLevel >= 25f)
				{
					((EnemyAI)this).StopSearch(base.currentSearch, true);
					previousStateIndex = base.currentBehaviourStateIndex;
					nextStateIndex = 3;
					nextAnimationName = "startChase";
					DoAnimationClientRpc("startScream");
					((EnemyAI)this).SwitchToBehaviourClientRpc(7);
				}
				break;
			case 3:
				base.agent.speed = 20f;
				if (targettingEnemy)
				{
					if ((Vector3.Distance(((Component)this).transform.position, ((Component)targetEnemy).transform.position) > seeableDistance + 10f && !DWHasLineOfSightToPosition(((Component)targetEnemy).transform.position)) || (Object)(object)targetEnemy == (Object)null)
					{
						LogIfDebugBuild("Stop chasing target enemy");
						((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
						targettingEnemy = false;
						targetEnemy = null;
						previousStateIndex = base.currentBehaviourStateIndex;
						nextStateIndex = 2;
						nextAnimationName = "startWalk";
						DoAnimationClientRpc("startScream");
						((EnemyAI)this).SwitchToBehaviourClientRpc(7);
					}
					else
					{
						((EnemyAI)this).SetDestinationToPosition(((Component)targetEnemy).transform.position, true);
					}
				}
				else if ((Object)(object)DriftwoodTargetPlayer != (Object)null)
				{
					if (!(Vector3.Distance(((Component)this).transform.position, ((Component)DriftwoodTargetPlayer).transform.position) > seeableDistance + 10f) || DWHasLineOfSightToPosition(((Component)DriftwoodTargetPlayer).transform.position))
					{
						Bounds bounds = shipBoundaries.bounds;
						if (!((Bounds)(ref bounds)).Contains(((Component)DriftwoodTargetPlayer).transform.position))
						{
							((EnemyAI)this).SetDestinationToPosition(((Component)DriftwoodTargetPlayer).transform.position, true);
							break;
						}
					}
					LogIfDebugBuild("Stop chasing target player");
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					previousStateIndex = base.currentBehaviourStateIndex;
					nextStateIndex = 2;
					nextAnimationName = "startWalk";
					DoAnimationClientRpc("startScream");
					((EnemyAI)this).SwitchToBehaviourClientRpc(7);
				}
				else
				{
					LogIfDebugBuild("If you see this, something went wrong.");
					LogIfDebugBuild("Resettings state to Scream Animation");
					previousStateIndex = base.currentBehaviourStateIndex;
					((EnemyAI)this).SwitchToBehaviourClientRpc(7);
				}
				break;
			case 4:
			{
				base.agent.speed = 0f;
				if (!targettingEnemy)
				{
					break;
				}
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)targetEnemy).transform.position);
				if (canSlash && num < slashingRange + 1f)
				{
					if (num < slashingRange)
					{
						base.creatureSFX.PlayOneShot(slashSound);
						DoAnimationClientRpc("startSlash");
						((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)RightShoulder).data)).target = ((Component)targetEnemy).transform;
						canSlash = false;
						((MonoBehaviour)this).StartCoroutine(SlashCooldown());
					}
				}
				else if (num > slashingRange && num <= seeableDistance && (Object)(object)targetEnemy != (Object)null && canSlash)
				{
					previousStateIndex = base.currentBehaviourStateIndex;
					nextStateIndex = 3;
					DoAnimationClientRpc("startChase");
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				}
				break;
			}
			case 6:
				base.agent.speed = 0f;
				break;
			case 7:
				base.agent.speed = 0f;
				break;
			case 8:
				base.agent.speed = 0f;
				break;
			case 9:
				base.agent.speed = 7f;
				LogIfDebugBuild(isScared.ToString() + isScaredFromRedwood + isScaredFromOldBird);
				if (!isScared)
				{
					DoAnimationClientRpc("startWalk");
					((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				}
				else if (isScaredFromOldBird)
				{
					((EnemyAI)this).SetDestinationToPosition(((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, false, 0, false, 50, false).position, true);
				}
				else if (isScaredFromRedwood)
				{
					((EnemyAI)this).SetDestinationToPosition(((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)ScaryThing).transform.position, false, 0, false, 50, false).position, true);
				}
				break;
			default:
				LogIfDebugBuild("This Behavior State doesn't exist!");
				break;
			case 5:
				break;
			}
		}

		public IEnumerator ScareCooldown()
		{
			isScared = true;
			yield return (object)new WaitForSeconds(7.5f);
			isScared = false;
			isScaredFromOldBird = false;
			isScaredFromRedwood = false;
			((MonoBehaviour)this).StopCoroutine(ScareCooldown());
		}

		public static IEnumerator DrawPath(LineRenderer line, NavMeshAgent agent)
		{
			if (((Behaviour)agent).enabled)
			{
				yield return (object)new WaitForEndOfFrame();
				line.SetPosition(0, ((Component)agent).transform.position);
				line.positionCount = agent.path.corners.Length;
				for (int i = 1; i < agent.path.corners.Length; i++)
				{
					line.SetPosition(i, agent.path.corners[i]);
				}
			}
		}

		public void ShakePlayerCameraOnDistance()
		{
			//IL_0006: 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)
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position);
			if (!(num < 4f))
			{
				if (num < 15f)
				{
					if (num >= 5f)
					{
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
						HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
						HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					}
				}
				else if (num < 25f)
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				}
			}
			else
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)2);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
		}

		public IEnumerator ScreamPause()
		{
			yield return (object)new WaitForSeconds(screamAnimation.length);
			DoAnimationClientRpc(nextAnimationName);
			if (previousStateIndex == 6)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
			((EnemyAI)this).SwitchToBehaviourClientRpc(nextStateIndex);
			((MonoBehaviour)this).StopCoroutine(ScreamPause());
		}

		public IEnumerator StunPause()
		{
			base.creatureVoice.PlayOneShot(stunSound);
			yield return (object)new WaitForSeconds(base.stunNormalizedTimer);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimationClientRpc(nextAnimationName);
			((EnemyAI)this).SwitchToBehaviourClientRpc(nextStateIndex);
			((MonoBehaviour)this).StopCoroutine(StunPause());
		}

		public void Screaming()
		{
			base.creatureVoice.PlayOneShot(screamSound);
		}

		public void DriftwoodScream()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (((NetworkBehaviour)localPlayerController).IsSpawned && localPlayerController.isPlayerControlled && !localPlayerController.isPlayerDead)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayerController).transform.position);
				if (num <= screamRange && !localPlayerController.isInHangarShipRoom)
				{
					localPlayerController.DamagePlayer(5, true, true, Plugin.RupturedEardrums, 0, false, default(Vector3));
				}
			}
		}

		public void ParticlesFromEatingPrey()
		{
		}

		public void PlayRunFootsteps()
		{
			base.creatureVoice.PlayOneShot(stompSounds[Random.Range(0, stompSounds.Length)]);
		}

		public void PlayWalkFootsteps()
		{
			base.creatureVoice.PlayOneShot(walkSounds[Random.Range(0, walkSounds.Length)]);
		}

		public IEnumerator ThrowPlayer()
		{
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)RightShoulder).data)).target = ((Component)DriftwoodTargetPlayer).transform;
			yield return (object)new WaitForSeconds(throwAnimation.length + 2f);
			try
			{
				LogIfDebugBuild("Setting Kinematics to true");
				((Component)DriftwoodTargetPlayer).GetComponent<Rigidbody>().isKinematic = true;
			}
			catch
			{
				LogIfDebugBuild("Trying to change kinematics of an unknown player.");
			}
			previousStateIndex = base.currentBehaviourStateIndex;
			nextStateIndex = 2;
			nextAnimationName = "startWalk";
			DoAnimationClientRpc("startScream");
			((EnemyAI)this).SwitchToBehaviourClientRpc(7);
			((MonoBehaviour)this).StopCoroutine(ThrowPlayer());
		}

		public void GrabPlayer()
		{
			GiantPatches.grabbedByGiant = true;
			currentlyGrabbed = true;
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)RightShoulder).data)).target = null;
		}

		public void ThrowingPlayer()
		{
			//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_0045: 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_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_0063: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DriftwoodTargetPlayer == (Object)null || (Object)(object)DriftwoodTargetPlayer == (Object)null)
			{
				LogIfDebugBuild("No player to throw, This is a bug, please report this");
				return;
			}
			GiantPatches.grabbedByGiant = false;
			currentlyGrabbed = false;
			Vector3 val = ((Component)this).transform.TransformDirection(Vector3.back);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = ((Component)this).transform.TransformDirection(Vector3.up);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = normalized + Quaternion.AngleAxis(55f, ((Component)this).transform.right) * normalized2;
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			float num = 125f;
			LogIfDebugBuild("Launching Player");
			GiantPatches.thrownByGiant = true;
			GiantPatches.playerControllerB = DriftwoodTargetPlayer;
			Rigidbody component = ((Component)DriftwoodTargetPlayer).GetComponent<Rigidbody>();
			((Component)DriftwoodTargetPlayer).GetComponent<Rigidbody>().isKinematic = false;
			component.velocity = Vector3.zero;
			component.AddTorque(Vector3.Cross(normalized3, ((Component)this).transform.up) * num, (ForceMode)1);
			component.AddForce(normalized3 * num, (ForceMode)1);
		}

		public void SlashEnemy()
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0079: Unknown result type (might be due to invalid IL or missing references)
			if (targettingEnemy)
			{
				enemyPositionBeforeDeath = ((Component)targetEnemy).transform.position;
				Vector3 val = ((Component)targetEnemy).transform.position - ((Component)this).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Quaternion val2 = Quaternion.LookRotation(normalized, ((Component)this).transform.up);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * 3f);
				targetEnemy.HitEnemy(1, (PlayerControllerB)null, false, -1);
				if (targetEnemy.enemyHP <= 0)
				{
					nextStateIndex = 5;
					base.creatureVoice.PlayOneShot(eatenSound);
					nextAnimationName = "startEating";
					targettingEnemy = false;
					targetEnemy = null;
					ApproachCorpse();
				}
			}
			else
			{
				LogIfDebugBuild("This shouldn't be happening, please report this.");
			}
		}

		public void DiggingIntoEnemyBody()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			numberOfFeedings++;
			AdjustMaterialColor(newHandsMaterial, 0.05f);
			if (numberOfFeedings >= 8)
			{
				numberOfFeedings = 0;
				previousStateIndex = base.currentBehaviourStateIndex;
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				DoAnimationClientRpc("startWalk");
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			}
		}

		public void ApproachCorpse()
		{
			//IL_0012: 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)
			base.agent.speed = 3.5f;
			((EnemyAI)this).SetDestinationToPosition(enemyPositionBeforeDeath, true);
			((Component)this).transform.LookAt(enemyPositionBeforeDeath);
			((EnemyAI)this).SwitchToBehaviourClientRpc(nextStateIndex);
			DoAnimationClientRpc(nextAnimationName);
		}

		public bool FindClosestTargetEnemyInRange(float range)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			EnemyAI val = null;
			float num = float.MaxValue;
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (enemyTargetWhitelist.Contains(spawnedEnemy.enemyType.enemyName) && spawnedEnemy.enemyHP > 0 && DWHasLineOfSightToPosition(((Component)spawnedEnemy).transform.position, 75f, (int)range) && !spawnedEnemy.isEnemyDead)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)spawnedEnemy).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = spawnedEnemy;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				targetEnemy = val;
				targettingEnemy = true;
				return true;
			}
			return false;
		}

		public bool FindClosestPlayerInRange(float range)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = null;
			float num = float.MaxValue;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (((NetworkBehaviour)val2).IsSpawned && val2.isPlayerControlled && !val2.isPlayerDead && !val2.isInHangarShipRoom && DWHasLineOfSightToPosition(((Component)val2).transform.position, 45f, (int)range))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				DriftwoodTargetPlayer = val;
				return true;
			}
			return false;
		}

		public override void OnCollideWithEnemy(Collider other, EnemyAI collidedEnemy)
		{
			if (!base.isEnemyDead && (Object)(object)collidedEnemy == (Object)(object)targetEnemy && (Object)(object)targetEnemy != (Object)null && base.currentBehaviourStateIndex == 3 && targettingEnemy)
			{
				((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//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)
			if (!base.isEnemyDead && !((Object)(object)DriftwoodTargetPlayer == (Object)null))
			{
				if (Object.op_Implicit((Object)(object)((Component)other).GetComponent<PlayerControllerB>()))
				{
					awarenessLevel += 10f;
				}
				if ((Object)(object)((Component)other).GetComponent<PlayerControllerB>() == (Object)(object)DriftwoodTargetPlayer && base.currentBehaviourStateIndex == 3 && (Object)(object)DriftwoodTargetPlayer != (Object)null)
				{
					playerPositionBeforeGrab = ((Component)GameNetworkManager.Instance.localPlayerController).transform.position;
					base.creatureSFX.PlayOneShot(throwSound);
					DoAnimationClientRpc("startThrow");
					((EnemyAI)this).SwitchToBehaviourClientRpc(6);
				}
			}
		}

		public void DriftwoodGiantSeePlayerEffect()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (GameNetworkManager.Instance.localPlayerController.isPlayerDead || (GameNetworkManager.Instance.localPlayerController.isInsideFactory && (Object)(object)DriftwoodTargetPlayer != (Object)null && !((Object)(object)DriftwoodTargetPlayer != (Object)null)))
			{
				return;
			}
			if (base.currentBehaviourStateIndex == 3 && (Object)(object)DriftwoodTargetPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				GameNetworkManager.Instance.localPlayerController.IncreaseFearLevelOverTime(1.4f, 1f);
			}
			else if (!GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom && DWHasLineOfSightToPosition(((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position, 45f, 60))
			{
				if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 15f)
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.7f, true);
				}
				else
				{
					GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.4f, true);
				}
			}
		}

		public bool DWHasLineOfSightToPosition(Vector3 pos, float width = 120f, int range = 50, float proximityAwareness = 10f)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.eye == (Object)null)
			{
				_ = ((Component)this).transform;
			}
			else
			{
				_ = base.eye;
			}
			if (Vector3.Distance(base.eye.position, pos) < (float)range && !Physics.Linecast(base.eye.position, pos, StartOfRound.Instance.collidersAndRoomMaskAndDefault))
			{
				Vector3 val = pos - base.eye.position;
				if (Vector3.Angle(base.eye.forward, val) < width || Vector3.Distance(((Component)this).transform.position, pos) < proximityAwareness)
				{
					return true;
				}
			}
			return false;
		}

		public IEnumerator SpawnAnimationCooldown()
		{
			yield return (object)new WaitForSeconds(spawnAnimation.length);
			previousStateIndex = base.currentBehaviourStateIndex;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimationClientRpc("startWalk");
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			((MonoBehaviour)this).StopCoroutine(SpawnAnimationCooldown());
		}

		public void UpdateAwareness()
		{
			//IL_0048: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			float num = float.MaxValue;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (((NetworkBehaviour)val).IsSpawned && val.isPlayerControlled && !val.isPlayerDead && !val.isInHangarShipRoom && DWHasLineOfSightToPosition(((Component)val).transform.position))
				{
					flag = true;
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
					}
				}
			}
			if (flag)
			{
				float num3 = Mathf.Clamp01((rangeOfSight - num) / rangeOfSight);
				awarenessLevel += awarenessIncreaseRate * Time.deltaTime * (1f + num3 * awarenessIncreaseMultiplier);
				awarenessLevel = Mathf.Min(awarenessLevel, maxAwarenessLevel);
			}
			else
			{
				awarenessLevel -= awarenessDecreaseRate * Time.deltaTime;
				awarenessLevel = Mathf.Max(awarenessLevel, 0f);
			}
		}

		public bool PlayerInSight()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (((NetworkBehaviour)val).IsSpawned && val.isPlayerControlled && !val.isPlayerDead && !val.isInHangarShipRoom && DWHasLineOfSightToPosition(((Component)val).transform.position))
				{
					return true;
				}
			}
			return false;
		}

		public IEnumerator SlashCooldown()
		{
			yield return (object)new WaitForSeconds(1.5f);
			canSlash = true;
			((ChainIKConstraintData)(ref ((RigConstraint<ChainIKConstraintJob, ChainIKConstraintData, ChainIKConstraintJobBinder<ChainIKConstraintData>>)(object)RightShoulder).data)).target = null;
			((MonoBehaviour)this).StopCoroutine(SlashCooldown());
		}

		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)
			{
				base.creatureVoice.PlayOneShot(hitSound[Random.Range(0, hitSound.Length)]);
				if (force == 6 && !isScaredFromOldBird)
				{
					isScaredFromOldBird = true;
					RunFarAway();
				}
				base.enemyHP -= force;
				LogIfDebugBuild("Enemy HP: " + base.enemyHP);
				if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).KillEnemy(destroy);
			SpawnHeartOnDeath(((Component)this).transform.position);
			DoAnimationClientRpc("startDeath");
			base.creatureVoice.PlayOneShot(base.dieSFX);
		}

		public void RunFarAway()
		{
			((MonoBehaviour)this).StartCoroutine(ScareCooldown());
			DoAnimationClientRpc("startChase");
			((EnemyAI)this).SwitchToBehaviourClientRpc(9);
		}

		public void SpawnHeartOnDeath(Vector3 position)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (GiantSpecimensConfig.ConfigDriftwoodHeartEnabled.Value && ((NetworkBehaviour)this).IsHost && !Plugin.LGULoaded)
			{
				GiantSpecimensUtils.Instance.SpawnScrapServerRpc("DriftWoodGiant", position);
			}
		}

		public bool DetectScaryThings()
		{
			//IL_0030: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			EnemyAI val = null;
			float num = float.MaxValue;
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (!spawnedEnemy.isEnemyDead && Vector3.Distance(((Component)this).transform.position, ((Component)spawnedEnemy).transform.position) <= 50f && spawnedEnemy.enemyType.enemyName == "RedWoodGiant")
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)spawnedEnemy).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = spawnedEnemy;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				isScaredFromRedwood = true;
				ScaryThing = val;
				return true;
			}
			return false;
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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(3177514901u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3177514901u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				LogIfDebugBuild("Animation: " + animationName);
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		protected override void __initializeVariables()
		{
			if (_playerNetVar == null)
			{
				throw new Exception("DriftwoodGiantAI._playerNetVar cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)_playerNetVar).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_playerNetVar, "_playerNetVar");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_playerNetVar);
			((EnemyAI)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_DriftwoodGiantAI()
		{
			//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(3177514901u, new RpcReceiveHandler(__rpc_handler_3177514901));
		}

		private static void __rpc_handler_3177514901(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((DriftwoodGiantAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DriftwoodGiantAI";
		}
	}
	internal class PinkGiantAI : EnemyAI, IVisibleThreat
	{
		private enum State
		{
			SpawnAnimation,
			IdleAnimation,
			SearchingForGiant,
			RunningToGiant,
			EatingGiant
		}

		public Collider AttackArea;

		public ParticleSystem DustParticlesLeft;

		public ParticleSystem DustParticlesRight;

		public ParticleSystem ForestKeeperParticles;

		public ParticleSystem DriftwoodGiantParticles;

		public ParticleSystem OldBirdParticles;

		public ParticleSystem DeathParticles;

		public Collider CollisionFootR;

		public Collider CollisionFootL;

		public ChainIKConstraint LeftFoot;

		public ChainIKConstraint RightFoot;

		public AudioSource FootSource;

		public AudioSource EnemyMouthSource;

		public AnimationClip idle;

		public AnimationClip walking;

		public AnimationClip eating;

		public AnimationClip roaring;

		public AudioClip[] stompSounds;

		public AudioClip eatenSound;

		public AudioClip spawnSound;

		public AudioClip roarSound;

		public GameObject rightBone;

		public GameObject leftBone;

		public GameObject[] lightningSpots;

		public GameObject eatingArea;

		[NonSerialized]
		public bool sizeUp;

		[NonSerialized]
		public static LevelColorMapper levelColorMapper = new LevelColorMapper();

		[NonSerialized]
		public Vector3 newScale;

		[NonSerialized]
		public string levelName;

		[NonSerialized]
		public bool waitAfterChase;

		[NonSerialized]
		public bool eatingEnemy;

		[NonSerialized]
		public string footstepColour;

		[NonSerialized]
		public EnemyAI targetEnemy;

		[NonSerialized]
		public bool idleGiant = true;

		[NonSerialized]
		public float walkingSpeed;

		[NonSerialized]
		public float seeableDistance;

		[NonSerialized]
		public float distanceFromShip;

		[NonSerialized]
		public bool eatOldBirds;

		[NonSerialized]
		public bool zeusMode;

		[NonSerialized]
		public float distanceFromEnemy;

		[NonSerialized]
		public Transform shipBoundaries;

		[NonSerialized]
		public Vector3 midpoint;

		[NonSerialized]
		public bool testBuild;

		[NonSerialized]
		public LineRenderer line;

		[NonSerialized]
		public bool canMove = true;

		[NonSerialized]
		public bool shockwaveDamageFromLeftFoot;

		[NonSerialized]
		public bool shockwaveDamageFromRightFoot;

		ThreatType IVisibleThreat.type => (ThreatType)4;

		int IVisibleThreat.SendSpecialBehaviour(int id)
		{
			return 0;
		}

		int IVisibleThreat.GetThreatLevel(Vector3 seenByPosition)
		{
			return 18;
		}

		int IVisibleThreat.GetInterestLevel()
		{
			return 0;
		}

		Transform IVisibleThreat.GetThreatLookTransform()
		{
			return base.eye;
		}

		Transform IVisibleThreat.GetThreatTransform()
		{
			return ((Component)this).transform;
		}

		Vector3 IVisibleThreat.GetThreatVelocity()
		{
			//IL_0014: 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)
			if (((NetworkBehaviour)this).IsOwner)
			{
				return base.agent.velocity;
			}
			return Vector3.zero;
		}

		float IVisibleThreat.GetVisibility()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (base.isEnemyDead)
			{
				return 0f;
			}
			Vector3 velocity = base.agent.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0f)
			{
				return 1f;
			}
			return 0.75f;
		}

		private void LogIfDebugBuild(string text)
		{
		}

		public override void Start()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			levelName = ((Object)RoundManager.Instance.currentLevel).name;
			LogIfDebugBuild(levelName);
			shipBoundaries = ((Component)StartOfRound.Instance.shipBounds).transform;
			Color val = Color.grey;
			string value = GiantSpecimensConfig.ConfigColourHexcode.Value;
			if (string.IsNullOrEmpty(value))
			{
				footstepColour = null;
			}
			else if (Regex.IsMatch(value, "^#?[0-9a-fA-F]{6}$"))
			{
				footstepColour = value;
			}
			else
			{
				Plugin.Logger.LogWarning((object)("Invalid hexcode: " + value + ". Using default colour."));
				footstepColour = null;
			}
			List<string> colorsForLevel = levelColorMapper.GetColorsForLevel(levelName);
			if (footstepColour == null && colorsForLevel.Count > 0)
			{
				footstepColour = colorsForLevel[0];
			}
			if (footstepColour != null)
			{
				val = HexToColor(footstepColour);
			}
			MainModule main = DustParticlesLeft.main;
			MainModule main2 = DustParticlesRight.main;
			((MainModule)(ref main)).startColor = new MinMaxGradient(val);
			((MainModule)(ref main2)).startColor = new MinMaxGradient(val);
			LogIfDebugBuild(((object)(Color)(ref val)).ToString());
			SpawnableEnemyWithRarity val2 = RoundManager.Instance.currentLevel.OutsideEnemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyName.Equals("ForestGiant"));
			if (val2 != null && GiantSpecimensConfig.ConfigMultiplierForestkeeper.Value > 0)
			{
				val2.rarity *= Mathf.Clamp(GiantSpecimensConfig.ConfigMultiplierForestkeeper.Value, 0, 9999);
			}
			SpawnableEnemyWithRarity val3 = RoundManager.Instance.currentLevel.OutsideEnemies.Find((SpawnableEnemyWithRarity x) => x.enemyType.enemyNam