Decompiled source of Welcome To Ooblterra v2.2.2

plugins/Welcome_To_Ooblterra.dll

Decompiled 2 hours 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using Welcome_To_Ooblterra.Enemies;
using Welcome_To_Ooblterra.Enemies.EnemyThings;
using Welcome_To_Ooblterra.Items;
using Welcome_To_Ooblterra.NetcodePatcher;
using Welcome_To_Ooblterra.RoomBehaviors;
using Welcome_To_Ooblterra.Things;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Welcome_To_Ooblterra")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.2.2.0")]
[assembly: AssemblyInformationalVersion("2.2.2+47ed0c300d6ccca9cd98c2d299090edf5a7e27b0")]
[assembly: AssemblyProduct("Welcome_To_Ooblterra")]
[assembly: AssemblyTitle("Welcome_To_Ooblterra")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Count;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => _items.Count;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Count;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyList(List<T> items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return _items.Contains(item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		_items.CopyTo(array, arrayIndex);
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return _items.IndexOf(item);
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			return !_moveNextCalled && (_moveNextCalled = true);
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Welcome_To_Ooblterra
{
	public enum LogType
	{
		Debug,
		Info,
		Warning,
		Error
	}
	public enum LogSourceType
	{
		Generic,
		Enemy,
		Item,
		Thing,
		Room
	}
	public enum StartupType
	{
		Normal,
		ContourMapRender
	}
	[BepInPlugin("SkullCrusher.WTO", "Welcome To Ooblterra!", "2.2.2")]
	public class WTOBase : BaseUnityPlugin
	{
		public class WTOLogger(Type Type, LogSourceType SourceType = LogSourceType.Generic)
		{
			public readonly Type Type = Type;

			public readonly LogSourceType SourceType = SourceType;

			public void Debug(string text, bool AddFlair = true, bool ForcePrint = false)
			{
				LogToConsole(Type, SourceType, LogType.Debug, text, AddFlair, ForcePrint);
			}

			public void Info(string text, bool AddFlair = true, bool ForcePrint = false)
			{
				LogToConsole(Type, SourceType, LogType.Info, text, AddFlair, ForcePrint);
			}

			public void Warning(string text, bool AddFlair = true, bool ForcePrint = false)
			{
				LogToConsole(Type, SourceType, LogType.Warning, text, AddFlair, ForcePrint);
			}

			public void Error(string text, bool AddFlair = true, bool ForcePrint = false)
			{
				LogToConsole(Type, SourceType, LogType.Error, text, AddFlair, ForcePrint);
			}
		}

		private class AssetBundleLoadException : Exception
		{
			public AssetBundleLoadException(string message)
				: base(message)
			{
			}
		}

		private const string modGUID = "SkullCrusher.WTO";

		private const string modName = "Welcome To Ooblterra!";

		private const string modVersion = "2.2.2";

		private readonly Harmony WTOHarmony = new Harmony("SkullCrusher.WTO");

		public static ManualLogSource WTOLogSource;

		public static WTOBase Instance;

		private static AssetBundle ContentAssetBundle;

		private static readonly string[] RootPaths = new string[4] { "Assets/Resources/WelcomeToOoblterra/", "Assets/WelcomeToOoblterra/", "WelcomeToOoblterra/", "" };

		private static string resolvedRootPath = "";

		public static ConfigEntry<bool> WTODebug;

		public static ConfigEntry<bool> WTOLogSpawnLists;

		public static ConfigEntry<bool> WTOCustomPoster;

		public static ConfigEntry<bool> WTOAllSuitsEnabled;

		public static ConfigEntry<bool> WTOLogging_Debug;

		public static ConfigEntry<bool> WTOLogging_Info;

		public static ConfigEntry<bool> WTOLogging_Warning;

		public static ConfigEntry<bool> WTOLogging_Error;

		public static ConfigEntry<string> WTOLogging_Filter;

		public static ConfigEntry<bool> WTOTestRoom;

		public static ConfigEntry<StartupType> WTOStartupType;

		public static ConfigEntry<bool> WTOAutoRoute;

		public static ConfigEntry<string> WTOContourMapWritePath;

		private static readonly WTOLogger Log = new WTOLogger(typeof(WTOBase));

		private static AudioClip? originalDiscoBallMusic;

		private static AudioClip? ooblterraCozyLightsMusic;

		public static Material? ghostPlayerSuit;

		public static Material? customPoster;

		private static GameObject teslaCoilManagerPrefab;

		private void Awake()
		{
			WTODebug = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Print Debug Strings", false, "Whether or not to write WTO's debug print-strings to the log.");
			WTOLogSpawnLists = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Log Moon Spawn Lists", false, "When landing, write the moon's scrap, enemy, dungeon, and map-object spawn lists to the log. Zero-rarity entries and all-zero curves are omitted. DawnLib outside objects are listed from DawnLib weights, because DawnLib removes them from the vanilla list before it spawns them.");
			WTOLogging_Debug = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Log Level Debug Messages", false, "Whether or not to write debug messages to the log. These are the lowest, most spammy logs.");
			WTOLogging_Info = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Log Level Info Messages", true, "Whether or not to write info messages to the log. General info logs that shouldn't be printed too often.");
			WTOLogging_Warning = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Log Level Warning Messages", true, "Whether or not to write warning messages to the log. Warnings that are potentially errors or misconfigurations.");
			WTOLogging_Error = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Debugging", "Log Level Error Messages", true, "Whether or not to write error messages to the log. Errors that represent genuine problems that should not be happening.");
			WTOLogging_Filter = ((BaseUnityPlugin)this).Config.Bind<string>("1. Debugging", "Log Filter", "WTO", "The filter to apply to the log. Only messages that match this RegEx filter will be printed. If empty, all messages will be printed. This is applied to the final log string, including class name.");
			WTOCustomPoster = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Ship Stuff", "Visit Ooblterra Poster Status", true, "Whether or not to add WTO's custom poster.");
			WTOAllSuitsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Ship Stuff", "Enable All Suits", true, "Whether or not to show all suits. If set to false, all suits are hidden. If true, use the individual config entries below to enable/disable specific suits.");
			Plugin.onSetupComplete += delegate
			{
				ConfigureUnlockableItems(PatchedContent.ExtendedUnlockableItems);
			};
			WTOTestRoom = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Testing", "Enable Test Room Teleporter", false, "Whether or not to enable the test room teleporter in Ooblterra. This spawns a teleporter outside of the ship and spawns the test room.");
			WTOStartupType = ((BaseUnityPlugin)this).Config.Bind<StartupType>("3. Testing", "Startup Type", StartupType.Normal, "The type of startup to use for the game. Leave this set to Normal. The other modes are for internal use only (e.g. for automated tools)");
			WTOAutoRoute = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Testing", "Auto Route", false, "When true, automatically routes to Ooblterra on game start.");
			WTOContourMapWritePath = ((BaseUnityPlugin)this).Config.Bind<string>("4. Contour Map Render", "Contour Map Write Path", "contourmap.exr", "The file path to write the contour map file to when Startup Type is set to ContourMapRender");
			if (Instance == null)
			{
				Instance = this;
			}
			WTOLogSource = Logger.CreateLogSource("SkullCrusher.WTO");
			try
			{
				LoadWelcomeToOoblterra();
			}
			catch (Exception ex)
			{
				Log.Error("Failed to load Welcome To Ooblterra. If you have the time, please report this error on our GitHub repository https://github.com/Skeleton-Studios/Welcome_To_Ooblterra/issues : " + ex.Message);
			}
		}

		private void LoadWelcomeToOoblterra()
		{
			Log.Info("Loading - Start!");
			WTOHarmony.PatchAll(typeof(WTOBase));
			Log.Info("Harmony Patches applied! Loading non-LLL asset bundle...");
			LoadNonLLLAssetBundle();
			Log.Info("Assets read successfully! Applying netcode runtime init...");
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			Log.Info("Runtime init applied! Welcome To Ooblterra successfully loaded");
		}

		[HarmonyPatch(typeof(TerminalManager), "CreateEnemyTypeTerminalData")]
		[HarmonyPostfix]
		private static void FixWtoEnemyBestiaryTerminalNode(ExtendedEnemyType extendedEnemyType)
		{
			if (!((Object)(object)extendedEnemyType == (Object)null) && !((Object)(object)extendedEnemyType.EnemyInfoNode == (Object)null) && !((Object)(object)((ExtendedContent)extendedEnemyType).ExtendedMod == (Object)null) && !(((ExtendedContent)extendedEnemyType).AuthorName != "SkullCrusher") && !(((ExtendedContent)extendedEnemyType).ModName != "Welcome To Ooblterra!"))
			{
				TerminalNode enemyInfoNode = extendedEnemyType.EnemyInfoNode;
				if (!enemyInfoNode.clearPreviousText && enemyInfoNode.maxCharactersToType != 35)
				{
					Log.Info("Fixing LLL bestiary TerminalNode defaults for WTO enemy '" + extendedEnemyType.EnemyDisplayName + "'");
					enemyInfoNode.clearPreviousText = true;
					enemyInfoNode.maxCharactersToType = 35;
				}
			}
		}

		[HarmonyPatch(typeof(CozyLights), "SetAudio")]
		[HarmonyPrefix]
		private static bool ReplaceCozyLights(CozyLights __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.transform.parent == (Object)null || !((Object)((Component)__instance).gameObject.transform.parent).name.Contains("Disco"))
			{
				return true;
			}
			if (IsOnOoblterra())
			{
				Log.Info("Found disco ball cozy lights, replacing music...");
				originalDiscoBallMusic = __instance.turnOnAudio.clip;
			}
			else if ((Object)(object)__instance.turnOnAudio.clip == (Object)(object)ooblterraCozyLightsMusic)
			{
				__instance.turnOnAudio.clip = originalDiscoBallMusic;
			}
			return true;
		}

		[HarmonyPatch(typeof(EnemyAI), "SetEnemyStunned")]
		[HarmonyPostfix]
		private static void SetOwnershipToStunningPlayer(EnemyAI __instance)
		{
			if (__instance is WTOEnemy && !((Object)(object)__instance.stunnedByPlayer == (Object)null))
			{
				Log.Info($"Enemy: {((object)__instance).GetType()} STUNNED BY: {__instance.stunnedByPlayer}; Switching ownership...");
				__instance.ChangeOwnershipOfEnemy(__instance.stunnedByPlayer.actualClientId);
			}
		}

		[HarmonyPatch(typeof(EnemyAI), "SetClientCalculatingAI")]
		[HarmonyPrefix]
		private static bool PreventGhostAgentEnable(EnemyAI __instance, bool enable)
		{
			if (__instance is OoblGhostAI)
			{
				__instance.isClientCalculatingAI = enable;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "UseSignalTranslatorClientRpc")]
		[HarmonyPostfix]
		private static void TellAllGhostsOfSignalTransmission()
		{
			OoblGhostAI[] array = Object.FindObjectsOfType<OoblGhostAI>();
			OoblGhostAI[] array2 = array;
			foreach (OoblGhostAI ooblGhostAI in array2)
			{
				ooblGhostAI.EvalulateSignalTranslatorUse();
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SceneManager_OnLoadComplete1")]
		[HarmonyPostfix]
		private static void ManageNav(StartOfRound __instance)
		{
			SoundManager.Instance.DaytimeMusic = (AudioClip[])(object)new AudioClip[0];
		}

		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void SetFogTies(StartOfRound __instance)
		{
			if (IsOnOoblterra())
			{
				Animator component = GameObject.Find("OoblFog").gameObject.GetComponent<Animator>();
				Log.Debug($"Fog animator found : {(Object)(object)component != (Object)null}");
				if ((Object)(object)TimeOfDay.Instance.sunAnimator == (Object)(object)component)
				{
					Log.Debug("Sun Animator IS fog animator, supposedly");
					return;
				}
				TimeOfDay.Instance.sunAnimator = component;
				Log.Debug($"Is Sun Animator Fog Animator? {(Object)(object)TimeOfDay.Instance.sunAnimator == (Object)(object)component}");
				TimeOfDay.Instance.playDelayedMusicCoroutine = null;
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetInsideLightingDimness")]
		[HarmonyPrefix]
		private static void SpoofLightValues(TimeOfDay __instance)
		{
			if (IsOnOoblterra())
			{
				Light component = GameObject.Find("ActualSun").GetComponent<Light>();
				Light component2 = GameObject.Find("ActualIndirect").GetComponent<Light>();
				TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
				val.sunIndirect = component2;
				val.sunDirect = component;
			}
		}

		[HarmonyPatch(typeof(StartMatchLever), "Start")]
		[HarmonyPrefix]
		private static void AutoRouteToOoblterra(StartMatchLever __instance)
		{
			if (WTOAutoRoute.Value && ((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				((MonoBehaviour)StartOfRound.Instance).StartCoroutine(RouteToOoblterraOnceLLLIsLoaded(__instance));
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void OnStartOfRoundAwake(StartOfRound __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(teslaCoilManagerPrefab);
				SceneManager.MoveGameObjectToScene(val, ((Component)__instance).gameObject.scene);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void ApplyBearTrapFloorTagsForCurrentSpawnPath()
		{
			if (!((Registry<DawnMapObjectInfo>)(object)LethalContent.MapObjects).IsFrozen)
			{
				return;
			}
			foreach (DawnMapObjectInfo value in ((Registry<DawnMapObjectInfo>)(object)LethalContent.MapObjects).Values)
			{
				DawnOutsideMapObjectInfo outsideInfo = value.OutsideInfo;
				SpawnableOutsideObject val = ((outsideInfo != null) ? outsideInfo.SpawnableOutsideObject : null);
				object obj;
				if (val == null)
				{
					obj = null;
				}
				else
				{
					GameObject prefabToSpawn = val.prefabToSpawn;
					obj = ((prefabToSpawn != null) ? ((Object)prefabToSpawn).name : null);
				}
				if ((string?)obj == "BearTrapSpawner")
				{
					val.spawnableFloorTags = ((!((DawnBaseInfo<DawnMapObjectInfo>)(object)value).ShouldSkipRespectOverride()) ? Array.Empty<string>() : new string[3] { "Grass", "Gravel", "Snow" });
					Log.Info(string.Format("Bear trap floor tags set to [{0}] (DawnLib spawn path: {1})", string.Join(", ", val.spawnableFloorTags), !((DawnBaseInfo<DawnMapObjectInfo>)(object)value).ShouldSkipRespectOverride()));
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPatch(typeof(RoundManager), "GenerateNewLevelClientRpc")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void PatchPosters()
		{
			if (WTOCustomPoster.Value)
			{
				GameObject val = GameObject.Find("HangarShip/Plane.001");
				if (!((Object)(object)val == (Object)null) && !((Object)(object)customPoster == (Object)null))
				{
					MeshRenderer component = val.GetComponent<MeshRenderer>();
					Material[] materials = ((Renderer)component).materials;
					materials[1] = customPoster;
					((Renderer)component).materials = materials;
				}
			}
		}

		private void ConfigureUnlockableItems(List<ExtendedUnlockableItem> items)
		{
			foreach (ExtendedUnlockableItem item in items)
			{
				if (HasOoblterraTag(((ExtendedContent)item).ContentTags) && (Object)(object)item.UnlockableItem.suitMaterial != (Object)null)
				{
					string text;
					if (!item.UnlockableItem.unlockableName.StartsWith("WTO "))
					{
						text = item.UnlockableItem.unlockableName;
					}
					else
					{
						string unlockableName = item.UnlockableItem.unlockableName;
						int length = "WTO ".Length;
						text = unlockableName.Substring(length, unlockableName.Length - length);
					}
					string text2 = text;
					ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Ship Stuff", "Enable " + text2, true, "Whether or not to show the " + text2 + ".");
					if (!WTOAllSuitsEnabled.Value || !val.Value)
					{
						Log.Info("Disabling " + item.UnlockableItem.unlockableName + " suit.");
						item.UnlockableItem.alreadyUnlocked = false;
					}
				}
			}
		}

		private static Func<bool> GetIsLLLReadyFunc()
		{
			Assembly assembly = Assembly.GetAssembly(typeof(AssetBundleLoader));
			Type type = assembly.GetType("LethalLevelLoader.NetworkBundleManager");
			if (type == null)
			{
				Log.Warning("Could not find LethalLevelLoader.NetworkBundleManager type");
				return () => true;
			}
			PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
			if (property == null)
			{
				Log.Warning("Could not find Instance field in NetworkBundleManager");
				return () => true;
			}
			object value = property.GetValue(null);
			FieldInfo field = type.GetField("allowedToLoadLevel", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null)
			{
				Log.Warning("Could not find allowedToLoadLevel field in NetworkBundleManager");
				return () => true;
			}
			NetworkVariable<bool> allowedToLoadLevel = field.GetValue(value) as NetworkVariable<bool>;
			return delegate
			{
				try
				{
					return allowedToLoadLevel.Value;
				}
				catch (Exception arg)
				{
					Log.Warning($"Exception while trying to get allowedToLoadLevel value: {arg}");
					return true;
				}
			};
		}

		private static bool IsOoblterraTag(ContentTag tag)
		{
			return tag.contentTagName == "Welcome To Ooblterra!";
		}

		private static bool HasOoblterraTag(List<ContentTag> tags)
		{
			return tags.Any(IsOoblterraTag);
		}

		private static ExtendedLevel? GetOooblterraExtendedLevel()
		{
			foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels)
			{
				if (HasOoblterraTag(((ExtendedContent)extendedLevel).ContentTags))
				{
					return extendedLevel;
				}
			}
			return null;
		}

		private static string GetOoblterraMoonName()
		{
			ExtendedLevel? oooblterraExtendedLevel = GetOooblterraExtendedLevel();
			return ((oooblterraExtendedLevel != null) ? oooblterraExtendedLevel.SelectableLevel.PlanetName : null) ?? "523 Ooblterra";
		}

		private static string? GetCurrentMoonName()
		{
			ExtendedLevel currentExtendedLevel = LevelManager.CurrentExtendedLevel;
			return (currentExtendedLevel == null) ? null : currentExtendedLevel.SelectableLevel?.PlanetName;
		}

		private static bool IsOnOoblterra()
		{
			return GetCurrentMoonName() == GetOoblterraMoonName();
		}

		private static IEnumerator RouteToOoblterraOnceLLLIsLoaded(StartMatchLever startMatchLever)
		{
			Log.Info("Waiting for LLL to finish loading before routing to Ooblterra...");
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)GetOooblterraExtendedLevel() != (Object)null));
			Log.Info("Ooblterra extended level found, now waiting for LLL to allow level loading...");
			yield return (object)new WaitUntil(GetIsLLLReadyFunc());
			ExtendedLevel ooblterraLevel = GetOooblterraExtendedLevel();
			if ((Object)(object)ooblterraLevel == (Object)null)
			{
				Log.Error("Somehow, Ooblterra extended level is null. Cannot route to Ooblterra.");
				yield break;
			}
			Log.Info("LLL finished loading, routing to Ooblterra...");
			StartOfRound.Instance.ChangeLevel(ooblterraLevel.SelectableLevel.levelID);
			yield return (object)new WaitUntil(GetIsLLLReadyFunc());
			StartOfRound.Instance.ArriveAtLevel();
			yield return (object)new WaitUntil(GetIsLLLReadyFunc());
			Log.Info("Pulling lever to start match...");
			startMatchLever.leverHasBeenPulled = true;
			startMatchLever.leverAnimatorObject.SetBool("pullLever", true);
			startMatchLever.triggerScript.interactable = false;
			startMatchLever.PullLever();
		}

		private void LoadNonLLLAssetBundle()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "non_lll_content");
			if (!File.Exists(text))
			{
				throw new FileNotFoundException("Asset bundle not found at path: " + text);
			}
			ContentAssetBundle = AssetBundle.LoadFromFile(text);
			if (!Object.op_Implicit((Object)(object)ContentAssetBundle))
			{
				throw new AssetBundleLoadException("Failed to load asset bundle from path: " + text);
			}
			ooblterraCozyLightsMusic = WTOBase.ContextualLoadAsset<AudioClip>("CustomItems/ooblboombox.ogg", LogLoading: true);
			ghostPlayerSuit = WTOBase.ContextualLoadAsset<Material>("CustomSuits/GhostPlayerSuit.mat", LogLoading: true);
			customPoster = WTOBase.ContextualLoadAsset<Material>("CustomSuits/Poster.mat", LogLoading: true);
			teslaCoilManagerPrefab = WTOBase.ContextualLoadAsset<GameObject>("CustomDungeon/Security/TeslaCoilManager.prefab", LogLoading: true);
			LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(teslaCoilManagerPrefab);
			string[] array = new string[5] { "CustomDungeon/Behaviors/BatteryRecepticleTransform.prefab", "CustomDungeon/Behaviors/ScrapShelf.prefab", "CustomDungeon/Behaviors/Crusher.prefab", "CustomDungeon/Security/BabyLurkerEgg/BabyLurkerEggProjectile.prefab", "CustomMoon/BearTrap/BearTrap.prefab" };
			string[] array2 = array;
			foreach (string pathToAsset in array2)
			{
				GameObject val = WTOBase.ContextualLoadAsset<GameObject>(pathToAsset, LogLoading: true);
				LethalLevelLoaderNetworkManager.RegisterNetworkPrefab(val);
			}
		}

		private static string ResolveRootPath(string pathToAsset)
		{
			string[] rootPaths = RootPaths;
			foreach (string text in rootPaths)
			{
				string text2 = Path.Join(text.AsSpan(), pathToAsset.AsSpan()).ToLower();
				if (ContentAssetBundle.Contains(text2))
				{
					Log.Info("Resolved asset bundle root path: " + text);
					return text;
				}
			}
			string[] allAssetNames = ContentAssetBundle.GetAllAssetNames();
			foreach (string text3 in allAssetNames)
			{
				string text4 = text3.ToLower();
				if (text4.EndsWith(pathToAsset.ToLower()))
				{
					string text5 = text3;
					int length = pathToAsset.Length;
					return text5.Substring(0, text5.Length - length);
				}
			}
			Log.Error("Could not resolve asset bundle root path using target " + pathToAsset + ". This will most likely cause asset loading to fail.");
			return "";
		}

		public static T ContextualLoadAsset<T>(string PathToAsset, bool LogLoading = true) where T : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)Application.platform == 7)
			{
				string text = PathToAsset.Substring(17);
				text = text.Substring(0, text.LastIndexOf("."));
				if (LogLoading)
				{
					Log.Info("Loading " + text + " from resources folder...", AddFlair: true, ForcePrint: true);
				}
				return Resources.Load<T>(text);
			}
			if (LogLoading)
			{
				Log.Info("Loading " + PathToAsset + "...", AddFlair: true, ForcePrint: true);
			}
			if (!Object.op_Implicit((Object)(object)ContentAssetBundle))
			{
				throw new AssetBundleLoadException("Cannot load " + PathToAsset + " because ContentAssetBundle is not loaded yet.");
			}
			if (resolvedRootPath == "")
			{
				resolvedRootPath = ResolveRootPath(PathToAsset);
			}
			PathToAsset = Path.Join(resolvedRootPath.AsSpan(), PathToAsset.AsSpan());
			return ContentAssetBundle.LoadAsset<T>(PathToAsset) ?? throw new AssetBundleLoadException("Failed to load asset at path " + PathToAsset + ". Asset was null after loading.");
		}

		private static void LogToConsole(Type LogClassType, LogSourceType SourceType, LogType logType, string text, bool AddFlair = true, bool ForcePrint = false)
		{
			if (!ForcePrint)
			{
				if (1 == 0)
				{
				}
				bool flag = logType switch
				{
					LogType.Debug => WTOLogging_Debug.Value, 
					LogType.Info => WTOLogging_Info.Value, 
					LogType.Warning => WTOLogging_Warning.Value, 
					LogType.Error => WTOLogging_Error.Value, 
					_ => true, 
				};
				if (1 == 0)
				{
				}
				bool flag2 = flag;
				if (!WTODebug.Value || !flag2)
				{
					return;
				}
			}
			text = "[" + LogClassType.Name + "]: " + text;
			if (AddFlair)
			{
				text = "=======" + text + "=======";
			}
			switch (logType)
			{
			case LogType.Debug:
				WTOLogSource.LogDebug((object)text);
				break;
			case LogType.Info:
				WTOLogSource.LogInfo((object)text);
				break;
			case LogType.Warning:
				WTOLogSource.LogWarning((object)text);
				break;
			case LogType.Error:
				WTOLogSource.LogError((object)text);
				break;
			default:
				WTOLogSource.LogMessage((object)text);
				break;
			}
		}

		public static ClientRpcSendParams AllClientsButHost()
		{
			//IL_0028: 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)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsHost)
			{
				Log.Error("AllClientsButHost called on a client that is not the host.");
			}
			ClientRpcSendParams result = default(ClientRpcSendParams);
			List<ulong> list = new List<ulong>();
			list.AddRange(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong id) => id != NetworkManager.Singleton.LocalClientId));
			result.TargetClientIds = new <>z__ReadOnlyList<ulong>(list);
			return result;
		}

		public static ClientRpcSendParams AllClientsButSender(ServerRpcParams rpcParams)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_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_004d: Unknown result type (might be due to invalid IL or missing references)
			ClientRpcSendParams result = default(ClientRpcSendParams);
			List<ulong> list = new List<ulong>();
			list.AddRange(NetworkManager.Singleton.ConnectedClientsIds.Where((ulong id) => id != rpcParams.Receive.SenderClientId));
			result.TargetClientIds = new <>z__ReadOnlyList<ulong>(list);
			return result;
		}

		public static ClientRpcSendParams SingleClient(ulong clientId)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return new ClientRpcSendParams
			{
				TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId)
			};
		}

		public static int PlayerIndex(PlayerControllerB? player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return -1;
			}
			return Array.IndexOf(StartOfRound.Instance.allPlayerScripts, player);
		}

		public static PlayerControllerB? PlayerFromIndex(int index)
		{
			if (index < 0 || index >= StartOfRound.Instance.allPlayerScripts.Length)
			{
				return null;
			}
			return StartOfRound.Instance.allPlayerScripts[index];
		}

		private static void PrintReferences(IEnumerable<Object> objects)
		{
			foreach (Object @object in objects)
			{
				PrintReference(@object);
			}
			static string HierarchyString(GameObject x)
			{
				string text = ((Object)x).name;
				while ((Object)(object)x.transform.parent != (Object)null)
				{
					x = ((Component)x.transform.parent).gameObject;
					text = ((Object)x).name + "/" + text;
				}
				return text;
			}
			static void PrintReference(Object o)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected O, but got Unknown
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Expected O, but got Unknown
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Expected O, but got Unknown
				if (!(o == (Object)null))
				{
					if (o is GameObject)
					{
						GameObject val = (GameObject)o;
						Component[] components = val.GetComponents(typeof(Component));
						foreach (Component o2 in components)
						{
							PrintReference((Object)(object)o2);
						}
						for (int j = 0; j < val.transform.childCount; j++)
						{
							PrintReference((Object)(object)((Component)val.transform.GetChild(j)).gameObject);
						}
					}
					else if (o is MeshFilter)
					{
						MeshFilter val2 = (MeshFilter)o;
						if (!((Object)(object)val2.sharedMesh == (Object)null))
						{
							string text = HierarchyString(((Component)val2).gameObject);
							Log.Info(text + ": " + ((Object)val2.sharedMesh).name);
						}
					}
					else if (o is MeshRenderer)
					{
						MeshRenderer val3 = (MeshRenderer)o;
						string text2 = HierarchyString(((Component)val3).gameObject);
						for (int k = 0; k < ((Renderer)val3).materials.Length; k++)
						{
							Log.Info(text2 + " - " + k + ": " + ((Object)((Renderer)val3).materials[k]).name);
						}
					}
					else if (o is AudioSource)
					{
						AudioSource val4 = (AudioSource)o;
						string text3 = HierarchyString(((Component)val4).gameObject);
						if ((Object)(object)val4.clip != (Object)null)
						{
							Log.Info(text3 + ": " + ((Object)val4.clip).name);
						}
						if ((Object)(object)val4.outputAudioMixerGroup != (Object)null)
						{
							Log.Info(text3 + ": " + ((Object)val4.outputAudioMixerGroup).name);
						}
					}
					else
					{
						string name = o.name;
						Log.Info(name + ": " + ((object)o).GetType().ToString());
					}
				}
			}
		}
	}
	internal class Utils
	{
		public static NavMeshHit? GetRandomNavMeshPositionInRadius(Vector3 pos, float radius = 10f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			float y = pos.y;
			pos = Random.insideUnitSphere * radius + pos;
			pos.y = y;
			NavMeshHit value = default(NavMeshHit);
			if (NavMesh.SamplePosition(pos, ref value, radius, -1))
			{
				return value;
			}
			return null;
		}

		public static NavMeshHit? GetRandomNavMeshPositionInRadiusExtended(Vector3 pos, float radius = 10f, float radiusExpansionFactor = 2f, int maxIterations = 3)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < maxIterations; i++)
			{
				float radius2 = radius * Mathf.Pow(radiusExpansionFactor, (float)i);
				NavMeshHit? randomNavMeshPositionInRadius = GetRandomNavMeshPositionInRadius(pos, radius2);
				if (randomNavMeshPositionInRadius.HasValue)
				{
					return randomNavMeshPositionInRadius;
				}
			}
			return null;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Welcome_To_Ooblterra";

		public const string PLUGIN_NAME = "Welcome_To_Ooblterra";

		public const string PLUGIN_VERSION = "2.2.2";
	}
}
namespace Welcome_To_Ooblterra.Security
{
	internal class SpikeTrap : NetworkBehaviour
	{
		public GameObject SpikeMesh;

