using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Antro.FunnyHats")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Antro.FunnyHats")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0.0")] [assembly: AssemblyProduct("Antro.FunnyHats")] [assembly: AssemblyTitle("Antro.FunnyHats")] [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; } } } [BepInPlugin("Antro.FunnyHats", "FunnyHats", "1.0.0")] public class FunnyHats : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__4_0; public static HandleNamedMessageDelegate <>9__5_0; public static Action <>9__5_1; internal void b__4_0(object sender, EventArgs args) { SyncToClients(); } internal void b__5_0(ulong senderId, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) float value = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, default(ForPrimitives)); HatLengthConfig.Value = value; } internal void b__5_1(ulong id) { SyncToClients(); } } public static ConfigEntry HatLengthConfig; public static ManualLogSource Log; private const string SYNC_MSG = "FunnyHats_SyncLength"; private bool msgRegistered = false; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; HatLengthConfig = ((BaseUnityPlugin)this).Config.Bind("General", "HatLength", 1f, "Physically and visually scales the hat length."); HatLengthConfig.SettingChanged += delegate { SyncToClients(); }; Log.LogInfo((object)"[FunnyHats] Mod initialized successfully!"); } private void Update() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (Input.GetKeyDown((KeyCode)286)) { ((BaseUnityPlugin)this).Config.Reload(); Log.LogInfo((object)$"[FunnyHats] Config reloaded! New Value: {HatLengthConfig.Value}"); SyncToClients(); } if (!msgRegistered && (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsListening && NetworkManager.Singleton.CustomMessagingManager != null) { CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__5_0; if (obj == null) { HandleNamedMessageDelegate val = delegate(ulong senderId, FastBufferReader reader) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) float value = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref value, default(ForPrimitives)); HatLengthConfig.Value = value; }; <>c.<>9__5_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("FunnyHats_SyncLength", (HandleNamedMessageDelegate)obj); if (NetworkManager.Singleton.IsServer) { NetworkManager.Singleton.OnClientConnectedCallback += delegate { SyncToClients(); }; } msgRegistered = true; } if (GameProgressionManager.AllPlayers == null) { return; } foreach (PlayerNetworking allPlayer in GameProgressionManager.AllPlayers) { if ((Object)(object)allPlayer != (Object)null && (Object)(object)((Component)allPlayer).gameObject.GetComponent() == (Object)null) { HatScaler hatScaler = ((Component)allPlayer).gameObject.AddComponent(); hatScaler.player = allPlayer; } } } public unsafe static void SyncToClients() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsServer) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1); FastBufferWriter val2 = val; try { float value = HatLengthConfig.Value; ((FastBufferWriter)(ref val)).WriteValueSafe(ref value, default(ForPrimitives)); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("FunnyHats_SyncLength", val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } } [DefaultExecutionOrder(10000)] public class HatScaler : MonoBehaviour { private class PhysicsBoneData { public Transform t; public bool isRoot; public Vector3 origLocalPos; public Joint joint; public Vector3 origConnectedAnchor; public CapsuleCollider cap; public float origHeight; public Vector3 origCenter; } public PlayerNetworking player; private List physicsBones = new List(); private Transform visualHatRoot; private Vector3 origVisualScale; private bool isInitialized = false; private float searchTimer = 0f; private void Update() { if (!isInitialized) { searchTimer += Time.deltaTime; if (searchTimer > 0.5f) { searchTimer = 0f; TryFindHatBones(); } } } private void FixedUpdate() { if (isInitialized) { ApplyScale(FunnyHats.HatLengthConfig.Value); } } private void LateUpdate() { if (isInitialized) { ApplyScale(FunnyHats.HatLengthConfig.Value); } } private void TryFindHatBones() { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) if ((Object)(object)player == (Object)null) { return; } physicsBones.Clear(); visualHatRoot = null; Transform[] componentsInChildren = ((Component)((Component)player).transform.root).GetComponentsInChildren(true); Transform[] array = componentsInChildren; foreach (Transform val in array) { string text = ((Object)val).name.ToLower(); if (!text.Contains("hat_")) { continue; } bool flag = (Object)(object)val.parent == (Object)null || !((Object)val.parent).name.ToLower().Contains("hat_"); bool flag2 = false; Transform val2 = val; while ((Object)(object)val2 != (Object)null) { if (((Object)val2).name.ToLower().Contains("puppetmaster")) { flag2 = true; break; } val2 = val2.parent; } if (flag2) { PhysicsBoneData physicsBoneData = new PhysicsBoneData(); physicsBoneData.t = val; physicsBoneData.isRoot = flag; physicsBoneData.origLocalPos = val.localPosition; physicsBoneData.joint = ((Component)val).GetComponent(); if ((Object)(object)physicsBoneData.joint != (Object)null) { physicsBoneData.origConnectedAnchor = physicsBoneData.joint.connectedAnchor; } physicsBoneData.cap = ((Component)val).GetComponent(); if ((Object)(object)physicsBoneData.cap != (Object)null) { physicsBoneData.origHeight = physicsBoneData.cap.height; physicsBoneData.origCenter = physicsBoneData.cap.center; } physicsBones.Add(physicsBoneData); } else if (flag) { visualHatRoot = val; origVisualScale = val.localScale; } } if ((Object)(object)visualHatRoot != (Object)null && physicsBones.Count > 0) { isInitialized = true; FunnyHats.Log.LogInfo((object)$"[FunnyHats] READY! Visual Root found. Physics Bones: {physicsBones.Count}"); } } private void ApplyScale(float length) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)visualHatRoot != (Object)null) { visualHatRoot.localScale = new Vector3(origVisualScale.x, origVisualScale.y * length, origVisualScale.z); } foreach (PhysicsBoneData physicsBone in physicsBones) { if (!physicsBone.isRoot) { physicsBone.t.localPosition = new Vector3(physicsBone.origLocalPos.x, physicsBone.origLocalPos.y * length, physicsBone.origLocalPos.z); if ((Object)(object)physicsBone.joint != (Object)null) { physicsBone.joint.connectedAnchor = new Vector3(physicsBone.origConnectedAnchor.x, physicsBone.origConnectedAnchor.y * length, physicsBone.origConnectedAnchor.z); } } if ((Object)(object)physicsBone.cap != (Object)null) { physicsBone.cap.height = physicsBone.origHeight * length; physicsBone.cap.center = new Vector3(physicsBone.origCenter.x, physicsBone.origCenter.y * length, physicsBone.origCenter.z); } } } }