Decompiled source of LCGoldScrapMod v2.0.5

LCGoldScrapMod.dll

Decompiled 5 days ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using HarmonyLib.Tools;
using LethalConfig;
using LethalConfig.ConfigItems;
using STSharedAudioLib;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
	}
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/ArtOfGoldMaterials", order = 1)]
public class ArtOfGoldMaterials : ScriptableObject
{
	public List<Material> allArtwork;

	public List<Material> allSillyArtwork;
}
public enum GoldScrapLevels
{
	Experimentation,
	Assurance,
	Vow,
	Offense,
	March,
	Rend,
	Dine,
	Titan,
	Adamance,
	Artifice,
	Embrion
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/ItemData", order = 0)]
public class ItemData : ScriptableObject
{
	[Header("Item")]
	[Tooltip("The LCGoldScrapMod itemProperties the game will read from on the host.")]
	public Item itemProperties;

	[Tooltip("If true, it will be registered to levels and its itemProperties' weight, max-, and minValues will be put through the configMultipliers.\nIf false, only weight will be multiplied by its configMultiplier.")]
	public bool isScrap = true;

	[Tooltip("If true, its value will not be counted when collected in levels and when sold on the Company desk.")]
	public bool isStoreItem;

	[Space(3f)]
	[Header("Defaults")]
	[Tooltip("The intended default weight not yet taking the default 1.5x weightMultiplier into account.\nUsually the weight of the original item, unless that has no weight.")]
	public float defaultWeight = 1f;

	[Tooltip("The intended default maxValue not yet taking the default 2x maxValueMultiplier into account.\nUsually the maxValue of the original item.")]
	public int defaultMaxValue;

	[Tooltip("The intended default minValue not yet taking the default 2.5x minValueMultiplier into account.\nUsually the minValue of the original item.")]
	public int defaultMinValue;

	[Tooltip("The intended default rarity not yet taking the custom plusGain and minusLoss into account.\nRefer to 'GoldScrap - Items' document.")]
	public int defaultRarity = 3;

	[Space(3f)]
	[Header("Levels")]
	[Tooltip("The vanilla levels where this gold scrap can appear.\nTakes a calculation of 'Default Rarity - 1' into account.")]
	public GoldScrapLevels[] levelsToAddMinus;

	[Tooltip("The vanilla levels where this gold scrap can appear.\nOnly takes Default Rarity into account.")]
	public GoldScrapLevels[] levelsToAddDefault;

	[Tooltip("The vanilla levels where this gold scrap can appear.\nTakes a calculation of 'Default Rarity + 2' into account.")]
	public GoldScrapLevels[] levelsToAddPlus;

	[Tooltip("A custom positive gain or negative loss that will influence the Default Rarity of gold scrap on levels selected in 'Levels To Add Custom'.\nWill have no effect if Default Rarity is 2 or smaller and Custom Change is -2 or lower.")]
	public int customChange;

	[Tooltip("The vanilla levels where this gold scrap can appear.\nTakes a calculation of 'Default Rarity + Custom Change' into account.")]
	public GoldScrapLevels[] levelsToAddCustom;

	[Space(3f)]
	[Header("Host values")]
	[HideInInspector]
	public int localMaxValue;

	[HideInInspector]
	public int localMinValue;
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/List/AudioClipList")]
public class AudioClipList : ScriptableObject
{
	public List<AudioClip> allClips = new List<AudioClip>();
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/List/GameObjectList")]
public class GameObjectList : ScriptableObject
{
	public GameObject[] allPrefabs;
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/List/ItemDataList")]
public class ItemDataList : ScriptableObject
{
	public ItemData[] allItemData;
}
[CreateAssetMenu(menuName = "LCGoldScrapMod/List/StringList")]
public class StringList : ScriptableObject
{
	[TextArea(1, 20)]
	public string[] allStrings;
}
public interface IGoldenGlassSecret
{
	void BeginReveal();

	void EndReveal();
}
public class GoldBirdScript : GrabbableObject
{
	[HarmonyPatch(typeof(HUDManager), "RadiationWarningHUD")]
	public class NewHUDManagerRadiationWarning
	{
		[HarmonyPostfix]
		public static void AwakenGoldBirds()
		{
			if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && GameNetworkManager.Instance.localPlayerController.isHostPlayerObject)
			{
				GoldBirdScript[] array = Object.FindObjectsOfType<GoldBirdScript>();
				foreach (GoldBirdScript obj in array)
				{
					obj.AwakenClientRpc((int)((float)((GrabbableObject)obj).scrapValue * Random.Range(3f, 4f)));
				}
			}
		}
	}

	private static ManualLogSource Logger = Plugin.Logger;

	[Space(3f)]
	[Header("Alarm")]
	public AudioSource alarmSource;

	public AudioClip alarmClip;

	private float alarmTimer;

	private bool canAlarmFire;

	[Space(3f)]
	[Header("Spotlight")]
	public AudioSource spotlightAudio;

	public AudioClip lightOnClip;

	public AudioClip lightOffClip;

	public Light headlight;

	public Color normalColor;

	public Color alarmColor;

	[Space(3f)]
	[Header("Dormancy")]
	public AudioSource awakeSource;

	public AudioClip awakeClip;

	public AudioClip dieClip;

	public bool dormant = true;

	public ScanNodeProperties scanNode;

	private bool canWakeThisRound = true;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		alarmSource.clip = alarmClip;
		if (base.isInShipRoom)
		{
			canWakeThisRound = false;
		}
		else
		{
			scanNode.headerText = "Gold Bird (Dormant)";
		}
	}

	public override void Update()
	{
		((GrabbableObject)this).Update();
		if (!((NetworkBehaviour)this).IsServer || dormant)
		{
			return;
		}
		canAlarmFire = (Object)(object)base.playerHeldBy != (Object)null && StartOfRound.Instance.shipDoorsEnabled && !StartOfRound.Instance.inShipPhase;
		if (!canAlarmFire && alarmTimer < 0.1f)
		{
			alarmTimer = 0.1f;
			ToggleAlarmClientRpc(alarm: false);
			return;
		}
		alarmTimer += Time.deltaTime;
		if (alarmTimer > 2f)
		{
			alarmTimer = 0f;
			DoAlarmInterval();
		}
	}