		public AudioClip SpikesExtend;

		public AudioClip SpikesRetract;

		public AudioClip SpikesDisable;

		public AudioSource SpikeSoundPlayer;

		public Transform RootRotation;

		private bool SpikesEnabled = true;

		private bool SpikesActivated;

		private bool AllowDamagePlayer;

		private float SecondsSinceSpikesActivated;

		private float SecondsUntilCanDamagePlayer;

		private int PlayerDamageAmount = 80;

		private float TimeElapsed;

		private const float MoveTime = 0.2f;

		private readonly Vector3 SpikeRaisePos = new Vector3(0f, 1.163f, 0f);

		private readonly Vector3 SpikeFallPos = new Vector3(0f, 0f, 0f);

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(SpikeTrap), LogSourceType.Room);

		public void OnTriggerEnter(Collider other)
		{
			if (SpikesEnabled && !SpikesActivated && ((Component)other).gameObject.CompareTag("Player"))
			{
				Log.Debug("Player entered spike trap, calling Raise RPC!");
				RaiseSpikesServerRpc();
			}
		}

		public void OnTriggerStay(Collider other)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (AllowDamagePlayer && ((Component)other).gameObject.CompareTag("Player") && SecondsUntilCanDamagePlayer <= 0f)
			{
				PlayerDamageAmount = ((StartOfRound.Instance.connectedPlayersAmount <= 0) ? 80 : 100);
				((Component)other).GetComponent<PlayerControllerB>().DamagePlayer(PlayerDamageAmount, true, true, (CauseOfDeath)6, 0, false, default(Vector3));
				SecondsUntilCanDamagePlayer = 0.75f;
			}
		}

		public void Update()
		{
			if (SecondsUntilCanDamagePlayer > 0f)
			{
				SecondsUntilCanDamagePlayer -= Time.deltaTime;
			}
			if (SecondsSinceSpikesActivated >= 3f)
			{
				if (SpikesActivated)
				{
					SpikeSoundPlayer.clip = SpikesRetract;
					SpikeSoundPlayer.Play();
					TimeElapsed = 0f;
				}
				SpikesActivated = false;
				Log.Info("Lowering Spikes!");
				((MonoBehaviour)this).StartCoroutine(LowerSpikes());
			}
			if (SpikesEnabled && SpikesActivated)
			{
				Log.Info("Raising Spikes!");
				((MonoBehaviour)this).StartCoroutine(RaiseSpikes());
				SecondsSinceSpikesActivated += Time.deltaTime;
			}
		}

		private IEnumerator RaiseSpikes()
		{
			TimeElapsed += Time.deltaTime;
			SpikeMesh.transform.localPosition = Vector3.Lerp(SpikeFallPos, SpikeRaisePos, TimeElapsed / 0.2f);
			if (TimeElapsed / 0.2f >= 1f)
			{
				AllowDamagePlayer = true;
				Log.Info("Finished Raising Spikes");
				((MonoBehaviour)this).StopCoroutine(RaiseSpikes());
			}
			yield return null;
		}

		private IEnumerator LowerSpikes()
		{
			TimeElapsed += Time.deltaTime;
			Log.Debug($"Current Lerp Position: {TimeElapsed / 0.2f}");
			SpikeMesh.transform.localPosition = Vector3.Lerp(SpikeRaisePos, SpikeFallPos, TimeElapsed / 0.2f);
			if (TimeElapsed / 0.2f >= 1f)
			{
				AllowDamagePlayer = false;
				Log.Info("Finished Lowering Spikes");
				((MonoBehaviour)this).StopCoroutine(LowerSpikes());
				SecondsSinceSpikesActivated = 0f;
				((Renderer)SpikeMesh.GetComponent<MeshRenderer>()).enabled = false;
			}
			yield return null;
		}

		public void RecieveToggleSpikes(bool enabled)
		{
			Log.Debug($"Called toggle spikes with state: {enabled}");
			ToggleSpikesServerRpc(enabled);
			ToggleSpikes(enabled);
		}

		[ServerRpc(RequireOwnership = false)]
		public void ToggleSpikesServerRpc(bool enabled)
		{
			//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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1273677579u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1273677579u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					Log.Debug($"Toggling spikes to {enabled} serverRpc");
					ToggleSpikesClientRpc(enabled);
				}
			}
		}

		[ClientRpc]
		public void ToggleSpikesClientRpc(bool enabled)
		{
			//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)
			//IL_00dc: 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.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1768198554u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1768198554u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				Log.Debug($"Toggling spikes to {enabled} clientRpc");
				if (SpikesEnabled != enabled)
				{
					ToggleSpikes(enabled);
				}
			}
		}

		private void ToggleSpikes(bool enabled)
		{
			if (!enabled)
			{
				SpikeSoundPlayer.clip = SpikesDisable;
				SpikeSoundPlayer.Play();
			}
			SpikesEnabled = enabled;
			Log.Debug($"SPIKES STATE: {SpikesEnabled}");
			if (SpikesActivated)
			{
				SecondsSinceSpikesActivated = 5f;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RaiseSpikesServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2638217131u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 2638217131u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					RaiseSpikesClientRpc();
				}
			}
		}

		[ClientRpc]
		public void RaiseSpikesClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3449189664u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3449189664u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					TimeElapsed = 0f;
					SpikeSoundPlayer.clip = SpikesExtend;
					SpikeSoundPlayer.Play();
					((Renderer)SpikeMesh.GetComponent<MeshRenderer>()).enabled = true;
					SpikesActivated = true;
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1273677579u, new RpcReceiveHandler(__rpc_handler_1273677579), "ToggleSpikesServerRpc");
			((NetworkBehaviour)this).__registerRpc(1768198554u, new RpcReceiveHandler(__rpc_handler_1768198554), "ToggleSpikesClientRpc");
			((NetworkBehaviour)this).__registerRpc(2638217131u, new RpcReceiveHandler(__rpc_handler_2638217131), "RaiseSpikesServerRpc");
			((NetworkBehaviour)this).__registerRpc(3449189664u, new RpcReceiveHandler(__rpc_handler_3449189664), "RaiseSpikesClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1273677579(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)
			{
				bool enabled = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enabled, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpikeTrap)(object)target).ToggleSpikesServerRpc(enabled);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1768198554(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)
			{
				bool enabled = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enabled, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpikeTrap)(object)target).ToggleSpikesClientRpc(enabled);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2638217131(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpikeTrap)(object)target).RaiseSpikesServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3449189664(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SpikeTrap)(object)target).RaiseSpikesClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "SpikeTrap";
		}
	}
}
namespace Welcome_To_Ooblterra.RoomBehaviors
{
	public class FrankensteinVisuals : MonoBehaviour
	{
		[InspectorName("SceneAnim")]
		public AudioClip ReviveSound;

