Decompiled source of REPOPresents v1.3.0

REPOPresents.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Commands;
using REPOLib.Modules;
using REPOPresents.Chance;
using REPOPresents.Chance.Impl;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("REPOPresents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("REPOPresents")]
[assembly: AssemblyTitle("REPOPresents")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPOPresents
{
	public static class ConfigValues
	{
		internal static ConfigEntry<int> PresentSpawnRate;

		internal static ConfigEntry<bool> EnableMonsterPresents;

		internal static ConfigEntry<int> TallMonsterPresentSpawnRate;

		internal static ConfigEntry<bool> EnableChancePresents;

		internal static ConfigEntry<int> BigChancePresentSpawnRate;

		internal static ConfigEntry<bool> EnableOnlyGoodOutcomes;

		internal static ConfigEntry<bool> EnableDebug;

		internal static ConfigEntry<bool> EnableDebugLogs;

		public static void Configure(BaseUnityPlugin plugin)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			PresentSpawnRate = plugin.Config.Bind<int>("General", "Present Spawn Rate", 70, new ConfigDescription("The spawn rate of presents in %, can be used to reduce the spawning compared to other valuables at same volume type. (Recommended value = 70%)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			EnableMonsterPresents = plugin.Config.Bind<bool>("Monster Presents", "Enable Monster Presents", true, new ConfigDescription("Enable monster variants of specific presents. (Recommended value = true)", (AcceptableValueBase)null, Array.Empty<object>()));
			TallMonsterPresentSpawnRate = plugin.Config.Bind<int>("Monster Presents", "Tall Monster Present Spawn Rate", 50, new ConfigDescription("The spawn rate of the tall monster present in %. (Recommended value = 50%)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			EnableChancePresents = plugin.Config.Bind<bool>("Chance Presents", "Enable Chance Presents", true, new ConfigDescription("Enable chance variants of specific presents. (Recommended value = true)", (AcceptableValueBase)null, Array.Empty<object>()));
			BigChancePresentSpawnRate = plugin.Config.Bind<int>("Chance Presents", "Big Chance Present Spawn Rate", 50, new ConfigDescription("The spawn rate of the big chance present in %. (Recommended value = 50%)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			EnableOnlyGoodOutcomes = plugin.Config.Bind<bool>("Chance Presents", "Enable Good Outcomes Only", false, new ConfigDescription("Enable chance present to roll only good outcomes. (Recommended value = false)", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableDebug = plugin.Config.Bind<bool>("Debug", "Enable Debug Mode", false, new ConfigDescription("Will replace all valuables with presents for testing :) (Recommended value = false)", (AcceptableValueBase)null, Array.Empty<object>()));
			EnableDebugLogs = plugin.Config.Bind<bool>("Debug", "Enable Debug Logs", false, new ConfigDescription("Log debug messages (Recommended value = false)", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	public class GoofyEyes : MonoBehaviour
	{
		private static Vector3 CROUCH_EYE_MODIFIER = new Vector3(0f, -0.85f, 0f);

		private static Vector3 TUMBLE_EYE_MODIFIER = new Vector3(0f, -1.85f, 0f);

		public Transform eyeLeft;

		public Transform eyeRight;

		public Transform pupilLeft;

		public Transform pupilRight;

		[Space]
		public MeshRenderer[] eyeRenderers;

		public MeshRenderer[] pupilRenderers;

		[Space]
		public Transform lookAt;

		[Space]
		public SpringQuaternion springQuaternionLeft;

		public SpringQuaternion springQuaternionRight;

		private Vector3 lookAtIdle;

		private PlayerAvatar lockedInAvatar;

		private float coolDownClosestPlayer = 1f;

		private float pupilSizeMultiplierTarget = 1f;

		private float pupilSizeMultiplierTimer = 0f;

		private float pupilSizeMultiplierTimerStart = 0f;

		private float pupilSizeMultiplierPreviousTarget = 1f;

		private float pupilSizeMultiplier = 1f;

		private Material eyeMaterial;

		private Material pupilMaterial;

		private int materialHurtAmount;

		private int materialHurtColor;

		private void Awake()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] array = eyeRenderers;
			foreach (MeshRenderer val in array)
			{
				if (!Object.op_Implicit((Object)(object)eyeMaterial))
				{
					eyeMaterial = ((Renderer)val).material;
				}
				((Renderer)val).material = eyeMaterial;
			}
			MeshRenderer[] array2 = pupilRenderers;
			foreach (MeshRenderer val2 in array2)
			{
				if (!Object.op_Implicit((Object)(object)pupilMaterial))
				{
					pupilMaterial = ((Renderer)val2).material;
				}
				((Renderer)val2).material = pupilMaterial;
			}
			lookAtIdle = lookAt.position;
			materialHurtColor = Shader.PropertyToID("_ColorOverlay");
			materialHurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
		}

		private void Update()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			if (coolDownClosestPlayer > 0f)
			{
				coolDownClosestPlayer -= Time.deltaTime;
			}
			else
			{
				PlayerAvatar val = null;
				float num = float.MaxValue;
				foreach (PlayerAvatar item in SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)this).gameObject.transform.position, false, default(LayerMask)))
				{
					float num2 = Vector3.Distance(((Component)this).gameObject.transform.position, ((Component)item).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = item;
					}
				}
				lockedInAvatar = val;
				coolDownClosestPlayer = 3f;
			}
			if ((Object)(object)lockedInAvatar != (Object)null)
			{
				Vector3 val2 = Vector3.zero;
				if (lockedInAvatar.isCrouching || lockedInAvatar.isCrawling)
				{
					val2 = CROUCH_EYE_MODIFIER;
				}
				else if (lockedInAvatar.isTumbling)
				{
					val2 = TUMBLE_EYE_MODIFIER;
				}
				((Component)lookAt).transform.position = Vector3.Lerp(((Component)lockedInAvatar.playerAvatarVisuals.playerEyes.eyeLeft).transform.position + val2, ((Component)lockedInAvatar.playerAvatarVisuals.playerEyes.eyeRight).transform.position + val2, 0.5f);
			}
			else
			{
				((Component)lookAt).transform.position = lookAtIdle;
			}
			if (pupilSizeMultiplierTimer > 0f)
			{
				pupilSizeMultiplierTimer = Mathf.Max(pupilSizeMultiplierTimer - Time.fixedDeltaTime, 0f);
				pupilSizeMultiplier = Mathf.Lerp(pupilSizeMultiplierPreviousTarget, pupilSizeMultiplierTarget, (pupilSizeMultiplierTimerStart - pupilSizeMultiplierTimer) / pupilSizeMultiplierTimerStart);
			}
			else
			{
				pupilSizeMultiplier = pupilSizeMultiplierTarget;
			}
			pupilLeft.localScale = Vector3.one * pupilSizeMultiplier;
			pupilRight.localScale = Vector3.one * pupilSizeMultiplier;
			EyeLookAt(ref eyeRight, ref springQuaternionRight, _useSpring: true, 50f, 30f);
			EyeLookAt(ref eyeLeft, ref springQuaternionLeft, _useSpring: true, 50f, 30f);
		}

		private void EyeLookAt(ref Transform _eyeTransform, ref SpringQuaternion _springQuaternion, bool _useSpring, float _clampX, float _clamY)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Quaternion localRotation = _eyeTransform.localRotation;
			Vector3 val = SemiFunc.ClampDirection(lookAt.position - ((Component)_eyeTransform).transform.position, lookAt.forward, _clampX);
			_eyeTransform.rotation = Quaternion.LookRotation(val);
			float num = _eyeTransform.localEulerAngles.y;
			if (num > _clamY && num < 180f)
			{
				num = _clamY;
			}
			else if (num < 360f - _clamY && num > 180f)
			{
				num = 360f - _clamY;
			}
			else if (num < 0f - _clamY)
			{
				num = 0f - _clamY;
			}
			_eyeTransform.localEulerAngles = new Vector3(_eyeTransform.localEulerAngles.x, num, _eyeTransform.localEulerAngles.z);
			Quaternion localRotation2 = _eyeTransform.localRotation;
			_eyeTransform.localRotation = localRotation;
			if (_useSpring)
			{
				_eyeTransform.localRotation = SemiFunc.SpringQuaternionGet(_springQuaternion, localRotation2, -1f);
			}
			else
			{
				_eyeTransform.localRotation = localRotation2;
			}
		}

		public void SetPupilSizeMultiplierTarget(float target, float time)
		{
			pupilSizeMultiplierPreviousTarget = pupilSizeMultiplierTarget;
			pupilSizeMultiplierTarget = target;
			pupilSizeMultiplierTimer = time;
			pupilSizeMultiplierTimerStart = time;
		}

		public void SetEyeColor(Color eyeColor, float num)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			eyeMaterial.SetFloat(materialHurtAmount, num);
			eyeMaterial.SetColor(materialHurtColor, eyeColor);
		}

		public void SetPupilColor(Color pupilColor, float num)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			pupilMaterial.SetFloat(materialHurtAmount, num);
			pupilMaterial.SetColor(materialHurtColor, pupilColor);
		}
	}
	[BepInPlugin("REPOPresents", "REPOPresents", "1.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ValuableDirector), "Spawn")]
		internal static class ValuableDirectorSpawnPatch
		{
			private static bool Prefix(ref GameObject _valuable, ValuableVolume _volume, string _path)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				if (ConfigValues.EnableDebug.Value)
				{
					GameObject debugObjectForType = Instance.GetDebugObjectForType(_volume.VolumeType);
					if ((Object)(object)debugObjectForType != (Object)null)
					{
						_valuable = debugObjectForType;
						return true;
					}
				}
				ValuablePresent component = _valuable.GetComponent<ValuablePresent>();
				ValuablePresentEnemy component2 = _valuable.GetComponent<ValuablePresentEnemy>();
				ValuablePresentChance component3 = _valuable.GetComponent<ValuablePresentChance>();
				if ((Object)(object)component != (Object)null || (Object)(object)component2 != (Object)null || (Object)(object)component3 != (Object)null)
				{
					int value = ConfigValues.PresentSpawnRate.Value;
					if ((Object)(object)component2 != (Object)null)
					{
						value = ConfigValues.TallMonsterPresentSpawnRate.Value;
					}
					else if ((Object)(object)component3 != (Object)null)
					{
						value = ConfigValues.BigChancePresentSpawnRate.Value;
					}
					float num = 1f - (float)value / 100f;
					if (Random.value < num)
					{
						List<GameObject> valuablesByVolumeType = ValuableUtil.GetValuablesByVolumeType(RunManager.instance.levelCurrent, _volume.VolumeType);
						if (valuablesByVolumeType.Count > 0)
						{
							GameObject val = valuablesByVolumeType[Random.Range(0, valuablesByVolumeType.Count)];
							if ((Object)(object)val != (Object)null)
							{
								DebugLog("Replaced " + ((Object)_valuable).name + " with " + ((Object)val).name);
								_valuable = val;
							}
						}
					}
				}
				return true;
			}

			private static void Postfix(GameObject _valuable)
			{
				DebugLog("Spawned : " + ((Object)_valuable).name);
			}
		}

		private static readonly string ENEMY_VALUABLE = "Valuable Present Tall (Enemy)";

		private static readonly string CHANCE_VALUABLE = "Valuable Present Big (Chance)";

		private static readonly string[] BUNDLED_VALUABLES = new string[7] { "Valuable Present Tiny", "Valuable Present Small", "Valuable Present Medium", "Valuable Present Big", "Valuable Present Tall", CHANCE_VALUABLE, ENEMY_VALUABLE };

		private readonly Harmony _harmony = new Harmony("REPOPresents");

		internal static ManualLogSource Logger;

		private Dictionary<string, GameObject> registeredPrefabs = new Dictionary<string, GameObject>();

		private Dictionary<Type, GameObject> debugVolumeTypes = new Dictionary<Type, GameObject>();

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = ((BaseUnityPlugin)this).Logger;
			ConfigValues.Configure((BaseUnityPlugin)(object)this);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "presents_assets.file"));
			string[] bUNDLED_VALUABLES = BUNDLED_VALUABLES;
			foreach (string text in bUNDLED_VALUABLES)
			{
				if ((!(text == ENEMY_VALUABLE) || ConfigValues.EnableMonsterPresents.Value) && (!(text == CHANCE_VALUABLE) || ConfigValues.EnableChancePresents.Value))
				{
					GameObject val2 = val.LoadAsset<GameObject>(text);
					Valuables.RegisterValuable(val2);
					ValuableObject component = val2.GetComponent<ValuableObject>();
					if ((Object)(object)component != (Object)null && !debugVolumeTypes.ContainsKey(component.volumeType))
					{
						debugVolumeTypes.Add(component.volumeType, val2);
					}
					registeredPrefabs.Add(text, val2);
					Logger.LogInfo((object)("Registered: " + text));
				}
			}
			_harmony.PatchAll(typeof(ValuableDirectorSpawnPatch));
			Logger.LogInfo((object)"Plugin REPOPresents is loaded!");
		}

		public bool WasRegisteredBySelf(GameObject gameObject)
		{
			return registeredPrefabs.ContainsValue(gameObject);
		}

		public GameObject GetDebugObjectForType(Type type)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!debugVolumeTypes.ContainsKey(type))
			{
				return null;
			}
			return debugVolumeTypes[type];
		}

		public static void DebugLog(object data)
		{
			if (ConfigValues.EnableDebugLogs.Value)
			{
				Logger.LogInfo(data);
			}
		}
	}
	public class ValuablePresent : MonoBehaviour
	{
		private PhysGrabObject physGrabObject;

		private ValuableObject valuableObject;

		private ParticleSystem particles;

		private bool particlesPlaying;

		private List<GameObject> potentialItems;

		private bool wasReplaced = false;

		private void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			valuableObject = ((Component)this).GetComponent<ValuableObject>();
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			particles = ((Component)this).GetComponentInChildren<ParticleSystem>();
			potentialItems = ValuableUtil.GetValuablesByVolumeType(RunManager.instance.levelCurrent, valuableObject.volumeType);
		}

		private void Update()
		{
			if ((Object)(object)particles != (Object)null)
			{
				if (physGrabObject.grabbed)
				{
					if (!particlesPlaying)
					{
						particles.Play();
						particlesPlaying = true;
					}
				}
				else if (particlesPlaying)
				{
					particles.Stop();
					particlesPlaying = false;
				}
			}
			if (physGrabObject.grabbedLocal)
			{
				PlayerAvatar instance = PlayerAvatar.instance;
				if ((Object)(object)instance != (Object)null)
				{
					instance.OverridePupilSize(3f, 4, 1f, 1f, 5f, 0.5f, 0.1f);
				}
			}
		}

		public GameObject FindReplacement()
		{
			if (potentialItems == null)
			{
				return null;
			}
			int num = 0;
			GameObject val = null;
			while ((Object)(object)val == (Object)null && potentialItems.Count > 0 && num < 5)
			{
				GameObject val2 = potentialItems[Random.Range(0, potentialItems.Count)];
				if (!Plugin.Instance.WasRegisteredBySelf(val2))
				{
					val = val2;
				}
				num++;
			}
			return val;
		}

		public void OnDestroy()
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)particles != (Object)null && particlesPlaying)
			{
				particles.Stop();
				particlesPlaying = false;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer() || wasReplaced)
			{
				return;
			}
			wasReplaced = true;
			GameObject val = FindReplacement();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to find suitable item");
				return;
			}
			ValuableObject val2 = Valuables.GetValuableByName(((Object)val).name);
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val.GetComponent<ValuableObject>();
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.Logger.LogError((object)("Item is missing ValuableObject: " + ((Object)val).name));
					return;
				}
			}
			if (!SemiFunc.IsMultiplayer())
			{
				Object.Instantiate<GameObject>(val, ((Component)this).gameObject.transform.position, ((Component)this).gameObject.transform.rotation);
			}
			else
			{
				Valuables.SpawnValuable(val2, ((Component)this).gameObject.transform.position, ((Component)this).gameObject.transform.rotation);
			}
		}
	}
	public class ValuablePresentChance : MonoBehaviour
	{
		private static int MAX_ENTRY_ATTEMPTS = 5;

		private PhysGrabObject physGrabObject;

		private ValuablePresentChanceNetwork network;

		private ValuableObject valuableObject;

		private Type overriddenChanceEntry = null;

		private bool wasReplaced = false;

		[HideInInspector]
		public PlayerAvatar lastPlayerGrabbed;

		private void Awake()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			network = ((Component)this).GetComponent<ValuablePresentChanceNetwork>();
			valuableObject = ((Component)this).GetComponent<ValuableObject>();
		}

		private void Update()
		{
			if (physGrabObject.grabbedLocal)
			{
				PlayerAvatar instance = PlayerAvatar.instance;
				if ((Object)(object)instance != (Object)null)
				{
					instance.OverridePupilSize(3f, 4, 1f, 1f, 5f, 0.5f, 0.1f);
				}
			}
			if ((Object)(object)physGrabObject.lastPlayerGrabbing != (Object)null && (Object)(object)physGrabObject.lastPlayerGrabbing != (Object)(object)lastPlayerGrabbed)
			{
				lastPlayerGrabbed = physGrabObject.lastPlayerGrabbing;
			}
		}

		public void OnDestroy()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || wasReplaced)
			{
				return;
			}
			wasReplaced = true;
			if (valuableObject.dollarValueCurrent >= valuableObject.dollarValueOriginal * 0.15f)
			{
				Plugin.DebugLog("Not rolling chance due to not fully broken");
				return;
			}
			PlayerAvatar val = lastPlayerGrabbed;
			if ((Object)(object)val == (Object)null)
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)this).gameObject.transform.position, false, default(LayerMask));
				if (list.Count == 0)
				{
					Plugin.Logger.LogWarning((object)"Last player grab is null and no players within range");
					return;
				}
				val = list[0];
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Logger.LogWarning((object)"Last player grab is null and no players within range");
					return;
				}
				Plugin.DebugLog("Using roller from range " + val.playerName);
			}
			if ((Object)(object)network == (Object)null)
			{
				Plugin.Logger.LogError((object)"Network is null");
				return;
			}
			for (int i = 0; i < MAX_ENTRY_ATTEMPTS; i++)
			{
				IChanceEntry chanceEntry = ((!(overriddenChanceEntry != null)) ? GetRandomChanceEntry() : ((IChanceEntry)Activator.CreateInstance(overriddenChanceEntry)));
				if (chanceEntry == null)
				{
					Plugin.Logger.LogError((object)$"Failed to find chance entry (attempt {i})");
					continue;
				}
				if (!chanceEntry.Execute(val, network))
				{
					Plugin.Logger.LogWarning((object)$"Failed to execute chance entry {chanceEntry.GetType().Name} (attempt {i})");
					continue;
				}
				var (text, chatID, color) = chanceEntry.GetChatMessage();
				if (text != null)
				{
					network.PossessChat(val, chatID, text, color);
				}
				break;
			}
		}

		public void OverrideChanceEntry(Type chanceEntry)
		{
			overriddenChanceEntry = chanceEntry;
		}

		private static IChanceEntry GetRandomChanceEntry()
		{
			Dictionary<(ChanceRegistry.Outcome, Type), int> availableEntries = ChanceRegistry.GetAvailableEntries();
			int num = availableEntries.Values.Sum();
			int num2 = Random.Range(0, num);
			int num3 = 0;
			foreach (KeyValuePair<(ChanceRegistry.Outcome, Type), int> item in availableEntries)
			{
				num3 += item.Value;
				if (num2 < num3)
				{
					return (IChanceEntry)Activator.CreateInstance(item.Key.Item2);
				}
			}
			return null;
		}
	}
	public class ValuablePresentChanceNetwork : MonoBehaviour
	{
		private PhotonView photonView;

		private void Awake()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		public void PossessChat(PlayerAvatar player, PossessChatID chatID, string message, Color color)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer() && !player.photonView.IsMine)
			{
				photonView.RPC("PossessChatRPC", player.photonView.Owner, new object[5] { chatID, message, color.r, color.g, color.b });
			}
			else
			{
				PossessChatRPC(chatID, message, color.r, color.g, color.b);
			}
		}

		[PunRPC]
		public void PossessChatRPC(PossessChatID chatID, string message, float r, float g, float b)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			ChatManager.instance.PossessChatScheduleStart(10);
			ChatManager.instance.PossessChat(chatID, message, 1f, new Color(r, g, b), 0f, false, 0, (UnityEvent)null);
			ChatManager.instance.PossessChatScheduleEnd();
		}

		public void Teleport(PlayerAvatar player, Vector3 position)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer() && !player.photonView.IsMine)
			{
				photonView.RPC("TeleportRPC", player.photonView.Owner, new object[1] { position });
			}
			else
			{
				TeleportRPC(position);
			}
		}

		[PunRPC]
		public void TeleportRPC(Vector3 position)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			((Component)PlayerController.instance).transform.position = position;
		}

		public void SetScale(int viewID, Vector3 scale)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			SetScaleRPC(viewID, scale);
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SetScaleRPC", (RpcTarget)1, new object[2] { viewID, scale });
			}
		}

		[PunRPC]
		public void SetScaleRPC(int viewID, Vector3 scale)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			PhotonView val = PhotonView.Find(viewID);
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).transform.localScale = new Vector3(((Component)val).transform.localScale.x * scale.x, ((Component)val).transform.localScale.y * scale.y, ((Component)val).transform.localScale.z * scale.z);
			}
		}
	}
	public class ValuablePresentChanceVariant : MonoBehaviour
	{
		public string valuableName;
	}
	public class ValuablePresentEnemy : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SpawnEnemyAfterTime>d__22 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnemySetup enemySetup;

			public Vector3 position;

			public TimeSpan timeSpan;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SpawnEnemyAfterTime>d__22(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds((float)timeSpan.TotalSeconds);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Enemies.SpawnEnemy(enemySetup, position, Quaternion.identity, false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const float PUPIL_SIZE_INTERVAL = 0.5f;

		private const float AGGRESSIVE_INTERVAL = 10f;

		private const float GRAB_INTERVAL = 45f;

		public Sound aggressive;

		private PhysGrabObject physGrabObject;

		private PhysGrabObjectImpactDetector physGrabObjectImpactDetector;

		private ValuableObject valuableObject;

		private GoofyEyes[] eyes;

		private Rigidbody rb;

		private bool isGrabActive = false;

		private bool isAggressive = false;

		private bool wasAggressiveDestroyed = false;

		private bool wasReplaced = false;

		private float grabTimer = 0f;

		private float timeToApplyForce = 0f;

		private List<EnemySetup> potentialEnemies;

		private void Awake()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
			physGrabObjectImpactDetector = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
			valuableObject = ((Component)this).GetComponent<ValuableObject>();
			eyes = ((Component)this).GetComponentsInChildren<GoofyEyes>(true);
			rb = ((Component)this).GetComponent<Rigidbody>();
			potentialEnemies = FindPotentialEnemies();
		}

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			GoofyEyes[] array = eyes;
			foreach (GoofyEyes goofyEyes in array)
			{
				goofyEyes.SetEyeColor(Color.white, 1f);
			}
		}

		private void Update()
		{
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			if (physGrabObject.grabbed)
			{
				if (!isGrabActive && grabTimer <= 0f)
				{
					isGrabActive = true;
					grabTimer = 45f;
					GoofyEyes[] array = eyes;
					foreach (GoofyEyes goofyEyes in array)
					{
						goofyEyes.SetPupilSizeMultiplierTarget(3f, 0.5f);
					}
				}
				grabTimer = Mathf.Max(grabTimer - Time.fixedDeltaTime, 0f);
				if (isGrabActive && grabTimer <= 10f)
				{
					if (!isAggressive)
					{
						isAggressive = true;
						GoofyEyes[] array2 = eyes;
						foreach (GoofyEyes goofyEyes2 in array2)
						{
							goofyEyes2.SetPupilSizeMultiplierTarget(1f, 5f);
							goofyEyes2.SetEyeColor(Color.red, 1f);
						}
					}
					if (isAggressive)
					{
						GameDirector.instance.CameraImpact.ShakeDistance(1.5f, 1f, 6f, ((Component)this).transform.position, 0.02f);
					}
					if (grabTimer <= 0f)
					{
						isGrabActive = false;
						isAggressive = false;
						wasAggressiveDestroyed = true;
						grabTimer = 0f;
						GoofyEyes[] array3 = eyes;
						foreach (GoofyEyes goofyEyes3 in array3)
						{
							goofyEyes3.SetPupilSizeMultiplierTarget(1f, 0f);
							goofyEyes3.SetEyeColor(Color.white, 1f);
						}
						if (SemiFunc.IsMasterClientOrSingleplayer())
						{
							physGrabObjectImpactDetector.DestroyObject(true);
						}
					}
				}
			}
			else if (grabTimer > 0f)
			{
				isGrabActive = false;
				isAggressive = false;
				grabTimer = 0f;
				GoofyEyes[] array4 = eyes;
				foreach (GoofyEyes goofyEyes4 in array4)
				{
					goofyEyes4.SetPupilSizeMultiplierTarget(1f, 0.5f);
					goofyEyes4.SetEyeColor(Color.white, 1f);
				}
			}
			if (physGrabObject.grabbedLocal)
			{
				PlayerAvatar instance = PlayerAvatar.instance;
				if ((Object)(object)instance != (Object)null)
				{
					instance.OverridePupilSize(3f, 4, 1f, 1f, 5f, 0.5f, 0.1f);
				}
			}
			aggressive.PlayLoop(isAggressive, 1f, 1f, 1f);
		}

		private void FixedUpdate()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && isAggressive)
			{
				if (timeToApplyForce > 0f)
				{
					timeToApplyForce -= Time.deltaTime;
					return;
				}
				timeToApplyForce = 1f;
				float num = Random.Range(0.8f, 2f);
				rb.AddForce(Vector3.up * num, (ForceMode)1);
				Vector3 insideUnitSphere = Random.insideUnitSphere;
				Vector3 normalized = ((Vector3)(ref insideUnitSphere)).normalized;
				rb.AddTorque(normalized * 6f, (ForceMode)1);
			}
		}

		private List<EnemySetup> FindPotentialEnemies()
		{
			List<EnemySetup> list = new List<EnemySetup>();
			foreach (EnemySetup item in EnemyDirector.instance.enemiesDifficulty3)
			{
				if (!((Object)item).name.Contains("Group"))
				{
					list.Add(item);
				}
			}
			return list;
		}

		public void OnDestroy()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || wasReplaced)
			{
				return;
			}
			wasReplaced = true;
			if (valuableObject.dollarValueCurrent >= valuableObject.dollarValueOriginal * 0.15f && !wasAggressiveDestroyed)
			{
				Plugin.DebugLog("Not spawning enemy due to not fully broken");
				return;
			}
			if (potentialEnemies.Count == 0)
			{
				Plugin.Logger.LogError((object)"No valid enemies to spawn");
				return;
			}
			EnemySetup val = potentialEnemies[Random.Range(0, potentialEnemies.Count)];
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to find suitable enemy");
			}
			else
			{
				((MonoBehaviour)EnemyDirector.instance).StartCoroutine(SpawnEnemyAfterTime(val, ((Component)this).gameObject.transform.position, TimeSpan.FromSeconds(3.0)));
			}
		}

		[IteratorStateMachine(typeof(<SpawnEnemyAfterTime>d__22))]
		private static IEnumerator SpawnEnemyAfterTime(EnemySetup enemySetup, Vector3 position, TimeSpan timeSpan)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnEnemyAfterTime>d__22(0)
			{
				enemySetup = enemySetup,
				position = position,
				timeSpan = timeSpan
			};
		}
	}
	public class ValuablePresentEnemyVariant : MonoBehaviour
	{
		public string valuableName;
	}
	public static class ValuableUtil
	{
		public static List<GameObject> GetValuablesByVolumeType(Level level, Type volumeType)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected I4, but got Unknown
			List<GameObject> list = new List<GameObject>();
			foreach (LevelValuables valuablePreset in level.ValuablePresets)
			{
				Type val = volumeType;
				Type val2 = val;
				switch ((int)val2)
				{
				case 0:
					list.AddRange(valuablePreset.tiny);
					break;
				case 1:
					list.AddRange(valuablePreset.small);
					break;
				case 2:
					list.AddRange(valuablePreset.medium);
					break;
				case 3:
					list.AddRange(valuablePreset.big);
					break;
				case 4:
					list.AddRange(valuablePreset.wide);
					break;
				case 5:
					list.AddRange(valuablePreset.tall);
					break;
				case 6:
					list.AddRange(valuablePreset.veryTall);
					break;
				default:
					Plugin.Logger.LogError((object)("Unhandled volume type: " + ((object)(Type)(ref volumeType)).ToString()));
					break;
				}
			}
			return list;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "REPOPresents";

		public const string PLUGIN_NAME = "REPOPresents";

		public const string PLUGIN_VERSION = "1.3.0";
	}
}
namespace REPOPresents.Chance
{
	internal static class ChanceRegistry
	{
		public enum Outcome
		{
			Good,
			Bad
		}

