Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Trick or Treat v1.3.7
Omniscye.YourMod.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; [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("Omniscye.YourMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c87e16f0670810358d8a18117f1d03abfbee70ad")] [assembly: AssemblyProduct("YourMod")] [assembly: AssemblyTitle("Omniscye.YourMod")] [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 TrickOrTreat { [BepInPlugin("Omniscye.TrickOrTreat", "TrickOrTreat", "1.0")] public class TrickOrTreat : BaseUnityPlugin { internal static TrickOrTreat Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: 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) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } } namespace Empress.TrickOrTreat { internal static class EnemyErrorSilencer { private sealed class FilteringUnityLogHandler : ILogHandler { private readonly ILogHandler _inner; private readonly Func<LogType, string, string, Exception, bool> _predicate; public FilteringUnityLogHandler(ILogHandler inner, Func<LogType, string, string, Exception, bool> predicate) { _inner = inner; _predicate = predicate; } public void LogFormat(LogType logType, Object context, string format, params object[] args) { //IL_0010: 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) string arg = SafeFormat(format, args); if (!_predicate(logType, arg, string.Empty, null)) { _inner.LogFormat(logType, context, format, args); } } public void LogException(Exception exception, Object context) { if (!_predicate((LogType)4, exception?.Message, exception?.StackTrace, exception)) { _inner.LogException(exception, context); } } private static string SafeFormat(string fmt, object[] args) { try { return (args == null || args.Length == 0) ? fmt : string.Format(fmt, args); } catch { return fmt; } } } private sealed class FilteringBepListener : ILogListener, IDisposable { private readonly ILogListener[] _inners; private readonly Func<LogLevel, object, bool> _predicate; public FilteringBepListener(ILogListener[] inners, Func<LogLevel, object, bool> predicate) { _inners = inners ?? Array.Empty<ILogListener>(); _predicate = predicate; } public void LogEvent(object sender, LogEventArgs eventArgs) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!_predicate(eventArgs.Level, eventArgs.Data)) { for (int i = 0; i < _inners.Length; i++) { _inners[i].LogEvent(sender, eventArgs); } } } public void Dispose() { for (int i = 0; i < _inners.Length; i++) { ((IDisposable)_inners[i]).Dispose(); } } } internal static bool Enabled = true; private static readonly string[] DefaultTokens = new string[10] { "Enemy", "AI", "NavMesh", "VisionTrigger", "StateIdle", "StateChase", "OnCollision", "Update (", "REPOLib.Modules.Enemies", "SpawnEnemy" }; private static bool _installed; private static ILogHandler _unityInner; private static ManualLogSource _log; internal static void Install(ManualLogSource logger, IEnumerable<string> extraTokens = null) { if (_installed) { return; } _installed = true; _log = logger; try { string[] tokens = ((extraTokens == null) ? DefaultTokens : DefaultTokens.Concat(extraTokens).ToArray()); _unityInner = Debug.unityLogger.logHandler; Debug.unityLogger.logHandler = (ILogHandler)(object)new FilteringUnityLogHandler(_unityInner, (LogType type, string msg, string st, Exception ex) => ShouldDrop(type, msg, st, ex, tokens)); ILogListener[] inners = Logger.Listeners.ToArray(); Logger.Listeners.Clear(); Logger.Listeners.Add((ILogListener)(object)new FilteringBepListener(inners, delegate(LogLevel level, object data) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if (!Enabled) { return false; } if ((level & 3) == 0) { return false; } string s = data?.ToString() ?? string.Empty; return tokens.Any((string t) => s.IndexOf(t, StringComparison.OrdinalIgnoreCase) >= 0); })); ManualLogSource log = _log; if (log != null) { log.LogInfo((object)"[Silencer] Enemy-related error spam will be filtered."); } } catch (Exception ex2) { ManualLogSource log2 = _log; if (log2 != null) { log2.LogWarning((object)("[Silencer] Failed to install: " + ex2.Message)); } } } private static bool ShouldDrop(LogType type, string message, string stackTrace, Exception exception, string[] tokens) { //IL_0028: 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_002d: Invalid comparison between Unknown and I4 if (!Enabled) { return false; } if ((int)type != 0 && (int)type != 4) { return false; } if (!string.IsNullOrEmpty(message) && tokens.Any((string t) => message.IndexOf(t, StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } if (!string.IsNullOrEmpty(stackTrace) && tokens.Any((string t) => stackTrace.IndexOf(t, StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } if (exception != null) { string es = exception.ToString(); if (tokens.Any((string t) => es.IndexOf(t, StringComparison.OrdinalIgnoreCase) >= 0)) { return true; } } return false; } } [BepInPlugin("empress.repo.trickortreat.pumpkins", "Empress Pumpkins (Press-E, Host-Synced)", "4.5.4")] public class TrickOrTreatPlugin : BaseUnityPlugin { public const string PluginGuid = "empress.repo.trickortreat.pumpkins"; public const string PluginName = "Empress Pumpkins (Press-E, Host-Synced)"; public const string PluginVersion = "4.5.4"; internal static TrickOrTreatPlugin Instance; internal static ManualLogSource LogSrc; internal static ConfigEntry<float> ExplosionChance; internal static ConfigEntry<int> MinSpawnItems; internal static ConfigEntry<int> MaxSpawnItems; internal static ConfigEntry<int> MinPumpkins; internal static ConfigEntry<int> MaxPumpkins; internal static ConfigEntry<bool> SkipStartRoom; private void Awake() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown Instance = this; LogSrc = ((BaseUnityPlugin)this).Logger; ExplosionChance = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "ExplosionChance", 0.2f, "Chance [0..1] to explode instead of spawn loot or enemies."); MinSpawnItems = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "MinSpawnItems", 1, "Minimum drops on treat (items + valuables)."); MaxSpawnItems = ((BaseUnityPlugin)this).Config.Bind<int>("Gameplay", "MaxSpawnItems", 6, "Maximum drops on treat (items + valuables)."); MinPumpkins = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MinPumpkins", 1, "Minimum pumpkins per level."); MaxPumpkins = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxPumpkins", 3, "Maximum pumpkins per level."); SkipStartRoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawning", "SkipStartRoom", true, "Skip points closest to the truck."); GameObject val = new GameObject("Empress_Pumpkins_Host"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; val.AddComponent<PumpkinEventRouter>(); } internal static bool IsHostOrOffline() { return !PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient; } internal static bool IsHost() { return PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient; } internal static bool IsOffline() { return !PhotonNetwork.InRoom; } internal static void HostSpawnPumpkins() { //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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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) try { LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated) { return; } List<LevelPoint> list = ((instance.LevelPathPoints != null) ? instance.LevelPathPoints.Where((LevelPoint p) => (Object)(object)p != (Object)null).ToList() : new List<LevelPoint>()); if (list.Count == 0) { return; } if (SkipStartRoom.Value && (Object)(object)instance.LevelPathTruck != (Object)null) { Vector3 truckPos = ((Component)instance.LevelPathTruck).transform.position; list = list.OrderBy((LevelPoint p) => Vector3.Distance(truckPos, ((Component)p).transform.position)).Skip(3).ToList(); if (list.Count == 0) { list = instance.LevelPathPoints.Where((LevelPoint p) => (Object)(object)p != (Object)null).ToList(); } } int num = Mathf.Clamp(MinPumpkins.Value, 0, 1000); int num2 = Mathf.Max(num, MaxPumpkins.Value); int num3 = Random.Range(num, num2 + 1); num3 = Mathf.Min(num3, list.Count); Random rng = new Random((int)(DateTime.UtcNow.Ticks & 0x7FFFFFF)); List<LevelPoint> list2 = list.OrderBy((LevelPoint _) => rng.Next()).Take(num3).ToList(); foreach (LevelPoint item in list2) { Vector3 val = ((Component)item).transform.position + Vector3.up * 0.25f; Quaternion rotation = ((Component)item).transform.rotation; string text = Guid.NewGuid().ToString("N"); PumpkinEventRouter.CreateLocalPumpkin(text, val, rotation, announce: false); PumpkinEventRouter.Raise(PumpkinEventRouter.Ev.Create, new object[3] { text, val, rotation }, (ReceiverGroup)0); } } catch { } } internal static void HostResolveInteraction(string id, Vector3 at) { //IL_00ca: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) PumpkinEventRouter.Ev code = PumpkinEventRouter.Ev.TreatFX; try { if (Random.value < Mathf.Clamp01(ExplosionChance.Value)) { code = PumpkinEventRouter.Ev.ExplodeFX; PumpkinEventRouter.PlayFXLocal(PumpkinEventRouter.Ev.ExplodeFX, at); return; } code = PumpkinEventRouter.Ev.TreatFX; PumpkinEventRouter.PlayFXLocal(PumpkinEventRouter.Ev.TreatFX, at); BuildMixedSpawnPayload(out var items, out var valuables, out var _); bool flag = false; if (items != null && items.Length != 0) { HostSpawnItems(items, at); flag = true; } if (valuables != null && valuables.Length != 0) { HostSpawnValuables(valuables, at); flag = true; } if (!flag) { code = PumpkinEventRouter.Ev.ExplodeFX; PumpkinEventRouter.PlayFXLocal(PumpkinEventRouter.Ev.ExplodeFX, at); } } catch (Exception arg) { LogSrc.LogError((object)$"[Pumpkins] HostResolveInteraction fatal: {arg}"); } finally { try { PumpkinEventRouter.Raise(code, at, (ReceiverGroup)0); } catch { } try { PumpkinEventRouter.LocalDestroy(id); } catch { } try { PumpkinEventRouter.Raise(PumpkinEventRouter.Ev.Destroy, id, (ReceiverGroup)0); } catch { } } } private static void BuildMixedSpawnPayload(out Item[] items, out PrefabRef[] valuables, out int count) { items = Array.Empty<Item>(); valuables = Array.Empty<PrefabRef>(); count = Random.Range(Mathf.Max(1, MinSpawnItems.Value), Mathf.Max(MinSpawnItems.Value, MaxSpawnItems.Value) + 1); if (count <= 0) { return; } List<Item> list = BuildItemPool(); List<PrefabRef> list2 = BuildValuablePool(); if (list.Count == 0 && list2.Count == 0) { return; } Random random = new Random((int)(DateTime.UtcNow.Ticks & 0x7FFFFFFF)); List<Item> list3 = new List<Item>(count); List<PrefabRef> list4 = new List<PrefabRef>(count); for (int i = 0; i < count; i++) { bool flag = list.Count > 0; bool flag2 = list2.Count > 0; if (flag && flag2) { if (random.NextDouble() < 0.5) { list3.Add(list[random.Next(list.Count)]); } else { list4.Add(list2[random.Next(list2.Count)]); } } else if (flag) { list3.Add(list[random.Next(list.Count)]); } else { list4.Add(list2[random.Next(list2.Count)]); } } items = list3.ToArray(); valuables = list4.ToArray(); } private static List<Item> BuildItemPool() { try { List<Item> list = new List<Item>(); ShopManager instance = ShopManager.instance; if ((Object)(object)instance != (Object)null) { if (instance.potentialItems != null) { list.AddRange(instance.potentialItems); } if (instance.potentialItemConsumables != null) { list.AddRange(instance.potentialItemConsumables); } if (instance.potentialItemUpgrades != null) { list.AddRange(instance.potentialItemUpgrades); } } if (list.Count == 0 && (Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary != null) { list.AddRange(StatsManager.instance.itemDictionary.Values); } return list.Where((Item i) => (Object)(object)i != (Object)null && i.prefab != null && i.prefab.IsValid()).Distinct().ToList(); } catch { return new List<Item>(); } } private static List<PrefabRef> BuildValuablePool() { try { List<PrefabRef> list = new List<PrefabRef>(); LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.Level == (Object)null || instance.Level.ValuablePresets == null) { return list; } foreach (LevelValuables valuablePreset in instance.Level.ValuablePresets) { if (!((Object)(object)valuablePreset == (Object)null)) { if (valuablePreset.tiny != null) { list.AddRange(valuablePreset.tiny); } if (valuablePreset.small != null) { list.AddRange(valuablePreset.small); } if (valuablePreset.medium != null) { list.AddRange(valuablePreset.medium); } if (valuablePreset.big != null) { list.AddRange(valuablePreset.big); } if (valuablePreset.wide != null) { list.AddRange(valuablePreset.wide); } if (valuablePreset.tall != null) { list.AddRange(valuablePreset.tall); } if (valuablePreset.veryTall != null) { list.AddRange(valuablePreset.veryTall); } } } return list.Where((PrefabRef v) => v != null && v.IsValid() && ((Object)(object)v.Prefab != (Object)null || !string.IsNullOrEmpty(v.ResourcePath))).Distinct().ToList(); } catch { return new List<PrefabRef>(); } } private static void HostSpawnItems(Item[] items, Vector3 center) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrOffline() || items == null || items.Length == 0) { return; } Quaternion val = Quaternion.identity; try { if ((Object)(object)ShopManager.instance != (Object)null) { Transform itemRotateHelper = ShopManager.instance.itemRotateHelper; if ((Object)(object)itemRotateHelper != (Object)null) { ((Component)itemRotateHelper).transform.parent = null; val = ((Component)itemRotateHelper).transform.rotation; } } } catch { } Vector3 val2 = center + Vector3.up * 0.35f; foreach (Item val3 in items) { try { if ((Object)(object)val3 == (Object)null || val3.prefab == null || !val3.prefab.IsValid()) { continue; } string resourcePath = val3.prefab.ResourcePath; GameObject prefab = val3.prefab.Prefab; Vector3 val4 = val2 + Random.insideUnitSphere * 0.4f; if (IsHost()) { PhotonNetwork.Instantiate(resourcePath, val4, val, (byte)0, (object[])null); } else { if (!IsOffline()) { continue; } if ((Object)(object)prefab != (Object)null) { Object.Instantiate<GameObject>(prefab, val4, val); continue; } GameObject val5 = Resources.Load<GameObject>(resourcePath); if ((Object)(object)val5 != (Object)null) { Object.Instantiate<GameObject>(val5, val4, val); } continue; } } catch { } } } private static void HostSpawnValuables(PrefabRef[] valuables, Vector3 center) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (!IsHostOrOffline() || valuables == null || valuables.Length == 0) { return; } Quaternion val = Quaternion.identity; try { if ((Object)(object)ShopManager.instance != (Object)null) { Transform itemRotateHelper = ShopManager.instance.itemRotateHelper; if ((Object)(object)itemRotateHelper != (Object)null) { ((Component)itemRotateHelper).transform.parent = null; val = ((Component)itemRotateHelper).transform.rotation; } } } catch { } Vector3 val2 = center + Vector3.up * 0.35f; foreach (PrefabRef val3 in valuables) { try { if (val3 == null || !val3.IsValid()) { continue; } string resourcePath = val3.ResourcePath; GameObject prefab = val3.Prefab; Vector3 val4 = val2 + Random.insideUnitSphere * 0.4f; if (IsHost()) { PhotonNetwork.Instantiate(resourcePath, val4, val, (byte)0, (object[])null); } else { if (!IsOffline()) { continue; } if ((Object)(object)prefab != (Object)null) { Object.Instantiate<GameObject>(prefab, val4, val); continue; } GameObject val5 = Resources.Load<GameObject>(resourcePath); if ((Object)(object)val5 != (Object)null) { Object.Instantiate<GameObject>(val5, val4, val); } continue; } } catch { } } } } public class PumpkinEventRouter : MonoBehaviourPunCallbacks, IOnEventCallback { public enum Ev : byte { Create = 61, Interact, TreatFX, ExplodeFX, Destroy } [CompilerGenerated] private sealed class <WaitLevelThenSpawn>d__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PumpkinEventRouter <>4__this; private float <t>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitLevelThenSpawn>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; _spawnRoutineRunning = true; <t>5__1 = 0f; break; case 1: <>1__state = -1; break; } if (((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) && <t>5__1 < 20f) { <t>5__1 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } if (TrickOrTreatPlugin.IsHostOrOffline() && !_spawnedThisScene) { TrickOrTreatPlugin.HostSpawnPumpkins(); _spawnedThisScene = true; } _spawnRoutineRunning = 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 static readonly Dictionary<string, GameObject> Active = new Dictionary<string, GameObject>(); private static bool _spawnRoutineRunning; private static bool _spawnedThisScene; private static string _loadedSceneName; private bool _callbackHooked; private void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; if (_callbackHooked) { PhotonNetwork.RemoveCallbackTarget((object)this); } _callbackHooked = false; } public override void OnJoinedRoom() { EnsureCallbackHooked(); } public override void OnLeftRoom() { if (_callbackHooked) { PhotonNetwork.RemoveCallbackTarget((object)this); _callbackHooked = false; } _spawnRoutineRunning = false; _spawnedThisScene = false; Active.Clear(); } private void EnsureCallbackHooked() { if (!_callbackHooked) { PhotonNetwork.AddCallbackTarget((object)this); _callbackHooked = true; } } private void OnSceneLoaded(Scene s, LoadSceneMode m) { _loadedSceneName = ((Scene)(ref s)).name ?? string.Empty; _spawnRoutineRunning = false; _spawnedThisScene = false; Active.Clear(); EnsureCallbackHooked(); if (PhotonNetwork.InRoom) { TrySpawnIfRealLevel(); } } private void TrySpawnIfRealLevel() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); string text = ((Scene)(ref activeScene)).name ?? ""; if (text.IndexOf("Lobby", StringComparison.OrdinalIgnoreCase) < 0 && (PhotonNetwork.InRoom || !PhotonNetwork.IsConnected) && !_spawnRoutineRunning && !_spawnedThisScene) { ((MonoBehaviour)this).StartCoroutine(WaitLevelThenSpawn()); } } [IteratorStateMachine(typeof(<WaitLevelThenSpawn>d__13))] private IEnumerator WaitLevelThenSpawn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitLevelThenSpawn>d__13(0) { <>4__this = this }; } internal static void PlayFXLocal(Ev code, Vector3 pos) { //IL_0014: 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) try { switch (code) { case Ev.TreatFX: TrickPumpkin.SpawnExplosionPrefab(pos, 0.5f, 0, 0, 0f, disableSound: true, 0f); break; case Ev.ExplodeFX: TrickPumpkin.SpawnExplosionPrefab(pos, 1.2f, 75, 160, 4f, disableSound: false, 1f); break; } } catch { } } internal static void LocalDestroy(string id) { try { if (!string.IsNullOrEmpty(id)) { if (Active.TryGetValue(id, out var value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } Active.Remove(id); } } catch { } } public static void Raise(Ev code, object payload, ReceiverGroup receivers) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0020: 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_002f: Expected O, but got Unknown //IL_005e: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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) if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)code, payload, new RaiseEventOptions { Receivers = receivers }, SendOptions.SendReliable); return; } try { switch (code) { case Ev.TreatFX: TrickPumpkin.SpawnExplosionPrefab((Vector3)payload, 0.5f, 0, 0, 0f, disableSound: true, 0f); break; case Ev.ExplodeFX: TrickPumpkin.SpawnExplosionPrefab((Vector3)payload, 1.2f, 75, 160, 4f, disableSound: false, 1f); break; case Ev.Destroy: { string id2 = payload as string; LocalDestroy(id2); break; } case Ev.Create: if (payload is object[] array && array.Length >= 3) { string id = array[0] as string; Vector3 pos = (Vector3)array[1]; Quaternion rot = (Quaternion)array[2]; CreateLocalPumpkin(id, pos, rot, announce: false); } break; case Ev.Interact: break; } } catch { } } public static void CreateLocalPumpkin(string id, Vector3 pos, Quaternion rot, bool announce) { //IL_0014: 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) try { if (!Active.ContainsKey(id)) { GameObject value = PumpkinPrefabBuilder.Build(id, pos, rot); Active[id] = value; } } catch { } } public void OnEvent(EventData photonEvent) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) try { switch ((Ev)photonEvent.Code) { case Ev.Create: if (photonEvent.CustomData is object[] array2 && array2.Length >= 3) { string id3 = array2[0] as string; Vector3 pos3 = (Vector3)array2[1]; Quaternion rot = (Quaternion)array2[2]; if (!TrickOrTreatPlugin.IsHost()) { CreateLocalPumpkin(id3, pos3, rot, announce: true); } } break; case Ev.Interact: if (TrickOrTreatPlugin.IsHostOrOffline() && photonEvent.CustomData is object[] array && array.Length >= 2) { string id2 = array[0] as string; Vector3 at = (Vector3)array[1]; TrickOrTreatPlugin.HostResolveInteraction(id2, at); } break; case Ev.TreatFX: { Vector3 pos2 = (Vector3)photonEvent.CustomData; PlayFXLocal(Ev.TreatFX, pos2); break; } case Ev.ExplodeFX: { Vector3 pos = (Vector3)photonEvent.CustomData; PlayFXLocal(Ev.ExplodeFX, pos); break; } case Ev.Destroy: { string id = photonEvent.CustomData as string; LocalDestroy(id); break; } } } catch { } } public static void RequestInteract(string id, Vector3 at) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (TrickOrTreatPlugin.IsHostOrOffline()) { TrickOrTreatPlugin.HostResolveInteraction(id, at); return; } Raise(Ev.Interact, new object[2] { id, at }, (ReceiverGroup)2); } } public static class PumpkinPrefabBuilder { public static GameObject Build(string id, Vector3 pos, Quaternion rot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_007f: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos + Vector3.up * 0.5f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.down, ref val2, 2f, -1, (QueryTriggerInteraction)1)) { val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.05f; rot = Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val2)).normal) * rot; } GameObject val3 = new GameObject("EmpressPumpkin_" + id); val3.transform.position = val; val3.transform.rotation = rot; Rigidbody val4 = val3.AddComponent<Rigidbody>(); val4.useGravity = false; val4.isKinematic = false; val4.collisionDetectionMode = (CollisionDetectionMode)0; val4.interpolation = (RigidbodyInterpolation)0; val4.constraints = (RigidbodyConstraints)126; GameObject val5 = new GameObject("InteractCollider"); val5.transform.SetParent(val3.transform, false); BoxCollider val6 = val5.AddComponent<BoxCollider>(); val6.size = new Vector3(0.45f, 0.35f, 0.45f); val6.center = new Vector3(0f, 0.175f, 0f); ((Collider)val6).isTrigger = true; val3.AddComponent<PumpkinVisualBinder>(); TrickPumpkin trickPumpkin = val3.AddComponent<TrickPumpkin>(); trickPumpkin.Id = id; return val3; } } public class PumpkinVisualBinder : MonoBehaviour { private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = TrickAssetLoader.LoadTreatPrefab(); if ((Object)(object)val != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, ((Component)this).transform.rotation); val2.transform.SetParent(((Component)this).transform, true); } } catch { } } } public class TrickPumpkin : MonoBehaviour { [CompilerGenerated] private sealed class <Start>d__12 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TrickPumpkin <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Start>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this._armed = true; 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 string Id; private bool _armed; private float _nextUse; private readonly float _cooldown = 0.6f; private readonly float _useRange = 2f; private static FieldRef<ParticlePrefabExplosion, float> _fExplosionSize; private static FieldRef<ParticlePrefabExplosion, int> _fExplosionDamage; private static FieldRef<ParticlePrefabExplosion, int> _fExplosionDamageEnemy; private static bool _fieldRefsReady; private static bool _fieldRefsFailed; private static void EnsureFieldRefs() { if (_fieldRefsReady || _fieldRefsFailed) { return; } try { _fExplosionSize = AccessTools.FieldRefAccess<ParticlePrefabExplosion, float>("explosionSize"); _fExplosionDamage = AccessTools.FieldRefAccess<ParticlePrefabExplosion, int>("explosionDamage"); _fExplosionDamageEnemy = AccessTools.FieldRefAccess<ParticlePrefabExplosion, int>("explosionDamageEnemy"); _fieldRefsReady = true; } catch { _fieldRefsFailed = true; } } private static void TrySetFieldReflect<T>(object target, string fieldName, T value) { if (target == null) { return; } try { FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType.IsAssignableFrom(typeof(T))) { field.SetValue(target, value); } } catch { } } [IteratorStateMachine(typeof(<Start>d__12))] private IEnumerator Start() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Start>d__12(0) { <>4__this = this }; } private void Update() { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (!_armed || string.IsNullOrEmpty(Id) || Time.time < _nextUse) { return; } PlayerController instance = PlayerController.instance; Vector3 position; if ((Object)(object)instance != (Object)null) { position = ((Component)instance).transform.position; } else { if (!((Object)(object)Camera.main != (Object)null)) { return; } position = ((Component)Camera.main).transform.position; } float num = Vector3.Distance(position, ((Component)this).transform.position); if (num > _useRange) { return; } SemiFunc.UIFocusText("Press <color=yellow>E</color> to open", Color.white, Color.yellow, 3f); if (!SemiFunc.InputDown((InputKey)2)) { return; } _nextUse = Time.time + _cooldown; _armed = false; try { Transform obj = ((Component)this).transform.Find("InteractCollider"); Collider val = ((obj != null) ? ((Component)obj).GetComponent<Collider>() : null); if ((Object)(object)val != (Object)null) { val.enabled = false; } } catch { } PumpkinEventRouter.RequestInteract(Id, ((Component)this).transform.position); } public static bool SpawnExplosionPrefab(Vector3 pos, float size, int damage, int enemyDamage, float forceMulti, bool disableSound, float shakeMultiplier) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = Resources.Load<GameObject>("Effects/Part Prefab Explosion"); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate<GameObject>(val, pos, Quaternion.identity); ParticlePrefabExplosion component = val2.GetComponent<ParticlePrefabExplosion>(); if ((Object)(object)component != (Object)null) { EnsureFieldRefs(); float num = Mathf.Max(0.01f, size); int num2 = Mathf.Max(0, damage); int num3 = Mathf.Max(0, enemyDamage); float forceMultiplier = Mathf.Max(0f, forceMulti); if (_fieldRefsReady) { try { _fExplosionSize.Invoke(component) = num; _fExplosionDamage.Invoke(component) = num2; _fExplosionDamageEnemy.Invoke(component) = num3; } catch { TrySetFieldReflect(component, "explosionSize", num); TrySetFieldReflect(component, "explosionDamage", num2); TrySetFieldReflect(component, "explosionDamageEnemy", num3); } } else { TrySetFieldReflect(component, "explosionSize", num); TrySetFieldReflect(component, "explosionDamage", num2); TrySetFieldReflect(component, "explosionDamageEnemy", num3); } component.forceMultiplier = forceMultiplier; if (disableSound) { try { AudioSource[] componentsInChildren = val2.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val3 in componentsInChildren) { val3.mute = true; } } catch { } } } return true; } catch { return false; } } } 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 directoryName = Path.GetDirectoryName(typeof(TrickOrTreatPlugin).Assembly.Location); string text = Path.Combine(directoryName, "trick"); string text2 = Path.Combine(directoryName, "Empress", "trick"); string text3 = (File.Exists(text) ? text : text2); if (!File.Exists(text3)) { return null; } _bundle = AssetBundle.LoadFromFile(text3); if ((Object)(object)_bundle == (Object)null) { return null; } } _cachedTreat = _bundle.LoadAsset<GameObject>("treat"); return _cachedTreat; } catch { return null; } } } }