		public AudioSource ReviveSoundPlayer;

		public Animator CoilAnim;

		public ParticleSystem[] LightningParticles;

		public LightComponent[] Lights;

		private bool ShouldAnimate;

		private bool AnimStarted;

		private bool AnimStopped;

		private Random MyRandom;

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(FrankensteinVisuals), LogSourceType.Room);

		private void Start()
		{
			MyRandom = new Random(StartOfRound.Instance.randomMapSeed);
		}

		private void Update()
		{
			if (ShouldAnimate)
			{
				((MonoBehaviour)this).StartCoroutine(VisualsHandler());
			}
		}

		public void StartVisuals()
		{
			Log.Debug("Visuals script starting coroutine ...");
			ShouldAnimate = true;
		}

		private IEnumerator VisualsHandler()
		{
			if (!AnimStarted)
			{
				ReviveSoundPlayer.clip = ReviveSound;
				ReviveSoundPlayer.Play();
				CoilAnim.SetTrigger("HeatCoils");
				ParticleSystem[] lightningParticles = LightningParticles;
				foreach (ParticleSystem LightningBolt in lightningParticles)
				{
					LightningBolt.Play();
				}
				AnimStarted = true;
			}
			if (!AnimStopped)
			{
				LightComponent[] lights = Lights;
				foreach (LightComponent Light in lights)
				{
					Light.SetLightBrightness((MyRandom.Next(0, 10) % 2 == 0) ? 200 : 0);
				}
			}
			yield return (object)new WaitForSeconds(3.4f);
			if (!AnimStopped)
			{
				ParticleSystem[] lightningParticles2 = LightningParticles;
				foreach (ParticleSystem LightningBolt2 in lightningParticles2)
				{
					LightningBolt2.Stop();
				}
				LightComponent[] lights2 = Lights;
				foreach (LightComponent Light2 in lights2)
				{
					Light2.SetLightBrightness(0);
				}
				AnimStopped = true;
			}
		}
	}
}
namespace Welcome_To_Ooblterra.Items
{
	public class Chemical : GrabbableObject
	{
		[HideInInspector]
		public enum ChemColor
		{
			Red,
			Orange,
			Yellow,
			Green,
			Blue,
			Indigo,
			Purple,
			Clear
		}