	private void DoAlarmInterval()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (canAlarmFire)
		{
			if (IsNearbyPlayerInSight())
			{
				ToggleAlarmClientRpc(alarm: true);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, alarmSource.maxDistance + 15f, 1f, 0, false, 0);
			}
			else
			{
				ToggleAlarmClientRpc(alarm: false);
			}
		}
	}

	private bool IsNearbyPlayerInSight()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: 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)
		if (StartOfRound.Instance.connectedPlayersAmount > 0)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)base.playerHeldBy) && val.isPlayerControlled && !(Vector3.Distance(((Component)headlight).transform.position, ((Component)val).transform.position) > alarmSource.maxDistance - 15f))
				{
					return !Physics.Linecast(((Component)headlight).transform.position, val.playerEye.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
				}
			}
		}
		return false;
	}

	[ClientRpc]
	private void ToggleAlarmClientRpc(bool alarm)
	{
		//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_0122: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3862976390u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref alarm, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3862976390u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (!((Behaviour)headlight).enabled)
			{
				((Behaviour)headlight).enabled = true;
			}
			if (alarm && !alarmSource.isPlaying)
			{
				spotlightAudio.PlayOneShot(lightOnClip);
				alarmSource.Play();
				headlight.color = alarmColor;
			}
			else if (!alarm && alarmSource.isPlaying)
			{
				spotlightAudio.PlayOneShot(lightOffClip);
				alarmSource.Stop();
				headlight.color = normalColor;
			}
		}
	}

	[ClientRpc]
	public void AwakenClientRpc(int awakenedValue)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4211676833u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, awakenedValue);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4211676833u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		Logger.LogDebug((object)$"{((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId}: canWake {canWakeThisRound} // dormant {dormant}");
		if (canWakeThisRound && dormant)
		{
			Logger.LogDebug((object)"awakening");
			awakeSource.PlayOneShot(awakeClip);
			WalkieTalkie.TransmitOneShotAudio(awakeSource, awakeClip, 0.5f);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, awakeSource.maxDistance, 0.1f, 0, false, 0);
			((Behaviour)headlight).enabled = true;
			headlight.color = normalColor;
			dormant = false;
			canWakeThisRound = false;
			if (scanNode.headerText.Contains("(Dormant)"))
			{
				scanNode.headerText = scanNode.headerText.Replace("Dormant", "Awake");
			}
			((GrabbableObject)this).SetScrapValue(awakenedValue);
		}
	}

	[ClientRpc]
	public void DeactivateAtEndOfDayClientRpc()
	{
		//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_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(634004460u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 634004460u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || !canWakeThisRound)
		{
			return;
		}
		canWakeThisRound = false;
		Logger.LogDebug((object)$"{((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId} can no longer wake");
		if (dormant)
		{
			if (scanNode.headerText.Contains("(Dormant)"))
			{
				scanNode.headerText = scanNode.headerText.Replace("Dormant", "Dead");
			}
			spotlightAudio.PlayOneShot(dieClip);
			Object.Instantiate<GameObject>(AssetsCollection.poofParticle, ((Component)headlight).transform.position, new Quaternion(0f, 0f, 0f, 0f)).GetComponent<ParticleSystem>().Play();
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncUponJoinServerRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2991509102u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2991509102u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncUponJoinClientRpc(canWakeThisRound, ((Behaviour)headlight).enabled, scanNode.headerText, playerID);
			}
		}
	}

	[ClientRpc]
	private void SyncUponJoinClientRpc(bool hostCanWakeValue, bool enableHeadlight, string scanNodeName, int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1832698290u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hostCanWakeValue, default(ForPrimitives));
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enableHeadlight, default(ForPrimitives));
			bool flag = scanNodeName != null;
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
			if (flag)
			{
				((FastBufferWriter)(ref val2)).WriteValueSafe(scanNodeName, false);
			}
			BytePacker.WriteValueBitPacked(val2, playerID);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1832698290u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && playerID == (int)StartOfRound.Instance.localPlayerController.playerClientId)
		{
			canWakeThisRound = hostCanWakeValue;
			((Behaviour)headlight).enabled = enableHeadlight;
			if (enableHeadlight)
			{
				headlight.color = (alarmSource.isPlaying ? alarmColor : normalColor);
			}
			scanNode.headerText = scanNodeName;
		}
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_GoldBirdScript()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(3862976390u, new RpcReceiveHandler(__rpc_handler_3862976390));
		NetworkManager.__rpc_func_table.Add(4211676833u, new RpcReceiveHandler(__rpc_handler_4211676833));
		NetworkManager.__rpc_func_table.Add(634004460u, new RpcReceiveHandler(__rpc_handler_634004460));
		NetworkManager.__rpc_func_table.Add(2991509102u, new RpcReceiveHandler(__rpc_handler_2991509102));
		NetworkManager.__rpc_func_table.Add(1832698290u, new RpcReceiveHandler(__rpc_handler_1832698290));
	}

	private static void __rpc_handler_3862976390(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 alarm = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref alarm, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldBirdScript)(object)target).ToggleAlarmClientRpc(alarm);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4211676833(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int awakenedValue = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref awakenedValue);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldBirdScript)(object)target).AwakenClientRpc(awakenedValue);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

	private static void __rpc_handler_2991509102(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GoldBirdScript)(object)target).SyncUponJoinServerRpc(playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1832698290(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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool hostCanWakeValue = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hostCanWakeValue, default(ForPrimitives));
			bool enableHeadlight = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enableHeadlight, default(ForPrimitives));
			bool flag = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
			string scanNodeName = null;
			if (flag)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe(ref scanNodeName, false);
			}
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldBirdScript)(object)target).SyncUponJoinClientRpc(hostCanWakeValue, enableHeadlight, scanNodeName, playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "GoldBirdScript";
	}
}
public class GoldenClockScript : GrabbableObject
{
	private static ManualLogSource Logger = Plugin.Logger;