		public static readonly Dictionary<(Outcome, Type), int> MULTIPLAYER = new Dictionary<(Outcome, Type), int>
		{
			{
				(Outcome.Good, typeof(HealRandomPlayer)),
				4
			},
			{
				(Outcome.Bad, typeof(HurtRandomPlayer)),
				4
			},
			{
				(Outcome.Bad, typeof(TeleportRandomPlayer)),
				4
			},
			{
				(Outcome.Good, typeof(ReviveRandomPlayer)),
				4
			},
			{
				(Outcome.Good, typeof(ReviveAllPlayers)),
				3
			}
		};

		public static readonly Dictionary<(Outcome, Type), int> SINGLEPLAYER = new Dictionary<(Outcome, Type), int>();

		public static readonly Dictionary<(Outcome, Type), int> SHARED = new Dictionary<(Outcome, Type), int>
		{
			{
				(Outcome.Good, typeof(HealRoller)),
				4
			},
			{
				(Outcome.Bad, typeof(HurtRoller)),
				4
			},
			{
				(Outcome.Bad, typeof(TeleportRoller)),
				4
			},
			{
				(Outcome.Good, typeof(SpawnRandomValuable)),
				4
			},
			{
				(Outcome.Bad, typeof(BreakRandomValuable)),
				3
			},
			{
				(Outcome.Good, typeof(IncreaseValuableWorth)),
				4
			},
			{
				(Outcome.Good, typeof(IncreaseAllValuableWorthTenPercent)),
				3
			},
			{
				(Outcome.Good, typeof(IncreaseAllValuableWorthTwentyPercent)),
				1
			},
			{
				(Outcome.Bad, typeof(DecreaseAllValuableWorthTenPercent)),
				3
			},
			{
				(Outcome.Bad, typeof(SpawnEnemy)),
				2
			},
			{
				(Outcome.Bad, typeof(SpawnMiniEnemy)),
				2
			},
			{
				(Outcome.Good, typeof(SpawnRandomUpgradeItem)),
				3
			},
			{
				(Outcome.Good, typeof(SpawnRandomHealthPack)),
				3
			},
			{
				(Outcome.Good, typeof(SpawnRandomDroneItem)),
				1
			}
		};

