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 Collector Enemy v1.1.0
EmpressGalaxy.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+18d7522dc6b94df95b9da7f0476ec5efba010364")] [assembly: AssemblyProduct("EmpressGalaxy")] [assembly: AssemblyTitle("EmpressGalaxy")] [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 EmpressGalaxy { [BepInPlugin("Omniscye.EmpressGalaxy", "EmpressGalaxy", "1.0")] public class EmpressGalaxy : BaseUnityPlugin { internal static EmpressGalaxy Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } } namespace Empress.KittyCurse { [BepInPlugin("empress.repo.kittycurse", "KittyCurse", "1.0.4")] public class KittyCursePlugin : BaseUnityPlugin { [CompilerGenerated] private sealed class <WaitLevelThenSpawn>d__24 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public KittyCursePlugin <>4__this; private float <t>5__1; private float <chance>5__2; private bool <pass>5__3; private Transform <tSpawn>5__4; private Vector3 <pos>5__5; private Quaternion <rot>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitLevelThenSpawn>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <tSpawn>5__4 = 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_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: 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)_kittyPrefab == (Object)null) { <>4__this._spawnRoutineRunning = false; return false; } <chance>5__2 = Mathf.Clamp01(SpawnChance?.Value ?? 0.25f); <pass>5__3 = Random.value <= <chance>5__2; if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { KittyEventRouter.BroadcastSpawnRoll(<pass>5__3, <chance>5__2); } if (!<pass>5__3) { <>4__this._spawnRoutineRunning = false; <>4__this._spawnedThisScene = false; return false; } <tSpawn>5__4 = PickRandomSpawnPoint(); <pos>5__5 = <tSpawn>5__4.position + Vector3.up * 0.2f; <rot>5__6 = <tSpawn>5__4.rotation; KittyEventRouter.BroadcastSpawn(<pos>5__5, <rot>5__6, PatrolPointRadius, EngageDistance, ((LayerMask)(ref VisionMask)).value, AskGraceSeconds, AskIntervalSeconds); <>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.kittycurse"; public const string PluginName = "KittyCurse"; public const string PluginVersion = "1.0.4"; internal static ManualLogSource Log; private Harmony _harmony; private static AssetBundle _bundle; private static GameObject _kittyPrefab; public static float PatrolPointRadius = 18f; public static float EngageDistance = 30f; public static LayerMask VisionMask = LayerMask.op_Implicit(-1); public static float AskGraceSeconds = 10f; public static float AskIntervalSeconds = 11f; public static float VoiceVolume = 0.9f; public static float MusicVolume = 0.5f; private bool _spawnRoutineRunning; private bool _spawnedThisScene; internal static ConfigEntry<float> SpawnChance; 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("empress.repo.kittycurse"); try { _harmony.PatchAll(typeof(KittyCursePlugin).Assembly); SpawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawn", "SpawnChance", 0.25f, new ConfigDescription("Chance [0..1] that the Kitty spawns per playable level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LoadBundle(); if ((Object)(object)_kittyPrefab == (Object)null) { Log.LogError((object)"Kitty prefab not found in AssetBundle 'skript' with prefab name 'kitty'."); } GameObject val = new GameObject("KittyCurse_RouterHost"); Object.DontDestroyOnLoad((Object)(object)val); ((Object)val).hideFlags = (HideFlags)52; val.AddComponent<KittyEventRouter>(); KittyEventRouter.SetPrefab(_kittyPrefab); AudioClip[] array = LoadVoiceClips(); AudioClip val2 = LoadMusicClip(); try { if (Object.op_Implicit((Object)(object)val2) && !val2.preloadAudioData) { val2.LoadAudioData(); } if (array != null) { foreach (AudioClip val3 in array) { if (Object.op_Implicit((Object)(object)val3) && !val3.preloadAudioData) { val3.LoadAudioData(); } } } if (Object.op_Implicit((Object)(object)val2)) { GameObject val4 = new GameObject("KittyCurse_AudioWarmup", new Type[1] { typeof(AudioSource) }); ((Object)val4).hideFlags = (HideFlags)61; AudioSource component = val4.GetComponent<AudioSource>(); component.playOnAwake = false; component.spatialBlend = 0f; component.volume = 0f; component.clip = val2; component.Play(); component.Stop(); Object.Destroy((Object)(object)val4); } } catch (Exception ex) { Log.LogDebug((object)("Audio warmup failed (safe to ignore): " + ex.Message)); } KittyEventRouter.SetAudio(array, val2, VoiceVolume, MusicVolume); SceneManager.sceneLoaded += OnSceneLoaded; } catch (Exception arg) { Log.LogError((object)$"Init failed: {arg}"); } } 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; ((MonoBehaviour)this).StopAllCoroutines(); if (PhotonNetwork.InRoom || !PhotonNetwork.IsConnected) { ((MonoBehaviour)this).StartCoroutine(WaitLevelThenSpawn()); } } 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 nameA = SafeLower(val.NarrativeName); string nameB = SafeLower(val.ResourcePath); return LooksLikeNonPlayable(nameA, nameB); } catch { return true; } } private static bool LooksLikeNonPlayable(string nameA, string nameB) { if (nameA.Contains("lobby menu") || nameB.Contains("lobby menu")) { return true; } if (nameA.Contains("main menu") || nameB.Contains("main menu")) { return true; } if (nameA.Contains("splash screen") || nameB.Contains("splash")) { return true; } if (nameA.Contains("shop") || nameB.Contains("shop") || nameB.Contains("store")) { return true; } if (nameA.Contains("lobby") || nameB.Contains("lobby")) { return true; } if (nameA.Contains("arena") || nameB.Contains("arena")) { return true; } if (nameB.Contains("/menu/")) { return true; } return false; } 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; } [IteratorStateMachine(typeof(<WaitLevelThenSpawn>d__24))] private IEnumerator WaitLevelThenSpawn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitLevelThenSpawn>d__24(0) { <>4__this = this }; } 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("KittyCurse_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, "skript", SearchOption.TopDirectoryOnly).Concat(Directory.GetFiles(text, "skript.*", SearchOption.TopDirectoryOnly)).ToArray(); string[] array2 = array; foreach (string text2 in array2) { try { _bundle = AssetBundle.LoadFromFile(text2); if (!Object.op_Implicit((Object)(object)_bundle)) { continue; } _kittyPrefab = _bundle.LoadAsset<GameObject>("kitty"); if (Object.op_Implicit((Object)(object)_kittyPrefab)) { if (!Object.op_Implicit((Object)(object)_kittyPrefab.GetComponent<NavMeshAgent>())) { _kittyPrefab.AddComponent<NavMeshAgent>(); } if (!Object.op_Implicit((Object)(object)_kittyPrefab.GetComponent<AudioSource>())) { _kittyPrefab.AddComponent<AudioSource>(); } if (!Object.op_Implicit((Object)(object)_kittyPrefab.GetComponent<Animator>())) { _kittyPrefab.AddComponent<Animator>(); } if (!Object.op_Implicit((Object)(object)_kittyPrefab.GetComponent<KittyCatController>())) { _kittyPrefab.AddComponent<KittyCatController>(); } Log.LogInfo((object)("Loaded AssetBundle at " + text2 + " with kitty prefab.")); return; } } catch (Exception ex) { Log.LogWarning((object)("Failed to load bundle at " + text2 + ": " + ex.Message)); } } Log.LogWarning((object)"No 'skript' AssetBundle found beside the plugin .dll. Place it next to the .dll."); } catch (Exception arg) { Log.LogError((object)$"LoadBundle failed: {arg}"); } } private static AudioClip[] LoadVoiceClips() { if ((Object)(object)_bundle == (Object)null) { return Array.Empty<AudioClip>(); } string[] array = new string[4] { "sfx1", "sfx2", "sfx3", "sfx3.off" }; List<AudioClip> list = new List<AudioClip>(); string[] array2 = array; foreach (string text in array2) { AudioClip val = _bundle.LoadAsset<AudioClip>(text); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list.ToArray(); } private static AudioClip LoadMusicClip() { if ((Object)(object)_bundle == (Object)null) { return null; } return _bundle.LoadAsset<AudioClip>("music"); } } [RequireComponent(typeof(NavMeshAgent))] [DisallowMultipleComponent] public class KittyCatController : MonoBehaviour { private enum State { Patrol, Pursue, Ask, KillAll } [CompilerGenerated] private sealed class <AskSequence>d__47 : 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__47(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__51 : 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__51(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 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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; if ((Object)(object)_anim != (Object)null) { for (int i = 0; i < _anim.parameterCount; i++) { if (_anim.GetParameter(i).name == "catidle" && (int)_anim.GetParameter(i).type == 9) { _hasCatIdleTrigger = 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) 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(); } } 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__47))] private IEnumerator AskSequence(PlayerAvatar player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AskSequence>d__47(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"); } } 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__51))] private IEnumerator WanderOffAndDie() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WanderOffAndDie>d__51(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 class KittyEventRouter : MonoBehaviourPunCallbacks, IOnEventCallback { public enum Ev : byte { Spawn = 101, Pose, Voice1, Voice2, Voice3, MusicOn, MusicOff, ValuableDrop, Despawn, SpawnRoll } private static bool _callbackHooked; private static GameObject _active; private static KittyCatController _ctrl; private static GameObject _prefab; private static AudioClip[] _voices; private static AudioClip _music; private static float _voiceVol = 1f; private static float _musicVol = 0.5f; internal static void SetPrefab(GameObject prefab) { _prefab = prefab; } internal static void SetAudio(AudioClip[] voices, AudioClip music, float voiceVol, float musicVol) { _voices = voices; _music = music; _voiceVol = Mathf.Clamp01(voiceVol); _musicVol = Mathf.Clamp01(musicVol); } 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)110, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)1 }, SendOptions.SendReliable); } } internal static void BroadcastSpawn(Vector3 pos, Quaternion rot, float patrolRadius, float engageDist, int visionMask, float askGrace, float askInterval) { //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_002d: 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_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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown CreateLocal(pos, rot, patrolRadius, engageDist, visionMask, askGrace, askInterval); if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { object[] array = new object[7] { pos, rot, patrolRadius, engageDist, visionMask, askGrace, askInterval }; PhotonNetwork.RaiseEvent((byte)101, (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)102, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendUnreliable); } } internal static void BroadcastVoice(int index) { //IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)_ctrl)) { _ctrl.PlayVoiceLocal(index); } if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent(index switch { 1 => 104, 0 => 103, _ => 105, }, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendUnreliable); } } internal static void BroadcastMusic(bool on) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)_ctrl)) { _ctrl.ToggleMusicLocal(on); } if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { PhotonNetwork.RaiseEvent((byte)(on ? 106 : 107), (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } 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)109, (object)null, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } } private static void CreateLocal(Vector3 pos, Quaternion rot, float patrolRadius, float engageDist, int visionMask, float askGrace, float askInterval) { //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_00c1: 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 = "KittyCurse_Kitty"; NavMeshAgent component = _active.GetComponent<NavMeshAgent>(); if (Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled) { component.Warp(pos); component.stoppingDistance = 1.6f; } _ctrl = _active.GetComponent<KittyCatController>(); if (Object.op_Implicit((Object)(object)_ctrl)) { _ctrl.Setup(patrolRadius, engageDist, LayerMask.op_Implicit(visionMask), askGrace, askInterval); _ctrl.AssignAudio(_voices, _music, _voiceVol, _musicVol); } } } 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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 >= 7) { Vector3 pos = (Vector3)array2[0]; Quaternion rot = (Quaternion)array2[1]; float patrolRadius = (float)array2[2]; float engageDist = (float)array2[3]; int visionMask = (int)array2[4]; float askGrace = (float)array2[5]; float askInterval = (float)array2[6]; CreateLocal(pos, rot, patrolRadius, engageDist, visionMask, askGrace, askInterval); } break; case Ev.Pose: if (!KittyManager.IsAuthority() && !((Object)(object)_ctrl == (Object)null) && e.CustomData is object[] array3 && array3.Length >= 2) { _ctrl.ApplyNetworkPose((Vector3)array3[0], (Quaternion)array3[1]); } break; case Ev.Voice1: _ctrl?.PlayVoiceLocal(0); break; case Ev.Voice2: _ctrl?.PlayVoiceLocal(1); break; case Ev.Voice3: _ctrl?.PlayVoiceLocal(2); break; case Ev.MusicOn: _ctrl?.ToggleMusicLocal(on: true); break; case Ev.MusicOff: _ctrl?.ToggleMusicLocal(on: false); break; case Ev.ValuableDrop: if (KittyManager.IsAuthority() && e.CustomData is object[] array && array.Length >= 2) { Vector3 where = (Vector3)array[0]; float time = (float)array[1]; KittyManager.NoteValuableDroppedNet(where, time); } break; case Ev.Despawn: LocalDespawn(); break; case Ev.SpawnRoll: break; } } catch { } } } [HarmonyPatch] internal static class KittyGrabPatcher { [HarmonyPatch(typeof(PhysGrabObject), "GrabEnded")] [HarmonyPostfix] private static void PhysGrabObject_GrabEnded_Postfix(PhysGrabObject __instance, PhysGrabber player) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown if ((Object)(object)player == (Object)null || (Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent<ValuableObject>() == (Object)null) { return; } PlayerAvatar componentInParent = ((Component)player).GetComponentInParent<PlayerAvatar>(); if (Object.op_Implicit((Object)(object)componentInParent)) { Vector3 position = ((Component)__instance).transform.position; KittyManager.NoteValuableDropped(componentInParent, position); if (KittyManager.IsAuthority()) { KittyManager.NoteValuableDroppedNet(position, Time.time); } if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { object[] array = new object[2] { position, Time.time }; PhotonNetwork.RaiseEvent((byte)108, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable); } } } } [HarmonyPatch(typeof(PhysGrabObject))] internal static class KittyGrabRPCPatches { [CompilerGenerated] private sealed class <TargetGrabRPCs>d__0 : IEnumerable<MethodBase>, IEnumerable, IEnumerator<MethodBase>, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private Type <t>5__1; private List<MethodInfo>.Enumerator <>s__2; private MethodInfo <m>5__3; MethodBase IEnumerator<MethodBase>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TargetGrabRPCs>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <t>5__1 = null; <>s__2 = default(List<MethodInfo>.Enumerator); <m>5__3 = null; <>1__state = -2; } private bool MoveNext() { try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; goto IL_00bd; } <>1__state = -1; <t>5__1 = typeof(PhysGrabObject); <>s__2 = AccessTools.GetDeclaredMethods(<t>5__1).GetEnumerator(); <>1__state = -3; goto IL_00c5; IL_00bd: <m>5__3 = null; goto IL_00c5; IL_00c5: if (<>s__2.MoveNext()) { <m>5__3 = <>s__2.Current; if (<m>5__3.Name == "GrabPlayerAddRPC" || <m>5__3.Name == "GrabPlayerRemoveRPC") { <>2__current = <m>5__3; <>1__state = 1; return true; } goto IL_00bd; } <>m__Finally1(); <>s__2 = default(List<MethodInfo>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<MethodBase> IEnumerable<MethodBase>.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new <TargetGrabRPCs>d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<MethodBase>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<TargetGrabRPCs>d__0))] [HarmonyTargetMethods] private static IEnumerable<MethodBase> TargetGrabRPCs() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TargetGrabRPCs>d__0(-2); } [HarmonyPostfix] private static void Postfix_AllGrabRPCs(PhysGrabObject __instance, MethodBase __originalMethod, object[] __args) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (KittyManager.IsAuthority() && Object.op_Implicit((Object)(object)__instance) && !((Object)(object)((Component)__instance).GetComponent<ValuableObject>() == (Object)null) && __originalMethod.Name == "GrabPlayerRemoveRPC") { Vector3 position = ((Component)__instance).transform.position; KittyManager.NoteValuableDroppedNet(position, Time.time); } } } public static class KittyManager { private struct DropRec { public float t; public Vector3 pos; } private static readonly List<KittyCatController> _cats = new List<KittyCatController>(); private static readonly Dictionary<int, (float t, Vector3 pos)> _playerDrop = new Dictionary<int, (float, Vector3)>(); private static readonly DropRec[] _recentDrops = new DropRec[16]; private static int _recentDropsHead; private static readonly List<PlayerAvatar> _playersCache = new List<PlayerAvatar>(8); private static float _playersNextRefresh; private const float PlayersRefreshInterval = 1f; public static void Register(KittyCatController c) { if ((Object)(object)c != (Object)null && !_cats.Contains(c)) { _cats.Add(c); } } public static void Unregister(KittyCatController c) { if ((Object)(object)c != (Object)null) { _cats.Remove(c); } } public static bool IsAuthority() { return !GameManager.Multiplayer() || PhotonNetwork.IsMasterClient; } public static bool CanStreamPose() { return PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady && IsAuthority(); } public static bool AnyCatNear(Vector3 where, float withinMeters) { //IL_0021: 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) for (int i = 0; i < _cats.Count; i++) { KittyCatController kittyCatController = _cats[i]; if (Object.op_Implicit((Object)(object)kittyCatController) && Vector3.Distance(where, ((Component)kittyCatController).transform.position) <= withinMeters) { return true; } } return false; } public static void NoteValuableDropped(PlayerAvatar avatar, Vector3 where) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)avatar)) { _playerDrop[((Object)avatar).GetInstanceID()] = (Time.time, where); } } public static void NoteValuableDroppedNet(Vector3 where, float time) { //IL_0035: 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) int num = _recentDropsHead++ & (_recentDrops.Length - 1); _recentDrops[num].t = time; _recentDrops[num].pos = where; } public static bool AnyRecentDropNear(Vector3 where, float withinSeconds, float withinMeters) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; float num = withinMeters * withinMeters; for (int i = 0; i < _recentDrops.Length; i++) { float num2 = time - _recentDrops[i].t; if (num2 > 0f && num2 <= withinSeconds) { Vector3 val = where - _recentDrops[i].pos; if (((Vector3)(ref val)).sqrMagnitude <= num) { return true; } } } return false; } public static bool PlayerDroppedValuableNear(PlayerAvatar avatar, Vector3 where, float withinSeconds, float withinMeters) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)avatar)) { return false; } if (_playerDrop.TryGetValue(((Object)avatar).GetInstanceID(), out (float, Vector3) value) && Time.time - value.Item1 <= withinSeconds) { return Vector3.Distance(value.Item2, where) <= withinMeters; } return false; } public static IReadOnlyList<PlayerAvatar> AllPlayersCached() { if (Time.unscaledTime >= _playersNextRefresh) { _playersCache.Clear(); PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>(); if (array != null) { foreach (PlayerAvatar val in array) { if (Object.op_Implicit((Object)(object)val)) { _playersCache.Add(val); } } } _playersNextRefresh = Time.unscaledTime + 1f; } return _playersCache; } } }