	[Space(3f)]
	[Header("Original Clock")]
	public Transform minuteHand;

	public Transform secondHand;

	private float timeOfLastSecond;

	public AudioSource tickAudio;

	public AudioClip tickSFX;

	public AudioClip tockSFX;

	private bool tickOrTock;

	[Space(3f)]
	[Header("Custom Timer")]
	public AudioClip intervalClip;

	public AudioClip failClip;

	public int maxRealSeconds;

	public int minRealSeconds;

	public float countdownInterval;

	[Space(3f)]
	[Header("Close Call")]
	public AudioSource closeCallAudio;

	public AudioClip closeCallApproach;

	public AudioClip closeCallSuccess;

	public AudioClip closeCallFail;

	private bool shouldCountDown;

	private bool approachedShipFinalPhase;

	private int secondsLeft;

	private int thisClocksStartingSeconds;

	private int thisClocksStartingValue;

	private int thisClocksIntervalAmount;

	private int thisClocksSpecialMultiplier;

	private float timeOfLastTickTock;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		if (((NetworkBehaviour)this).IsServer && !base.isInShipRoom)
		{
			((MonoBehaviour)this).StartCoroutine(RollForNewTimer());
		}
	}

	public override void Update()
	{
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).Update();
		if (!shouldCountDown)
		{
			return;
		}
		if (Time.realtimeSinceStartup - timeOfLastSecond > countdownInterval)
		{
			timeOfLastSecond = Time.realtimeSinceStartup;
			if (((NetworkBehaviour)this).IsServer || (!((NetworkBehaviour)this).IsServer && secondsLeft % 60 != 1))
			{
				secondsLeft--;
				secondHand.Rotate(6f, 0f, 0f, (Space)1);
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				if (secondsLeft <= 0)
				{
					shouldCountDown = false;
					SyncFailureClientRpc(base.scrapValue / thisClocksSpecialMultiplier);
					return;
				}
				if (secondsLeft % 60 == 0)
				{
					SyncTimeAndValueClientRpc(secondsLeft, base.scrapValue - (int)Mathf.Lerp(0f, (float)thisClocksStartingValue, (float)(Random.Range(40, 70) / thisClocksIntervalAmount) / 100f), isMinute: true);
				}
				if (secondsLeft < 60 && !approachedShipFinalPhase && (Object)(object)base.playerHeldBy != (Object)null && Vector3.Distance(((Component)base.playerHeldBy).transform.position, ((Component)StartOfRound.Instance.shipDoorNode).transform.position) < 10f)
				{
					approachedShipFinalPhase = true;
					SyncApproachClientRpc();
				}
			}
			if (secondsLeft > 60)
			{
				TickTock();
			}
		}
		if (secondsLeft <= 60 && Time.realtimeSinceStartup - timeOfLastTickTock > countdownInterval / 2f)
		{
			TickTock();
		}
	}

	public override void OnBroughtToShip()
	{
		((GrabbableObject)this).OnBroughtToShip();
		if (shouldCountDown)
		{
			SyncSuccessServerRpc();
		}
	}

	private IEnumerator RollForNewTimer()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => StartOfRound.Instance.shipHasLanded));
		int num = Random.Range(minRealSeconds, maxRealSeconds);
		int num2 = (int)((float)num / countdownInterval);
		int intervalAmount = num2 / 60;
		int num3 = Mathf.Clamp(TimeOfDay.Instance.daysUntilDeadline, 1, 3) + 1;
		int num4 = base.scrapValue * num3 + (maxRealSeconds - num) / 2;
		if (RarityManager.CurrentlyGoldFever())
		{
			num4 *= 2;
		}
		SendNewTimerClientRpc(num2, intervalAmount, num3, num4);
	}

	[ClientRpc]
	private void SendNewTimerClientRpc(int startingSeconds, int intervalAmount, int specialMultiplier, int startingValue)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(724639717u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, startingSeconds);
				BytePacker.WriteValueBitPacked(val2, intervalAmount);
				BytePacker.WriteValueBitPacked(val2, specialMultiplier);
				BytePacker.WriteValueBitPacked(val2, startingValue);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 724639717u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				thisClocksStartingSeconds = startingSeconds;
				thisClocksIntervalAmount = intervalAmount;
				thisClocksSpecialMultiplier = specialMultiplier;
				thisClocksStartingValue = startingValue;
				shouldCountDown = true;
				minuteHand.Rotate(-20f * (float)(thisClocksIntervalAmount % 18), 0f, 0f, (Space)1);
				SetTimerRotationAndValue(thisClocksStartingSeconds, isMinute: false, thisClocksStartingValue);
				Logger.LogDebug((object)$"{((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId}:");
				Logger.LogDebug((object)$"{thisClocksStartingSeconds}");
				Logger.LogDebug((object)$"{thisClocksIntervalAmount}");
				Logger.LogDebug((object)$"{thisClocksSpecialMultiplier}");
				Logger.LogDebug((object)$"{thisClocksStartingValue}");
			}
		}
	}

	private void SetTimerRotationAndValue(int seconds, bool isMinute = false, int newScrapValue = -1)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		secondsLeft = seconds;
		if (isMinute)
		{
			secondHand.localRotation = new Quaternion(0f, 0f, 0f, 0f);
		}
		else
		{
			secondHand.Rotate(-6f * (float)(seconds % 60), 0f, 0f, (Space)1);
		}
		if (newScrapValue != -1)
		{
			((GrabbableObject)this).SetScrapValue(newScrapValue);
		}
	}

	[ClientRpc]
	private void SyncTimeAndValueClientRpc(int hostSecondsLeft, int newScrapValue, bool isMinute)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(173399023u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, hostSecondsLeft);
				BytePacker.WriteValueBitPacked(val2, newScrapValue);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isMinute, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 173399023u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				minuteHand.Rotate(20f, 0f, 0f, (Space)1);
				tickAudio.PlayOneShot(intervalClip);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 5f, 0.5f, 0, false, 0);
				WalkieTalkie.TransmitOneShotAudio(tickAudio, intervalClip, 1f);
				SetTimerRotationAndValue(hostSecondsLeft, isMinute, newScrapValue);
			}
		}
	}

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

	[ClientRpc]
	private void SyncSuccessClientRpc(bool inFinalPhase)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2850989775u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref inFinalPhase, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2850989775u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			shouldCountDown = false;
			tickAudio.PlayOneShot(intervalClip);
			WalkieTalkie.TransmitOneShotAudio(tickAudio, intervalClip, 1f);
			if (inFinalPhase)
			{
				closeCallAudio.Stop();
				closeCallAudio.PlayOneShot(closeCallSuccess);
				WalkieTalkie.TransmitOneShotAudio(closeCallAudio, closeCallSuccess, 1f);
			}
		}
	}

	[ClientRpc]
	private void SyncFailureClientRpc(int failedScrapValue)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3360715093u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, failedScrapValue);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3360715093u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			shouldCountDown = false;
			secondsLeft = 0;
			tickAudio.PlayOneShot(failClip);
			WalkieTalkie.TransmitOneShotAudio(tickAudio, failClip, 1f);
			RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 15f, 1f, 0, false, 0);
			((GrabbableObject)this).SetScrapValue(failedScrapValue);
			secondHand.localRotation = new Quaternion(0f, 0f, 0f, 0f);
			minuteHand.localRotation = new Quaternion(0f, 0f, 0f, 0f);
			if (approachedShipFinalPhase)
			{
				closeCallAudio.Stop();
				closeCallAudio.PlayOneShot(closeCallFail);
				WalkieTalkie.TransmitOneShotAudio(closeCallAudio, closeCallFail, 1f);
			}
		}
	}

	[ClientRpc]
	private void SyncApproachClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2869504692u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2869504692u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				approachedShipFinalPhase = true;
				closeCallAudio.PlayOneShot(closeCallApproach);
				WalkieTalkie.TransmitOneShotAudio(closeCallAudio, closeCallApproach, 1f);
			}
		}
	}

	private void TickTock()
	{
		tickOrTock = !tickOrTock;
		AudioClip val = (tickOrTock ? tickSFX : tockSFX);
		tickAudio.PlayOneShot(val);
		WalkieTalkie.TransmitOneShotAudio(tickAudio, val, 0.33f);
		timeOfLastTickTock = Time.realtimeSinceStartup;
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncUponJoinServerRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(118909299u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 118909299u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncUponJoinClientRpc(shouldCountDown, secondsLeft, playerID);
			}
		}
	}

	[ClientRpc]
	private void SyncUponJoinClientRpc(bool hostBroughtToShip, int hostSecondsLeft, int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3919497654u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hostBroughtToShip, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, hostSecondsLeft);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3919497654u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && playerID == (int)StartOfRound.Instance.localPlayerController.playerClientId)
			{
				shouldCountDown = hostBroughtToShip;
				SetTimerRotationAndValue(hostSecondsLeft);
			}
		}
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_GoldenClockScript()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(724639717u, new RpcReceiveHandler(__rpc_handler_724639717));
		NetworkManager.__rpc_func_table.Add(173399023u, new RpcReceiveHandler(__rpc_handler_173399023));
		NetworkManager.__rpc_func_table.Add(1373350663u, new RpcReceiveHandler(__rpc_handler_1373350663));
		NetworkManager.__rpc_func_table.Add(2850989775u, new RpcReceiveHandler(__rpc_handler_2850989775));
		NetworkManager.__rpc_func_table.Add(3360715093u, new RpcReceiveHandler(__rpc_handler_3360715093));
		NetworkManager.__rpc_func_table.Add(2869504692u, new RpcReceiveHandler(__rpc_handler_2869504692));
		NetworkManager.__rpc_func_table.Add(118909299u, new RpcReceiveHandler(__rpc_handler_118909299));
		NetworkManager.__rpc_func_table.Add(3919497654u, new RpcReceiveHandler(__rpc_handler_3919497654));
	}

	private static void __rpc_handler_724639717(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_005d: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int startingSeconds = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref startingSeconds);
			int intervalAmount = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref intervalAmount);
			int specialMultiplier = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref specialMultiplier);
			int startingValue = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref startingValue);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenClockScript)(object)target).SendNewTimerClientRpc(startingSeconds, intervalAmount, specialMultiplier, startingValue);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_173399023(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int hostSecondsLeft = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref hostSecondsLeft);
			int newScrapValue = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref newScrapValue);
			bool isMinute = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isMinute, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenClockScript)(object)target).SyncTimeAndValueClientRpc(hostSecondsLeft, newScrapValue, isMinute);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1373350663(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;
			((GoldenClockScript)(object)target).SyncSuccessServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2850989775(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 inFinalPhase = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref inFinalPhase, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenClockScript)(object)target).SyncSuccessClientRpc(inFinalPhase);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3360715093(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int failedScrapValue = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref failedScrapValue);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenClockScript)(object)target).SyncFailureClientRpc(failedScrapValue);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

	private static void __rpc_handler_118909299(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GoldenClockScript)(object)target).SyncUponJoinServerRpc(playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3919497654(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_004b: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool hostBroughtToShip = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hostBroughtToShip, default(ForPrimitives));
			int hostSecondsLeft = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref hostSecondsLeft);
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenClockScript)(object)target).SyncUponJoinClientRpc(hostBroughtToShip, hostSecondsLeft, playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "GoldenClockScript";
	}
}
public class GoldenGirlScript : GrabbableObject, IGoldenGlassSecret
{
	private static ManualLogSource Logger = Plugin.Logger;

