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 Pacman Gamemode v1.0.1
EmpressGhosts.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressGhosts")] [assembly: AssemblyTitle("EmpressGhosts")] [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 EmpressMods.GhostizePlayersOnly { [BepInPlugin("com.empress.repo.ghostize_players", "GhostizePlayersOnly", "1.0.0")] public class GhostizePlugin : BaseUnityPlugin { public const string PluginGuid = "com.empress.repo.ghostize_players"; public const string PluginName = "GhostizePlayersOnly"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log = null; internal static Harmony Harmony = null; internal static AssetBundle Bundle; internal static readonly GameObject[] Avatars = (GameObject[])(object)new GameObject[6]; internal const bool ReplaceMenuAvatarsToo = true; internal const bool HideLocalInGameplay = true; internal const float PlayerYOffset = 0.9f; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("com.empress.repo.ghostize_players"); try { Harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"GhostizePlayersOnly 1.0.0 loaded. Players only—no enemies, no nonsense."); } catch (Exception arg) { Log.LogError((object)$"Harmony patching failed: {arg}"); } } private void OnDestroy() { try { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } internal static bool EnsureBundle() { if ((Object)(object)Bundle != (Object)null && (Object)(object)Avatars[0] != (Object)null) { return true; } try { string location = Assembly.GetExecutingAssembly().Location; string text = Path.GetDirectoryName(location) ?? "."; string text2 = Path.Combine(text, "ghosts"); if ((Object)(object)Bundle == (Object)null) { if (File.Exists(text2)) { Bundle = AssetBundle.LoadFromFile(text2); } else { string[] files = Directory.GetFiles(text, "ghosts.*", SearchOption.TopDirectoryOnly); string[] array = files; foreach (string text3 in array) { Bundle = AssetBundle.LoadFromFile(text3); if ((Object)(object)Bundle != (Object)null) { Log.LogInfo((object)("[Ghosts] Loaded bundle '" + Path.GetFileName(text3) + "'.")); break; } } } } if ((Object)(object)Bundle == (Object)null) { Log.LogError((object)"[Ghosts] Could not load AssetBundle 'ghosts' (or ghosts.*). Place it next to the DLL."); return false; } string[] allAssetNames = Bundle.GetAllAssetNames(); if (allAssetNames == null || allAssetNames.Length == 0) { Log.LogError((object)"[Ghosts] Bundle is empty."); return false; } for (int j = 0; j < 6; j++) { string text4 = $"avatar{j + 1}"; GameObject val = null; try { val = Bundle.LoadAsset<GameObject>(text4); } catch { } if ((Object)(object)val == (Object)null) { string[] array2 = allAssetNames; foreach (string text5 in array2) { string text6 = Path.GetFileNameWithoutExtension(text5)?.ToLowerInvariant(); if (text6 == text4) { try { val = Bundle.LoadAsset<GameObject>(text5); } catch { } if ((Object)(object)val != (Object)null) { break; } } } } if ((Object)(object)val == (Object)null) { Log.LogError((object)("[Ghosts] Missing prefab '" + text4 + "' in bundle.")); return false; } Avatars[j] = val; } Log.LogInfo((object)"[Ghosts] Loaded avatar1..avatar6."); return true; } catch (Exception arg) { Log.LogError((object)$"[Ghosts] Error loading bundle: {arg}"); return false; } } internal static void DisableAllRenderers(GameObject root) { if (Object.op_Implicit((Object)(object)root)) { Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } internal static int PickIndexForActor(PhotonView pv) { int num = 1; try { num = ((!((Object)(object)pv != (Object)null) || pv.OwnerActorNr <= 0) ? 1 : pv.OwnerActorNr); } catch { num = 1; } return (num - 1) % 6; } } public sealed class GhostMarker : MonoBehaviour { } [HarmonyPatch(typeof(PlayerAvatarVisuals), "Start")] public static class PlayerAvatarVisuals_Start_Patch { private static void Postfix(PlayerAvatarVisuals __instance) { //IL_0082: 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_008b: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) try { if (!GhostizePlugin.EnsureBundle()) { return; } bool isMenuAvatar = __instance.isMenuAvatar; bool flag = false; if ((Object)(object)((Component)((Component)__instance).transform).GetComponentInChildren<GhostMarker>(true) != (Object)null) { return; } float num = 0f; Bounds bounds; if ((Object)(object)__instance.meshParent != (Object)null) { Renderer[] componentsInChildren = __instance.meshParent.GetComponentsInChildren<Renderer>(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { bounds = componentsInChildren[0].bounds; Vector3 center = ((Bounds)(ref bounds)).center; bounds = componentsInChildren[0].bounds; Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(center, ((Bounds)(ref bounds)).size); for (int i = 1; i < componentsInChildren.Length; i++) { ((Bounds)(ref val)).Encapsulate(componentsInChildren[i].bounds); } num = ((Bounds)(ref val)).size.y; } GhostizePlugin.DisableAllRenderers(__instance.meshParent); if (!__instance.meshParent.activeSelf) { __instance.meshParent.SetActive(true); } } PhotonView val2 = (((Object)(object)__instance.playerAvatar != (Object)null) ? __instance.playerAvatar.photonView : null); int num2 = GhostizePlugin.PickIndexForActor(val2); GameObject val3 = ((num2 >= 0 && num2 < GhostizePlugin.Avatars.Length) ? GhostizePlugin.Avatars[num2] : null); if ((Object)(object)val3 == (Object)null) { GhostizePlugin.Log.LogError((object)"[Ghosts] Prefab selection failed."); return; } GameObject val4 = Object.Instantiate<GameObject>(val3, ((Object)(object)__instance.meshParent != (Object)null) ? __instance.meshParent.transform : ((Component)__instance).transform); ((Object)val4).name = $"Empress_Ghost_{num2 + 1}"; Transform transform = val4.transform; transform.localPosition = Vector3.up * 0.9f; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; float num3 = 0f; Renderer[] componentsInChildren2 = val4.GetComponentsInChildren<Renderer>(true); if (componentsInChildren2 != null && componentsInChildren2.Length != 0) { bounds = componentsInChildren2[0].bounds; Vector3 center2 = ((Bounds)(ref bounds)).center; bounds = componentsInChildren2[0].bounds; Bounds val5 = default(Bounds); ((Bounds)(ref val5))..ctor(center2, ((Bounds)(ref bounds)).size); for (int j = 1; j < componentsInChildren2.Length; j++) { ((Bounds)(ref val5)).Encapsulate(componentsInChildren2[j].bounds); } num3 = ((Bounds)(ref val5)).size.y; } if (num > 0f && num3 > 0f) { float num4 = num / num3; transform.localScale *= num4; } val4.AddComponent<GhostMarker>(); bool flag2 = !((Object)(object)val2 != (Object)null) || !val2.IsMine || isMenuAvatar; Renderer[] array = componentsInChildren2; foreach (Renderer val6 in array) { val6.enabled = flag2; } if (!flag2) { GhostizePlugin.Log.LogDebug((object)"[Ghosts] Hid local player's ghost (camera safety)."); } } catch (Exception ex) { GhostizePlugin.Log.LogWarning((object)("[Ghosts] Player replacement failed: " + ex)); } } } }
EmpressPacman.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Empress.KittyCurse; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.AI; 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")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmpressPacman")] [assembly: AssemblyTitle("EmpressPacman")] [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 Empress.Pacman { public class PacDot : MonoBehaviour { private int _id; private bool _collected; public void Init(int id) { _id = id; } private void OnTriggerEnter(Collider other) { if (_collected) { return; } PlayerAvatar val = ((Component)other).GetComponentInParent<PlayerAvatar>(); if (!Object.op_Implicit((Object)(object)val)) { PlayerController componentInParent = ((Component)other).GetComponentInParent<PlayerController>(); if (Object.op_Implicit((Object)(object)componentInParent)) { val = componentInParent.playerAvatarScript; } } if (Object.op_Implicit((Object)(object)val)) { _collected = true; PacmanEventRouter.BroadcastDotCollected(_id); } } } public static class PacDotsManager { private class DotHost : MonoBehaviour { } [CompilerGenerated] private sealed class <DelayedWin>d__12 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedWin>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; PacmanPlugin.AdvanceLevelOrWinRound(); 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<int, GameObject> _dots = new Dictionary<int, GameObject>(); private static int _nextId; private static bool _built; private static Material _mat; public static int RemainingDots => _dots.Count; public static int TotalDots { get; private set; } public static void CreateOrRebuild(float spacing, float scale, int layer, bool usePathPoints) { ClearAll(); _nextId = 0; TotalDots = 0; try { if (usePathPoints) { BuildFromPathPoints(spacing, scale, layer); } else { BuildAroundTruck(spacing, scale, layer); } _built = true; TotalDots = _dots.Count; ManualLogSource log = PacmanPlugin.Log; if (log != null) { log.LogInfo((object)$"[PacDots] Built {_dots.Count} reachable dots."); } } catch (Exception arg) { ManualLogSource log2 = PacmanPlugin.Log; if (log2 != null) { log2.LogError((object)$"PacDots build failed: {arg}"); } } } public static void LocalDotCollected(int dotId) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) if (_dots.TryGetValue(dotId, out GameObject value)) { Vector3 position = value.transform.position; Object.Destroy((Object)(object)value); _dots.Remove(dotId); if (Object.op_Implicit((Object)(object)PacmanPlugin.DotCollectClip)) { AudioSource.PlayClipAtPoint(PacmanPlugin.DotCollectClip, position, PacmanPlugin.DotCollectVolume.Value); } if (_dots.Count <= 0 && KittyManager.IsAuthority()) { PacmanEventRouter.BroadcastRoundWin(); DotHost dotHost = EnsureHost(); ((MonoBehaviour)dotHost).StartCoroutine(DelayedWin((PacmanPlugin.Log != null) ? PacmanPlugin.WinSwitchDelay.Value : 1f)); } } } [IteratorStateMachine(typeof(<DelayedWin>d__12))] private static IEnumerator DelayedWin(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedWin>d__12(0) { delay = delay }; } private static void ClearAll() { foreach (KeyValuePair<int, GameObject> dot in _dots) { if (Object.op_Implicit((Object)(object)dot.Value)) { Object.Destroy((Object)(object)dot.Value); } } _dots.Clear(); } private static void BuildFromPathPoints(float spacing, float scale, int layer) { //IL_007c: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d0: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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) LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || !instance.Generated || instance.LevelPathPoints == null || instance.LevelPathPoints.Count == 0) { return; } Vector3? val = null; float num = 0f; for (int i = 0; i < instance.LevelPathPoints.Count; i++) { LevelPoint val2 = instance.LevelPathPoints[i]; if (!Object.op_Implicit((Object)(object)val2)) { continue; } Vector3 position = ((Component)val2).transform.position; if (!val.HasValue) { TrySpawnDot(position, scale, layer); val = position; continue; } float num2 = Vector3.Distance(val.Value, position) + num; Vector3 val3 = position - val.Value; Vector3 normalized = ((Vector3)(ref val3)).normalized; float num3 = num2; float num4 = spacing - num; while (num3 >= spacing) { Vector3 position2 = val.Value + normalized * num4; TrySpawnDot(position2, scale, layer); num4 += spacing; num3 -= spacing; } num = num3; val = position; } } private static void BuildAroundTruck(float spacing, float scale, int layer) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) LevelGenerator instance = LevelGenerator.Instance; if (!((Object)(object)instance == (Object)null) && instance.Generated && !((Object)(object)instance.LevelPathTruck == (Object)null)) { Vector3 position = ((Component)instance.LevelPathTruck).transform.position; for (float num = 0f; num < 360f; num += 10f) { Vector3 val = Quaternion.Euler(0f, num, 0f) * Vector3.forward; Vector3 position2 = position + val * spacing * 2f; TrySpawnDot(position2, scale, layer); } } } private static void TrySpawnDot(Vector3 position, float scale, int layer) { //IL_0001: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0084: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 0.6f, -1)) { position = ((NavMeshHit)(ref val)).position; GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val2).name = $"pacdot_{_nextId}"; val2.layer = layer; val2.transform.position = position + Vector3.up * 0.7f; float num = Mathf.Max(0.05f, scale); val2.transform.localScale = Vector3.one * num; SphereCollider component = val2.GetComponent<SphereCollider>(); if (Object.op_Implicit((Object)(object)component)) { ((Collider)component).isTrigger = true; component.radius = 1.2f / num; } Rigidbody val3 = val2.AddComponent<Rigidbody>(); val3.isKinematic = true; val3.useGravity = false; if ((Object)(object)_mat == (Object)null) { Shader val4 = Shader.Find("Standard"); _mat = new Material(val4); _mat.color = Color.cyan; _mat.EnableKeyword("_EMISSION"); _mat.SetColor("_EmissionColor", new Color(0.1f, 0.4f, 1f, 1f)); } Renderer component2 = val2.GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component2)) { component2.sharedMaterial = _mat; } val2.AddComponent<PacDot>().Init(_nextId); _dots[_nextId] = val2; _nextId++; } } private static DotHost EnsureHost() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown DotHost dotHost = Object.FindObjectOfType<DotHost>(); if (!Object.op_Implicit((Object)(object)dotHost)) { GameObject val = new GameObject("PacDots_Host"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; dotHost = val.AddComponent<DotHost>(); } return dotHost; } } [BepInPlugin("empress.repo.pacman.blockspawns", "PacmanBlockEnemySpawns", "1.0.1")] public class PacmanBlockEnemySpawns : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony _h = null; private void Awake() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; _h = new Harmony("empress.repo.pacman.blockspawns"); _h.PatchAll(); Log.LogInfo((object)"[PacmanBlockEnemySpawns] loaded"); } private void OnDestroy() { Harmony h = _h; if (h != null) { h.UnpatchSelf(); } } } [HarmonyPatch] internal static class Patch_LevelGenerator_EnemySetup { [CompilerGenerated] private sealed class <Empty>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Empty>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>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(); } } private static MethodBase TargetMethod() { return AccessTools.Method(typeof(LevelGenerator), "EnemySetup", (Type[])null, (Type[])null); } private static bool Prefix(ref IEnumerator __result) { __result = Empty(); return false; } [IteratorStateMachine(typeof(<Empty>d__2))] private static IEnumerator Empty() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Empty>d__2(0); } } [RequireComponent(typeof(NavMeshAgent))] [DisallowMultipleComponent] public class PacmanController : MonoBehaviour { public static PacmanController Instance; private NavMeshAgent _agent; private LayerMask _visionMask; private PlayerAvatar _target; private float _poseSendTimer; private const float PoseSendInterval = 0.2f; private Vector3 _netPos; private Quaternion _netRot; private bool _hasNetPose; private const float PoseSnapDist = 5f; private const float PoseLerpRate = 10f; private float _repathTimer; private Transform[] _levelPoints; private Transform _nextPatrol; private Animator _anim; private Vector3 _animLastPos; private bool _hasWalkBool; private AudioSource _moveLoop; private float _scaredTimer; public void Setup(LayerMask visionMask) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) _visionMask = visionMask; } public void Scare(float duration) { _scaredTimer = duration; } private void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Instance = this; _agent = ((Component)this).GetComponent<NavMeshAgent>(); if (Object.op_Implicit((Object)(object)_agent)) { _agent.stoppingDistance = 1.2f; _agent.speed = 3.6f; _agent.acceleration = 10f; _agent.angularSpeed = 540f; } _anim = ((Component)this).GetComponent<Animator>(); _animLastPos = ((Component)this).transform.position; if (Object.op_Implicit((Object)(object)PacmanPlugin.PacmanMoveClip)) { _moveLoop = ((Component)this).gameObject.AddComponent<AudioSource>(); _moveLoop.clip = PacmanPlugin.PacmanMoveClip; _moveLoop.loop = true; _moveLoop.playOnAwake = false; _moveLoop.spatialBlend = 1f; _moveLoop.volume = PacmanPlugin.PacmanMoveVolume.Value * 0.4f; _moveLoop.dopplerLevel = 0f; _moveLoop.rolloffMode = (AudioRolloffMode)0; _moveLoop.minDistance = 2f; _moveLoop.maxDistance = 12f; } } private void Start() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Invalid comparison between Unknown and I4 LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance != (Object)null && instance.Generated && instance.LevelPathPoints != null) { _levelPoints = (from p in instance.LevelPathPoints where (Object)(object)p != (Object)null select ((Component)p).transform).ToArray(); } if ((Object)(object)_anim != (Object)null) { for (int i = 0; i < _anim.parameterCount; i++) { AnimatorControllerParameter parameter = _anim.GetParameter(i); if (parameter.name == "Walk" && (int)parameter.type == 4) { _hasWalkBool = true; } } } if (!KittyManager.IsAuthority() && Object.op_Implicit((Object)(object)_agent) && ((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { //IL_0054: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_00de: Unknown result type (might be due to invalid IL or missing references) if (KittyManager.IsAuthority()) { HostTick(); if (KittyManager.CanStreamPose()) { _poseSendTimer += Time.deltaTime; if (_poseSendTimer >= 0.2f) { _poseSendTimer = 0f; PacmanEventRouter.BroadcastPose(((Component)this).transform.position, ((Component)this).transform.rotation); } } } else { ClientTick(); } Vector3 val; if (Object.op_Implicit((Object)(object)_anim) && _hasWalkBool) { bool flag = false; if (KittyManager.IsAuthority()) { if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { int num; if (!_agent.isStopped) { val = _agent.velocity; num = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? 1 : 0); } else { num = 0; } flag = (byte)num != 0; } } else { val = ((Component)this).transform.position - _animLastPos; flag = ((Vector3)(ref val)).sqrMagnitude > 0.0001f; } _anim.SetBool("Walk", flag); _animLastPos = ((Component)this).transform.position; } if (!Object.op_Implicit((Object)(object)_moveLoop)) { return; } bool flag2 = false; if (KittyManager.IsAuthority()) { if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { val = _agent.velocity; flag2 = ((Vector3)(ref val)).sqrMagnitude > 0.01f; } } else { val = ((Component)this).transform.position - _animLastPos; flag2 = ((Vector3)(ref val)).sqrMagnitude > 0.0001f; } if (flag2) { if (!_moveLoop.isPlaying) { _moveLoop.Play(); } } else if (_moveLoop.isPlaying) { _moveLoop.Pause(); } _moveLoop.volume = PacmanPlugin.PacmanMoveVolume.Value * 0.4f; } private void HostTick() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) if (_scaredTimer > 0f) { _scaredTimer -= Time.deltaTime; if (!Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh) { return; } _agent.speed = 2f; IReadOnlyList<PlayerAvatar> players = KittyManager.AllPlayersCached(); PlayerAvatar val = ChooseNearest(players); if (Object.op_Implicit((Object)(object)val)) { Vector3 val2 = ((Component)this).transform.position - ((Component)val).transform.position; Vector3 val3 = ((Component)this).transform.position + ((Vector3)(ref val2)).normalized * 6f; NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(val3, ref val4, 5f, -1)) { _agent.SetDestination(((NavMeshHit)(ref val4)).position); } } return; } if (Object.op_Implicit((Object)(object)_agent)) { _agent.speed = 3.6f; } IReadOnlyList<PlayerAvatar> players2 = KittyManager.AllPlayersCached(); _target = ChooseNearestVisible(players2); if (!Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh) { return; } if ((Object)(object)_target != (Object)null) { _repathTimer -= Time.deltaTime; if (_repathTimer <= 0f) { _repathTimer = 0.12f; _agent.isStopped = false; _agent.SetDestination(((Component)_target).transform.position); } } else { Patrol(); } } private PlayerAvatar ChooseNearest(IReadOnlyList<PlayerAvatar> players) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.PositiveInfinity; for (int i = 0; i < players.Count; i++) { PlayerAvatar val = players[i]; if (Object.op_Implicit((Object)(object)val)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num) { result = val; num = num2; } } } return result; } private PlayerAvatar ChooseNearestVisible(IReadOnlyList<PlayerAvatar> players) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.PositiveInfinity; for (int i = 0; i < players.Count; i++) { PlayerAvatar val = players[i]; if (Object.op_Implicit((Object)(object)val)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num2 < num && HasLineOfSight(val)) { result = val; num = num2; } } } return result; } private bool HasLineOfSight(PlayerAvatar player) { //IL_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_007c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player)) { return false; } Vector3 val = ((Component)this).transform.position + Vector3.up * 1.2f; Transform val2 = null; try { val2 = (((Object)(object)player.PlayerVisionTarget != (Object)null) ? player.PlayerVisionTarget.VisionTransform : null); } catch { } Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.position : ((Component)player).transform.position); RaycastHit val4 = default(RaycastHit); if (Physics.Linecast(val, val3, ref val4, LayerMask.op_Implicit(_visionMask))) { return (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerAvatar>() == (Object)(object)player; } return true; } private void Patrol() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (_levelPoints == null || _levelPoints.Length == 0) { return; } if ((Object)(object)_nextPatrol == (Object)null || Vector3.Distance(((Component)this).transform.position, _nextPatrol.position) <= 1f) { _nextPatrol = _levelPoints[Random.Range(0, _levelPoints.Length)]; } if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { _agent.isStopped = false; Vector3 position = _nextPatrol.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 3f, -1)) { position = ((NavMeshHit)(ref val)).position; } _agent.SetDestination(position); } } public void ApplyNetworkPose(Vector3 pos, Quaternion rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _netPos = pos; _netRot = rot; _hasNetPose = true; } private void ClientTick() { //IL_0019: 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_005b: 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) //IL_0071: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_hasNetPose) { if (Vector3.Distance(((Component)this).transform.position, _netPos) > 5f) { ((Component)this).transform.SetPositionAndRotation(_netPos, _netRot); return; } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, _netPos, Time.deltaTime * 10f); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _netRot, Time.deltaTime * 10f); } } } public class PacmanEventRouter : MonoBehaviourPunCallbacks, IOnEventCallback { public enum Ev : byte { Spawn = 51, Pose, Despawn, SpawnRoll, DotCollected, RoundWin, PowerUpCollected } private static bool _callbackHooked; private static GameObject _active; private static PacmanController _ctrl; private static GameObject _prefab; internal static void SetPrefab(GameObject prefab) { _prefab = prefab; } 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; } LocalDespawn(); } private void OnSceneLoaded(Scene s, LoadSceneMode m) { LocalDespawn(); if (PhotonNetwork.InRoom) { EnsureCallbackHooked(); } } private void EnsureCallbackHooked() { if (!_callbackHooked) { PhotonNetwork.AddCallbackTarget((object)this); _callbackHooked = true; } } internal static void BroadcastSpawnRoll(bool passed, float chance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { object[] array = new object[2] { passed, chance }; PhotonNetwork.RaiseEvent((byte)54, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } internal static void BroadcastSpawn(Vector3 pos, Quaternion rot, int visionMask, int seed) { //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_0026: 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) //IL_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown CreateLocal(pos, rot, visionMask); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { object[] array = new object[4] { pos, rot, visionMask, seed }; PhotonNetwork.RaiseEvent((byte)51, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } internal static void BroadcastPose(Vector3 pos, Quaternion rot) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { object[] array = new object[2] { pos, rot }; PhotonNetwork.RaiseEvent((byte)52, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendUnreliable); } } internal static void BroadcastDespawn() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown LocalDespawn(); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)53, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } internal static void BroadcastDotCollected(int dotId) { //IL_001d: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)55, (object)dotId, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } else { PacDotsManager.LocalDotCollected(dotId); } } internal static void BroadcastPowerUpCollected(int powerUpId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown PacPowerUpManager.RemovePowerUp(powerUpId); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)57, (object)powerUpId, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } internal static void BroadcastRoundWin() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown PacmanPlugin.AdvanceLevelOrWinRound(); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)56, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } private static void CreateLocal(Vector3 pos, Quaternion rot, int visionMask) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_active) && !((Object)(object)_prefab == (Object)null)) { NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(pos, ref val, 4f, -1)) { pos = ((NavMeshHit)(ref val)).position; } _active = Object.Instantiate<GameObject>(_prefab, pos, rot); ((Object)_active).name = "Pacman_Enemy"; NavMeshAgent component = _active.GetComponent<NavMeshAgent>(); if (Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled) { component.Warp(pos); component.stoppingDistance = 1.2f; component.speed = 3.6f; component.acceleration = 10f; component.angularSpeed = 540f; component.autoBraking = true; } _ctrl = _active.GetComponent<PacmanController>(); if (Object.op_Implicit((Object)(object)_ctrl)) { _ctrl.Setup(LayerMask.op_Implicit(visionMask)); } } } private static void LocalDespawn() { if (Object.op_Implicit((Object)(object)_active)) { Object.Destroy((Object)(object)_active); } _active = null; _ctrl = null; } public void OnEvent(EventData e) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_0154: Unknown result type (might be due to invalid IL or missing references) try { switch ((Ev)e.Code) { case Ev.Spawn: if (!KittyManager.IsAuthority() && e.CustomData is object[] array2 && array2.Length >= 4) { Vector3 pos = (Vector3)array2[0]; Quaternion rot = (Quaternion)array2[1]; int visionMask = (int)array2[2]; int num = (int)array2[3]; State state = Random.state; Random.InitState(num); PacDotsManager.CreateOrRebuild(PacmanPlugin.DotSpacing.Value, PacmanPlugin.DotScale.Value, PacmanPlugin.DotLayer.Value, PacmanPlugin.DotUseLevelPathPoints.Value); PacPowerUpManager.SpawnPowerUps(0.25f); Random.state = state; CreateLocal(pos, rot, visionMask); } break; case Ev.Pose: if (!KittyManager.IsAuthority() && !((Object)(object)_ctrl == (Object)null) && e.CustomData is object[] array && array.Length >= 2) { _ctrl.ApplyNetworkPose((Vector3)array[0], (Quaternion)array[1]); } break; case Ev.Despawn: LocalDespawn(); break; case Ev.SpawnRoll: break; case Ev.DotCollected: PacDotsManager.LocalDotCollected((int)e.CustomData); break; case Ev.RoundWin: break; case Ev.PowerUpCollected: PacPowerUpManager.RemovePowerUp((int)e.CustomData); break; } } catch { } } } [BepInPlugin("empress.repo.pacman", "PacmanRound", "1.0.4")] public class PacmanPlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <WaitLevelThenSpawn>d__25 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PacmanPlugin <>4__this; private float <t>5__1; private float <chance>5__2; private bool <pass>5__3; private int <seed>5__4; private State <oldState>5__5; private Transform <tSpawn>5__6; private Vector3 <pos>5__7; private Quaternion <rot>5__8; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitLevelThenSpawn>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <tSpawn>5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (<>4__this._spawnRoutineRunning || <>4__this._spawnedThisScene) { return false; } <>4__this._spawnRoutineRunning = true; <t>5__1 = 0f; goto IL_00c2; case 1: <>1__state = -1; goto IL_00c2; case 2: <>1__state = -1; goto IL_014c; case 3: { <>1__state = -1; break; } IL_014c: if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated) { if (<t>5__1 >= 30f) { <>4__this._spawnRoutineRunning = false; return false; } <t>5__1 += Time.unscaledDeltaTime; <>2__current = null; <>1__state = 2; return true; } <t>5__1 = 0f; break; IL_00c2: if (BlockedMenuOrHub()) { if (<t>5__1 >= 30f) { <>4__this._spawnRoutineRunning = false; return false; } <t>5__1 += Time.unscaledDeltaTime; <>2__current = null; <>1__state = 1; return true; } <t>5__1 = 0f; if (!PhotonNetwork.InRoom && PhotonNetwork.IsConnected) { <>4__this._spawnRoutineRunning = false; return false; } goto IL_014c; } if (!NavMeshReady()) { if (<t>5__1 >= 30f) { <>4__this._spawnRoutineRunning = false; return false; } <t>5__1 += Time.unscaledDeltaTime; <>2__current = null; <>1__state = 3; return true; } if (!KittyManager.IsAuthority()) { <>4__this._spawnRoutineRunning = false; return false; } if ((Object)(object)PacmanPrefab == (Object)null) { <>4__this._spawnRoutineRunning = false; return false; } <chance>5__2 = Mathf.Clamp01(SpawnChance?.Value ?? 1f); <pass>5__3 = Random.value <= <chance>5__2; if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PacmanEventRouter.BroadcastSpawnRoll(<pass>5__3, <chance>5__2); } if (!<pass>5__3) { <>4__this._spawnRoutineRunning = false; <>4__this._spawnedThisScene = false; return false; } <seed>5__4 = Random.Range(0, 1000000); <oldState>5__5 = Random.state; Random.InitState(<seed>5__4); <tSpawn>5__6 = PickRandomSpawnPoint(); <pos>5__7 = <tSpawn>5__6.position + Vector3.up * 0.2f; <rot>5__8 = <tSpawn>5__6.rotation; PacDotsManager.CreateOrRebuild(DotSpacing.Value, DotScale.Value, DotLayer.Value, DotUseLevelPathPoints.Value); PacPowerUpManager.SpawnPowerUps(0.4f); Random.state = <oldState>5__5; PacmanEventRouter.BroadcastSpawn(<pos>5__7, <rot>5__8, ((LayerMask)(ref VisionMask)).value, <seed>5__4); <>4__this._spawnedThisScene = true; <>4__this._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(); } } public const string PluginGuid = "empress.repo.pacman"; public const string PluginName = "PacmanRound"; public const string PluginVersion = "1.0.4"; internal static ManualLogSource Log; private Harmony _harmony; private static AssetBundle _bundle; internal static GameObject PacmanPrefab; internal static ConfigEntry<float> SpawnChance; internal static ConfigEntry<float> DotSpacing; internal static ConfigEntry<float> DotScale; internal static ConfigEntry<int> DotLayer; internal static ConfigEntry<bool> DotUseLevelPathPoints; internal static ConfigEntry<float> WinSwitchDelay; internal static ConfigEntry<float> DotCollectVolume; internal static ConfigEntry<float> PacmanMoveVolume; internal static AudioClip DotCollectClip; internal static AudioClip PacmanMoveClip; internal static AudioClip PowerUpCollectClip; private bool _spawnRoutineRunning; private bool _spawnedThisScene; public static LayerMask VisionMask = LayerMask.op_Implicit(-1); public static int PacmanLevel = 1; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("empress.repo.pacman"); _harmony.PatchAll(typeof(PacmanPlugin).Assembly); _harmony.PatchAll(typeof(GoalUIPatch)); SpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn", "SpawnChance", 1f, new ConfigDescription("Chance [0..1] that Pacman spawns per playable level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); DotSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Dots", "Spacing", 5f, new ConfigDescription("Meters between pac-dots along level paths.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); DotScale = ((BaseUnityPlugin)this).Config.Bind<float>("Dots", "Scale", 0.25f, new ConfigDescription("Uniform scale for pac-dots.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>())); DotLayer = ((BaseUnityPlugin)this).Config.Bind<int>("Dots", "Layer", 0, new ConfigDescription("Unity layer index for pac-dots.", (AcceptableValueBase)null, Array.Empty<object>())); DotUseLevelPathPoints = ((BaseUnityPlugin)this).Config.Bind<bool>("Dots", "UseLevelPathPoints", true, new ConfigDescription("If true, place dots along LevelGenerator.LevelPathPoints; otherwise grid around truck.", (AcceptableValueBase)null, Array.Empty<object>())); WinSwitchDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Win", "SwitchDelay", 1f, new ConfigDescription("Seconds to wait before switching level after last dot is collected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); DotCollectVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "DotCollectVolume", 0.2f, new ConfigDescription("Volume for dot collect sound.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PacmanMoveVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "PacmanMoveVolume", 0.2f, new ConfigDescription("Volume for Pacman movement loop.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LoadBundle(); GameObject val = new GameObject("Pacman_RouterHost"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; val.AddComponent<PacmanEventRouter>(); PacmanEventRouter.SetPrefab(PacmanPrefab); SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void OnSceneLoaded(Scene s, LoadSceneMode m) { _spawnRoutineRunning = false; _spawnedThisScene = false; PacPowerUpManager.ResetTimers(); ((MonoBehaviour)this).StopAllCoroutines(); if (PhotonNetwork.InRoom || !PhotonNetwork.IsConnected) { ((MonoBehaviour)this).StartCoroutine(WaitLevelThenSpawn()); } } [IteratorStateMachine(typeof(<WaitLevelThenSpawn>d__25))] private IEnumerator WaitLevelThenSpawn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitLevelThenSpawn>d__25(0) { <>4__this = this }; } private static bool BlockedMenuOrHub() { try { RunManager instance = RunManager.instance; Level val = instance?.levelCurrent; if ((Object)(object)instance == (Object)null || (Object)(object)val == (Object)null) { return true; } string text = SafeLower(val.NarrativeName); string text2 = SafeLower(val.ResourcePath); if (text.Contains("lobby menu") || text2.Contains("lobby menu")) { return true; } if (text.Contains("main menu") || text2.Contains("main menu")) { return true; } if (text.Contains("splash screen") || text.Contains("splash")) { return true; } if (text.Contains("shop") || text2.Contains("shop") || text2.Contains("store")) { return true; } if (text.Contains("lobby") || text2.Contains("lobby")) { return true; } if (text.Contains("arena") || text2.Contains("arena")) { return true; } if (text2.Contains("/menu/")) { return true; } return false; } catch { return true; } } private static string SafeLower(string s) { return (s ?? string.Empty).Trim().ToLowerInvariant(); } private static bool NavMeshReady() { //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) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) NavMeshTriangulation val = NavMesh.CalculateTriangulation(); return val.vertices != null && val.vertices.Length != 0 && val.indices != null && val.indices.Length != 0; } private static Transform PickRandomSpawnPoint() { //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance != (Object)null && instance.Generated && instance.LevelPathPoints != null && instance.LevelPathPoints.Count > 0) { List<Transform> list = new List<Transform>(instance.LevelPathPoints.Count); for (int i = 0; i < instance.LevelPathPoints.Count; i++) { LevelPoint val = instance.LevelPathPoints[i]; if (!((Object)(object)val == (Object)null)) { list.Add(((Component)val).transform); } } if ((Object)(object)instance.LevelPathTruck != (Object)null) { Vector3 position = ((Component)instance.LevelPathTruck).transform.position; for (int j = 1; j < list.Count; j++) { Transform val2 = list[j]; float num = Vector3.Distance(position, val2.position); int num2 = j - 1; while (num2 >= 0 && Vector3.Distance(position, list[num2].position) > num) { list[num2 + 1] = list[num2]; num2--; } list[num2 + 1] = val2; } int num3 = Mathf.Min(3, list.Count); int num4 = 0; for (int k = num3; k < list.Count; k++) { if (Vector3.Distance(position, list[k].position) > 6f) { list[num4++] = list[k]; } } if (num4 > 0) { list.RemoveRange(num4, list.Count - num4); } } if (list.Count > 0) { return list[Random.Range(0, list.Count)]; } } SpawnPoint[] array = Object.FindObjectsOfType<SpawnPoint>(); if (array == null || array.Length == 0) { GameObject val3 = new GameObject("Pacman_SpawnFallback"); val3.transform.position = Vector3.up; return val3.transform; } return ((Component)array[Random.Range(0, array.Length)]).transform; } private void LoadBundle() { if ((Object)(object)_bundle != (Object)null) { return; } try { string text = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); if (string.IsNullOrEmpty(text)) { text = Paths.PluginPath; } string[] array = Directory.GetFiles(text, "pacman", SearchOption.TopDirectoryOnly).Concat(Directory.GetFiles(text, "pacman.*", SearchOption.TopDirectoryOnly)).ToArray(); foreach (string text2 in array) { try { _bundle = AssetBundle.LoadFromFile(text2); if (!Object.op_Implicit((Object)(object)_bundle)) { continue; } PacmanPrefab = _bundle.LoadAsset<GameObject>("pacmanenemy"); DotCollectClip = _bundle.LoadAsset<AudioClip>("pacdot_collect"); PacmanMoveClip = _bundle.LoadAsset<AudioClip>("pacman_move"); PowerUpCollectClip = _bundle.LoadAsset<AudioClip>("powerup_collect"); if (!Object.op_Implicit((Object)(object)PowerUpCollectClip)) { PowerUpCollectClip = DotCollectClip; } if (!Object.op_Implicit((Object)(object)PacmanPrefab)) { continue; } AudioSource[] componentsInChildren = PacmanPrefab.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val)) { val.spatialBlend = 1f; val.dopplerLevel = 0f; val.rolloffMode = (AudioRolloffMode)0; val.minDistance = 8f; val.maxDistance = 20f; } } if (!Object.op_Implicit((Object)(object)PacmanPrefab.GetComponent<NavMeshAgent>())) { PacmanPrefab.AddComponent<NavMeshAgent>(); } if (!Object.op_Implicit((Object)(object)PacmanPrefab.GetComponent<PacmanController>())) { PacmanPrefab.AddComponent<PacmanController>(); } Log.LogInfo((object)("Loaded AssetBundle at " + text2 + " with pacmanenemy prefab.")); return; } catch (Exception ex) { Log.LogWarning((object)("Failed to load bundle at " + text2 + ": " + ex.Message)); } } Log.LogWarning((object)"No 'pacman' AssetBundle found beside the plugin .dll. Place it next to the .dll."); } catch (Exception arg) { Log.LogError((object)$"LoadBundle failed: {arg}"); } } internal static void AdvanceLevelOrWinRound() { try { if (!KittyManager.IsAuthority()) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[PacmanRound] Non-authority received win trigger; waiting for master."); } return; } RunManager instance = RunManager.instance; if ((Object)(object)instance == (Object)null) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)"[PacmanRound] RunManager.instance is null; cannot advance level."); } return; } PacmanLevel++; instance.ChangeLevel(true, false, (ChangeLevelType)1); ManualLogSource log3 = Log; if (log3 != null) { log3.LogInfo((object)$"[PacmanRound] All dots collected: advancing to Pacman Level {PacmanLevel}."); } } catch (Exception arg) { ManualLogSource log4 = Log; if (log4 != null) { log4.LogError((object)$"[PacmanRound] AdvanceLevelOrWinRound failed: {arg}"); } } } } public static class GoalUIPatch { [HarmonyPatch(typeof(GoalUI), "Update")] [HarmonyPostfix] public static void Postfix(GoalUI __instance) { if ((Object)(object)__instance == (Object)null) { return; } TextMeshProUGUI component = ((Component)__instance).GetComponent<TextMeshProUGUI>(); if (Object.op_Implicit((Object)(object)component)) { ((TMP_Text)component).richText = true; string text = $"\n\n<color=yellow>DOTS: {PacDotsManager.RemainingDots}</color>"; if (PacPowerUpManager.SpeedBoostTimeRemaining > 0.1f) { text += $"\n<color=#00FF00>SPEED: {PacPowerUpManager.SpeedBoostTimeRemaining:F0}</color>"; } if (PacPowerUpManager.ScareTimeRemaining > 0.1f) { text += $"\n<color=#00FFFF>SCARE: {PacPowerUpManager.ScareTimeRemaining:F0}</color>"; } ((TMP_Text)component).text = text; } } } public static class PacPowerUpManager { public enum Type { SpeedBoost, ScarePacman } public class PacPowerUp : MonoBehaviour { public Type MyType; public int ID; public Transform Visual; private void OnTriggerEnter(Collider other) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar val = ((Component)other).GetComponentInParent<PlayerAvatar>(); if (!Object.op_Implicit((Object)(object)val)) { PlayerController componentInParent = ((Component)other).GetComponentInParent<PlayerController>(); if (Object.op_Implicit((Object)(object)componentInParent)) { val = componentInParent.playerAvatarScript; } } if (Object.op_Implicit((Object)(object)val) && val.photonView.IsMine) { ActivateEffect(MyType); if (Object.op_Implicit((Object)(object)PacmanPlugin.PowerUpCollectClip)) { AudioSource.PlayClipAtPoint(PacmanPlugin.PowerUpCollectClip, ((Component)this).transform.position, 0.05f); } PacmanEventRouter.BroadcastPowerUpCollected(ID); } } private void Update() { //IL_0017: 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) if (Object.op_Implicit((Object)(object)Visual)) { Visual.Rotate(Vector3.up, 100f * Time.deltaTime, (Space)0); float num = 0.8f + Mathf.Sin(Time.time * 3f) * 0.1f; Visual.localPosition = new Vector3(0f, num, 0f); } } } public class PowerUpUpdater : MonoBehaviour { private void Update() { if (SpeedBoostTimeRemaining > 0f) { SpeedBoostTimeRemaining -= Time.deltaTime; if (Object.op_Implicit((Object)(object)PlayerController.instance)) { PlayerController.instance.OverrideSpeed(1.8f, 0.2f); PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart; } } if (ScareTimeRemaining > 0f) { ScareTimeRemaining -= Time.deltaTime; if (Object.op_Implicit((Object)(object)PacmanController.Instance)) { PacmanController.Instance.Scare(ScareTimeRemaining); } } } } private static readonly Dictionary<int, GameObject> _powerUps = new Dictionary<int, GameObject>(); private static GameObject _updater; public static float SpeedBoostTimeRemaining; public static float ScareTimeRemaining; public static void ResetTimers() { SpeedBoostTimeRemaining = 0f; ScareTimeRemaining = 0f; } public static void ClearAll() { foreach (KeyValuePair<int, GameObject> powerUp in _powerUps) { if (Object.op_Implicit((Object)(object)powerUp.Value)) { Object.Destroy((Object)(object)powerUp.Value); } } _powerUps.Clear(); if (Object.op_Implicit((Object)(object)_updater)) { Object.Destroy((Object)(object)_updater); } } public static void RemovePowerUp(int id) { if (_powerUps.TryGetValue(id, out GameObject value)) { if (Object.op_Implicit((Object)(object)value)) { Object.Destroy((Object)(object)value); } _powerUps.Remove(id); } } public static void SpawnPowerUps(float chancePerPoint) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) ClearAll(); EnsureUpdater(); LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance == (Object)null || instance.LevelPathPoints == null) { return; } int num = 0; foreach (LevelPoint levelPathPoint in instance.LevelPathPoints) { if (!((Object)(object)levelPathPoint == (Object)null)) { if (Random.value <= chancePerPoint) { Type t = ((!(Random.value > 0.5f)) ? Type.ScarePacman : Type.SpeedBoost); Spawn(((Component)levelPathPoint).transform.position, t, num); } num++; } } } private static void EnsureUpdater() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_updater)) { _updater = new GameObject("PacPowerUp_Updater"); Object.DontDestroyOnLoad((Object)(object)_updater); ((Object)_updater).hideFlags = (HideFlags)52; _updater.AddComponent<PowerUpUpdater>(); } } private static void Spawn(Vector3 pos, Type t, int id) { //IL_0001: 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_003a: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0080: 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_0096: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(pos, ref val, 2f, -1)) { GameObject val2 = new GameObject($"PowerUp_{t}_{id}"); val2.transform.position = ((NavMeshHit)(ref val)).position + Vector3.up * 0.5f; BoxCollider val3 = val2.AddComponent<BoxCollider>(); ((Collider)val3).isTrigger = true; val3.size = new Vector3(1.5f, 2.5f, 1.5f); val3.center = Vector3.up * 0.5f; GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)val4.GetComponent<Collider>()); val4.transform.SetParent(val2.transform); val4.transform.localPosition = Vector3.up * 0.8f; val4.transform.localScale = Vector3.one * 0.4f; val4.transform.localRotation = Quaternion.Euler(45f, 45f, 45f); Renderer component = val4.GetComponent<Renderer>(); Color val5 = ((t == Type.SpeedBoost) ? Color.green : Color.cyan); if (Object.op_Implicit((Object)(object)component)) { Material val6 = new Material(Shader.Find("Standard")); val6.color = val5; val6.EnableKeyword("_EMISSION"); val6.SetColor("_EmissionColor", val5 * 2f); component.material = val6; } Light val7 = val2.AddComponent<Light>(); val7.type = (LightType)2; val7.range = 3f; val7.color = val5; val7.intensity = 2f; PacPowerUp pacPowerUp = val2.AddComponent<PacPowerUp>(); pacPowerUp.MyType = t; pacPowerUp.ID = id; pacPowerUp.Visual = val4.transform; _powerUps[id] = val2; } } public static void ActivateEffect(Type t) { EnsureUpdater(); switch (t) { case Type.SpeedBoost: SpeedBoostTimeRemaining = 15f; if (Object.op_Implicit((Object)(object)PlayerController.instance)) { PlayerController.instance.OverrideSpeed(1.8f, 0.1f); } break; case Type.ScarePacman: ScareTimeRemaining = 15f; if (Object.op_Implicit((Object)(object)PacmanController.Instance)) { PacmanController.Instance.Scare(15f); } break; } } } } namespace Empress.KittyCurse { [RequireComponent(typeof(NavMeshAgent))] [DisallowMultipleComponent] public class KittyCatController : MonoBehaviour { private enum State { Patrol, Pursue, Ask, KillAll } [CompilerGenerated] private sealed class <AskSequence>d__49 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerAvatar player; public KittyCatController <>4__this; private int <i>5__1; private float <t>5__2; private float <end>5__3; private float <t2>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AskSequence>d__49(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_01e9: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (<>4__this._state == State.Ask) { return false; } <>4__this._state = State.Ask; <>4__this.IdleAnim(); <i>5__1 = 0; goto IL_026a; case 1: <>1__state = -1; goto IL_00eb; case 2: <>1__state = -1; goto IL_0234; case 3: { <>1__state = -1; goto IL_02e9; } IL_00eb: if (<t>5__2 < <>4__this._askGrace) { if (<>4__this.GiftSatisfied(player)) { <>4__this.OnGiftAccepted(); return false; } <t>5__2 += Time.deltaTime; <>2__current = null; <>1__state = 1; return true; } if (<i>5__1 < 2) { <end>5__3 = Time.time + <>4__this._askInterval; goto IL_0234; } goto IL_0257; IL_026a: if (<i>5__1 < 3) { if (KittyManager.IsAuthority()) { KittyEventRouter.BroadcastVoice(Mathf.Clamp(<i>5__1, 0, 2)); } <t>5__2 = 0f; goto IL_00eb; } if (!KittyManager.IsAuthority()) { break; } <t2>5__4 = 0f; goto IL_02e9; IL_0257: <i>5__1++; goto IL_026a; IL_0234: if (Time.time < <end>5__3) { if (Object.op_Implicit((Object)(object)<>4__this._agent) && <>4__this._agent.isOnNavMesh) { <>4__this._agent.isStopped = false; <>4__this._agent.speed = 4.2f; <>4__this._repathTimer -= Time.deltaTime; if (<>4__this._repathTimer <= 0f) { <>4__this._repathTimer = 0.2f; <>4__this._agent.SetDestination(((Component)player).transform.position); } } if (<>4__this.GiftSatisfied(player)) { <>4__this.OnGiftAccepted(); return false; } <>2__current = null; <>1__state = 2; return true; } <>4__this.IdleAnim(); goto IL_0257; IL_02e9: if (<t2>5__4 < <>4__this._askGrace) { if (<>4__this.GiftSatisfied(player)) { <>4__this.OnGiftAccepted(); return false; } <t2>5__4 += Time.deltaTime; <>2__current = null; <>1__state = 3; return true; } <>4__this.StartKillEveryoneMode(); break; } 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(); } } [CompilerGenerated] private sealed class <WanderOffAndDie>d__53 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public KittyCatController <>4__this; private Vector3 <best>5__1; private float <bestScore>5__2; private IReadOnlyList<PlayerAvatar> <players>5__3; private float <end>5__4; private int <i>5__5; private Vector3 <cand>5__6; private NavMeshHit <hit>5__7; private float <score>5__8; private int <p>5__9; private PlayerAvatar <av>5__10; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WanderOffAndDie>d__53(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <players>5__3 = null; <av>5__10 = null; <>1__state = -2; } private bool MoveNext() { //IL_002f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_01f9: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <best>5__1 = ((Component)<>4__this).transform.position; <bestScore>5__2 = float.NegativeInfinity; <players>5__3 = KittyManager.AllPlayersCached(); <i>5__5 = 0; while (<i>5__5 < 16) { <cand>5__6 = ((Component)<>4__this).transform.position + Random.insideUnitSphere * 45f; if (NavMesh.SamplePosition(<cand>5__6, ref <hit>5__7, 6f, -1)) { <score>5__8 = 0f; <p>5__9 = 0; while (<p>5__9 < <players>5__3.Count) { <av>5__10 = <players>5__3[<p>5__9]; if (Object.op_Implicit((Object)(object)<av>5__10)) { <score>5__8 += Vector3.Distance(((NavMeshHit)(ref <hit>5__7)).position, ((Component)<av>5__10).transform.position); } <av>5__10 = null; <p>5__9++; } if (<score>5__8 > <bestScore>5__2) { <bestScore>5__2 = <score>5__8; <best>5__1 = ((NavMeshHit)(ref <hit>5__7)).position; } } <i>5__5++; } if (Object.op_Implicit((Object)(object)<>4__this._agent) && <>4__this._agent.isOnNavMesh) { <>4__this._agent.isStopped = false; <>4__this._agent.speed = 3.8f; <>4__this._agent.SetDestination(<best>5__1); } <end>5__4 = Time.time + 10f; break; case 1: <>1__state = -1; break; } if (Time.time < <end>5__4) { <>2__current = null; <>1__state = 1; return true; } <>4__this.ToggleMusicLocal(on: false); KittyEventRouter.BroadcastDespawn(); Object.Destroy((Object)(object)((Component)<>4__this).gameObject); 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 NavMeshAgent _agent; private Animator _anim; private AudioSource _voice; private AudioSource _music; private AudioClip[] _voiceClips; private AudioClip _musicClip; private float _voiceVol = 1f; private float _musicVol = 0.5f; private float _patrolRadius; private float _engageDistance; private LayerMask _visionMask; private float _askGrace; private float _askInterval; private Transform[] _levelPoints; private Transform _truckPoint; private Transform _currentPatrolTarget; private float _idleUntil; private bool _movingToPatrol; private float _repathTimer; private Vector3 _lastPos; private float _stuckTimer; private PlayerAvatar _target; private State _state = State.Patrol; private float _scanTimer; private float _poseSendTimer; private const float PoseSendInterval = 0.2f; private Vector3 _netPos; private Quaternion _netRot; private bool _hasNetPose; private const float PoseSnapDist = 5f; private const float PoseLerpRate = 10f; private float _postGiftCooldownUntil; private bool _hasCatIdleTrigger; private bool _hasWalkBool; private Vector3 _animLastPos; private float _killRepathTimer; private static readonly List<PlayerAvatar> _victimsTmp = new List<PlayerAvatar>(8); public void Setup(float patrolRadius, float engageDistance, LayerMask visionMask, float askGrace, float askInterval) { //IL_0010: 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) _patrolRadius = patrolRadius; _engageDistance = engageDistance; _visionMask = visionMask; _askGrace = Mathf.Max(10f, askGrace); _askInterval = Mathf.Max(_askGrace, askInterval); } public void AssignAudio(AudioClip[] voices, AudioClip music, float voiceVol, float musicVol) { _voiceClips = voices ?? Array.Empty<AudioClip>(); _musicClip = music; _voiceVol = Mathf.Clamp01(voiceVol); _musicVol = Mathf.Clamp01(musicVol); } public void ApplyNetworkPose(Vector3 pos, Quaternion rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _netPos = pos; _netRot = rot; _hasNetPose = true; } private void Awake() { _agent = ((Component)this).GetComponent<NavMeshAgent>(); _anim = ((Component)this).GetComponent<Animator>(); _voice = ((Component)this).GetComponent<AudioSource>() ?? ((Component)this).gameObject.AddComponent<AudioSource>(); _voice.playOnAwake = false; _voice.loop = false; _voice.spatialBlend = 1f; _voice.dopplerLevel = 0f; _voice.rolloffMode = (AudioRolloffMode)0; _voice.minDistance = 8f; _voice.maxDistance = 18f; _music = ((Component)this).gameObject.AddComponent<AudioSource>(); _music.playOnAwake = false; _music.loop = true; _music.spatialBlend = 1f; _music.dopplerLevel = 0f; _music.rolloffMode = (AudioRolloffMode)0; _music.minDistance = 12f; _music.maxDistance = 30f; if (Object.op_Implicit((Object)(object)_agent)) { _agent.stoppingDistance = 1.5f; } } private void OnEnable() { KittyManager.Register(this); } private void OnDisable() { KittyManager.Unregister(this); } private void Start() { //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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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) //IL_012b: Invalid comparison between Unknown and I4 //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Invalid comparison between Unknown and I4 LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance != (Object)null && instance.Generated) { _truckPoint = (Object.op_Implicit((Object)(object)instance.LevelPathTruck) ? ((Component)instance.LevelPathTruck).transform : null); if (instance.LevelPathPoints != null) { _levelPoints = (from p in instance.LevelPathPoints where (Object)(object)p != (Object)null select ((Component)p).transform).ToArray(); } } _idleUntil = Time.time + Random.Range(10f, 30f); _lastPos = ((Component)this).transform.position; _animLastPos = ((Component)this).transform.position; if ((Object)(object)_anim != (Object)null) { for (int i = 0; i < _anim.parameterCount; i++) { AnimatorControllerParameter parameter = _anim.GetParameter(i); if (parameter.name == "catidle" && (int)parameter.type == 9) { _hasCatIdleTrigger = true; } if (parameter.name == "Walk" && (int)parameter.type == 4) { _hasWalkBool = true; } } } if (!KittyManager.IsAuthority() && Object.op_Implicit((Object)(object)_agent) && ((Behaviour)_agent).enabled) { ((Behaviour)_agent).enabled = false; } } private void Update() { //IL_0054: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_00de: Unknown result type (might be due to invalid IL or missing references) if (KittyManager.IsAuthority()) { HostTick(); if (KittyManager.CanStreamPose()) { _poseSendTimer += Time.deltaTime; if (_poseSendTimer >= 0.2f) { _poseSendTimer = 0f; KittyEventRouter.BroadcastPose(((Component)this).transform.position, ((Component)this).transform.rotation); } } } else { ClientTick(); } if (!Object.op_Implicit((Object)(object)_anim) || !_hasWalkBool) { return; } bool flag = false; Vector3 val; if (KittyManager.IsAuthority()) { if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { int num; if (!_agent.isStopped) { val = _agent.velocity; num = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? 1 : 0); } else { num = 0; } flag = (byte)num != 0; } } else { val = ((Component)this).transform.position - _animLastPos; flag = ((Vector3)(ref val)).sqrMagnitude > 0.0001f; } _anim.SetBool("Walk", flag); _animLastPos = ((Component)this).transform.position; } private void HostTick() { _scanTimer -= Time.deltaTime; if (_scanTimer <= 0f) { _scanTimer = 0.33f; ScanForTargets(); } switch (_state) { case State.Patrol: PatrolTick(); break; case State.Pursue: PursueTick(); break; case State.Ask: break; case State.KillAll: KillAllTick(); break; } } private void ScanForTargets() { //IL_006d: 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) if (Time.time < _postGiftCooldownUntil || _state == State.Ask || _state == State.KillAll) { return; } IReadOnlyList<PlayerAvatar> readOnlyList = KittyManager.AllPlayersCached(); PlayerAvatar val = null; float num = float.PositiveInfinity; for (int i = 0; i < readOnlyList.Count; i++) { PlayerAvatar val2 = readOnlyList[i]; if (Object.op_Implicit((Object)(object)val2)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val2).transform.position); if (num2 <= _engageDistance && num2 < num && HasLineOfSight(val2)) { val = val2; num = num2; } } } if ((Object)(object)val != (Object)null) { _target = val; _state = State.Pursue; } } private void PursueTick() { //IL_00a7: 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_0095: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_target == (Object)null) { _state = State.Patrol; } else if (Object.op_Implicit((Object)(object)_agent) && _agent.isOnNavMesh) { _agent.isStopped = false; _repathTimer -= Time.deltaTime; if (_repathTimer <= 0f) { _repathTimer = 0.15f; _agent.SetDestination(((Component)_target).transform.position); } if (Vector3.Distance(((Component)this).transform.position, ((Component)_target).transform.position) <= 4f) { ((MonoBehaviour)this).StartCoroutine(AskSequence(_target)); } } } [IteratorStateMachine(typeof(<AskSequence>d__49))] private IEnumerator AskSequence(PlayerAvatar player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AskSequence>d__49(0) { <>4__this = this, player = player }; } private void IdleAnim() { if (Object.op_Implicit((Object)(object)_agent)) { _agent.isStopped = true; } if (Object.op_Implicit((Object)(object)_anim) && _hasCatIdleTrigger) { _anim.SetTrigger("catidle"); } if (Object.op_Implicit((Object)(object)_anim) && _hasWalkBool) { _anim.SetBool("Walk", false); } } private bool GiftSatisfied(PlayerAvatar player) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (KittyManager.IsAuthority()) { return KittyManager.AnyRecentDropNear(((Component)this).transform.position, _askGrace, 6f); } return false; } private void OnGiftAccepted() { _target = null; _state = State.Patrol; if (Object.op_Implicit((Object)(object)_agent)) { _agent.speed = 3.5f; _agent.isStopped = false; } _postGiftCooldownUntil = Time.time + 15f; ((MonoBehaviour)this).StartCoroutine(WanderOffAndDie()); } [IteratorStateMachine(typeof(<WanderOffAndDie>d__53))] private IEnumerator WanderOffAndDie() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WanderOffAndDie>d__53(0) { <>4__this = this }; } private bool HasLineOfSight(PlayerAvatar player) { //IL_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_007c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player)) { return false; } Vector3 val = ((Component)this).transform.position + Vector3.up * 1.2f; Transform val2 = null; try { val2 = (((Object)(object)player.PlayerVisionTarget != (Object)null) ? player.PlayerVisionTarget.VisionTransform : null); } catch { } Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.position : ((Component)player).transform.position); RaycastHit val4 = default(RaycastHit); if (Physics.Linecast(val, val3, ref val4, LayerMask.op_Implicit(_visionMask))) { return (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerAvatar>() == (Object)(object)player; } return true; } private void PatrolTick() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh) { return; } if (_movingToPatrol) { if (!_agent.pathPending && _agent.remainingDistance <= 0.5f) { _movingToPatrol = false; _idleUntil = Time.time + Random.Range(10f, 30f); _agent.isStopped = true; return; } Vector3 val = ((Component)this).transform.position - _lastPos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; _stuckTimer = ((sqrMagnitude < 0.0004f) ? (_stuckTimer + Time.deltaTime) : 0f); _lastPos = ((Component)this).transform.position; if (_stuckTimer > 2f) { _stuckTimer = 0f; ForceNextPatrolDestination(); } } else if (Time.time < _idleUntil) { if (!_agent.isStopped) { _agent.isStopped = true; } } else { ForceNextPatrolDestination(); } } private void ForceNextPatrolDestination() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0068: 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_0091: Unknown result type (might be due to invalid IL or missing references) _agent.isStopped = false; _currentPatrolTarget = ChooseNextLevelPoint(); if ((Object)(object)_currentPatrolTarget != (Object)null) { Vector3 position = _currentPatrolTarget.position; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(position, ref val, 3f, -1)) { position = ((NavMeshHit)(ref val)).position; } if (_agent.isOnNavMesh) { _agent.SetDestination(position); } else { _agent.Warp(position); } _movingToPatrol = true; _lastPos = ((Component)this).transform.position; _stuckTimer = 0f; return; } Vector3 val2 = Random.insideUnitSphere * _patrolRadius + ((Component)this).transform.position; NavMeshHit val3 = default(NavMeshHit); if (NavMesh.SamplePosition(val2, ref val3, _patrolRadius, -1)) { if (_agent.isOnNavMesh) { _agent.SetDestination(((NavMeshHit)(ref val3)).position); } else { _agent.Warp(((NavMeshHit)(ref val3)).position); } } _movingToPatrol = true; _lastPos = ((Component)this).transform.position; _stuckTimer = 0f; } private Transform ChooseNextLevelPoint() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (_levelPoints == null || _levelPoints.Length == 0) { return null; } Vector3 position = ((Component)this).transform.position; Transform val = null; float num = float.NegativeInfinity; for (int i = 0; i < _levelPoints.Length; i++) { Transform val2 = _levelPoints[i]; if ((Object)(object)val2 == (Object)null || ((Object)(object)_truckPoint != (Object)null && Vector3.Distance(val2.position, _truckPoint.position) <= 6f)) { continue; } float num2 = Vector3.Distance(val2.position, position); if (!(num2 <= 12f)) { float num3 = num2; if (num3 > num) { num = num3; val = val2; } } } if ((Object)(object)val != (Object)null) { return val; } return _levelPoints[Random.Range(0, _levelPoints.Length)]; } private void TryKill(PlayerAvatar player) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)player == (Object)null) { return; } if ((Object)(object)player.playerHealth != (Object)null) { player.playerHealth.HurtOther(999, ((Component)player).transform.position, true, -1); return; } PlayerHealth playerHealth = player.playerHealth; if (playerHealth != null) { playerHealth.Hurt(999, true, -1); } } catch { } } private void StartKillEveryoneMode() { _state = State.KillAll; if (Object.op_Implicit((Object)(object)_agent)) { _agent.isStopped = false; _agent.speed = 9f; _agent.acceleration = 20f; _agent.angularSpeed = 720f; } if (KittyManager.IsAuthority()) { KittyEventRouter.BroadcastMusic(on: true); } } private void KillAllTick() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_agent) || !_agent.isOnNavMesh) { return; } _victimsTmp.Clear(); IReadOnlyList<PlayerAvatar> readOnlyList = KittyManager.AllPlayersCached(); for (int i = 0; i < readOnlyList.Count; i++) { PlayerAvatar val = readOnlyList[i]; if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerHealth) && ((Component)val.playerHealth).gameObject.activeInHierarchy) { _victimsTmp.Add(val); } } if (_victimsTmp.Count == 0) { return; } PlayerAvatar val2 = null; float num = float.PositiveInfinity; for (int j = 0; j < _victimsTmp.Count; j++) { PlayerAvatar val3 = _victimsTmp[j]; float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val3).transform.position); if (num2 < num) { num = num2; val2 = val3; } } if ((Object)(object)val2 != (Object)null) { _agent.isStopped = false; _killRepathTimer -= Time.deltaTime; if (_killRepathTimer <= 0f) { _killRepathTimer = 0.12f; _agent.SetDestination(((Component)val2).transform.position); } if (num <= 3.2f && KittyManager.IsAuthority()) { TryKill(val2); } } } internal void PlayVoiceLocal(int index) { if (!((Object)(object)_voice == (Object)null) && _voiceClips != null && _voiceClips.Length != 0) { int num = Mathf.Clamp(index, 0, _voiceClips.Length - 1); AudioClip val = _voiceClips[num]; if (Object.op_Implicit((Object)(object)val)) { _voice.volume = _voiceVol; _voice.PlayOneShot(val); } } } internal void ToggleMusicLocal(bool on) { if ((Object)(object)_music == (Object)null || (Object)(object)_musicClip == (Object)null) { return; } if (on) { if ((Object)(object)_music.clip != (Object)(object)_musicClip) { _music.clip = _musicClip; } _music.volume = _musicVol; if (!_music.isPlaying) { _music.Play(); } } else if (_music.isPlaying) { _music.Stop(); } } private void ClientTick() { //IL_0019: 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_005b: 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) //IL_0071: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_hasNetPose) { if (Vector3.Distance(((Component)this).transform.position, _netPos) > 5f) { ((Component)this).transform.SetPositionAndRotation(_netPos, _netRot); return; } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, _netPos, Time.deltaTime * 10f); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _netRot, Time.deltaTime * 10f); } } } public static class KittyEventRouter { public static void BroadcastPose(Vector3 pos, Quaternion r
PacmanLeaderboard.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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.Logging; using Empress.KittyCurse; using Empress.Pacman; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [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")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PacmanLeaderboard")] [assembly: AssemblyTitle("PacmanLeaderboard")] [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 Empress.PacmanLeaderboard { [BepInPlugin("empress.repo.pacman.leaderboard", "PacmanLeaderboard", "1.2.0")] public class PacmanLeaderboardPlugin : BaseUnityPlugin { internal static ManualLogSource Log; private Harmony _h; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _h = new Harmony("empress.repo.pacman.leaderboard"); _h.PatchAll(typeof(PacmanLeaderboardPlugin).Assembly); } private void OnDestroy() { Harmony h = _h; if (h != null) { h.UnpatchSelf(); } Router.Teardown(); UI.Teardown(); State.ResetRound(); } } internal static class State { internal static bool ActiveRound; internal static readonly Dictionary<int, int> Counts = new Dictionary<int, int>(); internal static void ResetRound() { Counts.Clear(); ActiveRound = false; } internal static void BeginRound() { Counts.Clear(); ActiveRound = true; } internal static void AddDotForActor(int actor) { if (actor > 0) { if (Counts.TryGetValue(actor, out var value)) { Counts[actor] = value + 1; } else { Counts[actor] = 1; } } } } internal class Router : MonoBehaviourPunCallbacks, IOnEventCallback { private enum Ev : byte { LB_Update = 101, LB_Show, LB_Begin, LB_Reset } private static Router _inst; private static bool _hooked; internal static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_inst != (Object)null)) { GameObject val = new GameObject("PacmanLeaderboard_RouterHost"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; _inst = val.AddComponent<Router>(); _inst.TryHook(); } } internal static void Teardown() { if (!((Object)(object)_inst == (Object)null)) { if (_hooked) { PhotonNetwork.RemoveCallbackTarget((object)_inst); } _hooked = false; Object.Destroy((Object)(object)((Component)_inst).gameObject); _inst = null; } } public override void OnJoinedRoom() { TryHook(); } public override void OnLeftRoom() { if (_hooked) { PhotonNetwork.RemoveCallbackTarget((object)this); } _hooked = false; State.ResetRound(); UI.HideNow(); } private void TryHook() { if (!_hooked && PhotonNetwork.InRoom) { PhotonNetwork.AddCallbackTarget((object)this); _hooked = true; } } internal static void BroadcastBegin() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //IL_0039: Expected O, but got Unknown State.BeginRound(); Ensure(); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)103, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } internal static void BroadcastReset() { //IL_001d: 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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown State.ResetRound(); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)104, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } UI.HideNow(); } internal static void BroadcastDotPickup(int actor) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown if (State.ActiveRound) { State.AddDotForActor(actor); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)101, (object)actor, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } } internal static void BroadcastShow() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) //IL_0096: Expected O, but got Unknown if (State.ActiveRound) { UI.Ensure(); int[] array = State.Counts.Keys.ToArray(); int[] array2 = array.Select((int k) => State.Counts[k]).ToArray(); object[] array3 = new object[2] { array, array2 }; UI.QueueShow(); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)102, (object)array3, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } } public void OnEvent(EventData e) { switch ((Ev)e.Code) { case Ev.LB_Begin: State.BeginRound(); UI.Ensure(); break; case Ev.LB_Reset: State.ResetRound(); UI.HideNow(); break; case Ev.LB_Update: { int actor = (int)e.CustomData; State.AddDotForActor(actor); break; } case Ev.LB_Show: if (e.CustomData is object[] array && array.Length >= 2) { State.Counts.Clear(); int[] array2 = (int[])array[0]; int[] array3 = (int[])array[1]; for (int i = 0; i < array2.Length && i < array3.Length; i++) { State.Counts[array2[i]] = array3[i]; } } UI.QueueShow(); break; } } } internal class UI : MonoBehaviour { private struct Row { public string name; public int count; } private static UI _inst; private static bool _visible; private static float _until; private const float Duration = 8f; internal static void Ensure() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)_inst != (Object)null)) { GameObject val = new GameObject("PacmanLeaderboard_UI"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; _inst = val.AddComponent<UI>(); } } internal static void Teardown() { if (!((Object)(object)_inst == (Object)null)) { Object.Destroy((Object)(object)((Component)_inst).gameObject); _inst = null; _visible = false; } } public static void QueueShow() { if (State.ActiveRound) { ShowNow(); } } public static void ShowNow() { if (!((Object)(object)_inst == (Object)null) && State.ActiveRound) { _visible = true; _until = Time.unscaledTime + 8f; } } public static void HideNow() { _visible = false; } private void OnGUI() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return; } if (!State.ActiveRound) { _visible = false; return; } if (Time.unscaledTime >= _until) { _visible = false; return; } float num = 520f; float num2 = 380f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.4f, num, num2); GUI.depth = -10000; GUI.Box(val, "PAC-MAN RESULTS"); List<Row> list = BuildSorted(); float num3 = 26f; float num4 = ((Rect)(ref val)).y + 48f; for (int i = 0; i < list.Count; i++) { Row row = list[i]; string name = row.name; string text = row.count.ToString(); GUI.Label(new Rect(((Rect)(ref val)).x + 24f, num4, ((Rect)(ref val)).width * 0.7f, num3), name); GUI.Label(new Rect(((Rect)(ref val)).x + ((Rect)(ref val)).width - 120f, num4, 100f, num3), text); num4 += num3 + 4f; } } private static List<Row> BuildSorted() { List<Row> list = new List<Row>(State.Counts.Count); Player[] array = (PhotonNetwork.InRoom ? PhotonNetwork.PlayerList : Array.Empty<Player>()); foreach (Player val in array) { if (val != null) { State.Counts.TryGetValue(val.ActorNumber, out var value); list.Add(new Row { name = (string.IsNullOrEmpty(val.NickName) ? $"Player {val.ActorNumber}" : val.NickName), count = value }); } } foreach (KeyValuePair<int, int> count in State.Counts) { bool flag = false; for (int j = 0; j < list.Count; j++) { if (list[j].name.EndsWith(count.Key.ToString())) { flag = true; break; } } if (!flag) { list.Add(new Row { name = $"Player {count.Key}", count = count.Value }); } } list.Sort((Row a, Row b) => b.count.CompareTo(a.count)); return list; } } [HarmonyPatch(typeof(PacmanEventRouter), "BroadcastSpawn")] internal static class Patch_BeginRound_OnSpawn { private static void Postfix() { Router.Ensure(); UI.Ensure(); Router.BroadcastBegin(); } } [HarmonyPatch(typeof(PacmanEventRouter), "BroadcastDespawn")] internal static class Patch_Reset_OnDespawn { private static void Postfix() { Router.BroadcastReset(); Router.Teardown(); UI.Teardown(); } } [HarmonyPatch(typeof(PacmanEventRouter), "BroadcastRoundWin")] internal static class Patch_Show_OnRoundWin { private static void Prefix() { if (State.ActiveRound) { Router.BroadcastShow(); } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class Patch_Show_OnLevelChange { private static void Prefix(bool _completedLevel, bool _levelFailed) { if (_levelFailed && State.ActiveRound) { Router.BroadcastShow(); } } } [HarmonyPatch(typeof(PacDot), "OnTriggerEnter")] internal static class Patch_Count_OnDotTrigger { private static void Postfix(Collider other, PacDot __instance) { if (State.ActiveRound && KittyManager.IsAuthority() && !((Object)(object)other == (Object)null)) { PhotonView componentInParent = ((Component)other).GetComponentInParent<PhotonView>(); int num = (((Object)(object)componentInParent != (Object)null) ? componentInParent.OwnerActorNr : 0); if (num <= 0 && PhotonNetwork.LocalPlayer != null) { num = PhotonNetwork.LocalPlayer.ActorNumber; } if (num > 0) { Router.BroadcastDotPickup(num); } } } } }
PacmanLoading.dll
Decompiled 2 months agousing System; using System.Diagnostics; 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 HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [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")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PacmanLoading")] [assembly: AssemblyTitle("PacmanLoading")] [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 EmpressMods.PacmanLevelLoader { [BepInPlugin("com.empress.repo.pacman_loader", "PacmanLevelLoader", "1.0.2")] public class PacmanPlugin : BaseUnityPlugin { private static class Patches { [HarmonyPatch(typeof(TruckLevelNumberScreen), "Start")] [HarmonyPostfix] private static void TruckLevelScreen_Patch(TruckLevelNumberScreen __instance) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) try { TMP_Text componentInChildren = (TMP_Text)(object)((Component)__instance).GetComponentInChildren<TextMeshProUGUI>(true); if ((Object)(object)componentInChildren == (Object)null) { componentInChildren = (TMP_Text)(object)((Component)__instance).GetComponentInChildren<TextMeshPro>(true); } if ((Object)(object)componentInChildren != (Object)null) { if (EnablePacmanColors.Value) { ((Graphic)componentInChildren).color = new Color(1f, 0.95f, 0f, 1f); } int num = ((!((Object)(object)RunManager.instance != (Object)null)) ? 1 : (RunManager.instance.levelsCompleted + 1)); componentInChildren.text = $"{LevelPrefixConfig.Value} {num}"; } } catch (Exception arg) { Log.LogError((object)$"Failed to patch TruckLevelNumberScreen: {arg}"); } } [HarmonyPatch(typeof(LoadingUI), "LevelAnimationStart")] [HarmonyPostfix] private static void LoadingUI_Patch(LoadingUI __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)__instance.levelNumberText != (Object)null) { if (EnablePacmanColors.Value) { ((Graphic)__instance.levelNumberText).color = new Color(1f, 0.95f, 0f, 1f); } if (!SemiFunc.RunIsShop() && !SemiFunc.RunIsArena()) { int num = ((!((Object)(object)RunManager.instance != (Object)null)) ? 1 : (RunManager.instance.levelsCompleted + 1)); ((TMP_Text)__instance.levelNumberText).text = $"{LevelPrefixConfig.Value} {num}"; } } if ((Object)(object)__instance.levelNameText != (Object)null && EnablePacmanColors.Value) { ((Graphic)__instance.levelNameText).color = Color.white; } } catch (Exception arg) { Log.LogWarning((object)$"Could not patch LoadingUI: {arg}"); } } } public const string PluginGuid = "com.empress.repo.pacman_loader"; public const string PluginName = "PacmanLevelLoader"; public const string PluginVersion = "1.0.2"; internal static ManualLogSource Log; internal static ConfigEntry<string> LevelPrefixConfig; internal static ConfigEntry<bool> EnablePacmanColors; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; LevelPrefixConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "LevelPrefix", "PAC-LEVEL", "Prefix for the level number."); EnablePacmanColors = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePacmanColors", true, "If true, changes text color to Pac-Man yellow."); Harmony.CreateAndPatchAll(typeof(Patches), (string)null); Log.LogInfo((object)"PacmanLevelLoader loaded. No more crashes!"); } } }