Decompiled source of Jonathan v1.0.0
plugins/JonathanGnomeMod.dll
Decompiled 39 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using Microsoft.CodeAnalysis; using RootMotion.Dynamics; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JonathanGnomeMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("JonathanGnomeMod")] [assembly: AssemblyTitle("JonathanGnomeMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 JonathanGnomeMod { [BepInPlugin("com.yourname.jonathangnomemod", "Jonathan, Seal, Fairy, Seagull, Bibi, Redcap, Boar & Dog Mod", "28.0.0")] public class JonathanPlugin : BaseUnityPlugin { public static JonathanPlugin Instance; public static int localSkinMode = 1; public static bool localMusicEnabled = true; public static bool secretSkinsUnlocked = false; public static readonly Hashtable playersSkinMode = new Hashtable(); public static readonly Hashtable playersMusicEnabled = new Hashtable(); private bool handlersRegistered; private float nextScanTime; private float nextSyncTime; private static GameObject cachedJonathanPrefab = null; private static GameObject cachedSealPrefab = null; private static GameObject cachedFairyPrefab = null; private static GameObject cachedSeagullPrefab = null; private static GameObject cachedBibiPrefab = null; private static GameObject cachedRedcapPrefab = null; private static GameObject cachedBoarPrefab = null; private static GameObject cachedDogPrefab = null; private static bool loggedAllAiPrefabs = false; private void Awake() { Instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Skin Mod v28.0.0 loaded!"); } public void LogInfo(string msg) { ((BaseUnityPlugin)this).Logger.LogInfo((object)msg); } public static int GetPlayerSkinMode(ulong clientId) { if ((Object)(object)NetworkManager.Singleton != (Object)null && clientId == NetworkManager.Singleton.LocalClientId) { return localSkinMode; } if (playersSkinMode.ContainsKey(clientId)) { return (int)playersSkinMode[clientId]; } return 0; } public static bool GetPlayerMusicEnabled(ulong clientId) { if ((Object)(object)NetworkManager.Singleton != (Object)null && clientId == NetworkManager.Singleton.LocalClientId) { return localMusicEnabled; } if (playersMusicEnabled.ContainsKey(clientId)) { return (bool)playersMusicEnabled[clientId]; } return true; } private void Update() { if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { if (handlersRegistered) { handlersRegistered = false; playersSkinMode.Clear(); playersMusicEnabled.Clear(); } return; } if (!handlersRegistered) { RegisterNetworkHandlers(); } if (Input.GetKey((KeyCode)107) && Input.GetKey((KeyCode)106) && Input.GetKey((KeyCode)104) && Input.GetKeyDown((KeyCode)103)) { secretSkinsUnlocked = !secretSkinsUnlocked; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Secret Characters (F7-F1): " + (secretSkinsUnlocked ? "UNLOCKED" : "HIDDEN"))); } if (Input.GetKeyDown((KeyCode)289)) { localSkinMode = ((localSkinMode != 1) ? 1 : 0); ApplyLocalSkinChange(); } if (secretSkinsUnlocked) { if (Input.GetKeyDown((KeyCode)288)) { localSkinMode = ((localSkinMode != 2) ? 2 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)287)) { localSkinMode = ((localSkinMode != 3) ? 3 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)286)) { localSkinMode = ((localSkinMode != 4) ? 4 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)285)) { localSkinMode = ((localSkinMode != 5) ? 5 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)284)) { localSkinMode = ((localSkinMode != 6) ? 6 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)283)) { localSkinMode = ((localSkinMode != 7) ? 7 : 0); ApplyLocalSkinChange(); } if (Input.GetKeyDown((KeyCode)282)) { localSkinMode = ((localSkinMode != 8) ? 8 : 0); ApplyLocalSkinChange(); } } if (Input.GetKeyDown((KeyCode)110)) { localMusicEnabled = !localMusicEnabled; ulong localClientId = NetworkManager.Singleton.LocalClientId; playersMusicEnabled[localClientId] = localMusicEnabled; SendMusicStatePacket(localClientId, localMusicEnabled); UpdateAllPlayersMusic(); } if (Time.time >= nextSyncTime) { nextSyncTime = Time.time + 3f; BroadcastMySkinState(); } if (Time.time >= nextScanTime) { nextScanTime = Time.time + 0.5f; UpdateAllPlayersVisuals(); } } private void ApplyLocalSkinChange() { ulong localClientId = NetworkManager.Singleton.LocalClientId; playersSkinMode[localClientId] = localSkinMode; BroadcastMySkinState(); UpdateAllPlayersVisuals(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Skin Mode changed to: " + localSkinMode)); } private void RegisterNetworkHandlers() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.CustomMessagingManager != null) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; customMessagingManager.RegisterNamedMessageHandler("JonathanSkinModeSync", new HandleNamedMessageDelegate(OnSkinSyncReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanMusicState", new HandleNamedMessageDelegate(OnMusicStateReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanSkinRequest", new HandleNamedMessageDelegate(OnSkinRequestReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanAttackAnim", new HandleNamedMessageDelegate(OnAttackAnimReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanAttackHit", new HandleNamedMessageDelegate(OnAttackHitReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanPunchConfirm", new HandleNamedMessageDelegate(OnPunchConfirmReceived)); customMessagingManager.RegisterNamedMessageHandler("JonathanVoicePlay", new HandleNamedMessageDelegate(OnVoicePlayReceived)); customMessagingManager.RegisterNamedMessageHandler("FairyLaserState", new HandleNamedMessageDelegate(OnFairyLaserStateReceived)); customMessagingManager.RegisterNamedMessageHandler("BibiActionCmd", new HandleNamedMessageDelegate(OnBibiActionCmdReceived)); handlersRegistered = true; ulong localClientId = NetworkManager.Singleton.LocalClientId; playersSkinMode[localClientId] = localSkinMode; playersMusicEnabled[localClientId] = localMusicEnabled; BroadcastMySkinState(); RequestAllSkins(); } } private void BroadcastMySkinState() { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsListening) { ulong localClientId = NetworkManager.Singleton.LocalClientId; SendSkinStatePacket(localClientId, localSkinMode); SendMusicStatePacket(localClientId, localMusicEnabled); } } private unsafe void SendSkinStatePacket(ulong clientId, int mode) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0052: 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_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref mode, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("JonathanSkinModeSync", val, (NetworkDelivery)3); } else { customMessagingManager.SendNamedMessage("JonathanSkinModeSync", 0uL, val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void SendMusicStatePacket(ulong clientId, bool enabled) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0052: 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_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref clientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref enabled, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("JonathanMusicState", val, (NetworkDelivery)3); } else { customMessagingManager.SendNamedMessage("JonathanMusicState", 0uL, val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnMusicStateReceived(ulong senderClientId, FastBufferReader reader) { //IL_0012: 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_0024: 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) if (((FastBufferReader)(ref reader)).TryBeginRead(9)) { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); playersMusicEnabled[num] = flag; if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && senderClientId != NetworkManager.Singleton.LocalClientId) { SendMusicStatePacket(num, flag); } UpdateAllPlayersMusic(); } } private void UpdateAllPlayersMusic() { PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); if (array == null) { return; } PlayerNetworking[] array2 = array; foreach (PlayerNetworking val in array2) { if (!((Object)(object)val == (Object)null)) { JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; if ((Object)(object)jonathanGnomeVisualHandler != (Object)null) { jonathanGnomeVisualHandler.SetBoomboxMusicState(GetPlayerMusicEnabled(((NetworkBehaviour)val).OwnerClientId)); } } } } private unsafe void RequestAllSkins() { //IL_0045: 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_0074: 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) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ulong localClientId = NetworkManager.Singleton.LocalClientId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref localClientId, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("JonathanSkinRequest", val, (NetworkDelivery)3); } else { customMessagingManager.SendNamedMessage("JonathanSkinRequest", 0uL, val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnSkinSyncReceived(ulong senderClientId, FastBufferReader reader) { //IL_0012: 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_0024: 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) if (((FastBufferReader)(ref reader)).TryBeginRead(12)) { ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); playersSkinMode[num] = num2; if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && senderClientId != NetworkManager.Singleton.LocalClientId) { SendSkinStatePacket(num, num2); } UpdateAllPlayersVisuals(); } } private void OnSkinRequestReceived(ulong senderClientId, FastBufferReader reader) { BroadcastMySkinState(); } public unsafe static void SendVoiceNetwork(ulong speakerClientId, int voiceIdx) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0052: 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_006a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref speakerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref voiceIdx, default(ForPrimitives)); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("JonathanVoicePlay", val, (NetworkDelivery)3); } else { customMessagingManager.SendNamedMessage("JonathanVoicePlay", 0uL, val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnVoicePlayReceived(ulong senderClientId, FastBufferReader reader) { //IL_0012: 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_0024: 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) if (!((FastBufferReader)(ref reader)).TryBeginRead(12)) { return; } ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); int num2 = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives)); if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && senderClientId != NetworkManager.Singleton.LocalClientId) { SendVoiceNetwork(num, num2); } if ((Object)(object)NetworkManager.Singleton != (Object)null && num == NetworkManager.Singleton.LocalClientId) { return; } PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (PlayerNetworking val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).OwnerClientId == num) { JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; if ((Object)(object)jonathanGnomeVisualHandler != (Object)null) { jonathanGnomeVisualHandler.PlayVoicePhrase(num2); } break; } } } public unsafe static void SendAttackAnimNetwork(ulong attackerClientId, string triggerName) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref attackerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(triggerName ?? "", false); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("JonathanAttackAnim", val, (NetworkDelivery)3); } else { customMessagingManager.SendNamedMessage("JonathanAttackAnim", 0uL, val, (NetworkDelivery)3); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnAttackAnimReceived(ulong senderClientId, FastBufferReader reader) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(8)) { return; } ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); string triggerName = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref triggerName, false); if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && senderClientId != NetworkManager.Singleton.LocalClientId) { SendAttackAnimNetwork(num, triggerName); } if ((Object)(object)NetworkManager.Singleton != (Object)null && num == NetworkManager.Singleton.LocalClientId) { return; } PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (PlayerNetworking val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).OwnerClientId == num) { JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; if ((Object)(object)jonathanGnomeVisualHandler != (Object)null) { jonathanGnomeVisualHandler.PlayRemoteAttackTrigger(triggerName); } break; } } } public unsafe static void SendBibiActionNetwork(ulong bibiClientId, int cmdType, Vector3 origin, Vector3 direction) { //IL_0028: 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_0050: 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_0062: 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_0088: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } if (NetworkManager.Singleton.IsServer) { JonathanGnomeVisualHandler.ExecuteServerBibiAction(bibiClientId, cmdType, origin, direction); return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(40, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref bibiClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref cmdType, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref origin); ((FastBufferWriter)(ref val)).WriteValueSafe(ref direction); customMessagingManager.SendNamedMessage("BibiActionCmd", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnBibiActionCmdReceived(ulong senderClientId, FastBufferReader reader) { //IL_002b: 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_003e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer && ((FastBufferReader)(ref reader)).TryBeginRead(36)) { ulong bibiClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref bibiClientId, default(ForPrimitives)); int cmdType = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref cmdType, default(ForPrimitives)); Vector3 origin = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref origin); Vector3 direction = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref direction); JonathanGnomeVisualHandler.ExecuteServerBibiAction(bibiClientId, cmdType, origin, direction); } } public unsafe static void SendFairyLaserStateNetwork(ulong shooterClientId, bool active, Vector3 originPos, Vector3 targetPos) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(40, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref shooterClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref active, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref originPos); ((FastBufferWriter)(ref val)).WriteValueSafe(ref targetPos); if (NetworkManager.Singleton.IsServer) { customMessagingManager.SendNamedMessageToAll("FairyLaserState", val, (NetworkDelivery)0); } else { customMessagingManager.SendNamedMessage("FairyLaserState", 0uL, val, (NetworkDelivery)0); } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnFairyLaserStateReceived(ulong senderClientId, FastBufferReader reader) { //IL_0012: 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_0025: 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_006c: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(33)) { return; } ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); Vector3 originPos = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref originPos); Vector3 targetPos = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref targetPos); if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && senderClientId != NetworkManager.Singleton.LocalClientId) { SendFairyLaserStateNetwork(num, flag, originPos, targetPos); } PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (PlayerNetworking val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).OwnerClientId == num) { JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; if ((Object)(object)jonathanGnomeVisualHandler != (Object)null && !((NetworkBehaviour)val).IsLocalPlayer) { jonathanGnomeVisualHandler.SetRemoteLaserState(flag, targetPos); } if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer && flag) { JonathanGnomeVisualHandler.ExecuteServerFairyLaserBeam(num, originPos, targetPos); } break; } } } public unsafe static void SendAttackHitNetwork(ulong attackerClientId, Vector3 origin, Vector3 direction, float damage, float knockback, bool applyStun) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0078: 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_008a: 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_009c: 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_00b0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } if (NetworkManager.Singleton.IsServer) { JonathanGnomeVisualHandler.ExecuteServerHit(attackerClientId, origin, direction, damage, knockback, applyStun); return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(48, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref attackerClientId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref origin); ((FastBufferWriter)(ref val)).WriteValueSafe(ref direction); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref damage, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref knockback, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref applyStun, default(ForPrimitives)); customMessagingManager.SendNamedMessage("JonathanAttackHit", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnAttackHitReceived(ulong senderClientId, FastBufferReader reader) { //IL_002b: 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_0050: 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_0063: 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_0076: 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_0084: 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) if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer && ((FastBufferReader)(ref reader)).TryBeginRead(41)) { ulong attackerClientId = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref attackerClientId, default(ForPrimitives)); Vector3 origin = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref origin); Vector3 direction = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref direction); float damage = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref damage, default(ForPrimitives)); float knockback = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref knockback, default(ForPrimitives)); bool applyStun = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref applyStun, default(ForPrimitives)); JonathanGnomeVisualHandler.ExecuteServerHit(attackerClientId, origin, direction, damage, knockback, applyStun); } } public unsafe static void BroadcastPunchConfirm(ulong attackerClientId) { //IL_0046: 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_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening || !NetworkManager.Singleton.IsServer) { return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; if (customMessagingManager == null) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref attackerClientId, default(ForPrimitives)); customMessagingManager.SendNamedMessageToAll("JonathanPunchConfirm", val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private void OnPunchConfirmReceived(ulong senderClientId, FastBufferReader reader) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(8)) { return; } ulong num = default(ulong); ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives)); PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (PlayerNetworking val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).OwnerClientId == num) { JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; if ((Object)(object)jonathanGnomeVisualHandler != (Object)null) { jonathanGnomeVisualHandler.PlayConfirmedPunchImpactSound(); } break; } } } private static bool MatchesKeywords(string text, string[] keywords, string[] excludeKeywords) { if (string.IsNullOrEmpty(text)) { return false; } if (excludeKeywords != null) { for (int i = 0; i < excludeKeywords.Length; i++) { if (text.IndexOf(excludeKeywords[i], StringComparison.OrdinalIgnoreCase) >= 0) { return false; } } } for (int j = 0; j < keywords.Length; j++) { if (text.IndexOf(keywords[j], StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static bool IsValidCharacterPrefab(GameObject go) { if ((Object)(object)go == (Object)null) { return false; } if ((Object)(object)go.GetComponentInChildren(typeof(Animator), true) == (Object)null) { return false; } if ((Object)(object)go.GetComponentInChildren(typeof(SkinnedMeshRenderer), true) == (Object)null) { return false; } if ((Object)(object)go.GetComponent(typeof(PlayerNetworking)) != (Object)null || (Object)(object)go.GetComponentInChildren(typeof(PlayerNetworking), true) != (Object)null) { return false; } if ((Object)(object)go.GetComponent(typeof(StealableObject)) != (Object)null || (Object)(object)go.GetComponentInChildren(typeof(StealableObject), true) != (Object)null) { return false; } return true; } private static bool HasComponentNamed(GameObject go, string componentTypeName) { if ((Object)(object)go == (Object)null || string.IsNullOrEmpty(componentTypeName)) { return false; } Component[] componentsInChildren = go.GetComponentsInChildren(typeof(Component), true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name.Equals(componentTypeName, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private GameObject FindPrefabByKeywords(string[] keywords, string[] excludeKeywords, ref GameObject cacheField, string logTag, string requiredComponentName = null) { if ((Object)(object)cacheField != (Object)null) { return cacheField; } BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; string text = ""; if (!string.IsNullOrEmpty(requiredComponentName)) { if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.NetworkConfig != null && NetworkManager.Singleton.NetworkConfig.Prefabs != null) { foreach (NetworkPrefab prefab in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs) { if (prefab != null && !((Object)(object)prefab.Prefab == (Object)null) && HasComponentNamed(prefab.Prefab, requiredComponentName) && IsValidCharacterPrefab(prefab.Prefab)) { cacheField = prefab.Prefab; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[" + logTag + "] Found prefab by component '" + requiredComponentName + "': " + ((Object)cacheField).name)); return cacheField; } } } if (Resources.FindObjectsOfTypeAll(typeof(GameObject)) is GameObject[] array) { GameObject[] array2 = array; foreach (GameObject val in array2) { if ((Object)(object)val != (Object)null && HasComponentNamed(val, requiredComponentName) && IsValidCharacterPrefab(val)) { cacheField = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[" + logTag + "] Found prefab by component '" + requiredComponentName + "': " + ((Object)cacheField).name)); return cacheField; } } } } if (Resources.FindObjectsOfTypeAll(typeof(MonoBehaviour)) is MonoBehaviour[] array3) { MonoBehaviour[] array4 = array3; foreach (MonoBehaviour val2 in array4) { if ((Object)(object)val2 == (Object)null || ((object)val2).GetType().Name != "AiDirector") { continue; } FieldInfo[] fields = ((object)val2).GetType().GetFields(bindingFlags); for (int j = 0; j < fields.Length; j++) { if (!(fields[j].GetValue(val2) is IEnumerable enumerable) || enumerable is string) { continue; } foreach (object item in enumerable) { if (item != null) { GameObject val3 = ExtractAnyPrefabFromEntry(item, bindingFlags); if ((Object)(object)val3 != (Object)null && !loggedAllAiPrefabs) { text = text + ((Object)val3).name + " | "; } GameObject val4 = ExtractPrefabFromEntry(item, bindingFlags, keywords, excludeKeywords); if ((Object)(object)val4 != (Object)null && IsValidCharacterPrefab(val4)) { cacheField = val4; return cacheField; } } } } } } if (!loggedAllAiPrefabs && !string.IsNullOrEmpty(text)) { loggedAllAiPrefabs = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[SkinMod] All AiDirector prefabs: " + text)); } if (Resources.FindObjectsOfTypeAll(typeof(ScriptableObject)) is ScriptableObject[] array5) { ScriptableObject[] array6 = array5; foreach (ScriptableObject val5 in array6) { if ((Object)(object)val5 != (Object)null && MatchesKeywords(((Object)val5).name, keywords, excludeKeywords)) { GameObject val6 = ExtractPrefabField(val5, bindingFlags); if ((Object)(object)val6 != (Object)null && IsValidCharacterPrefab(val6)) { cacheField = val6; return cacheField; } } } } if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.NetworkConfig != null && NetworkManager.Singleton.NetworkConfig.Prefabs != null) { foreach (NetworkPrefab prefab2 in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs) { if (prefab2 != null && (Object)(object)prefab2.Prefab != (Object)null && MatchesKeywords(((Object)prefab2.Prefab).name, keywords, excludeKeywords) && IsValidCharacterPrefab(prefab2.Prefab)) { cacheField = prefab2.Prefab; return cacheField; } } } if (Resources.FindObjectsOfTypeAll(typeof(GameObject)) is GameObject[] array7) { GameObject[] array2 = array7; foreach (GameObject val7 in array2) { if ((Object)(object)val7 != (Object)null && MatchesKeywords(((Object)val7).name, keywords, excludeKeywords) && IsValidCharacterPrefab(val7)) { cacheField = val7; return cacheField; } } } return null; } private GameObject ExtractAnyPrefabFromEntry(object entry, BindingFlags flags) { FieldInfo[] fields = entry.GetType().GetFields(flags); for (int i = 0; i < fields.Length; i++) { object value = fields[i].GetValue(entry); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { return val; } GameObject val2 = ExtractPrefabField(value, flags); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private GameObject ExtractPrefabFromEntry(object entry, BindingFlags flags, string[] keywords, string[] excludeKeywords) { Type type = entry.GetType(); bool flag = false; FieldInfo[] fields = type.GetFields(flags); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(string) && MatchesKeywords(fieldInfo.GetValue(entry) as string, keywords, excludeKeywords)) { flag = true; break; } } fields = type.GetFields(flags); for (int i = 0; i < fields.Length; i++) { object value = fields[i].GetValue(entry); if (value == null) { continue; } Object val = (Object)((value is Object) ? value : null); if (val != null && MatchesKeywords(val.name, keywords, excludeKeywords)) { flag = true; } if (flag) { GameObject val2 = (GameObject)((value is GameObject) ? value : null); if (val2 != null && !MatchesKeywords(((Object)val2).name, excludeKeywords, null)) { return val2; } GameObject val3 = ExtractPrefabField(value, flags); if ((Object)(object)val3 != (Object)null && !MatchesKeywords(((Object)val3).name, excludeKeywords, null)) { return val3; } } } return null; } private GameObject ExtractPrefabField(object entityDataObj, BindingFlags flags) { if (entityDataObj == null) { return null; } Type type = entityDataObj.GetType(); FieldInfo fieldInfo = type.GetField("prefab", flags) ?? type.GetField("Prefab", flags); if (fieldInfo != null) { object value = fieldInfo.GetValue(entityDataObj); GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { return val; } Component val2 = (Component)((value is Component) ? value : null); if (val2 != null) { return val2.gameObject; } } FieldInfo[] fields = type.GetFields(flags); for (int i = 0; i < fields.Length; i++) { object value2 = fields[i].GetValue(entityDataObj); GameObject val3 = (GameObject)((value2 is GameObject) ? value2 : null); if (val3 != null) { return val3; } Component val4 = (Component)((value2 is Component) ? value2 : null); if (val4 != null && (Object)(object)val4.GetComponentInChildren(typeof(Animator), true) != (Object)null) { return val4.gameObject; } } return null; } private void UpdateAllPlayersVisuals() { PlayerNetworking[] array = (PlayerNetworking[])(object)Object.FindObjectsByType(typeof(PlayerNetworking), (FindObjectsInactive)0, (FindObjectsSortMode)0); if (array == null || array.Length == 0) { return; } PlayerNetworking[] array2 = array; foreach (PlayerNetworking val in array2) { if ((Object)(object)val == (Object)null) { continue; } ulong ownerClientId = ((NetworkBehaviour)val).OwnerClientId; int num = (((NetworkBehaviour)val).IsLocalPlayer ? localSkinMode : (playersSkinMode.ContainsKey(ownerClientId) ? ((int)playersSkinMode[ownerClientId]) : 0)); if (((NetworkBehaviour)val).IsLocalPlayer) { playersSkinMode[ownerClientId] = localSkinMode; } JonathanGnomeVisualHandler jonathanGnomeVisualHandler = ((Component)val).GetComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; GameObject val2 = null; float scale = 1f; switch (num) { case 1: val2 = FindPrefabByKeywords(new string[1] { "jonathan" }, null, ref cachedJonathanPrefab, "JonathanMod"); scale = 1f; break; case 2: val2 = FindPrefabByKeywords(new string[2] { "sealman", "seal" }, null, ref cachedSealPrefab, "SealMod"); scale = 0.85f; break; case 3: val2 = FindPrefabByKeywords(new string[4] { "fairy", "bitch", "pixie", "keiju" }, null, ref cachedFairyPrefab, "FairyMod", "Fairy"); scale = 0.85f; break; case 4: val2 = FindPrefabByKeywords(new string[4] { "seagull", "gull", "lokki", "bird" }, null, ref cachedSeagullPrefab, "SeagullMod", "Seagull"); scale = 0.9f; break; case 5: val2 = FindPrefabByKeywords(new string[2] { "bibi", "beebee" }, null, ref cachedBibiPrefab, "BibiMod"); scale = 0.85f; break; case 6: val2 = FindPrefabByKeywords(new string[7] { "redcap", "red_cap", "red cap", "punahilkka", "punamyssy", "evilgnome", "badgnome" }, new string[7] { "cannon", "gun", "turret", "launcher", "weapon", "item", "trap" }, ref cachedRedcapPrefab, "RedcapMod"); scale = 0.95f; break; case 7: val2 = FindPrefabByKeywords(new string[5] { "boar", "wildboar", "pig", "hog", "villisika" }, null, ref cachedBoarPrefab, "BoarMod"); scale = 0.95f; break; case 8: val2 = FindPrefabByKeywords(new string[7] { "dog", "hound", "koira", "bulldog", "wolf", "pitbull", "mutt" }, new string[8] { "house", "kennel", "park", "bowl", "toy", "bone", "food", "blocker" }, ref cachedDogPrefab, "DogMod", "Dog"); scale = 0.95f; break; } if (num > 0 && (Object)(object)val2 != (Object)null) { if ((Object)(object)jonathanGnomeVisualHandler == (Object)null) { jonathanGnomeVisualHandler = ((Component)val).gameObject.AddComponent(typeof(JonathanGnomeVisualHandler)) as JonathanGnomeVisualHandler; } jonathanGnomeVisualHandler.SetSkinMode(val, num, val2, scale); } else if (num == 0 && (Object)(object)jonathanGnomeVisualHandler != (Object)null) { jonathanGnomeVisualHandler.SetSkinMode(val, 0, null, 1f); } } } } [DefaultExecutionOrder(10000)] public class JonathanGnomeVisualHandler : MonoBehaviour { private struct BoneMirrorPair { public Transform sourceBone; public Transform targetBone; public Quaternion rotOffset; } private PlayerNetworking targetPlayer; private Transform controllerTransform; private Rigidbody playerRigidbody; private GameObject visualRoot; private GameObject activePrefab; private Renderer[] visualModelRenderers; private Animator visualAnim; private Transform headBone; private Transform rightHandBone; private readonly ArrayList allVisualAnimators = new ArrayList(); private readonly ArrayList boomboxAudioSources = new ArrayList(); private readonly ArrayList boneMirrorPairs = new ArrayList(); private JonathanSoundRelay soundRelay; private int currentMode; private float modelScale = 1f; private float forcedStunUntil; private bool wasRagdolled; private Camera myCamera; private Renderer[] gnomeBodyRenderers; private Transform cachedTaskListTransform; private Vector3 originalTaskListLocalPos; private Quaternion originalTaskListLocalRot; private bool taskListOffsetApplied; private Vector3 lastWorldPos; private Vector3 smoothedRemotePos; private bool hasSmoothedRemotePos; private float smoothedSpeed; private float nextAmbientVoiceTime; private float nextDogLungeTime; private string speedFloatParam = "NormalizedSpeed"; private readonly ArrayList allSpeedFloatParams = new ArrayList(); private bool hasFlyingBool; private string[] attackTriggers = new string[1] { "Attack" }; private float attackHitDelay = 0.35f; private float attackCooldown = 0.9f; private float nextAttackTime; private float attackDamage = 40f; private static float cachedAttackRadius = 1.6f; private static float cachedAttackRange = 1.8f; private static float cachedKnockbackForce = 16f; private Component fairyLaserEyesVfx; private MethodInfo vfxPlayMethod; private MethodInfo vfxStopMethod; private MethodInfo vfxSetVector3Method; private Transform fairyLaserStart; private Component fairyLaserStartFeedback; private Component fairyLaserLoopFeedback; private float fairyMaxLaserDst = 14f; private LayerMask fairyLaserBlockLayers = LayerMask.op_Implicit(-1); private bool isFiringLaser; private Vector3 currentLaserTargetPos; private float nextLaserNetSyncTime; private float nextLaserDamageTickTime; private static readonly Hashtable bibiGrabbedTargets = new Hashtable(); private static readonly Hashtable bibiTiedTimers = new Hashtable(); private Component cachedStaminaComp; private FieldInfo cachedCurStaminaField; private FieldInfo cachedMaxStaminaField; private PropertyInfo cachedCurStaminaProp; private PropertyInfo cachedMaxStaminaProp; private bool healthModified; private float originalMaxHealth = -1f; public void SetSkinMode(PlayerNetworking player, int mode, GameObject prefab, float scale) { targetPlayer = player; if (mode == 0) { if (currentMode != 0) { StopFairyLaser(); UpdateTaskListHeight(raise: false); if ((Object)(object)player != (Object)null && bibiGrabbedTargets.ContainsKey(((NetworkBehaviour)player).OwnerClientId)) { bibiGrabbedTargets.Remove(((NetworkBehaviour)player).OwnerClientId); } currentMode = 0; activePrefab = null; visualModelRenderers = null; hasSmoothedRemotePos = false; forcedStunUntil = 0f; wasRagdolled = false; boomboxAudioSources.Clear(); boneMirrorPairs.Clear(); if ((Object)(object)visualRoot != (Object)null) { Object.Destroy((Object)(object)visualRoot); visualRoot = null; } SetGnomeVisibility(visible: true); UpdateHealthMultiplier(1f); } } else if (currentMode == mode && (Object)(object)visualRoot != (Object)null) { if (!visualRoot.activeSelf) { visualRoot.SetActive(true); } SetGnomeVisibility(visible: false); } else { SpawnVisualInstance(player, mode, prefab, scale); } } private void UpdateTaskListHeight(bool raise) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetPlayer == (Object)null || !((NetworkBehaviour)targetPlayer).IsLocalPlayer) { return; } if ((Object)(object)cachedTaskListTransform == (Object)null) { Component[] componentsInChildren = ((Component)((Component)targetPlayer).transform.root).GetComponentsInChildren(typeof(MonoBehaviour), true); for (int i = 0; i < componentsInChildren.Length; i++) { MonoBehaviour val = (MonoBehaviour)componentsInChildren[i]; if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == "TaskListUI") { cachedTaskListTransform = ((Component)val).transform; originalTaskListLocalPos = cachedTaskListTransform.localPosition; originalTaskListLocalRot = cachedTaskListTransform.localRotation; break; } } if ((Object)(object)cachedTaskListTransform == (Object)null) { Object obj = Object.FindAnyObjectByType(typeof(TaskListUI)); Component val2 = (Component)(object)((obj is Component) ? obj : null); if ((Object)(object)val2 != (Object)null) { cachedTaskListTransform = val2.transform; originalTaskListLocalPos = cachedTaskListTransform.localPosition; originalTaskListLocalRot = cachedTaskListTransform.localRotation; } } } if ((Object)(object)cachedTaskListTransform == (Object)null) { return; } if (raise && (Object)(object)visualRoot != (Object)null) { if ((Object)(object)rightHandBone != (Object)null) { cachedTaskListTransform.position = rightHandBone.position + visualRoot.transform.forward * 0.12f + Vector3.up * 0.08f; } else { Vector3 val3 = (((Object)(object)headBone != (Object)null) ? (headBone.position - Vector3.up * 0.25f) : (visualRoot.transform.position + Vector3.up * (1.35f * modelScale))); cachedTaskListTransform.position = val3 + visualRoot.transform.forward * 0.45f - visualRoot.transform.right * 0.25f; } taskListOffsetApplied = true; } else if (taskListOffsetApplied) { cachedTaskListTransform.localPosition = originalTaskListLocalPos; cachedTaskListTransform.localRotation = originalTaskListLocalRot; taskListOffsetApplied = false; } } public void SetBoomboxMusicState(bool enabled) { if (currentMode != 1) { return; } for (int i = 0; i < boomboxAudioSources.Count; i++) { object? obj = boomboxAudioSources[i]; AudioSource val = (AudioSource)((obj is AudioSource) ? obj : null); if ((Object)(object)val == (Object)null) { continue; } if (enabled) { val.mute = false; if (!val.isPlaying) { val.UnPause(); if (!val.isPlaying) { val.Play(); } } } else { val.mute = true; if (val.isPlaying) { val.Pause(); } } } } private bool IsThirdPersonCameraActive() { //IL_005f: 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_003c: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) if ((Object)(object)myCamera == (Object)null || (Object)(object)visualRoot == (Object)null) { return false; } Vector3 val = (((Object)(object)headBone != (Object)null) ? headBone.position : (visualRoot.transform.position + Vector3.up * (1.5f * modelScale))); if (Vector3.Distance(((Component)myCamera).transform.position, val) > 0.85f) { return true; } if (Vector3.Dot(((Component)myCamera).transform.position - val, -((Component)myCamera).transform.forward) > 0.45f) { return true; } return false; } private void ApplyHeadBoneCameraPosition() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetPlayer == (Object)null || !((NetworkBehaviour)targetPlayer).IsLocalPlayer || currentMode == 0 || (Object)(object)visualRoot == (Object)null) { return; } if ((Object)(object)myCamera == (Object)null) { myCamera = (Camera)(((object)Camera.main) ?? ((object)/*isinst with value type is only supported in some contexts*/)); } if ((Object)(object)myCamera == (Object)null || IsThirdPersonCameraActive()) { return; } if (myCamera.nearClipPlane > 0.05f) { myCamera.nearClipPlane = 0.05f; } if (IsPlayerRagdolledOrDead()) { if ((Object)(object)headBone != (Object)null) { ((Component)myCamera).transform.position = headBone.position + Vector3.up * 0.12f; } else { ((Component)myCamera).transform.position = ((GameEntityBase)targetPlayer).Center + Vector3.up * 0.25f; } } else { Vector3 val = (((Object)(object)headBone != (Object)null) ? headBone.position : (visualRoot.transform.position + Vector3.up * (1.5f * modelScale))); float num = ((currentMode == 1) ? 0.38f : ((currentMode == 2) ? 0.65f : ((currentMode == 3) ? 0.5f : ((currentMode == 4) ? 0.48f : ((currentMode == 5) ? 0.45f : ((currentMode == 6) ? 0.42f : ((currentMode == 7) ? 0.68f : 0.62f))))))); ((Component)myCamera).transform.position = val + visualRoot.transform.forward * (num * modelScale); } } private void SpawnVisualInstance(PlayerNetworking player, int mode, GameObject prefab, float scale) { //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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Expected O, but got Unknown //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Expected O, but got Unknown if ((Object)(object)prefab == (Object)null) { return; } StopFairyLaser(); if ((Object)(object)visualRoot != (Object)null) { Object.Destroy((Object)(object)visualRoot); visualRoot = null; } currentMode = mode; activePrefab = prefab; modelScale = scale; hasSmoothedRemotePos = false; forcedStunUntil = 0f; wasRagdolled = false; float num; switch (mode) { default: num = 25f; break; case 7: case 8: num = 35f; break; case 1: num = 40f; break; } attackDamage = num; Transform val = ((Component)player).transform.root.Find("Controller"); controllerTransform = (((Object)(object)val != (Object)null) ? val : ((Component)player).transform); ref Rigidbody reference = ref playerRigidbody; Component component = ((Component)controllerTransform).GetComponent(typeof(Rigidbody)); reference = (Rigidbody)(((object)((component is Rigidbody) ? component : null)) ?? ((object)/*isinst with value type is only supported in some contexts*/)); lastWorldPos = GetSyncedPlayerPosition(); nextAmbientVoiceTime = Time.time + Random.Range(6f, 14f); CacheGnomeBodyOnly(); CacheStaminaComponent(); ExtractAiAttackActionSettings(prefab, mode); visualRoot = Object.Instantiate<GameObject>(prefab); ((Object)visualRoot).name = "CustomSkin_" + mode + "_" + ((NetworkBehaviour)player).OwnerClientId; visualRoot.transform.position = GetSyncedPlayerPosition(); visualRoot.transform.rotation = GetSyncedPlayerRotation(); visualRoot.transform.localScale = Vector3.one * modelScale; if (mode == 3) { ExtractNativeFairyLaserComponents(visualRoot); } CleanExtraMeshes(visualRoot, mode); StripAllPhysicsAndAiComponents(visualRoot, mode); allVisualAnimators.Clear(); visualAnim = null; Component[] componentsInChildren = visualRoot.GetComponentsInChildren(typeof(Animator), true); for (int i = 0; i < componentsInChildren.Length; i++) { Animator val2 = (Animator)componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null)) { allVisualAnimators.Add(val2); if ((Object)(object)visualAnim == (Object)null && (Object)(object)val2.runtimeAnimatorController != (Object)null) { visualAnim = val2; } } } if ((Object)(object)visualAnim == (Object)null && allVisualAnimators.Count > 0) { ref Animator reference2 = ref visualAnim; object? obj = allVisualAnimators[0]; reference2 = (Animator)((obj is Animator) ? obj : null); } DetectAnimatorParameters(mode); FindHeadAndHandBones(); BuildRagdollBoneMirror(); boomboxAudioSources.Clear(); componentsInChildren = visualRoot.GetComponentsInChildren(typeof(AudioSource), true); for (int i = 0; i < componentsInChildren.Length; i++) { AudioSource val3 = (AudioSource)componentsInChildren[i]; if ((Object)(object)val3 == (Object)null) { continue; } val3.spatialBlend = 1f; string text = (((Object)(object)val3.clip != (Object)null) ? ((Object)val3.clip).name.ToLowerInvariant() : ""); string text2 = ((Object)((Component)val3).gameObject).name.ToLowerInvariant(); bool flag = val3.loop || text.Contains("music") || text.Contains("boombox") || text2.Contains("music") || text2.Contains("boombox"); if (mode == 1 && flag && !text.Contains("taser") && !text.Contains("shock") && !text.Contains("stun")) { boomboxAudioSources.Add(val3); val3.loop = true; bool playerMusicEnabled = JonathanPlugin.GetPlayerMusicEnabled(((NetworkBehaviour)player).OwnerClientId); val3.mute = !playerMusicEnabled; if (playerMusicEnabled) { if (!val3.isPlaying) { val3.Play(); } } else { val3.Pause(); } } else if (val3.loop || text.Contains("taser") || text.Contains("shock") || text.Contains("stun") || text.Contains("elec") || flag || text2.Contains("taser") || text2.Contains("shock") || text2.Contains("stun")) { val3.Stop(); val3.playOnAwake = false; val3.loop = false; } } foreach (Animator allVisualAnimator in allVisualAnimators) { Animator val4 = allVisualAnimator; if (!((Object)(object)val4 == (Object)null)) { ((Behaviour)val4).enabled = true; val4.applyRootMotion = false; val4.cullingMode = (AnimatorCullingMode)0; val4.Rebind(); } } visualModelRenderers = visualRoot.GetComponentsInChildren(typeof(Renderer), true) as Renderer[]; if (visualModelRenderers != null) { Renderer[] array = visualModelRenderers; foreach (Renderer val5 in array) { if ((Object)(object)val5 != (Object)null) { val5.enabled = true; val5.shadowCastingMode = (ShadowCastingMode)1; } } } SetGnomeVisibility(visible: false); float num2; switch (mode) { default: num2 = 1.2f; break; case 3: num2 = 1.3f; break; case 6: num2 = 1.4f; break; case 2: case 5: num2 = 1.5f; break; case 8: num2 = 1.6f; break; case 7: num2 = 1.8f; break; case 1: num2 = 2f; break; } float multiplier = num2; UpdateHealthMultiplier(multiplier); } private void BuildRagdollBoneMirror() { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) boneMirrorPairs.Clear(); if ((Object)(object)targetPlayer == (Object)null || (Object)(object)targetPlayer.Puppet == (Object)null || (Object)(object)((BehaviourBase)targetPlayer.Puppet).puppetMaster == (Object)null || (Object)(object)visualAnim == (Object)null || !visualAnim.isHuman) { return; } Component componentInChildren = ((Component)targetPlayer).GetComponentInChildren(typeof(Animator), true); Animator val = (Animator)(object)((componentInChildren is Animator) ? componentInChildren : null); if ((Object)(object)val == (Object)null || !val.isHuman) { return; } HumanBodyBones[] array = new HumanBodyBones[13]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); HumanBodyBones[] array2 = (HumanBodyBones[])(object)array; for (int i = 0; i < array2.Length; i++) { Transform boneTransform = val.GetBoneTransform(array2[i]); Transform boneTransform2 = visualAnim.GetBoneTransform(array2[i]); if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null) { BoneMirrorPair boneMirrorPair = new BoneMirrorPair { sourceBone = boneTransform, targetBone = boneTransform2, rotOffset = Quaternion.Inverse(boneTransform.rotation) * boneTransform2.rotation }; boneMirrorPairs.Add(boneMirrorPair); } } } private void SyncRagdollPoseFromGnome() { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) if ((Object)(object)targetPlayer == (Object)null) { return; } PuppetMaster val = (((Object)(object)targetPlayer.Puppet != (Object)null) ? ((BehaviourBase)targetPlayer.Puppet).puppetMaster : null); if ((Object)(object)val != (Object)null && val.muscles != null && val.muscles.Length != 0 && val.muscles[0] != null && (Object)(object)val.muscles[0].rigidbody != (Object)null) { Rigidbody rigidbody = val.muscles[0].rigidbody; visualRoot.transform.position = rigidbody.position - Vector3.up * (0.35f * modelScale); if (boneMirrorPairs.Count == 0) { visualRoot.transform.rotation = rigidbody.rotation; } if (boneMirrorPairs.Count <= 0) { return; } for (int i = 0; i < boneMirrorPairs.Count; i++) { BoneMirrorPair boneMirrorPair = (BoneMirrorPair)boneMirrorPairs[i]; if ((Object)(object)boneMirrorPair.sourceBone != (Object)null && (Object)(object)boneMirrorPair.targetBone != (Object)null) { boneMirrorPair.targetBone.rotation = boneMirrorPair.sourceBone.rotation * boneMirrorPair.rotOffset; } } BoneMirrorPair boneMirrorPair2 = (BoneMirrorPair)boneMirrorPairs[0]; if ((Object)(object)boneMirrorPair2.sourceBone != (Object)null && (Object)(object)boneMirrorPair2.targetBone != (Object)null) { boneMirrorPair2.targetBone.position = boneMirrorPair2.sourceBone.position; } } else { visualRoot.transform.position = ((GameEntityBase)targetPlayer).Center - Vector3.up * 0.25f; Transform transform = visualRoot.transform; Quaternion syncedPlayerRotation = GetSyncedPlayerRotation(); transform.rotation = Quaternion.Euler(80f, ((Quaternion)(ref syncedPlayerRotation)).eulerAngles.y, 0f); } } private void CacheStaminaComponent() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if ((Object)(object)targetPlayer == (Object)null || (Object)(object)cachedStaminaComp != (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren = ((Component)((Component)targetPlayer).transform.root).GetComponentsInChildren(typeof(MonoBehaviour), true); for (int i = 0; i < componentsInChildren.Length; i++) { MonoBehaviour val = (MonoBehaviour)componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } Type type = ((object)val).GetType(); if (type.Name.IndexOf("Stamina", StringComparison.OrdinalIgnoreCase) >= 0 || type.Name.IndexOf("Movement", StringComparison.OrdinalIgnoreCase) >= 0 || type.Name.IndexOf("Controller", StringComparison.OrdinalIgnoreCase) >= 0) { FieldInfo fieldInfo = type.GetField("stamina", bindingAttr) ?? type.GetField("currentStamina", bindingAttr) ?? type.GetField("_stamina", bindingAttr) ?? type.GetField("_currentStamina", bindingAttr); PropertyInfo propertyInfo = type.GetProperty("Stamina", bindingAttr) ?? type.GetProperty("CurrentStamina", bindingAttr) ?? type.GetProperty("stamina", bindingAttr); if (fieldInfo != null || (propertyInfo != null && propertyInfo.CanWrite)) { cachedStaminaComp = (Component)(object)val; cachedCurStaminaField = fieldInfo; cachedCurStaminaProp = propertyInfo; cachedMaxStaminaField = type.GetField("maxStamina", bindingAttr) ?? type.GetField("MaxStamina", bindingAttr) ?? type.GetField("_maxStamina", bindingAttr); cachedMaxStaminaProp = type.GetProperty("MaxStamina", bindingAttr) ?? type.GetProperty("maxStamina", bindingAttr); break; } } } } private void RefillInfiniteStamina() { if ((Object)(object)cachedStaminaComp == (Object)null) { return; } try { float num = 100f; if (cachedMaxStaminaField != null && cachedMaxStaminaField.FieldType == typeof(float)) { num = (float)cachedMaxStaminaField.GetValue(cachedStaminaComp); } else if (cachedMaxStaminaProp != null && cachedMaxStaminaProp.PropertyType == typeof(float)) { num = (float)cachedMaxStaminaProp.GetValue(cachedStaminaComp); } if (num <= 0f) { num = 100f; } if (cachedCurStaminaField != null && cachedCurStaminaField.FieldType == typeof(float)) { cachedCurStaminaField.SetValue(cachedStaminaComp, num); } else if (cachedCurStaminaProp != null && cachedCurStaminaProp.CanWrite && cachedCurStaminaProp.PropertyType == typeof(float)) { cachedCurStaminaProp.SetValue(cachedStaminaComp, num); } } catch { } } private void ExtractNativeFairyLaserComponents(GameObject root) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) fairyLaserEyesVfx = null; fairyLaserStart = null; fairyLaserStartFeedback = null; fairyLaserLoopFeedback = null; fairyMaxLaserDst = 14f; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; Component[] componentsInChildren = root.GetComponentsInChildren(typeof(MonoBehaviour), true); for (int i = 0; i < componentsInChildren.Length; i++) { MonoBehaviour val = (MonoBehaviour)componentsInChildren[i]; if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "Fairy") { continue; } Type type = ((object)val).GetType(); ref Component reference = ref fairyLaserEyesVfx; object? obj = type.GetField("laserEyes", bindingAttr)?.GetValue(val); reference = (Component)((obj is Component) ? obj : null); ref Transform reference2 = ref fairyLaserStart; object? obj2 = type.GetField("laserStart", bindingAttr)?.GetValue(val); reference2 = (Transform)((obj2 is Transform) ? obj2 : null); ref Component reference3 = ref fairyLaserStartFeedback; object? obj3 = type.GetField("laserStartFeedback", bindingAttr)?.GetValue(val); reference3 = (Component)((obj3 is Component) ? obj3 : null); ref Component reference4 = ref fairyLaserLoopFeedback; object? obj4 = type.GetField("laserLoopFeedback", bindingAttr)?.GetValue(val); reference4 = (Component)((obj4 is Component) ? obj4 : null); FieldInfo field = type.GetField("maxLaserDst", bindingAttr); if (field != null && field.FieldType == typeof(float)) { float num = (float)field.GetValue(val); if (num > 0.5f) { fairyMaxLaserDst = num; } } FieldInfo field2 = type.GetField("laserBlockLayers", bindingAttr); if (field2 != null && field2.FieldType == typeof(LayerMask)) { fairyLaserBlockLayers = (LayerMask)field2.GetValue(val); } object obj5 = type.GetField("text", bindingAttr)?.GetValue(val); GameObject val2 = (GameObject)((obj5 is GameObject) ? obj5 : null); if (val2 != null) { val2.SetActive(false); } else { Component val3 = (Component)((obj5 is Component) ? obj5 : null); if (val3 != null) { val3.gameObject.SetActive(false); } } if ((Object)(object)fairyLaserEyesVfx != (Object)null) { fairyLaserEyesVfx.gameObject.SetActive(true); Type type2 = ((object)fairyLaserEyesVfx).GetType(); vfxPlayMethod = type2.GetMethod("Play", bindingAttr, null, Type.EmptyTypes, null); vfxStopMethod = type2.GetMethod("Stop", bindingAttr, null, Type.EmptyTypes, null); vfxSetVector3Method = type2.GetMethod("SetVector3", bindingAttr, null, new Type[2] { typeof(string), typeof(Vector3) }, null); } break; } componentsInChildren = root.GetComponentsInChildren(typeof(Canvas), true); for (int i = 0; i < componentsInChildren.Length; i++) { Canvas val4 = (Canvas)componentsInChildren[i]; if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(false); } } } private void DetectAnimatorParameters(int mode) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Invalid comparison between Unknown and I4 //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Invalid comparison between Unknown and I4 speedFloatParam = "NormalizedSpeed"; allSpeedFloatParams.Clear(); hasFlyingBool = false; ArrayList arrayList = new ArrayList(); for (int i = 0; i < allVisualAnimators.Count; i++) { object? obj = allVisualAnimators[i]; Animator val = (Animator)((obj is Animator) ? obj : null); if ((Object)(object)val == (Object)null || (Object)(object)val.runtimeAnimatorController == (Object)null) { continue; } AnimatorControllerParameter[] parameters = val.parameters; foreach (AnimatorControllerParameter val2 in parameters) { if ((int)val2.type == 1) { if (!allSpeedFloatParams.Contains(val2.name)) { allSpeedFloatParams.Add(val2.name); } if (val2.name.Equals("NormalizedSpeed", StringComparison.OrdinalIgnoreCase) || val2.name.IndexOf("speed", StringComparison.OrdinalIgnoreCase) >= 0) { speedFloatParam = val2.name; } } else if ((int)val2.type == 4 && val2.name.Equals("Flying", StringComparison.OrdinalIgnoreCase)) { hasFlyingBool = true; } else if ((int)val2.type == 9 && !arrayList.Contains(val2.name)) { arrayList.Add(val2.name); } } } if (mode >= 3 && arrayList.Count > 0) { attackTriggers = arrayList.ToArray(typeof(string)) as string[]; } } private void CacheGnomeBodyOnly() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if ((Object)(object)targetPlayer == (Object)null) { return; } BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = typeof(PlayerNetworking).GetField("handController", bindingAttr); Component val = (Component)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); Transform obj = (((Object)(object)val != (Object)null) ? val.transform : ((Component)targetPlayer).transform); ArrayList arrayList = new ArrayList(); Component[] componentsInChildren = ((Component)obj).GetComponentsInChildren(typeof(Renderer), true); for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val2 = (Renderer)componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).GetComponentInParent(typeof(StealableObject)) != (Object)null) && !((Object)(object)((Component)val2).GetComponentInParent(typeof(InteractableObject)) != (Object)null)) { arrayList.Add(val2); } } gnomeBodyRenderers = arrayList.ToArray(typeof(Renderer)) as Renderer[]; } private Vector3 GetSyncedPlayerPosition() { //IL_000e: 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_0046: 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_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_009b: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)targetPlayer == (Object)null) { return Vector3.zero; } if (((NetworkBehaviour)targetPlayer).IsLocalPlayer) { if (!((Object)(object)controllerTransform != (Object)null)) { return ((Component)targetPlayer).transform.position; } return controllerTransform.position; } Vector3 val = ((GameEntityBase)targetPlayer).Position; if (((Vector3)(ref val)).sqrMagnitude <= 0.001f) { val = (((Object)(object)controllerTransform != (Object)null) ? controllerTransform.position : ((Component)targetPlayer).transform.position); } if (!hasSmoothedRemotePos || Vector3.Distance(smoothedRemotePos, val) > 4f) { smoothedRemotePos = val; hasSmoothedRemotePos = true; } else { float num = Mathf.Max(0.0001f, Time.deltaTime); smoothedRemotePos.x = Mathf.Lerp(smoothedRemotePos.x, val.x, num * 18f); smoothedRemotePos.z = Mathf.Lerp(smoothedRemotePos.z, val.z, num * 18f); float num2 = ((Mathf.Abs(val.y - smoothedRemotePos.y) < 0.25f) ? 8f : 18f); smoothedRemotePos.y = Mathf.Lerp(smoothedRemotePos.y, val.y, num * num2); } return smoothedRemotePos; } private Quaternion GetSyncedPlayerRotation() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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) if ((Object)(object)targetPlayer == (Object)null) { return Quaternion.identity; } if (((NetworkBehaviour)targetPlayer).IsLocalPlayer) { Camera val = (((Object)(object)myCamera != (Object)null) ? myCamera : Camera.main); if ((Object)(object)val != (Object)null) { return Quaternion.Euler(0f, ((Component)val).transform.eulerAngles.y, 0f); } if ((Object)(object)controllerTransform != (Object)null) { return Quaternion.Euler(0f, controllerTransform.eulerAngles.y, 0f); } } Quaternion rotation = ((GameEntityBase)targetPlayer).Rotation; return Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f); } private void FindHeadAndHandBones() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown headBone = null; rightHandBone = null; if ((Object)(object)visualAnim != (Object)null && visualAnim.isHuman) { headBone = visualAnim.GetBoneTransform((HumanBodyBones)10); rightHandBone = visualAnim.GetBoneTransform((HumanBodyBones)18) ?? visualAnim.GetBoneTransform((HumanBodyBones)17); if ((Object)(object)headBone != (Object)null) { return; } } Transform val = null; Component[] componentsInChildren = visualRoot.GetComponentsInChildren(typeof(Transform), true); for (int i = 0; i < componentsInChildren.Length; i++) { Transform val2 = (Transform)componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null)) { string text = ((Object)val2).name.ToLowerInvariant(); if ((Object)(object)headBone == (Object)null && (text == "head" || text.EndsWith(":head") || text.EndsWith("_head") || text.EndsWith(".head") || text.Contains("head") || text.Contains("skull") || text.Contains("beak") || text.Contains("snout"))) { headBone = val2; } if ((Object)(object)rightHandBone == (Object)null && (text.Contains("hand") || text.Contains("palm") || text.Contains("wrist"))) { rightHandBone = val2; } if ((Object)(object)val == (Object)null && (text.Contains("neck") || text.Contains("face"))) { val = val2; } } } if ((Object)(object)headBone == (Object)null) { headBone = val; } } private void CleanExtraMeshes(GameObject root, int mode) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return; } ArrayList arrayList = new ArrayList(); Component[] componentsInChildren = root.GetComponentsInChildren(typeof(Transform), true); for (int i = 0; i < componentsInChildren.Length; i++) { Transform val = (Transform)componentsInChildren[i]; if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)(object)root) { continue; } string text = ((Object)val).name.ToLowerInvariant(); bool flag = text.Contains("boombox") || text.Contains("musicbox") || text.Contains("jukebox") || text.Contains("radio"); if (mode == 1 && flag) { continue; } bool flag2 = false; Component component = ((Component)val).GetComponent(typeof(MeshFilter)); MeshFilter val2 = (MeshFilter)(object)((component is MeshFilter) ? component : null); Component component2 = ((Component)val).GetComponent(typeof(MeshRenderer)); MeshRenderer val3 = (MeshRenderer)(object)((component2 is MeshRenderer) ? component2 : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null) { switch (((Object)val2.sharedMesh).name.ToLowerInvariant()) { default: if (!text.Contains("hitbox") && !text.Contains("trigger") && !text.Contains("bounds") && !text.Contains("cube")) { break; } goto case "cube"; case "cube": case "sphere": case "capsule": flag2 = true; break; } } if (!(flag || flag2)) { continue; } Component[] componentsInChildren2 = ((Component)val).GetComponentsInChildren(typeof(Renderer), true); for (int j = 0; j < componentsInChildren2.Length; j++) { Renderer val4 = (Renderer)componentsInChildren2[j]; if ((Object)(object)val4 != (Object)null) { val4.enabled = false; } } if ((Object)(object)val3 != (Object)null || (Object)(object)((Component)val).GetComponentInChildren(typeof(MeshRenderer), true) != (Object)null || (Object)(object)((Component)val).GetComponentInChildren(typeof(SkinnedMeshRenderer), true) != (Object)null) { arrayList.Add(((Component)val).gameObject); } } foreach (GameObject item in arrayList) { GameObject val5 = item; if ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)val5); } } } private void ExtractAiAttackActionSettings(GameObject prefab, int mode) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown speedFloatParam = "NormalizedSpeed"; cachedKnockbackForce = 16f; switch (mode) { case 2: attackTriggers = new string[1] { "Slap" }; attackHitDelay = 0.3f; attackCooldown = 1.1f; return; case 3: attackTriggers = new string[1] { "Attack" }; attackHitDelay = 0.1f; attackCooldown = 0.2f; return; } if ((Object)(object)prefab == (Object)null) { return; } BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; attackTriggers = new string[1] { "Attack" }; attackHitDelay = 0.3f; attackCooldown = 0.85f; Component[] componentsInChildren = prefab.GetComponentsInChildren(typeof(MonoBehaviour), true); for (int i = 0; i < componentsInChildren.Length; i++) { MonoBehaviour val = (MonoBehaviour)componentsInChildren[i]; if ((Object)(object)val == (Object)null || ((object)val).GetType().Name != "AiAttackAction") { continue; } Type type = ((object)val).GetType(); FieldInfo field = type.GetField("attackTriggersRandom", bindingFlags); if (field != null && field.GetValue(val) is IList { Count: >0 } list) { string[] array = new string[list.Count]; for (int j = 0; j < list.Count; j++) { array[j] = list[j] as string; } attackTriggers = array; } ReadFloatField(val, type, bindingFlags, new string[4] { "hitDelay", "attackDelay", "damageDelay", "delay" }, ref attackHitDelay); ReadFloatField(val, type, bindingFlags, new string[3] { "cooldown", "attackCooldown", "duration" }, ref attackCooldown); ReadFloatField(val, type, bindingFlags, new string[3] { "hitRadius", "radius", "attackRadius" }, ref cachedAttackRadius); ReadFloatField(val, type, bindingFlags, new string[4] { "hitRange", "range", "attackRange", "distance" }, ref cachedAttackRange); float target = 0f; ReadFloatField(val, type, bindingFlags, new string[4] { "knockback", "knockbackForce", "force", "pushForce" }, ref target); cachedKnockbackForce = Mathf.Max(15f, target); break; } } private void ReadFloatField(object obj, Type t, BindingFlags flags, string[] names, ref float target) { foreach (string name in names) { FieldInfo field = t.GetField(name, flags); if (field != null && field.FieldType == typeof(float)) { float num = (float)field.GetValue(obj); if (num > 0.01f) { target = num; break; } } } } private void StripAllPhysicsAndAiComponents(GameObject root, int mode) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_0148: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown Component[] componentsInChildren = root.GetComponentsInChildren(typeof(MonoBehaviour), true); for (int i = 0; i < componentsInChildren.Length; i++) { MonoBehaviour val = (MonoBehaviour)componentsInChildren[i]; if (!((Object)(object)val == (Object)null)) { switch (((object)val).GetType().Name) { case "Transform": case "Animator": case "MMF_Player": continue; } Object.DestroyImmediate((Object)(object)val); } } componentsInChildren = root.GetComponentsInChildren(typeof(Joint), true); for (int i = 0; i < componentsInChildren.Length; i++) { Joint val2 = (Joint)componentsInChildren[i]; if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } } componentsInChildren = root.GetComponentsInChildren(typeof(Rigidbody), true); for (int i = 0; i < componentsInChildren.Length; i++) { Rigidbody val3 = (Rigidbody)componentsInChildren[i]; if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)val3); } } componentsInChildren = root.GetComponentsInChildren(typeof(Collider), true); for (int i = 0; i < componentsInChildren.Length; i++) { Collider val4 = (Collider)componentsInChildren[i]; if ((Object)(object)val4 != (Object)null) { Object.DestroyImmediate((Object)(object)val4); } } componentsInChildren = root.GetComponentsInChildren(typeof(ParticleSystem), true); for (int i = 0; i < componentsInChildren.Length; i++) { ParticleSystem val5 = (ParticleSystem)componentsInChildren[i]; if ((Object)(object)val5 != (Object)null) { MainModule main = val5.main; ((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0; } } soundRelay = root.AddComponent(typeof(JonathanSoundRelay)) as JonathanSoundRelay; soundRelay.Init(root, mode); componentsInChildren = root.GetComponentsInChildren(typeof(Animator), true); for (int i = 0; i < componentsInChildren.Length; i++) { Animator val6 = (Animator)componentsInChildren[i]; if ((Object)(object)val6 != (Object)null && (Object)(object)((Component)val6).gameObject.GetComponent(typeof(JonathanAnimEventProxy)) == (Object)null) { (((Component)val6).gameObject.AddComponent(typeof(JonathanAnimEventProxy)) as JonathanAnimEventProxy).relay = soundRelay; } } } private void UpdateHealthMultiplier(float multiplier) { if ((Object)(object)targetPlayer == (Object)null || (Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening) { return; } bool flag = multiplier > 1.01f; if (flag == healthModified && !flag) { return; } bool isServer = NetworkManager.Singleton.IsServer; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; object obj = null; Type type = ((object)targetPlayer).GetType(); while (type != null && type != typeof(object)) { FieldInfo fieldInfo = type.GetField("healthBase", bindingAttr) ?? type.GetField("HealthBase", bindingAttr) ?? type.GetField("health", bindingAttr); if (fieldInfo != null) { obj = fieldInfo.GetValue(targetPlayer); if (obj != null) { break; } } PropertyInfo propertyInfo = type.GetProperty("HealthBase", bindingAttr) ?? type.GetProperty("Health", bindingAttr); if (propertyInfo != null) { try { obj = propertyInfo.GetValue(targetPlayer); } catch { } if (obj != null) { break; } } type = type.BaseType; } if (obj == null) { Component[] componentsInChildren = ((Component)targetPlayer).GetComponentsInChildren(typeof(Component), true); foreach (Component val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name.IndexOf("Health", StringComparison.OrdinalIgnoreCase) >= 0) { obj = val; break; } } } if (obj == null) { return; } Type type2 = obj.GetType(); FieldInfo fieldInfo2 = type2.GetField("maxHealth", bindingAttr) ?? type2.GetField("MaxHealth", bindingAttr) ?? type2.GetField("_maxHealth", bindingAttr); PropertyInfo propertyInfo2 = type2.GetProperty("MaxHealth", bindingAttr) ?? type2.GetProperty("maxHealth", bindingAttr); if (originalMaxHealth <= 0f) { if (fieldInfo2 != null && fieldInfo2.FieldType == typeof(float)) { originalMaxHealth = (float)fieldInfo2.GetValue(obj); } else if (propertyInfo2 != null && propertyInfo2.PropertyType == typeof(fl