	private Mesh loadedMesh;

	private bool broughtToShip;

	private bool choseLocalPlayer;

	[Space(3f)]
	[Header("(In)visibility")]
	public MeshFilter meshToToggle;

	public MeshRenderer materialToToggle;

	public AudioSource audioToMute;

	[Space(3f)]
	[Header("Audiovisual feedback")]
	public AudioSource reappearSource;

	public AudioClip reappearClip;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		loadedMesh = ((Component)this).GetComponent<MeshFilter>().mesh;
		if (((NetworkBehaviour)this).IsServer)
		{
			if (base.isInShipRoom)
			{
				broughtToShip = true;
			}
			else
			{
				ChoosePlayer();
			}
		}
	}

	private void ChoosePlayer()
	{
		if (base.isInFactory && !base.isInShipRoom)
		{
			ChoosePlayerClientRpc((int)General.GetRandomPlayer().playerClientId);
		}
	}

	[ClientRpc]
	private void ChoosePlayerClientRpc(int playerClientId)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2685509517u, val, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val2, playerClientId);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2685509517u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			Logger.LogDebug((object)$"#{((NetworkBehaviour)this).NetworkObjectId}: [{playerClientId}]");
			if ((Object)(object)StartOfRound.Instance.allPlayerScripts[playerClientId] == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				choseLocalPlayer = true;
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(ToggleOnDelay());
			}
		}
	}

	private IEnumerator ToggleOnDelay()
	{
		yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)loadedMesh != (Object)null));
		ToggleGirl(enabled: false);
	}

	public override void OnHitGround()
	{
		((GrabbableObject)this).OnHitGround();
		if (!broughtToShip && !choseLocalPlayer)
		{
			ToggleGirl(enabled: false);
		}
	}

	public override void OnBroughtToShip()
	{
		((GrabbableObject)this).OnBroughtToShip();
		if (((NetworkBehaviour)this).IsOwner && !broughtToShip)
		{
			ReappearForEveryoneServerRpc();
		}
	}

	private void ToggleGirl(bool enabled)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		meshToToggle.mesh = (enabled ? loadedMesh : null);
		audioToMute.volume = (enabled ? 1 : 0);
		Collider[] propColliders = base.propColliders;
		for (int i = 0; i < propColliders.Length; i++)
		{
			((Collider)(BoxCollider)propColliders[i]).enabled = enabled;
		}
		if (!enabled && (Object)(object)base.radarIcon != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)base.radarIcon).gameObject);
		}
		if (enabled && !StartOfRound.Instance.inShipPhase)
		{
			reappearSource.PlayOneShot(reappearClip);
			Object.Instantiate<GameObject>(AssetsCollection.poofParticle, ((Component)this).transform.position, new Quaternion(0f, 0f, 0f, 0f)).GetComponent<ParticleSystem>().Play();
		}
		if (enabled)
		{
			((Renderer)materialToToggle).material = AssetsCollection.defaultMaterialGold;
		}
	}

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

	[ClientRpc]
	private void ReappearForEveryoneClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(958526731u, val, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 958526731u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
		{
			broughtToShip = true;
			if (!choseLocalPlayer)
			{
				ToggleGirl(enabled: true);
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncUponJoinServerRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2777299986u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2777299986u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncUponJoinClientRpc(broughtToShip, playerID);
			}
		}
	}

	[ClientRpc]
	private void SyncUponJoinClientRpc(bool onShip, int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4022450178u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref onShip, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4022450178u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && playerID == (int)StartOfRound.Instance.localPlayerController.playerClientId)
			{
				broughtToShip = onShip;
			}
		}
	}

	void IGoldenGlassSecret.BeginReveal()
	{
		if (!Config.hostToolRebalance && !broughtToShip && !choseLocalPlayer)
		{
			meshToToggle.mesh = loadedMesh;
			((Renderer)materialToToggle).material = AssetsCollection.defaultMaterialGoldTransparent;
		}
	}

	void IGoldenGlassSecret.EndReveal()
	{
		if (!broughtToShip && !choseLocalPlayer)
		{
			meshToToggle.mesh = null;
			((Renderer)materialToToggle).material = AssetsCollection.defaultMaterialGold;
		}
	}

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

	[RuntimeInitializeOnLoadMethod]
	internal static void InitializeRPCS_GoldenGirlScript()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Expected O, but got Unknown
		NetworkManager.__rpc_func_table.Add(2685509517u, new RpcReceiveHandler(__rpc_handler_2685509517));
		NetworkManager.__rpc_func_table.Add(247589533u, new RpcReceiveHandler(__rpc_handler_247589533));
		NetworkManager.__rpc_func_table.Add(958526731u, new RpcReceiveHandler(__rpc_handler_958526731));
		NetworkManager.__rpc_func_table.Add(2777299986u, new RpcReceiveHandler(__rpc_handler_2777299986));
		NetworkManager.__rpc_func_table.Add(4022450178u, new RpcReceiveHandler(__rpc_handler_4022450178));
	}

	private static void __rpc_handler_2685509517(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int playerClientId = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerClientId);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenGirlScript)(object)target).ChoosePlayerClientRpc(playerClientId);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_247589533(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;
			((GoldenGirlScript)(object)target).ReappearForEveryoneServerRpc();
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

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

	private static void __rpc_handler_2777299986(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GoldenGirlScript)(object)target).SyncUponJoinServerRpc(playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4022450178(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool onShip = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref onShip, default(ForPrimitives));
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenGirlScript)(object)target).SyncUponJoinClientRpc(onShip, playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "GoldenGirlScript";
	}
}
public class GoldenGlassScript : GrabbableObject
{
	private static ManualLogSource Logger = Plugin.Logger;