		[InspectorName("Defaults")]
		public MeshRenderer BeakerMesh;

		public List<AudioClip> ShakeSounds;

		private readonly Random MyRandom = new Random();

		private float ShakeCooldownSeconds = 0f;

		private ChemColor Color = ChemColor.Clear;

		private int ScrapValue = 0;

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(Chemical), LogSourceType.Item);

		public override void Start()
		{
			((GrabbableObject)this).Start();
			if (((NetworkBehaviour)this).IsServer)
			{
				Random random = new Random(StartOfRound.Instance.randomMapSeed);
				int num = random.Next(base.itemProperties.minValue, base.itemProperties.maxValue);
				num = (int)Mathf.Round((float)num * 0.4f);
				SetChemState(RandomColor(), num, playShakeSound: false);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			if (ShakeCooldownSeconds > 0f)
			{
				ShakeCooldownSeconds -= Time.deltaTime;
			}
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
			base.playerHeldBy.equippedUsableItemQE = true;
		}

		public override void ItemInteractLeftRight(bool right)
		{
			((GrabbableObject)this).ItemInteractLeftRight(right);
			if (!right && ShakeCooldownSeconds <= 0f && GetCurrentColor() != ChemColor.Clear)
			{
				ShakeCooldownSeconds = 1.2f;
				base.playerHeldBy.playerBodyAnimator.SetTrigger("shakeItem");
				SetChemState(NextColor(Color), ScrapValue, playShakeSound: true);
			}
		}

		private ChemColor RandomColor()
		{
			return (ChemColor)MyRandom.Next(0, 7);
		}

		private static ChemColor NextColor(ChemColor color)
		{
			int num = (int)(color + 1);
			int num2 = 6;
			return (ChemColor)(num % num2);
		}

		public void EmptyBeaker()
		{
			SetChemState(ChemColor.Clear, ScrapValue / 3, playShakeSound: false);
		}

		public ChemColor GetCurrentColor()
		{
			return Color;
		}

		public static Color GetColorFromEnum(ChemColor inColor)
		{
			//IL_003f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Color result = (Color)(inColor switch
			{
				ChemColor.Red => new Color(1f, 0f, 0f), 
				ChemColor.Orange => new Color(1f, 0.4f, 0f), 
				ChemColor.Yellow => new Color(1f, 1f, 0f), 
				ChemColor.Green => new Color(0f, 1f, 0f), 
				ChemColor.Blue => new Color(0f, 1f, 1f), 
				ChemColor.Indigo => new Color(0f, 0f, 1f), 
				ChemColor.Purple => new Color(1f, 0f, 1f), 
				ChemColor.Clear => new Color(0f, 0f, 0f, 0f), 
				_ => new Color(1f, 1f, 1f), 
			});
			if (1 == 0)
			{
			}
			return result;
		}