		public static readonly Dictionary<string, Type> NAME_TO_TYPED_ENTRY = new Dictionary<string, Type>
		{
			{
				"heal roller",
				typeof(HealRoller)
			},
			{
				"hurt roller",
				typeof(HurtRoller)
			},
			{
				"teleport roller",
				typeof(TeleportRoller)
			},
			{
				"heal random player",
				typeof(HealRandomPlayer)
			},
			{
				"hurt random player",
				typeof(HurtRandomPlayer)
			},
			{
				"teleport random player",
				typeof(TeleportRandomPlayer)
			},
			{
				"revive random player",
				typeof(ReviveRandomPlayer)
			},
			{
				"spawn random valuable",
				typeof(SpawnRandomValuable)
			},
			{
				"break random valuable",
				typeof(BreakRandomValuable)
			},
			{
				"increase valuable worth",
				typeof(IncreaseValuableWorth)
			},
			{
				"increase all valuable worth",
				typeof(IncreaseAllValuableWorthTenPercent)
			},
			{
				"increase all valuable worth 20",
				typeof(IncreaseAllValuableWorthTwentyPercent)
			},
			{
				"decrease all valuable worth",
				typeof(DecreaseAllValuableWorthTenPercent)
			},
			{
				"spawn enemy",
				typeof(SpawnEnemy)
			},
			{
				"spawn mini enemy",
				typeof(SpawnMiniEnemy)
			},
			{
				"nothing",
				typeof(Nothing)
			},
			{
				"spawn random upgrade",
				typeof(SpawnRandomUpgradeItem)
			},
			{
				"spawn random drone",
				typeof(SpawnRandomDroneItem)
			},
			{
				"spawn random health",
				typeof(SpawnRandomHealthPack)
			},
			{
				"revive all players",
				typeof(ReviveAllPlayers)
			}
		};