	private Coroutine beginRevealCoroutine;

	private Coroutine endRevealCoroutine;

	[Space(3f)]
	[Header("Audiovisual")]
	public AudioSource audio2D;

	public AudioClip beginRevealClip;

	public AudioClip endRevealClip;

	[Tooltip("The fewer reveals per frame, the better performance, but the slower things will appear/disappear on-screen when using the Glass.")]
	public int revealPerFrame;

	public override void InspectItem()
	{
		((GrabbableObject)this).InspectItem();
		if (base.playerHeldBy.IsInspectingItem)
		{
			StartAndStopCoroutine(beginReveal: true);
		}
		else
		{
			StartAndStopCoroutine(beginReveal: false);
		}
	}

	public override void PocketItem()
	{
		if ((Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			StartAndStopCoroutine(beginReveal: false, base.playerHeldBy.IsInspectingItem);
		}
		((GrabbableObject)this).PocketItem();
	}

	public override void DiscardItem()
	{
		StartAndStopCoroutine(beginReveal: false, base.playerHeldBy.IsInspectingItem);
		((GrabbableObject)this).DiscardItem();
	}

	private void StartAndStopCoroutine(bool beginReveal, bool playClip = true)
	{
		if (beginReveal)
		{
			if (endRevealCoroutine != null)
			{
				Logger.LogDebug((object)"!!!STOPPING END REVEAL COROUTINE!!!");
				((MonoBehaviour)this).StopCoroutine(endRevealCoroutine);
				endRevealCoroutine = null;
			}
			beginRevealCoroutine = ((MonoBehaviour)this).StartCoroutine(BeginRevealLocal(playClip));
		}
		else
		{
			if (beginRevealCoroutine != null)
			{
				Logger.LogDebug((object)"!!!STOPPING BEGIN REVEAL COROUTINE!!!");
				((MonoBehaviour)this).StopCoroutine(beginRevealCoroutine);
				beginRevealCoroutine = null;
			}
			endRevealCoroutine = ((MonoBehaviour)this).StartCoroutine(EndRevealLocal(playClip));
		}
	}

	private IEnumerator BeginRevealLocal(bool playClip = true)
	{
		if (!playClip)
		{
			yield break;
		}
		audio2D.Stop();
		audio2D.PlayOneShot(beginRevealClip);
		int num = 0;
		GoldScrapObject[] array = Object.FindObjectsOfType<GoldScrapObject>();
		GoldScrapObject[] array2 = array;
		foreach (GoldScrapObject goldScrapObject in array2)
		{
			if (RarityManager.CurrentlyGoldFever() && (Object)(object)goldScrapObject.item != (Object)null)
			{
				SetAllItemsScanNodes(goldScrapObject.item, setTo: true);
			}
			IGoldenGlassSecret component = ((Component)goldScrapObject).GetComponent<IGoldenGlassSecret>();
			if (component != null)
			{
				Logger.LogDebug((object)("BEGIN revealing " + ((Object)((Component)goldScrapObject).gameObject).name));
				component.BeginReveal();
				num++;
				if (num >= revealPerFrame)
				{
					yield return null;
					num = 0;
				}
			}
		}
		beginRevealCoroutine = null;
	}

	private IEnumerator EndRevealLocal(bool playClip = true)
	{
		if (!playClip)
		{
			yield break;
		}
		audio2D.Stop();
		audio2D.PlayOneShot(endRevealClip);
		int num = 0;
		GoldScrapObject[] array = Object.FindObjectsOfType<GoldScrapObject>();
		GoldScrapObject[] array2 = array;
		foreach (GoldScrapObject goldScrapObject in array2)
		{
			if ((StartOfRound.Instance.inShipPhase || RarityManager.CurrentlyGoldFever()) && (Object)(object)goldScrapObject.item != (Object)null)
			{
				SetAllItemsScanNodes(goldScrapObject.item, setTo: false);
			}
			IGoldenGlassSecret component = ((Component)goldScrapObject).GetComponent<IGoldenGlassSecret>();
			if (component != null)
			{
				Logger.LogDebug((object)("STOP revealing " + ((Object)((Component)goldScrapObject).gameObject).name));
				component.EndReveal();
				num++;
				if (num >= revealPerFrame)
				{
					yield return null;
					num = 0;
				}
			}
		}
		endRevealCoroutine = null;
	}

	private void SetAllItemsScanNodes(GrabbableObject item, bool setTo)
	{
		ScanNodeProperties componentInChildren = ((Component)item).gameObject.GetComponentInChildren<ScanNodeProperties>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			if (setTo && !item.isInShipRoom)
			{
				componentInChildren.maxRange = (Config.hostToolRebalance ? 128 : 256);
				componentInChildren.requiresLineOfSight = false;
			}
			else if (!setTo)
			{
				componentInChildren.maxRange = 13;
				componentInChildren.requiresLineOfSight = true;
			}
		}
	}

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