		[ServerRpc]
		private void SetChemStateServerRpc(ChemColor color, int scrapValue, bool playShakeSound, ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Invalid comparison between Unknown and I4
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d2: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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;
				}
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2988978897u, rpcParams, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<ChemColor>(ref color, default(ForEnums));
				BytePacker.WriteValueBitPacked(val, scrapValue);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref playShakeSound, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2988978897u, rpcParams, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				SetChemStateClientRpc(color, scrapValue, playShakeSound, new ClientRpcParams
				{
					Send = WTOBase.AllClientsButSender(rpcParams)
				});
			}
		}

		[ClientRpc]
		private void SetChemStateClientRpc(ChemColor color, int scrapValue, bool playShakeSound, ClientRpcParams rpcParams = default(ClientRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00a5: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2956456148u, rpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe<ChemColor>(ref color, default(ForEnums));
					BytePacker.WriteValueBitPacked(val, scrapValue);
					((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref playShakeSound, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2956456148u, rpcParams, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					UpdateChemStateOnClient(color, scrapValue, playShakeSound);
				}
			}
		}

		private void UpdateChemStateOnClient(ChemColor color, int scrapValue, bool playShakeSound)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (playShakeSound)
			{
				((Component)this).GetComponent<AudioSource>().PlayOneShot(ShakeSounds[MyRandom.Next(0, ShakeSounds.Count - 1)]);
			}
			Color = color;
			ScrapValue = scrapValue;
			((GrabbableObject)this).SetScrapValue(ScrapValue);
			((Renderer)BeakerMesh).materials[1].SetColor("_BaseColor", GetColorFromEnum(Color));
		}

		private void SetChemState(ChemColor color, int scrapValue, bool playShakeSound)
		{
			//IL_0050: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Log.Info($"Next Color Value: {color}");
			if (((NetworkBehaviour)this).IsClient)
			{
				UpdateChemStateOnClient(color, scrapValue, playShakeSound);
				SetChemStateServerRpc(color, scrapValue, playShakeSound);
			}
			else
			{
				SetChemStateClientRpc(color, scrapValue, playShakeSound);
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2988978897u, new RpcReceiveHandler(__rpc_handler_2988978897), "SetChemStateServerRpc");
			((NetworkBehaviour)this).__registerRpc(2956456148u, new RpcReceiveHandler(__rpc_handler_2956456148), "SetChemStateClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_2988978897(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_008b: 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)
			//IL_00aa: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00da: 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_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!");
				}
				return;
			}
			ChemColor color = default(ChemColor);
			((FastBufferReader)(ref reader)).ReadValueSafe<ChemColor>(ref color, default(ForEnums));
			int scrapValue = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref scrapValue);
			bool playShakeSound = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref playShakeSound, default(ForPrimitives));
			ServerRpcParams server = rpcParams.Server;
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((Chemical)(object)target).SetChemStateServerRpc(color, scrapValue, playShakeSound, server);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_2956456148(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_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ChemColor color = default(ChemColor);
				((FastBufferReader)(ref reader)).ReadValueSafe<ChemColor>(ref color, default(ForEnums));
				int scrapValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref scrapValue);
				bool playShakeSound = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref playShakeSound, default(ForPrimitives));
				ClientRpcParams client = rpcParams.Client;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Chemical)(object)target).SetChemStateClientRpc(color, scrapValue, playShakeSound, client);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "Chemical";
		}
	}
	internal class CursedEffigy : GrabbableObject
	{
		public EnemyType TheMimic;

		private bool MimicSpawned;

		private PlayerControllerB? previousPlayerHeldBy;

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(CursedEffigy), LogSourceType.Item);

		public override void Update()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).Update();
			if (((NetworkBehaviour)this).IsServer && !MimicSpawned)
			{
				PlayerControllerB? obj = previousPlayerHeldBy;
				if (obj != null && obj.isPlayerDead)
				{
					Log.Info($"Effigy knows that {previousPlayerHeldBy.playerUsername} is dead at position {((Component)previousPlayerHeldBy.deadBody).transform.position}");
					MimicSpawned = true;
					CreateMimic();
				}
			}
		}

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			SetOwningPlayerServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, base.playerHeldBy));
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			SetOwningPlayerServerRpc(-1);
		}

		[ServerRpc]
		public void SetOwningPlayerServerRpc(int OwnerID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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 val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3785399831u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, OwnerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3785399831u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (OwnerID == -1)
			{
				if ((Object)(object)previousPlayerHeldBy != (Object)null && !previousPlayerHeldBy.isPlayerDead)
				{
					previousPlayerHeldBy = null;
				}
			}
			else
			{
				previousPlayerHeldBy = StartOfRound.Instance.allPlayerScripts[OwnerID];
			}
		}

		public void CreateMimic()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)previousPlayerHeldBy == (Object)null)
			{
				Log.Error("Previousplayerheldby is null so the Ghost Player could not be spawned");
				return;
			}
			Log.Info("Server creating Ghost Player from Effigy. Previous Player: " + previousPlayerHeldBy.playerUsername);
			NavMeshHit? randomNavMeshPositionInRadiusExtended = Utils.GetRandomNavMeshPositionInRadiusExtended(((Component)previousPlayerHeldBy.deadBody).transform.position);
			if (!randomNavMeshPositionInRadiusExtended.HasValue)
			{
				Log.Error("No nav mesh found; no Ghost Player could be created");
				return;
			}
			RoundManager instance = RoundManager.Instance;
			NavMeshHit value = randomNavMeshPositionInRadiusExtended.Value;
			NetworkObjectReference netObjectRef = instance.SpawnEnemyGameObject(((NavMeshHit)(ref value)).position, 0f, -1, TheMimic);
			CreateMimicClientRpc(netObjectRef, previousPlayerHeldBy.isInsideFactory, Array.IndexOf(StartOfRound.Instance.allPlayerScripts, previousPlayerHeldBy));
		}

		[ClientRpc]
		public void CreateMimicClientRpc(NetworkObjectReference netObjectRef, bool inFactory, int playerIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3682496662u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref inFactory, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val, playerIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3682496662u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val3, (NetworkManager)null))
				{
					Log.Debug("Got network object for Ghost Player");
					MaskedPlayerEnemy component = ((Component)val3).GetComponent<MaskedPlayerEnemy>();
					PlayerControllerB val4 = (component.mimickingPlayer = StartOfRound.Instance.allPlayerScripts[playerIndex]);
					((Renderer)component.rendererLOD0).material = WTOBase.ghostPlayerSuit;
					((Renderer)component.rendererLOD1).material = WTOBase.ghostPlayerSuit;
					((Renderer)component.rendererLOD2).material = WTOBase.ghostPlayerSuit;
					((EnemyAI)component).SetEnemyOutside(inFactory);
					component.SetVisibilityOfMaskedEnemy();
					component.maskTypes[0].SetActive(false);
					component.maskTypes[1].SetActive(false);
					component.maskTypeIndex = 0;
					val4.redirectToEnemy = (EnemyAI)(object)component;
					val4.deadBody.DeactivateBody(false);
				}
				((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3785399831u, new RpcReceiveHandler(__rpc_handler_3785399831), "SetOwningPlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(3682496662u, new RpcReceiveHandler(__rpc_handler_3682496662), "CreateMimicClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_3785399831(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_0070: 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_009d: 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
			{
				int owningPlayerServerRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref owningPlayerServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CursedEffigy)(object)target).SetOwningPlayerServerRpc(owningPlayerServerRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3682496662(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_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				bool inFactory = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inFactory, default(ForPrimitives));
				int playerIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((CursedEffigy)(object)target).CreateMimicClientRpc(netObjectRef, inFactory, playerIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CursedEffigy";
		}
	}
	internal class OoblCorpsePart : GrabbableObject
	{
		public EnemyType OoblGhostTemplate;

		private OoblGhostAI MySpawnedGhost = null;

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(OoblCorpsePart), LogSourceType.Item);

		public override void GrabItem()
		{
			((GrabbableObject)this).GrabItem();
			OnGrabItemServerRpc(Array.IndexOf(StartOfRound.Instance.allPlayerScripts, base.playerHeldBy));
		}

		public override void DiscardItem()
		{
			((GrabbableObject)this).DiscardItem();
			OnDiscardItemServerRpc();
		}

		[ServerRpc]
		private void OnGrabItemServerRpc(int clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				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 val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2780701407u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, clientId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2780701407u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (base.isInShipRoom)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)MySpawnedGhost))
			{
				MySpawnedGhost.IsMovingTowardPlayer = true;
				MySpawnedGhost.SetGhostTargetServerRpc(clientId);
				return;
			}
			Log.Info("Spawning Oobl Ghost");
			NetworkObjectReference val3 = RoundManager.Instance.SpawnEnemyGameObject(new Vector3(0f, -700f, 0f), 0f, 1, OoblGhostTemplate);
			NetworkObject val4 = default(NetworkObject);
			if (((NetworkObjectReference)(ref val3)).TryGet(ref val4, (NetworkManager)null))
			{
				MySpawnedGhost = ((Component)val4).GetComponent<OoblGhostAI>();
				MySpawnedGhost.IsMovingTowardPlayer = true;
				MySpawnedGhost.LinkedCorpsePart = this;
				MySpawnedGhost.SetGhostTargetServerRpc(clientId);
			}
			else
			{
				Log.Error("Could not link this corpse part to the Oobl Ghost!");
			}
		}

		[ServerRpc]
		private void OnDiscardItemServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c2: 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 val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(787149749u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 787149749u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (Object.op_Implicit((Object)(object)MySpawnedGhost))
				{
					MySpawnedGhost.IsMovingTowardPlayer = false;
				}
			}
		}

		public void DestroyCorpsePart()
		{
			if (((NetworkBehaviour)this).IsHost)
			{
				DestroyCorpsePartClientRpc();
			}
			else
			{
				DestroyCorpsePartServerRpc();
			}
		}

		[ServerRpc]
		private void DestroyCorpsePartServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c2: 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 val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(370162681u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 370162681u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				DestroyCorpsePartClientRpc();
			}
		}

		[ClientRpc]
		private void DestroyCorpsePartClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3500768280u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3500768280u, val2, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Log.Info($"Destroying: {this}");
					((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2780701407u, new RpcReceiveHandler(__rpc_handler_2780701407), "OnGrabItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(787149749u, new RpcReceiveHandler(__rpc_handler_787149749), "OnDiscardItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(370162681u, new RpcReceiveHandler(__rpc_handler_370162681), "DestroyCorpsePartServerRpc");
			((NetworkBehaviour)this).__registerRpc(3500768280u, new RpcReceiveHandler(__rpc_handler_3500768280), "DestroyCorpsePartClientRpc");
			((GrabbableObject)this).__initializeRpcs();
		}

		private static void __rpc_handler_2780701407(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_0070: 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_009d: 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
			{
				int clientId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref clientId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OoblCorpsePart)(object)target).OnGrabItemServerRpc(clientId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_787149749(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_0076: 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_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
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OoblCorpsePart)(object)target).OnDiscardItemServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_370162681(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_0076: 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_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
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OoblCorpsePart)(object)target).DestroyCorpsePartServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3500768280(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OoblCorpsePart)(object)target).DestroyCorpsePartClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "OoblCorpsePart";
		}
	}
	public class WTOBattery : GrabbableObject
	{
		public bool HasCharge = true;

		public Material ChargedMaterial;

		public Material DrainedMaterial;

		public ScanNodeProperties ScanNode;

		private static readonly WTOBase.WTOLogger Log = new WTOBase.WTOLogger(typeof(WTOBattery), LogSourceType.Item);

		private void Awake()
		{
			if (ScanNode == null)
			{
				ScanNode = ((Component)this).gameObject.GetComponentInChildren<ScanNodeProperties>();
			}
		}

		public override void OnNetworkSpawn()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (((NetworkBehaviour)this).IsServer)
			{
				SetCharge(HasCharge);
				SetChargeClientRpc(HasCharge, new ClientRpcParams
				{
					Send = WTOBase.AllClientsButHost()
				});
			}
		}

		[ClientRpc]
		private void SetChargeClientRpc(bool hasCharge, ClientRpcParams clientRpcParams = default(ClientRpcParams))
		{
			//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