		public static Dictionary<(Outcome, Type), int> GetAvailableEntries()
		{
			Dictionary<(Outcome, Type), int> dictionary = SINGLEPLAYER;
			if (SemiFunc.IsMultiplayer() && PhotonNetwork.PlayerList.Length > 1)
			{
				dictionary = MULTIPLAYER;
			}
			Dictionary<(Outcome, Type), int> dictionary2 = new Dictionary<(Outcome, Type), int>();
			foreach (KeyValuePair<(Outcome, Type), int> item in dictionary)
			{
				if (!ConfigValues.EnableOnlyGoodOutcomes.Value || item.Key.Item1 == Outcome.Good)
				{
					dictionary2.Add(item.Key, item.Value);
				}
			}
			foreach (KeyValuePair<(Outcome, Type), int> item2 in SHARED)
			{
				if (!ConfigValues.EnableOnlyGoodOutcomes.Value || item2.Key.Item1 == Outcome.Good)
				{
					dictionary2.Add(item2.Key, item2.Value);
				}
			}
			return dictionary2;
		}
	}
	internal class ChanceUtil
	{
		public static PlayerAvatar GetRandomAlivePlayer()
		{
			List<PlayerAvatar> list = GameDirector.instance.PlayerList.Where((PlayerAvatar x) => (float)x.playerHealth.health > 0f).ToList();
			if (list.Count == 0)
			{
				return null;
			}
			int index = Random.Range(0, list.Count);
			return list[index];
		}

		public static PlayerAvatar GetRandomAlivePlayerButExclude(PlayerAvatar exclude)
		{
			List<PlayerAvatar> list = GameDirector.instance.PlayerList.Where((PlayerAvatar x) => (float)x.playerHealth.health > 0f && (Object)(object)x != (Object)(object)exclude).ToList();
			if (list.Count == 0)
			{
				return null;
			}
			int index = Random.Range(0, list.Count);
			return list[index];
		}

		public static PlayerAvatar GetRandomDeadPlayer()
		{
			List<PlayerAvatar> list = GameDirector.instance.PlayerList.Where((PlayerAvatar x) => (float)x.playerHealth.health <= 0f).ToList();
			if (list.Count == 0)
			{
				return null;
			}
			int index = Random.Range(0, list.Count);
			return list[index];
		}

		public static Item GetRandomItemOfType(itemType itemType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			List<Item> list = StatsManager.instance.itemDictionary.Values.Where((Item i) => i.itemType == itemType).ToList();
			if (list.Count == 0)
			{
				return null;
			}
			return list[Random.Range(0, list.Count)];
		}

		public static string RemoveSuffix(string original, string suffix)
		{
			if (original != null && suffix != null && original.EndsWith(suffix))
			{
				return original.Substring(0, original.Length - suffix.Length);
			}
			return original;
		}
	}
	internal interface IChanceEntry
	{
		bool Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network);