	protected internal override string __getTypeName()
	{
		return "GoldenGlassScript";
	}
}
public class GoldenGuardianScript : GrabbableObject
{
	[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
	public class NewPlayerDamage
	{
		[HarmonyPrefix]
		public static bool PreventDamage(PlayerControllerB __instance)
		{
			return PatchToPreventDamage(__instance, isKillCommand: false);
		}
	}

	[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
	public class NewPlayerKill
	{
		[HarmonyPrefix]
		public static bool PreventKill(PlayerControllerB __instance)
		{
			return PatchToPreventDamage(__instance, isKillCommand: true);
		}
	}

	private static ManualLogSource Logger = Plugin.Logger;

	private bool aboutToExplode;

	private Coroutine explosionCoroutine;

	[Space(3f)]
	[Header("Audiovisual")]
	public AudioSource audioSource;

	public AudioClip buildUpClip;

	public AudioClip explodeClip;

	public GameObject stunGrenadeExplosion;

	public override void Update()
	{
		((GrabbableObject)this).Update();
		if (((NetworkBehaviour)this).IsOwner && !((Object)(object)base.playerHeldBy == (Object)null) && (Object)(object)base.playerHeldBy.inAnimationWithEnemy != (Object)null && !aboutToExplode)
		{
			LocalPlayerStartExplosion(delay: true);
		}
	}

	public void LocalPlayerStartExplosion(bool delay = false, bool fromKillCommand = false)
	{
		float delayTime = 1.75f;
		if (Config.hostToolRebalance)
		{
			delayTime = 1.3f;
			delay = true;
		}
		if (fromKillCommand)
		{
			delay = false;
		}
		StartExplosion(delay, delayTime);
		StartExplosionServerRpc(delay, delayTime, (int)GameNetworkManager.Instance.localPlayerController.playerClientId);
	}

	private void StartExplosion(bool delay, float delayTime)
	{
		Logger.LogDebug((object)$"{((Object)this).name} #{((NetworkBehaviour)this).NetworkObjectId} called StartExplosion with delay {delay} and delayTime {delayTime}");
		aboutToExplode = true;
		if (delay)
		{
			explosionCoroutine = ((MonoBehaviour)this).StartCoroutine(ExplodeOnDelay(delayTime));
			return;
		}
		if (explosionCoroutine != null)
		{
			Logger.LogDebug((object)"interrupting coroutine to explode immediately!");
			((MonoBehaviour)this).StopCoroutine(explosionCoroutine);
		}
		Explode();
	}

	private IEnumerator ExplodeOnDelay(float delayTime = 1.75f)
	{
		yield return (object)new WaitForSeconds(0.1f);
		audioSource.PlayOneShot(buildUpClip);
		WalkieTalkie.TransmitOneShotAudio(audioSource, buildUpClip, 0.5f);
		yield return (object)new WaitForSeconds(delayTime);
		Explode();
	}

	public void Explode()
	{
		//IL_00e6: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		if (!base.deactivated)
		{
			audioSource.Stop();
			((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			if (!Config.hostToolRebalance)
			{
				audioSource.PlayOneShot(explodeClip);
				WalkieTalkie.TransmitOneShotAudio(audioSource, explodeClip, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 25f, 0.3f, 0, false, 0);
				StunGrenadeItem.StunExplosion(((Component)this).transform.position, true, 0.2f, 10f, 1f, false, (PlayerControllerB)null, (PlayerControllerB)null, 0f);
				Transform val = (base.isInElevator ? StartOfRound.Instance.elevatorTransform : RoundManager.Instance.mapPropsContainer.transform);
				Object.Instantiate<GameObject>(stunGrenadeExplosion, ((Component)this).transform.position, Quaternion.identity, val);
			}
			else
			{
				Landmine.SpawnExplosion(((Component)this).transform.position, true, 4f, 8f, 25, 5f, (GameObject)null, false);
			}
			((MonoBehaviour)this).StartCoroutine(DelaySettingObjectAway());
		}
	}

	private IEnumerator DelaySettingObjectAway()
	{
		yield return (object)new WaitForSeconds(5f);
		base.targetFloorPosition = new Vector3(3000f, -400f, 3000f);
		base.startFallingPosition = new Vector3(3000f, -400f, 3000f);
	}

	public override void PlayDropSFX()
	{
		if (!base.deactivated)
		{
			((GrabbableObject)this).PlayDropSFX();
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void StartExplosionServerRpc(bool delay, float delayTime, int heldPlayerID)
	{
		//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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(619446056u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref delay, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref delayTime, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, heldPlayerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 619446056u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				StartExplosionClientRpc(delay, delayTime, heldPlayerID);
			}
		}
	}

	[ClientRpc]
	private void StartExplosionClientRpc(bool delay, float delayTime, int heldPlayerID)
	{
		//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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4234394122u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref delay, default(ForPrimitives));
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref delayTime, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, heldPlayerID);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4234394122u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && heldPlayerID != (int)GameNetworkManager.Instance.localPlayerController.playerClientId)
			{
				Logger.LogDebug((object)$"non-owner client starting GoldenGuardian #{((NetworkBehaviour)this).NetworkObjectId} explosion");
				StartExplosion(delay, delayTime);
			}
		}
	}

	public static bool PatchToPreventDamage(PlayerControllerB __instance, bool isKillCommand)
	{
		if (!((NetworkBehaviour)__instance).IsOwner || __instance.isPlayerDead || !__instance.AllowPlayerDeath() || (Object)(object)__instance.currentlyHeldObjectServer == (Object)null)
		{
			return true;
		}
		GoldenGuardianScript component = ((Component)__instance.currentlyHeldObjectServer).GetComponent<GoldenGuardianScript>();
		if ((Object)(object)component != (Object)null && !((GrabbableObject)component).deactivated && (isKillCommand || !component.aboutToExplode))
		{
			Logger.LogDebug((object)$"GoldenGuardianScript patch: local player likely holding GoldenGuardian on server, trying to execute explosion | isKillCommand = {isKillCommand}");
			bool delay = !isKillCommand && Config.hostToolRebalance;
			component.LocalPlayerStartExplosion(delay, isKillCommand);
			return false;
		}
		return true;
	}

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

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

	private static void __rpc_handler_619446056(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_008e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool delay = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref delay, default(ForPrimitives));
			float delayTime = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref delayTime, default(ForPrimitives));
			int heldPlayerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref heldPlayerID);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GoldenGuardianScript)(object)target).StartExplosionServerRpc(delay, delayTime, heldPlayerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4234394122(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_008e: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool delay = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref delay, default(ForPrimitives));
			float delayTime = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref delayTime, default(ForPrimitives));
			int heldPlayerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref heldPlayerID);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldenGuardianScript)(object)target).StartExplosionClientRpc(delay, delayTime, heldPlayerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "GoldenGuardianScript";
	}
}
public class GoldkeeperScript : GrabbableObject
{
	private static ManualLogSource Logger = Plugin.Logger;

