Decompiled source of Christmas Presents v1.0.0

com.Omniscye.EmpressTrickOrTreat.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FMODUnity;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
using UnityEngine.Networking;
using YAPYAP;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Omniscye.EmpressTrickOrTreat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+174558dd641ee37bf40ded0d24866ac172d24388")]
[assembly: AssemblyProduct("com.Omniscye.EmpressTrickOrTreat")]
[assembly: AssemblyTitle("EmpressTrickOrTreat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Empress.TrickOrTreat.YapYapPort
{
	internal static class TrickAssetLoader
	{
		private static AssetBundle _bundle;

		private static GameObject _cachedTreat;

		public static GameObject LoadTreatPrefab()
		{
			try
			{
				if ((Object)(object)_cachedTreat != (Object)null)
				{
					return _cachedTreat;
				}
				if ((Object)(object)_bundle == (Object)null)
				{
					string text = Path.Combine(Path.GetDirectoryName(typeof(EmpressPresentsYapYap).Assembly.Location), "trick");
					if (!File.Exists(text))
					{
						EmpressPresentsYapYap.Log.LogWarning((object)("[AssetLoader] Could not find asset bundle at: " + text));
						return null;
					}
					_bundle = AssetBundle.LoadFromFile(text);
					if ((Object)(object)_bundle == (Object)null)
					{
						EmpressPresentsYapYap.Log.LogError((object)"[AssetLoader] Failed to load AssetBundle 'trick'.");
						return null;
					}
				}
				_cachedTreat = _bundle.LoadAsset<GameObject>("treat");
				if ((Object)(object)_cachedTreat == (Object)null)
				{
					EmpressPresentsYapYap.Log.LogError((object)"[AssetLoader] AssetBundle loaded, but 'treat' prefab not found!");
				}
				return _cachedTreat;
			}
			catch (Exception arg)
			{
				EmpressPresentsYapYap.Log.LogError((object)$"[AssetLoader] Error loading assets: {arg}");
				return null;
			}
		}
	}
	public struct PresentSpawnMsg : NetworkMessage
	{
		public string id;

		public Vector3 pos;

		public Quaternion rot;
	}
	public struct PresentDestroyMsg : NetworkMessage
	{
		public string id;
	}
	public struct PresentInteractMsg : NetworkMessage
	{
		public string id;
	}
	public struct PresentOpenMsg : NetworkMessage
	{
		public string id;
	}
	public struct PresentFxMsg : NetworkMessage
	{
		public string id;

		public byte fx;

		public Vector3 pos;
	}
	[HarmonyPatch(typeof(GameManager), "SvRoundFinish")]
	public static class Patch_GameManager_RoundFinish_Clear
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (NetworkServer.active)
			{
				PresentRouter presentRouter = Object.FindObjectOfType<PresentRouter>();
				if ((Object)(object)presentRouter != (Object)null)
				{
					presentRouter.Server_ClearAllPresents();
					PresentRouter.SpawnedThisDungeon = false;
				}
			}
		}
	}
	[BepInPlugin("empress.yapyap.empresspresents", "Empress Presents (YapYap Port, RuntimeStateSpawner)", "1.3.4")]
	public class EmpressPresentsYapYap : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <LoadAudioClip>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EmpressPresentsYapYap <>4__this;

			public string fileName;

			public Action<AudioClip> onLoaded;

			private UnityWebRequest <uwr>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<uwr>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Invalid comparison between Unknown and I4
				//IL_00d9: 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_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Invalid comparison between Unknown and I4
				try
				{
					int num = <>1__state;
					EmpressPresentsYapYap empressPresentsYapYap = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)empressPresentsYapYap).Info.Location);
						string text = Path.Combine(directoryName, fileName);
						if (!File.Exists(text))
						{
							if (Path.GetExtension(fileName) == ".ogg")
							{
								string text2 = Path.Combine(directoryName, Path.GetFileNameWithoutExtension(fileName) + ".off");
								if (File.Exists(text2))
								{
									text = text2;
								}
							}
							if (!File.Exists(text))
							{
								Log.LogWarning((object)("[Presents] Custom audio file not found at: " + text));
								return false;
							}
						}
						AudioType val = (AudioType)14;
						if (text.EndsWith(".wav", StringComparison.OrdinalIgnoreCase))
						{
							val = (AudioType)20;
						}
						<uwr>5__2 = UnityWebRequestMultimedia.GetAudioClip("file://" + text, val);
						<>1__state = -3;
						<>2__current = <uwr>5__2.SendWebRequest();
						<>1__state = 1;
						return true;
					}
					case 1:
						<>1__state = -3;
						if ((int)<uwr>5__2.result == 2 || (int)<uwr>5__2.result == 3)
						{
							Log.LogError((object)("[Presents] Failed to load custom audio " + fileName + ": " + <uwr>5__2.error));
						}
						else
						{
							AudioClip content = DownloadHandlerAudioClip.GetContent(<uwr>5__2);
							((Object)content).name = fileName;
							onLoaded?.Invoke(content);
							Log.LogInfo((object)("[Presents] Successfully loaded custom sound: " + fileName));
						}
						<>m__Finally1();
						<uwr>5__2 = null;
						return false;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<uwr>5__2 != null)
				{
					((IDisposable)<uwr>5__2).Dispose();
				}
			}

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

		[CompilerGenerated]
		private sealed class <LoadCustomSounds>d__25 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EmpressPresentsYapYap <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				EmpressPresentsYapYap empressPresentsYapYap = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = empressPresentsYapYap.LoadAudioClip(ExplosionAudioFile.Value, delegate(AudioClip clip)
					{
						CustomExplosionClip = clip;
					});
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = empressPresentsYapYap.LoadAudioClip(OpenAudioFile.Value, delegate(AudioClip clip)
					{
						CustomOpenClip = clip;
					});
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					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();
			}
		}

		public const string PluginGuid = "empress.yapyap.empresspresents";

		public const string PluginName = "Empress Presents (YapYap Port, RuntimeStateSpawner)";

		public const string PluginVersion = "1.3.4";

		internal static EmpressPresentsYapYap Instance = null;

		internal static ManualLogSource Log = null;

		internal Harmony Harmony;

		internal static ConfigEntry<float> ExplosionChance = null;

		internal static ConfigEntry<string> ExplosionSfxPath = null;

		internal static ConfigEntry<string> ExplosionAudioFile = null;

		internal static ConfigEntry<string> OpenAudioFile = null;

		internal static ConfigEntry<int> MinSpawnItems = null;

		internal static ConfigEntry<int> MaxSpawnItems = null;

		internal static ConfigEntry<int> MinPresents = null;

		internal static ConfigEntry<int> MaxPresents = null;

		internal static ConfigEntry<bool> SkipClosestSpawnPoints = null;

		internal static ConfigEntry<int> SkipClosestCount = null;

		internal static ConfigEntry<float> InteractRange = null;

		internal static ConfigEntry<float> OpenDelay = null;

		internal static ConfigEntry<float> ExplodeRadius = null;

		internal static ConfigEntry<int> ExplodeDamage = null;

		internal static ConfigEntry<float> ExplodeForce = null;

		public static List<NetworkIdentity> LootTable = new List<NetworkIdentity>();

		public static AudioClip CustomExplosionClip = null;

		public static AudioClip CustomOpenClip = null;

		private void Awake()
		{
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			((Component)this).gameObject.transform.parent = null;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			ExplosionChance = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "ExplosionChance", 0.2f, "Chance [0..1] to explode instead of spawning loot.");
			ExplosionSfxPath = ((BaseUnityPlugin)this).Config.Bind<string>("Explosion", "SfxPath", "event:/SFX/Props/Prop_Bomb_Explode", "FMOD Event path for explosion sound (Fallback if custom file missing).");
			ExplosionAudioFile = ((BaseUnityPlugin)this).Config.Bind<string>("Explosion", "AudioFileName", "explosion.ogg", "Name of the audio file to load from beside the DLL (supports .ogg, .wav).");
			OpenAudioFile = ((BaseUnityPlugin)this).Config.Bind<string>("Client", "OpenAudioFileName", "open.ogg", "Name of the audio file to load for opening a present (supports .ogg, .wav).");
			MinSpawnItems = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "MinSpawnItems", 1, "Minimum network props to spawn when opened.");
			MaxSpawnItems = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "MaxSpawnItems", 3, "Maximum network props to spawn when opened.");
			OpenDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Client", "OpenDelay", 1.25f, "Seconds to wait after opening before the effect/destroy triggers.");
			MinPresents = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MinPresents", 1, "Minimum presents per dungeon.");
			MaxPresents = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxPresents", 3, "Maximum presents per dungeon.");
			SkipClosestSpawnPoints = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "SkipClosestSpawnPoints", true, "Skip a few spawn points closest to the first spawnpoint.");
			SkipClosestCount = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "SkipClosestCount", 3, "How many closest spawn points to skip.");
			InteractRange = ((BaseUnityPlugin)this).Config.Bind<float>("Client", "InteractRange", 2f, "How close you must be to open a present.");
			ExplodeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "Radius", 6f, "Explosion radius.");
			ExplodeDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Explosion", "Damage", 35, "Explosion damage.");
			ExplodeForce = ((BaseUnityPlugin)this).Config.Bind<float>("Explosion", "Force", 14f, "Explosion push force.");
			RegisterSerializers();
			Harmony = new Harmony("empress.yapyap.empresspresents");
			Harmony.PatchAll(typeof(Patch_GameManager_RoundFinish_Clear));
			((MonoBehaviour)this).StartCoroutine(LoadCustomSounds());
			GameObject val = new GameObject("EmpressPresents_YapYap_Router");
			val.transform.parent = null;
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<PresentRouter>();
			Log.LogInfo((object)"Empress Presents (YapYap Port, RuntimeStateSpawner) v1.3.4 loaded.");
		}

		[IteratorStateMachine(typeof(<LoadCustomSounds>d__25))]
		private IEnumerator LoadCustomSounds()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadCustomSounds>d__25(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<LoadAudioClip>d__26))]
		private IEnumerator LoadAudioClip(string fileName, Action<AudioClip> onLoaded)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadAudioClip>d__26(0)
			{
				<>4__this = this,
				fileName = fileName,
				onLoaded = onLoaded
			};
		}

		public static void RefreshLootTable()
		{
			LootTable.Clear();
			if ((Object)(object)NetworkManager.singleton == (Object)null || NetworkManager.singleton.spawnPrefabs == null)
			{
				Log.LogWarning((object)"[Presents] NetworkManager not ready, cannot populate Loot Table yet.");
				return;
			}
			foreach (GameObject spawnPrefab in NetworkManager.singleton.spawnPrefabs)
			{
				if ((Object)(object)spawnPrefab == (Object)null)
				{
					continue;
				}
				NetworkIdentity component = spawnPrefab.GetComponent<NetworkIdentity>();
				if (!((Object)(object)component == (Object)null))
				{
					string text = ((Object)spawnPrefab).name.ToLowerInvariant();
					if (!text.Contains("enemy") && !text.Contains("monster") && !text.Contains("creature") && !text.Contains("manager") && !text.Contains("system") && !text.Contains("controller"))
					{
						LootTable.Add(component);
					}
				}
			}
			Log.LogInfo((object)$"[Presents] Loot Table Refreshed. Found {LootTable.Count} valid items.");
		}

		private void RegisterSerializers()
		{
			Writer<PresentSpawnMsg>.write = delegate(NetworkWriter writer, PresentSpawnMsg msg)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				NetworkWriterExtensions.WriteString(writer, msg.id);
				NetworkWriterExtensions.WriteVector3(writer, msg.pos);
				NetworkWriterExtensions.WriteQuaternion(writer, msg.rot);
			};
			Reader<PresentSpawnMsg>.read = delegate(NetworkReader reader)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: 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)
				PresentSpawnMsg result5 = default(PresentSpawnMsg);
				result5.id = NetworkReaderExtensions.ReadString(reader);
				result5.pos = NetworkReaderExtensions.ReadVector3(reader);
				result5.rot = NetworkReaderExtensions.ReadQuaternion(reader);
				return result5;
			};
			Writer<PresentDestroyMsg>.write = delegate(NetworkWriter writer, PresentDestroyMsg msg)
			{
				NetworkWriterExtensions.WriteString(writer, msg.id);
			};
			Reader<PresentDestroyMsg>.read = delegate(NetworkReader reader)
			{
				PresentDestroyMsg result4 = default(PresentDestroyMsg);
				result4.id = NetworkReaderExtensions.ReadString(reader);
				return result4;
			};
			Writer<PresentInteractMsg>.write = delegate(NetworkWriter writer, PresentInteractMsg msg)
			{
				NetworkWriterExtensions.WriteString(writer, msg.id);
			};
			Reader<PresentInteractMsg>.read = delegate(NetworkReader reader)
			{
				PresentInteractMsg result3 = default(PresentInteractMsg);
				result3.id = NetworkReaderExtensions.ReadString(reader);
				return result3;
			};
			Writer<PresentOpenMsg>.write = delegate(NetworkWriter writer, PresentOpenMsg msg)
			{
				NetworkWriterExtensions.WriteString(writer, msg.id);
			};
			Reader<PresentOpenMsg>.read = delegate(NetworkReader reader)
			{
				PresentOpenMsg result2 = default(PresentOpenMsg);
				result2.id = NetworkReaderExtensions.ReadString(reader);
				return result2;
			};
			Writer<PresentFxMsg>.write = delegate(NetworkWriter writer, PresentFxMsg msg)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				NetworkWriterExtensions.WriteString(writer, msg.id);
				writer.WriteByte(msg.fx);
				NetworkWriterExtensions.WriteVector3(writer, msg.pos);
			};
			Reader<PresentFxMsg>.read = delegate(NetworkReader reader)
			{
				//IL_0025: 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)
				PresentFxMsg result = default(PresentFxMsg);
				result.id = NetworkReaderExtensions.ReadString(reader);
				result.fx = reader.ReadByte();
				result.pos = NetworkReaderExtensions.ReadVector3(reader);
				return result;
			};
		}
	}
	public class PresentLocal : MonoBehaviour
	{
		public string Id = "";

		private float _nextUseTime;

		private Transform _t;

		private PresentRouter _router;

		private bool _armed = true;

		private bool _playing;

		private bool _showingTooltip;

		private Transform _visualRoot;

		private Animator _anim;

		private static MethodInfo _miGetAction;

		private static MethodInfo _miWasPressedThisFrame;

		private const string AnimBool = "Present";

		private const string AnimStateName = "Open Present";

		public static GameObject BuildVisual(string id, Vector3 pos, Quaternion rot)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0017: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("EmpressPresent_" + id);
			val.transform.position = pos;
			val.transform.rotation = rot;
			((Object)val).hideFlags = (HideFlags)61;
			Transform val2 = null;
			GameObject val3 = TrickAssetLoader.LoadTreatPrefab();
			if ((Object)(object)val3 != (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(val3, val.transform);
				obj.transform.localPosition = Vector3.zero;
				obj.transform.localRotation = Quaternion.identity;
				val2 = obj.transform;
				Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
				Shader val4 = Shader.Find("CustomLit_Amplify") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Universal Render Pipeline/Simple Lit") ?? Shader.Find("Standard");
				if ((Object)(object)val4 != (Object)null)
				{
					Renderer[] array = componentsInChildren;
					foreach (Renderer val5 in array)
					{
						if ((Object)(object)val5 == (Object)null)
						{
							continue;
						}
						Material[] materials = val5.materials;
						foreach (Material val6 in materials)
						{
							if ((Object)(object)val6 == (Object)null)
							{
								continue;
							}
							val6.shader = val4;
							try
							{
								if (val6.HasProperty("_BaseMap") && val6.HasProperty("_MainTex") && (Object)(object)val6.GetTexture("_BaseMap") == (Object)null)
								{
									val6.SetTexture("_BaseMap", val6.GetTexture("_MainTex"));
								}
								if (val6.HasProperty("_BaseColor") && val6.HasProperty("_Color"))
								{
									val6.SetColor("_BaseColor", val6.GetColor("_Color"));
								}
							}
							catch
							{
							}
						}
					}
				}
			}
			else
			{
				GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)obj3).name = "VisualFallback";
				obj3.transform.SetParent(val.transform, false);
				obj3.transform.localScale = Vector3.one * 0.5f;
				Collider component = obj3.GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				val2 = obj3.transform;
			}
			BoxCollider obj4 = val.AddComponent<BoxCollider>();
			((Collider)obj4).isTrigger = true;
			obj4.size = new Vector3(1f, 1f, 1f);
			obj4.center = new Vector3(0f, 0.5f, 0f);
			PresentLocal presentLocal = val.AddComponent<PresentLocal>();
			presentLocal.Id = id;
			presentLocal.BindVisualRoot(val2);
			Object.DontDestroyOnLoad((Object)(object)val);
			return val;
		}

		private void BindVisualRoot(Transform root)
		{
			_visualRoot = root;
			if ((Object)(object)_visualRoot == (Object)null)
			{
				return;
			}
			try
			{
				Transform[] componentsInChildren = ((Component)_visualRoot).GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if ((Object)(object)componentsInChildren[i] != (Object)null)
					{
						((Component)componentsInChildren[i]).gameObject.SetActive(true);
					}
				}
			}
			catch
			{
			}
			_anim = ((Component)_visualRoot).GetComponentInChildren<Animator>(true);
			if (!((Object)(object)_anim != (Object)null))
			{
				return;
			}
			((Behaviour)_anim).enabled = true;
			_anim.cullingMode = (AnimatorCullingMode)0;
			_anim.updateMode = (AnimatorUpdateMode)0;
			try
			{
				_anim.Rebind();
				_anim.Update(0f);
			}
			catch
			{
			}
		}

		private void Awake()
		{
			((Component)this).transform.parent = null;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			_t = ((Component)this).transform;
			_router = PresentRouter.Instance;
		}

		private void OnDestroy()
		{
			if (_showingTooltip && (Object)(object)UIManager.Instance != (Object)null && (Object)(object)UIManager.Instance.uiTooltip != (Object)null)
			{
				UIManager.Instance.uiTooltip.HideTooltip();
			}
		}

		private void Update()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (_router == null)
			{
				_router = PresentRouter.Instance;
			}
			if ((Object)(object)_router == (Object)null || !_armed || _playing || Time.time < _nextUseTime)
			{
				return;
			}
			Pawn localInstance = Pawn.LocalInstance;
			if ((Object)(object)localInstance == (Object)null)
			{
				return;
			}
			float num = Mathf.Max(0.25f, EmpressPresentsYapYap.InteractRange.Value);
			if (Vector3.Distance(((Component)localInstance).transform.position, _t.position) > num)
			{
				if (_showingTooltip)
				{
					if ((Object)(object)UIManager.Instance != (Object)null && (Object)(object)UIManager.Instance.uiTooltip != (Object)null)
					{
						UIManager.Instance.uiTooltip.HideTooltip();
					}
					_showingTooltip = false;
				}
				return;
			}
			if ((Object)(object)UIManager.Instance != (Object)null && (Object)(object)UIManager.Instance.uiTooltip != (Object)null)
			{
				UIManager.Instance.uiTooltip.ShowTooltip("Press E to open", (InputTarget)2, true, false, (string)null, (InputTarget)8, true, false, (string)null, (InputTarget)9, true, false);
				_showingTooltip = true;
			}
			if (IsInteractPressed())
			{
				if ((Object)(object)UIManager.Instance != (Object)null && (Object)(object)UIManager.Instance.uiTooltip != (Object)null)
				{
					UIManager.Instance.uiTooltip.HideTooltip();
					_showingTooltip = false;
				}
				_nextUseTime = Time.time + 0.6f;
				_armed = false;
				_router.SendInteractRequest(Id);
			}
		}

		public void PlayOpenAnimation()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Invalid comparison between Unknown and I4
			if (_playing)
			{
				return;
			}
			_playing = true;
			_armed = false;
			if ((Object)(object)EmpressPresentsYapYap.CustomOpenClip != (Object)null)
			{
				AudioSource.PlayClipAtPoint(EmpressPresentsYapYap.CustomOpenClip, _t.position, 1f);
			}
			try
			{
				Collider component = ((Component)this).GetComponent<Collider>();
				if ((Object)(object)component != (Object)null)
				{
					component.enabled = false;
				}
			}
			catch
			{
			}
			if (!((Object)(object)_anim != (Object)null))
			{
				return;
			}
			((Behaviour)_anim).enabled = true;
			bool flag = false;
			try
			{
				AnimatorControllerParameter[] parameters = _anim.parameters;
				foreach (AnimatorControllerParameter val in parameters)
				{
					if (val.name == "Present" && (int)val.type == 4)
					{
						flag = true;
						break;
					}
				}
			}
			catch
			{
			}
			if (flag)
			{
				_anim.SetBool("Present", true);
			}
			else
			{
				_anim.CrossFade("Open Present", 0.05f);
			}
		}

		private bool IsInteractPressed()
		{
			if (Input.GetKeyDown((KeyCode)101))
			{
				return true;
			}
			if (TryIsInteractPressed())
			{
				return true;
			}
			return false;
		}

		private static bool TryIsInteractPressed()
		{
			try
			{
				InputManager instance = InputManager.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return false;
				}
				if ((object)_miGetAction == null)
				{
					_miGetAction = typeof(InputManager).GetMethod("GetActionByInputTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if (_miGetAction == null)
				{
					return false;
				}
				object obj = _miGetAction.Invoke(instance, new object[1] { (object)(InputTarget)2 });
				if (obj == null)
				{
					return false;
				}
				if ((object)_miWasPressedThisFrame == null)
				{
					_miWasPressedThisFrame = obj.GetType().GetMethod("WasPressedThisFrame", BindingFlags.Instance | BindingFlags.Public);
				}
				if (_miWasPressedThisFrame == null)
				{
					return false;
				}
				object obj2 = _miWasPressedThisFrame.Invoke(obj, Array.Empty<object>());
				bool flag = default(bool);
				int num;
				if (obj2 is bool)
				{
					flag = (bool)obj2;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch
			{
				return false;
			}
		}
	}
	public class PresentRouter : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <Server_ProcessResultCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PresentRouter <>4__this;

			public Vector3 pos;

			public string id;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: 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_0087: 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)
				int num = <>1__state;
				PresentRouter presentRouter = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(EmpressPresentsYapYap.OpenDelay.Value);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					try
					{
						if (Random.value < Mathf.Clamp01(EmpressPresentsYapYap.ExplosionChance.Value))
						{
							presentRouter.Server_DoExplosion(pos);
							PresentFxMsg presentFxMsg = default(PresentFxMsg);
							presentFxMsg.id = id;
							presentFxMsg.fx = 1;
							presentFxMsg.pos = pos;
							NetworkServer.SendToAll<PresentFxMsg>(presentFxMsg, 0, false);
						}
						else
						{
							presentRouter.Server_SpawnLoot(pos);
							PresentFxMsg presentFxMsg = default(PresentFxMsg);
							presentFxMsg.id = id;
							presentFxMsg.fx = 0;
							presentFxMsg.pos = pos;
							NetworkServer.SendToAll<PresentFxMsg>(presentFxMsg, 0, false);
						}
					}
					catch (Exception arg)
					{
						EmpressPresentsYapYap.Log.LogError((object)$"[Presents] Error in Interact Logic: {arg}");
					}
					finally
					{
						presentRouter._serverPresentPositions.Remove(id);
						presentRouter._openingPresents.Remove(id);
						PresentDestroyMsg presentDestroyMsg = default(PresentDestroyMsg);
						presentDestroyMsg.id = id;
						NetworkServer.SendToAll<PresentDestroyMsg>(presentDestroyMsg, 0, 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 readonly Dictionary<string, PresentLocal> _localPresents = new Dictionary<string, PresentLocal>(StringComparer.Ordinal);

		private readonly Dictionary<string, Vector3> _serverPresentPositions = new Dictionary<string, Vector3>(StringComparer.Ordinal);

		private readonly HashSet<string> _openingPresents = new HashSet<string>();

		private bool _clientHandlersRegistered;

		private bool _serverHandlersRegistered;

		internal static bool SpawnedThisDungeon;

		private int _lastDungeonInstanceId = -1;

		private float _serverPollNextTime;

		public static PresentRouter Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).transform.parent = null;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}

		private void Update()
		{
			TryRegisterHandlers();
			if (NetworkServer.active)
			{
				Server_RuntimeStatePoll();
			}
		}

		private void TryRegisterHandlers()
		{
			if (NetworkClient.active && !_clientHandlersRegistered)
			{
				_clientHandlersRegistered = true;
				NetworkClient.RegisterHandler<PresentSpawnMsg>((Action<PresentSpawnMsg>)OnClientSpawnMsg, false);
				NetworkClient.RegisterHandler<PresentDestroyMsg>((Action<PresentDestroyMsg>)OnClientDestroyMsg, false);
				NetworkClient.RegisterHandler<PresentOpenMsg>((Action<PresentOpenMsg>)OnClientOpenMsg, false);
				NetworkClient.RegisterHandler<PresentFxMsg>((Action<PresentFxMsg>)OnClientFxMsg, false);
				EmpressPresentsYapYap.Log.LogInfo((object)"[Presents] Client handlers registered.");
			}
			if (NetworkServer.active && !_serverHandlersRegistered)
			{
				_serverHandlersRegistered = true;
				NetworkServer.RegisterHandler<PresentInteractMsg>((Action<NetworkConnectionToClient, PresentInteractMsg>)OnServerInteractMsg, false);
				EmpressPresentsYapYap.Log.LogInfo((object)"[Presents] Server handlers registered.");
			}
			if (!NetworkClient.active)
			{
				_clientHandlersRegistered = false;
			}
			if (!NetworkServer.active)
			{
				_serverHandlersRegistered = false;
			}
		}

		private void Server_RuntimeStatePoll()
		{
			if (Time.realtimeSinceStartup < _serverPollNextTime)
			{
				return;
			}
			_serverPollNextTime = Time.realtimeSinceStartup + 0.25f;
			DungeonGameplay instance = DungeonGameplay.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				_lastDungeonInstanceId = -1;
				SpawnedThisDungeon = false;
				return;
			}
			int instanceID = ((Object)instance).GetInstanceID();
			int num = ((instance.validSpawnPoints != null) ? instance.validSpawnPoints.Length : 0);
			if (instanceID != _lastDungeonInstanceId)
			{
				_lastDungeonInstanceId = instanceID;
				SpawnedThisDungeon = false;
				Server_ClearAllPresents();
				EmpressPresentsYapYap.RefreshLootTable();
				EmpressPresentsYapYap.Log.LogInfo((object)$"[Presents] New Dungeon (id={instanceID}). Waiting for spawn points...");
			}
			if (!SpawnedThisDungeon && num > 0)
			{
				Server_TrySpawnPresents();
			}
		}

		public void Server_ClearAllPresents()
		{
			if (NetworkServer.active)
			{
				string[] array = _serverPresentPositions.Keys.ToArray();
				foreach (string id in array)
				{
					PresentDestroyMsg presentDestroyMsg = default(PresentDestroyMsg);
					presentDestroyMsg.id = id;
					NetworkServer.SendToAll<PresentDestroyMsg>(presentDestroyMsg, 0, false);
				}
				_serverPresentPositions.Clear();
				_openingPresents.Clear();
			}
		}

		public void Server_TrySpawnPresents()
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || SpawnedThisDungeon)
			{
				return;
			}
			DungeonGameplay instance = DungeonGameplay.Instance;
			if ((Object)(object)instance == (Object)null || instance.validSpawnPoints == null || instance.validSpawnPoints.Length == 0)
			{
				return;
			}
			SpawnedThisDungeon = true;
			List<Transform> list = instance.validSpawnPoints.Where((Transform t) => (Object)(object)t != (Object)null).ToList();
			if (list.Count == 0)
			{
				return;
			}
			if (EmpressPresentsYapYap.SkipClosestSpawnPoints.Value && list.Count > EmpressPresentsYapYap.SkipClosestCount.Value)
			{
				Vector3 anchor = list[0].position;
				list = list.OrderBy((Transform p) => Vector3.Distance(anchor, p.position)).Skip(Mathf.Max(0, EmpressPresentsYapYap.SkipClosestCount.Value)).ToList();
				if (list.Count == 0)
				{
					list = instance.validSpawnPoints.Where((Transform t) => (Object)(object)t != (Object)null).ToList();
				}
			}
			int num = Mathf.Clamp(EmpressPresentsYapYap.MinPresents.Value, 0, 999);
			int num2 = Mathf.Max(num, EmpressPresentsYapYap.MaxPresents.Value);
			int num3 = Random.Range(num, num2 + 1);
			num3 = Mathf.Min(num3, list.Count);
			list = list.OrderBy((Transform _) => Random.value).Take(num3).ToList();
			foreach (Transform item in list)
			{
				string text = Guid.NewGuid().ToString("N");
				Vector3 val = item.position + Vector3.up * 0.25f;
				Quaternion rotation = item.rotation;
				_serverPresentPositions[text] = val;
				PresentSpawnMsg presentSpawnMsg = default(PresentSpawnMsg);
				presentSpawnMsg.id = text;
				presentSpawnMsg.pos = val;
				presentSpawnMsg.rot = rotation;
				NetworkServer.SendToAll<PresentSpawnMsg>(presentSpawnMsg, 0, false);
			}
			EmpressPresentsYapYap.Log.LogInfo((object)$"[Presents] Spawned {num3} presents.");
		}

		internal void OnServerInteractMsg(NetworkConnectionToClient conn, PresentInteractMsg msg)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && !string.IsNullOrEmpty(msg.id) && _serverPresentPositions.TryGetValue(msg.id, out var value) && !_openingPresents.Contains(msg.id))
			{
				NetworkIdentity val = ((conn != null) ? ((NetworkConnection)conn).identity : null);
				if (!((Object)(object)val != (Object)null) || !(Vector3.Distance(((Component)val).transform.position, value) > EmpressPresentsYapYap.InteractRange.Value + 1f))
				{
					_openingPresents.Add(msg.id);
					PresentOpenMsg presentOpenMsg = default(PresentOpenMsg);
					presentOpenMsg.id = msg.id;
					NetworkServer.SendToAll<PresentOpenMsg>(presentOpenMsg, 0, false);
					((MonoBehaviour)this).StartCoroutine(Server_ProcessResultCoroutine(msg.id, value));
				}
			}
		}

		[IteratorStateMachine(typeof(<Server_ProcessResultCoroutine>d__19))]
		private IEnumerator Server_ProcessResultCoroutine(string id, Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Server_ProcessResultCoroutine>d__19(0)
			{
				<>4__this = this,
				id = id,
				pos = pos
			};
		}

		private void Server_DoExplosion(Vector3 pos)
		{
			//IL_003b: 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_0078: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.1f, EmpressPresentsYapYap.ExplodeRadius.Value);
			int num2 = Mathf.Max(0, EmpressPresentsYapYap.ExplodeDamage.Value);
			float num3 = Mathf.Max(0f, EmpressPresentsYapYap.ExplodeForce.Value);
			Collider[] array = Physics.OverlapSphere(pos, num);
			foreach (Collider val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				PawnHurtbox componentInParent = ((Component)val).GetComponentInParent<PawnHurtbox>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					Vector3 val2 = ((Component)componentInParent).transform.position - pos;
					if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
					{
						val2 = Vector3.up;
					}
					((Vector3)(ref val2)).Normalize();
					componentInParent.OnHit(num2, num3, val2, (StatusSO)null, false, true, false);
				}
			}
		}

		private void Server_SpawnLoot(Vector3 at)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00cb: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if (EmpressPresentsYapYap.LootTable.Count == 0)
			{
				EmpressPresentsYapYap.RefreshLootTable();
				if (EmpressPresentsYapYap.LootTable.Count == 0)
				{
					EmpressPresentsYapYap.Log.LogWarning((object)"[Presents] Loot Table is empty! Cannot spawn loot.");
					return;
				}
			}
			int num = Mathf.Max(0, EmpressPresentsYapYap.MinSpawnItems.Value);
			int num2 = Mathf.Max(num, EmpressPresentsYapYap.MaxSpawnItems.Value);
			int num3 = Random.Range(num, num2 + 1);
			if (num3 <= 0)
			{
				return;
			}
			for (int i = 0; i < num3; i++)
			{
				NetworkIdentity val = EmpressPresentsYapYap.LootTable[Random.Range(0, EmpressPresentsYapYap.LootTable.Count)];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Vector3 val2 = Random.insideUnitSphere * 0.7f;
				val2.y = Mathf.Abs(val2.y) * 0.3f;
				Vector3 val3 = at + val2 + Vector3.up * 0.25f;
				GameObject val4 = GameManager.SpawnNetworkPrefab(val, val3, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), true);
				if ((Object)(object)val4 != (Object)null)
				{
					Rigidbody componentInChildren = val4.GetComponentInChildren<Rigidbody>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.AddForce(Random.onUnitSphere * 3f, (ForceMode)1);
					}
				}
			}
		}

		private void OnClientSpawnMsg(PresentSpawnMsg msg)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(msg.id) && !_localPresents.ContainsKey(msg.id))
			{
				GameObject val = PresentLocal.BuildVisual(msg.id, msg.pos, msg.rot);
				_localPresents[msg.id] = val.GetComponent<PresentLocal>();
			}
		}

		private void OnClientDestroyMsg(PresentDestroyMsg msg)
		{
			if (!string.IsNullOrEmpty(msg.id) && _localPresents.TryGetValue(msg.id, out PresentLocal value) && (Object)(object)value != (Object)null)
			{
				_localPresents.Remove(msg.id);
				Object.Destroy((Object)(object)((Component)value).gameObject);
			}
		}

		private void OnClientOpenMsg(PresentOpenMsg msg)
		{
			if (_localPresents.TryGetValue(msg.id, out PresentLocal value) && (Object)(object)value != (Object)null)
			{
				value.PlayOpenAnimation();
			}
		}

		private void OnClientFxMsg(PresentFxMsg msg)
		{
			//IL_0055: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			if (msg.fx == 1)
			{
				if ((Object)(object)EmpressPresentsYapYap.CustomExplosionClip != (Object)null)
				{
					AudioSource.PlayClipAtPoint(EmpressPresentsYapYap.CustomExplosionClip, msg.pos, 1f);
				}
				else if (!string.IsNullOrEmpty(EmpressPresentsYapYap.ExplosionSfxPath.Value))
				{
					RuntimeManager.PlayOneShot(EmpressPresentsYapYap.ExplosionSfxPath.Value, msg.pos);
				}
			}
			Client_Pulse(msg.pos, (msg.fx == 1) ? 0.55f : 0.35f);
		}

		private void Client_Pulse(Vector3 pos, float scale)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003c: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
			obj.transform.position = pos + Vector3.up * 0.25f;
			obj.transform.localScale = Vector3.one * Mathf.Max(0.1f, scale);
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Object.Destroy((Object)(object)obj, 0.25f);
		}

		public void SendInteractRequest(string id)
		{
			if (NetworkClient.active)
			{
				PresentInteractMsg presentInteractMsg = default(PresentInteractMsg);
				presentInteractMsg.id = id;
				NetworkClient.Send<PresentInteractMsg>(presentInteractMsg, 0);
			}
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ConstantExpectedAttribute : Attribute
	{
		public object? Min { get; set; }

		public object? Max { get; set; }
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ExperimentalAttribute : Attribute
	{
		public string DiagnosticId { get; }

		public string? UrlFormat { get; set; }

		public ExperimentalAttribute(string diagnosticId)
		{
			DiagnosticId = diagnosticId;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullAttribute : Attribute
	{
		public string[] Members { get; }

		public MemberNotNullAttribute(string member)
		{
			Members = new string[1] { member };
		}

		public MemberNotNullAttribute(params string[] members)
		{
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
	[ExcludeFromCodeCoverage]
	internal sealed class MemberNotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public string[] Members { get; }

		public MemberNotNullWhenAttribute(bool returnValue, string member)
		{
			ReturnValue = returnValue;
			Members = new string[1] { member };
		}

		public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
		{
			ReturnValue = returnValue;
			Members = members;
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SetsRequiredMembersAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class StringSyntaxAttribute : Attribute
	{
		public const string CompositeFormat = "CompositeFormat";

		public const string DateOnlyFormat = "DateOnlyFormat";

		public const string DateTimeFormat = "DateTimeFormat";

		public const string EnumFormat = "EnumFormat";

		public const string GuidFormat = "GuidFormat";

		public const string Json = "Json";

		public const string NumericFormat = "NumericFormat";

		public const string Regex = "Regex";

		public const string TimeOnlyFormat = "TimeOnlyFormat";

		public const string TimeSpanFormat = "TimeSpanFormat";

		public const string Uri = "Uri";

		public const string Xml = "Xml";

		public string Syntax { get; }

		public object?[] Arguments { get; }

		public StringSyntaxAttribute(string syntax)
		{
			Syntax = syntax;
			Arguments = new object[0];
		}

		public StringSyntaxAttribute(string syntax, params object?[] arguments)
		{
			Syntax = syntax;
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class UnscopedRefAttribute : Attribute
	{
	}
}
namespace System.Runtime.Versioning
{
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresPreviewFeaturesAttribute : Attribute
	{
		public string? Message { get; }

		public string? Url { get; set; }

		public RequiresPreviewFeaturesAttribute()
		{
		}

		public RequiresPreviewFeaturesAttribute(string? message)
		{
			Message = message;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CallerArgumentExpressionAttribute : Attribute
	{
		public string ParameterName { get; }

		public CallerArgumentExpressionAttribute(string parameterName)
		{
			ParameterName = parameterName;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CollectionBuilderAttribute : Attribute
	{
		public Type BuilderType { get; }

		public string MethodName { get; }

		public CollectionBuilderAttribute(Type builderType, string methodName)
		{
			BuilderType = builderType;
			MethodName = methodName;
		}
	}
	[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class CompilerFeatureRequiredAttribute : Attribute
	{
		public const string RefStructs = "RefStructs";

		public const string RequiredMembers = "RequiredMembers";

		public string FeatureName { get; }

		public bool IsOptional { get; set; }

		public CompilerFeatureRequiredAttribute(string featureName)
		{
			FeatureName = featureName;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
	{
		public string[] Arguments { get; }

		public InterpolatedStringHandlerArgumentAttribute(string argument)
		{
			Arguments = new string[1] { argument };
		}

		public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
		{
			Arguments = arguments;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class InterpolatedStringHandlerAttribute : Attribute
	{
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal static class IsExternalInit
	{
	}
	[AttributeUsage(AttributeTargets.Method, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ModuleInitializerAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class OverloadResolutionPriorityAttribute : Attribute
	{
		public int Priority { get; }

		public OverloadResolutionPriorityAttribute(int priority)
		{
			Priority = priority;
		}
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class ParamCollectionAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiredMemberAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	[EditorBrowsable(EditorBrowsableState.Never)]
	[ExcludeFromCodeCoverage]
	internal sealed class RequiresLocationAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
	[ExcludeFromCodeCoverage]
	internal sealed class SkipLocalsInitAttribute : Attribute
	{
	}
}