		(string, PossessChatID, Color) GetChatMessage();
	}
	public static class TestCommand
	{
		[CommandExecution("Test Chance Entry", "Test a specific chance entry by name.", true, true)]
		[CommandAlias("testchanceentry")]
		[CommandAlias("testchance")]
		[CommandAlias("tce")]
		public static void Execute(string args)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(args))
			{
				Plugin.Logger.LogWarning((object)"No args provided to command.");
				return;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				Plugin.Logger.LogWarning((object)"Only the host can test!");
				return;
			}
			Type chanceEntry = ChanceRegistry.NAME_TO_TYPED_ENTRY[args];
			if (chanceEntry == null)
			{
				Plugin.Logger.LogWarning((object)"Unable to find chance type");
				return;
			}
			Vector3 val = ((Component)PlayerAvatar.instance).transform.position + new Vector3(0f, 1f, 0f) + ((Component)PlayerAvatar.instance).transform.forward * 1f;
			ValuableObject val2 = default(ValuableObject);
			if (!Valuables.TryGetValuableThatContainsName("Valuable Present Big (Chance)", ref val2))
			{
				Plugin.Logger.LogWarning((object)"Spawn valuable failed.");
				return;
			}
			ChatManager.instance.ClearAllChatBatches();
			ChatManager.instance.ChatReset();
			GameObject gameObject = Valuables.SpawnValuable(val2, val, Quaternion.identity);
			Task.Delay(500).ContinueWith(delegate
			{
				ValuablePresentChance component = gameObject.GetComponent<ValuablePresentChance>();
				component.OverrideChanceEntry(chanceEntry);
				component.lastPlayerGrabbed = PlayerAvatar.instance;
				PhysGrabObject component2 = gameObject.GetComponent<PhysGrabObject>();
				component2.lastPlayerGrabbing = PlayerAvatar.instance;
				component2.grabbedTimer = 10f;
				PhysGrabObjectImpactDetector component3 = gameObject.GetComponent<PhysGrabObjectImpactDetector>();
				component3.DestroyObject(true);
			});
		}
	}
}
namespace REPOPresents.Chance.Impl
{
	internal class BreakRandomValuable : IChanceEntry
	{
		private string destroyedName = null;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			if (valuableList == null || valuableList.Count == 0)
			{
				return false;
			}
			ValuableObject val = valuableList[Random.Range(0, valuableList.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			destroyedName = ((Object)val).name;
			PhysGrabObjectImpactDetector component = ((Component)val).GetComponent<PhysGrabObjectImpactDetector>();
			component.DestroyObject(true);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (destroyedName == null)
			{
				return ("Broken a random item!", (PossessChatID)3, Color.red);
			}
			return ("Broken a " + ChanceUtil.RemoveSuffix(destroyedName, "(Clone)").ToLower(), (PossessChatID)3, Color.red);
		}
	}
	internal class DecreaseAllValuableWorthTenPercent : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			if (valuableList == null || valuableList.Count == 0)
			{
				return false;
			}
			foreach (ValuableObject item in valuableList)
			{
				float num = item.dollarValueCurrent * 0.9f;
				item.dollarValueCurrent = Mathf.Round(num / 100f) * 100f;
				if (SemiFunc.IsMultiplayer())
				{
					item.photonView.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { item.dollarValueCurrent });
				}
			}
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Decreased all valuables by 10%!", (PossessChatID)4, Color.red);
		}
	}
	internal class HealRandomPlayer : IChanceEntry
	{
		private PlayerAvatar selected;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			selected = ChanceUtil.GetRandomAlivePlayerButExclude(roller);
			if ((Object)(object)selected == (Object)null)
			{
				return false;
			}
			selected.playerHealth.HealOther(selected.playerHealth.maxHealth, true);
			network.PossessChat(selected, (PossessChatID)0, roller.playerName + " has healed me!", Color.green);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return (selected.playerName + " has been healed!", (PossessChatID)0, Color.green);
		}
	}
	internal class HealRoller : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			roller.playerHealth.HealOther(roller.playerHealth.maxHealth, true);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("I have been healed!", (PossessChatID)0, Color.green);
		}
	}
	internal class HurtRandomPlayer : IChanceEntry
	{
		private PlayerAvatar selected;

		private int damage;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_004c: 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)
			damage = Random.Range(10, 50);
			selected = ChanceUtil.GetRandomAlivePlayerButExclude(roller);
			if ((Object)(object)selected == (Object)null)
			{
				return false;
			}
			selected.playerHealth.HurtOther(damage, new Vector3(0f, 0f), false, -1);
			network.PossessChat(selected, (PossessChatID)3, $"-{damage} health from {roller.playerName}", Color.red);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			return ($"-{damage} health for {selected.playerName}", (PossessChatID)4, Color.red);
		}
	}
	internal class HurtRoller : IChanceEntry
	{
		private int damage;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			damage = Random.Range(10, 50);
			roller.playerHealth.HurtOther(damage, new Vector3(0f, 0f), false, -1);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return ($"-{damage} health", (PossessChatID)3, Color.red);
		}
	}
	internal class IncreaseAllValuableWorthTenPercent : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			if (valuableList == null || valuableList.Count == 0)
			{
				return false;
			}
			foreach (ValuableObject item in valuableList)
			{
				float num = item.dollarValueCurrent * 1.1f;
				item.dollarValueCurrent = Mathf.Round(num / 100f) * 100f;
				item.dollarValueOriginal = Mathf.Max(item.dollarValueCurrent, item.dollarValueOriginal);
				if (SemiFunc.IsMultiplayer())
				{
					item.photonView.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { item.dollarValueCurrent });
				}
			}
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Increased all valuables by 10%!", (PossessChatID)0, Color.green);
		}
	}
	internal class IncreaseAllValuableWorthTwentyPercent : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			if (valuableList == null || valuableList.Count == 0)
			{
				return false;
			}
			foreach (ValuableObject item in valuableList)
			{
				float num = item.dollarValueCurrent * 1.2f;
				item.dollarValueCurrent = Mathf.Round(num / 100f) * 100f;
				item.dollarValueOriginal = Mathf.Max(item.dollarValueCurrent, item.dollarValueOriginal);
				if (SemiFunc.IsMultiplayer())
				{
					item.photonView.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { item.dollarValueCurrent });
				}
			}
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Increased all valuables by 20%!", (PossessChatID)0, Color.green);
		}
	}
	internal class IncreaseValuableWorth : IChanceEntry
	{
		private const int MAX_VALUE = 10000;

		private const int MIN_VALUE = 2000;

		private string selectedName = null;

		private int increasedValue = 0;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			List<ValuableObject> valuableList = ValuableDirector.instance.valuableList;
			if (valuableList == null || valuableList.Count == 0)
			{
				return false;
			}
			ValuableObject val = valuableList[Random.Range(0, valuableList.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			increasedValue = Random.Range(2000, 10000);
			selectedName = ((Object)val).name;
			val.dollarValueCurrent += (float)increasedValue;
			val.DollarValueSetLogic();
			if (SemiFunc.IsMultiplayer())
			{
				val.photonView.RPC("DollarValueSetRPC", (RpcTarget)1, new object[1] { val.dollarValueCurrent });
			}
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (selectedName == null)
			{
				return ($"Increased a random item by ${increasedValue}!", (PossessChatID)0, Color.green);
			}
			return (string.Format("Increased {0} by ${1}", ChanceUtil.RemoveSuffix(selectedName, "(Clone)").ToLower(), increasedValue), (PossessChatID)0, Color.green);
		}
	}
	internal class Nothing : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return (null, (PossessChatID)0, Color.white);
		}
	}
	internal class ReviveAllPlayers : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if ((float)player.playerHealth.health <= 0f)
				{
					player.Revive(false);
				}
			}
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Revived all dead players!", (PossessChatID)0, Color.green);
		}
	}
	internal class ReviveRandomPlayer : IChanceEntry
	{
		private PlayerAvatar selected;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			selected = ChanceUtil.GetRandomDeadPlayer();
			if ((Object)(object)selected == (Object)null)
			{
				return false;
			}
			selected.Revive(false);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return (selected.playerName + " has been revived!", (PossessChatID)0, Color.green);
		}
	}
	internal class SpawnEnemy : IChanceEntry
	{
		[CompilerGenerated]
		private sealed class <SpawnEnemyAfterTime>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnemySetup enemySetup;

			public Vector3 position;

			public TimeSpan timeSpan;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SpawnEnemyAfterTime>d__2(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds((float)timeSpan.TotalSeconds);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Enemies.SpawnEnemy(enemySetup, position, Quaternion.identity, false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			List<EnemySetup> list = new List<EnemySetup>();
			foreach (EnemySetup item in EnemyDirector.instance.enemiesDifficulty3)
			{
				if (!((Object)item).name.Contains("Group"))
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			EnemySetup val = list[Random.Range(0, list.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			((MonoBehaviour)EnemyDirector.instance).StartCoroutine(SpawnEnemyAfterTime(val, ((Component)network).gameObject.transform.position, TimeSpan.FromSeconds(3.0)));
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("RUN! NOW!", (PossessChatID)3, Color.red);
		}

		[IteratorStateMachine(typeof(<SpawnEnemyAfterTime>d__2))]
		private static IEnumerator SpawnEnemyAfterTime(EnemySetup enemySetup, Vector3 position, TimeSpan timeSpan)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnEnemyAfterTime>d__2(0)
			{
				enemySetup = enemySetup,
				position = position,
				timeSpan = timeSpan
			};
		}
	}
	internal class SpawnMiniEnemy : IChanceEntry
	{
		[CompilerGenerated]
		private sealed class <SpawnEnemyAfterTime>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnemySetup enemySetup;

			public Vector3 position;

			public TimeSpan timeSpan;

			public ValuablePresentChanceNetwork network;

			private List<EnemyParent> <parts>5__1;

			private List<EnemyParent>.Enumerator <>s__2;

			private EnemyParent <item>5__3;

			private PhotonView <photonView>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SpawnEnemyAfterTime>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<parts>5__1 = null;
				<>s__2 = default(List<EnemyParent>.Enumerator);
				<item>5__3 = null;
				<photonView>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds((float)timeSpan.TotalSeconds);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<parts>5__1 = Enemies.SpawnEnemy(enemySetup, position, Quaternion.identity, false);
					<>s__2 = <parts>5__1.GetEnumerator();
					try
					{
						while (<>s__2.MoveNext())
						{
							<item>5__3 = <>s__2.Current;
							<photonView>5__4 = ((Component)<item>5__3).GetComponent<PhotonView>();
							if ((Object)(object)<photonView>5__4 != (Object)null)
							{
								network.SetScale(<photonView>5__4.ViewID, new Vector3(0.5f, 0.5f, 0.5f));
							}
							<photonView>5__4 = null;
							<item>5__3 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__2).Dispose();
					}
					<>s__2 = default(List<EnemyParent>.Enumerator);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly List<string> SPAWNABLES = new List<string> { "Head", "Robe", "Huntsman", "Reaper" };

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			string text = SPAWNABLES[Random.Range(0, SPAWNABLES.Count)];
			EnemySetup enemyThatContainsName = Enemies.GetEnemyThatContainsName(text);
			if ((Object)(object)enemyThatContainsName == (Object)null)
			{
				return false;
			}
			((MonoBehaviour)EnemyDirector.instance).StartCoroutine(SpawnEnemyAfterTime(enemyThatContainsName, ((Component)network).gameObject.transform.position, TimeSpan.FromSeconds(3.0), network));
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("RUN! SMALL!", (PossessChatID)3, Color.red);
		}

		[IteratorStateMachine(typeof(<SpawnEnemyAfterTime>d__3))]
		private static IEnumerator SpawnEnemyAfterTime(EnemySetup enemySetup, Vector3 position, TimeSpan timeSpan, ValuablePresentChanceNetwork network)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnEnemyAfterTime>d__3(0)
			{
				enemySetup = enemySetup,
				position = position,
				timeSpan = timeSpan,
				network = network
			};
		}
	}
	internal class SpawnRandomDroneItem : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Item randomItemOfType = ChanceUtil.GetRandomItemOfType((itemType)0);
			if ((Object)(object)randomItemOfType == (Object)null)
			{
				return false;
			}
			Items.SpawnItem(randomItemOfType, ((Component)network).gameObject.transform.position, Quaternion.identity);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("A drone", (PossessChatID)0, Color.blue);
		}
	}
	internal class SpawnRandomHealthPack : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Item randomItemOfType = ChanceUtil.GetRandomItemOfType((itemType)8);
			if ((Object)(object)randomItemOfType == (Object)null)
			{
				return false;
			}
			Items.SpawnItem(randomItemOfType, ((Component)network).gameObject.transform.position, Quaternion.identity);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Some health", (PossessChatID)0, Color.green);
		}
	}
	internal class SpawnRandomUpgradeItem : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Item randomItemOfType = ChanceUtil.GetRandomItemOfType((itemType)3);
			if ((Object)(object)randomItemOfType == (Object)null)
			{
				return false;
			}
			Items.SpawnItem(randomItemOfType, ((Component)network).gameObject.transform.position, Quaternion.identity);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Shiny upgrade", (PossessChatID)0, Color.cyan);
		}
	}
	internal class SpawnRandomValuable : IChanceEntry
	{
		private static readonly List<Type> TYPES = new List<Type>
		{
			(Type)2,
			(Type)3,
			(Type)5
		};

		private Type type;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			type = TYPES[Random.Range(0, TYPES.Count)];
			List<GameObject> valuablesByVolumeType = ValuableUtil.GetValuablesByVolumeType(RunManager.instance.levelCurrent, type);
			if (valuablesByVolumeType.Count == 0)
			{
				return false;
			}
			GameObject val = valuablesByVolumeType[Random.Range(0, valuablesByVolumeType.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			ValuableObject component = val.GetComponent<ValuableObject>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			Valuables.SpawnValuable(component, ((Component)network).gameObject.transform.position, ((Component)network).gameObject.transform.rotation);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			return ("A " + ((object)(Type)(ref type)).ToString().ToLower() + " item!", (PossessChatID)0, Color.white);
		}
	}
	internal class TeleportRandomPlayer : IChanceEntry
	{
		private PlayerAvatar selected;

		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_006e: 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)
			selected = ChanceUtil.GetRandomAlivePlayerButExclude(roller);
			if ((Object)(object)selected == (Object)null)
			{
				return false;
			}
			List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
			if (list.Count == 0)
			{
				return false;
			}
			LevelPoint val = list[Random.Range(0, list.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			network.Teleport(selected, ((Component)val).transform.position);
			network.PossessChat(selected, (PossessChatID)3, roller.playerName + " has teleported me!", Color.red);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return (selected.playerName + " has been teleported!", (PossessChatID)4, Color.red);
		}
	}
	internal class TeleportRoller : IChanceEntry
	{
		bool IChanceEntry.Execute(PlayerAvatar roller, ValuablePresentChanceNetwork network)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
			if (list.Count == 0)
			{
				return false;
			}
			LevelPoint val = list[Random.Range(0, list.Count)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			network.Teleport(roller, ((Component)val).transform.position);
			return true;
		}

		(string, PossessChatID, Color) IChanceEntry.GetChatMessage()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ("Teleported :(", (PossessChatID)0, Color.red);
		}
	}
}