	[Space(3f)]
	[Header("Blockers")]
	public Collider losBlocker;

	public NavMeshObstacle navBlocker;

	private Coroutine checkDistanceCoroutine;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		navBlocker.carveOnlyStationary = true;
	}

	public override void EquipItem()
	{
		((GrabbableObject)this).EquipItem();
		if (checkDistanceCoroutine != null)
		{
			Logger.LogDebug((object)"stopped CheckDistance Coroutine");
			((MonoBehaviour)this).StopCoroutine(checkDistanceCoroutine);
			checkDistanceCoroutine = null;
		}
		losBlocker.enabled = false;
		navBlocker.carving = false;
		((Behaviour)navBlocker).enabled = false;
		LogEnabled();
	}

	public override void PlayDropSFX()
	{
		((GrabbableObject)this).PlayDropSFX();
		if (checkDistanceCoroutine != null)
		{
			Logger.LogDebug((object)"stopped CheckDistance Coroutine");
			((MonoBehaviour)this).StopCoroutine(checkDistanceCoroutine);
			checkDistanceCoroutine = null;
		}
		checkDistanceCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckDistance());
	}

	private IEnumerator CheckDistance()
	{
		bool playerInRange = true;
		bool setTo = true;
		PlayerControllerB player = StartOfRound.Instance.localPlayerController;
		while (playerInRange)
		{
			yield return (object)new WaitForSeconds(0.1f);
			if ((Object)(object)((Component)this).GetComponentInParent<VehicleController>() != (Object)null || (Object)(object)((Component)this).GetComponentInParent<MineshaftElevatorController>() != (Object)null)
			{
				setTo = false;
				Logger.LogDebug((object)$"WARNING!!! {((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId} dropped inside vehicle or elevator! breaking and setting collision enabled to {setTo}");
				break;
			}
			if ((Object)(object)player == (Object)null || !player.isPlayerControlled)
			{
				playerInRange = false;
			}
			if (Vector3.Distance(((Component)this).transform.position - Vector3.back * 0.15f, ((Component)player).transform.position) >= 0.65f)
			{
				playerInRange = false;
			}
		}
		checkDistanceCoroutine = null;
		losBlocker.enabled = setTo;
		navBlocker.carving = setTo;
		((Behaviour)navBlocker).enabled = setTo;
		LogEnabled();
	}

	private void LogEnabled()
	{
		Logger.LogDebug((object)$"{((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId}: {((Object)((Component)losBlocker).gameObject).name} enabled = {losBlocker.enabled}");
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncUponJoinServerRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(688314264u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 688314264u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncUponJoinClientRpc((Object)(object)base.playerHeldBy == (Object)null, playerID);
			}
		}
	}

	[ClientRpc]
	private void SyncUponJoinClientRpc(bool hostNullHeld, int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val = default(ClientRpcParams);
			FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4258008049u, val, (RpcDelivery)0);
			((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hostNullHeld, default(ForPrimitives));
			BytePacker.WriteValueBitPacked(val2, playerID);
			((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4258008049u, val, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && playerID == (int)StartOfRound.Instance.localPlayerController.playerClientId)
		{
			losBlocker.enabled = hostNullHeld;
			navBlocker.carving = hostNullHeld;
			((Behaviour)navBlocker).enabled = hostNullHeld;
			if (!hostNullHeld)
			{
				Logger.LogDebug((object)$"custom injecting hasHitGround on {((Object)((Component)this).gameObject).name} #{((NetworkBehaviour)this).NetworkObjectId} since likely held on host");
				base.hasHitGround = false;
			}
			LogEnabled();
		}
	}

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

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

	private static void __rpc_handler_688314264(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((GoldkeeperScript)(object)target).SyncUponJoinServerRpc(playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_4258008049(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool hostNullHeld = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hostNullHeld, default(ForPrimitives));
			int playerID = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
			target.__rpc_exec_stage = (__RpcExecStage)2;
			((GoldkeeperScript)(object)target).SyncUponJoinClientRpc(hostNullHeld, playerID);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	protected internal override string __getTypeName()
	{
		return "GoldkeeperScript";
	}
}
public class GoldmineScript : GrabbableObject
{
	private static ManualLogSource Logger = Plugin.Logger;

	[Space(3f)]
	[Header("Functionality")]
	public GoldmineTrigger trigger;

	public bool hasExploded;

	public bool activated;

	public bool willExplodeImmediately;

	public bool willExplodeOnDelay;

	private float timeAtLastLightToggle;

	[Space(3f)]
	[Header("Audiovisual")]
	public AudioSource audioSource;

	public AudioClip triggerClip;

	public AudioClip beepClip;

	public AudioClip onClip;

	public AudioClip offClip;

	public Light triggerLight;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		((Behaviour)triggerLight).enabled = false;
		int num = (Config.hostToolRebalance ? 67 : 33);
		if (((NetworkBehaviour)this).IsServer && !base.isInShipRoom && Random.Range(1, 101) < num)
		{
			ToggleActiveClientRpc(hostActivated: true);
		}
	}

	public override void Update()
	{
		((GrabbableObject)this).Update();
		if (hasExploded)
		{
			return;
		}
		if (willExplodeOnDelay && (double)(Time.realtimeSinceStartup - timeAtLastLightToggle) > 0.075)
		{
			ToggleLight();
		}
		if (activated)
		{
			if (Time.realtimeSinceStartup - timeAtLastLightToggle > 5f)
			{
				audioSource.PlayOneShot(beepClip);
				ToggleLight();
			}
			if (((Behaviour)triggerLight).enabled && Time.realtimeSinceStartup - timeAtLastLightToggle > 0.1f)
			{
				ToggleLight();
			}
		}
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		if (StartOfRound.Instance.shipDoorsEnabled && !StartOfRound.Instance.inShipPhase)
		{
			ImmediateExplosionServerRpc((int)base.playerHeldBy.playerClientId);
		}
	}

	[ServerRpc(RequireOwnership = false)]
	private void ImmediateExplosionServerRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3185693378u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3185693378u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ImmediateExplosionClientRpc(playerID);
			}
		}
	}

	[ClientRpc]
	private void ImmediateExplosionClientRpc(int playerID)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (net