Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SuitLocker v1.0.9
BepInEx/plugins/SuitLocker/SuitLocker.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] namespace SuitLocker; [BepInPlugin("clair.suitlocker", "SuitLocker", "1.0.9")] public sealed class SuitLockerPlugin : BaseUnityPlugin { public const string Id = "clair.suitlocker"; internal static SuitLockerPlugin Instance; internal const string RequestMessage = "clair.suitlocker.request.v1"; internal const string ApplyMessage = "clair.suitlocker.apply.v1"; internal static ConfigEntry<float> HoldSeconds; internal static ConfigEntry<Vector3> PositionOffset; internal static ConfigEntry<float> RotationOffset; internal static ConfigEntry<float> Size; internal static ConfigEntry<float> MountBelowAnchor; internal GameObject Locker; internal SuitMenu Menu; private GameObject lockerPrefab; private AssetBundle bundle; private NetworkManager registeredManager; private float nextScan; private float nextSnapshot; private readonly Dictionary<ulong, float> requestTimes = new Dictionary<ulong, float>(); private readonly Dictionary<Renderer, bool> hiddenRackRenderers = new Dictionary<Renderer, bool>(); private readonly Dictionary<Collider, bool> hiddenRackColliders = new Dictionary<Collider, bool>(); private readonly Dictionary<GameObject, bool> hiddenRackObjects = new Dictionary<GameObject, bool>(); private bool loggedRack; internal static PlayerControllerB LocalPlayer => Object.op_Implicit((Object)(object)GameNetworkManager.Instance) ? GameNetworkManager.Instance.localPlayerController : null; private void Awake() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_01f1: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) Instance = this; HoldSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Interaction", "HoldSeconds", 0.7f, new ConfigDescription("Time to hold the game's interact control (E by default).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>())); PositionOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Placement", "PositionOffset", Vector3.zero, "Optional adjustment in locker-local meters for custom ship interiors."); RotationOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "RotationOffset", 0f, "Optional extra rotation around the ship's up axis, in degrees."); Size = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "LockerScale", 1.2f, new ConfigDescription("Locker size multiplier. This wall-mount setting replaces the old Scale setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.5f), Array.Empty<object>())); MountBelowAnchor = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "MountBelowAnchor", 0.9f, new ConfigDescription("Locker center distance below the top suit-rack anchor in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1.8f), Array.Empty<object>())); bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "suitlockerassets")); if (!Object.op_Implicit((Object)(object)bundle) || !Object.op_Implicit((Object)(object)(lockerPrefab = bundle.LoadAsset<GameObject>("Assets/Locker/SuitLocker.prefab")))) { throw new InvalidOperationException("SuitLocker needs suitlockerassets beside SuitLocker.dll."); } MeshFilter component = lockerPrefab.GetComponent<MeshFilter>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh) && lockerPrefab.transform.childCount == 0) { Bounds bounds = component.sharedMesh.bounds; if (!(Mathf.Abs(((Bounds)(ref bounds)).size.y - 1.95f) > 0.001f)) { Menu = ((Component)this).gameObject.AddComponent<SuitMenu>(); new Harmony("clair.suitlocker").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SuitLocker loaded. Uses the supplied locker and all registered suit materials. All players need this mod."); return; } } throw new InvalidOperationException("SuitLocker 1.0.3 needs its new baked mesh bundle. Replace BOTH SuitLocker.dll and suitlockerassets, then fully restart the game."); } private void Update() { RegisterMessages(); if (Time.unscaledTime < nextScan) { return; } nextScan = Time.unscaledTime + 0.5f; HideHangingSuits(); StartOfRound instance = StartOfRound.Instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.rightmostSuitPosition) || !Object.op_Implicit((Object)(object)instance.elevatorTransform)) { return; } if (!Object.op_Implicit((Object)(object)Locker)) { CreateLocker(instance); } HideOriginalRack(instance); if (!Object.op_Implicit((Object)(object)registeredManager) || !registeredManager.IsListening || !registeredManager.IsServer || !(Time.unscaledTime >= nextSnapshot)) { return; } nextSnapshot = Time.unscaledTime + 5f; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (Object.op_Implicit((Object)(object)val) && val.isPlayerControlled && SuitCatalog.TryById(val.currentSuitID, out var entry)) { Broadcast(val.actualClientId, entry, sound: false); } } } private void RegisterMessages() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if (!((Object)(object)singleton == (Object)(object)registeredManager)) { UnregisterMessages(); registeredManager = singleton; requestTimes.Clear(); nextSnapshot = 0f; if (!Object.op_Implicit((Object)(object)singleton) || singleton.CustomMessagingManager == null) { registeredManager = null; return; } singleton.CustomMessagingManager.RegisterNamedMessageHandler("clair.suitlocker.request.v1", new HandleNamedMessageDelegate(OnRequest)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("clair.suitlocker.apply.v1", new HandleNamedMessageDelegate(OnApply)); } } private void UnregisterMessages() { if (Object.op_Implicit((Object)(object)registeredManager) && registeredManager.CustomMessagingManager != null) { registeredManager.CustomMessagingManager.UnregisterNamedMessageHandler("clair.suitlocker.request.v1"); registeredManager.CustomMessagingManager.UnregisterNamedMessageHandler("clair.suitlocker.apply.v1"); } } internal void HideHangingSuits() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) UnlockableSuit[] array = Object.FindObjectsOfType<UnlockableSuit>(true); foreach (UnlockableSuit val in array) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { HiddenSuit hiddenSuit = ((Component)val).GetComponent<HiddenSuit>(); if (!Object.op_Implicit((Object)(object)hiddenSuit)) { hiddenSuit = ((Component)val).gameObject.AddComponent<HiddenSuit>(); } hiddenSuit.Enforce(); } } } private void HideOriginalRack(StartOfRound round) { //IL_004c: 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_0063: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Renderer[] array = Object.FindObjectsOfType<Renderer>(true); foreach (Renderer val in array) { if (Object.op_Implicit((Object)(object)Locker) && ((Component)val).transform.IsChildOf(Locker.transform)) { continue; } float num = Vector3.Distance(((Component)val).transform.position, round.rightmostSuitPosition.position); Bounds bounds = val.bounds; if (Vector3.Distance(((Bounds)(ref bounds)).center, round.rightmostSuitPosition.position) > 5f && num > 4f) { continue; } Transform val2 = null; if (((Component)val).transform.IsChildOf(round.elevatorTransform) && ((((Object)val).name == "NurbsPath.002" && num < 4f) || (((Object)val).name == "NurbsPath.004" && num < 0.6f))) { val2 = ((Component)val).transform; if (!hiddenRackObjects.ContainsKey(((Component)val).gameObject)) { hiddenRackObjects[((Component)val).gameObject] = ((Component)val).gameObject.activeSelf; } ((Component)val).gameObject.SetActive(false); } Transform val3 = ((Component)val).transform; while (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3 != (Object)(object)round.elevatorTransform) { string text = ((Object)val3).name.Replace(" ", "").Replace("_", "").ToLowerInvariant(); if (text.Contains("suitrack") || text.Contains("clothingrack") || text.Contains("clothesrack")) { val2 = val3; break; } val3 = val3.parent; } if (!Object.op_Implicit((Object)(object)val2)) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials.Length != 0 && sharedMaterials.All(IsRackMaterial)) { val2 = ((Component)val).transform; } MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh)) { string text2 = ((Object)component.sharedMesh).name.Replace(" ", "").Replace("_", "").ToLowerInvariant(); if (text2.Contains("clothesrack") || text2.Contains("clothingrack") || text2.Contains("suitrack")) { val2 = ((Component)val).transform; } } } if (!Object.op_Implicit((Object)(object)val2)) { continue; } if (!hiddenRackRenderers.ContainsKey(val)) { hiddenRackRenderers[val] = val.enabled; } val.enabled = false; Collider[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Collider>(true); foreach (Collider val4 in componentsInChildren) { if (!hiddenRackColliders.ContainsKey(val4)) { hiddenRackColliders[val4] = val4.enabled; } val4.enabled = false; } if (!loggedRack) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("Replaced rack mesh: " + ((Object)val).name)); loggedRack = true; } } } private static bool IsRackMaterial(Material material) { if (!Object.op_Implicit((Object)(object)material)) { return false; } string text = ((Object)material).name.Replace(" ", "").Replace("_", "").ToLowerInvariant(); if (text.Contains("clothesrack") || text.Contains("clothingrack") || text.Contains("suitrack")) { return true; } string[] array = new string[2] { "_BaseColorMap", "_MainTex" }; foreach (string text2 in array) { Texture val = (material.HasProperty(text2) ? material.GetTexture(text2) : null); if (Object.op_Implicit((Object)(object)val)) { text = ((Object)val).name.Replace(" ", "").Replace("_", "").ToLowerInvariant(); if (text.Contains("clothesrack") || text.Contains("clothingrack") || text.Contains("suitrack")) { return true; } } } return false; } private void LateUpdate() { HiddenSuit[] array = Object.FindObjectsOfType<HiddenSuit>(true); foreach (HiddenSuit hiddenSuit in array) { hiddenSuit.Enforce(); } foreach (KeyValuePair<GameObject, bool> hiddenRackObject in hiddenRackObjects) { if (Object.op_Implicit((Object)(object)hiddenRackObject.Key) && hiddenRackObject.Key.activeSelf) { hiddenRackObject.Key.SetActive(false); } } foreach (KeyValuePair<Renderer, bool> hiddenRackRenderer in hiddenRackRenderers) { if (Object.op_Implicit((Object)(object)hiddenRackRenderer.Key)) { hiddenRackRenderer.Key.enabled = false; } } foreach (KeyValuePair<Collider, bool> hiddenRackCollider in hiddenRackColliders) { if (Object.op_Implicit((Object)(object)hiddenRackCollider.Key)) { hiddenRackCollider.Key.enabled = false; } } } private unsafe void CreateLocker(StartOfRound round) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: 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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Expected O, but got Unknown //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Expected O, but got Unknown //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Expected O, but got Unknown //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Expected O, but got Unknown //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Expected O, but got Unknown //IL_0714: Unknown result type (might be due to invalid IL or missing references) //IL_071e: Expected O, but got Unknown //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Expected O, but got Unknown //IL_07a4: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Unknown result type (might be due to invalid IL or missing references) //IL_07d0: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) Transform rightmostSuitPosition = round.rightmostSuitPosition; Transform elevatorTransform = round.elevatorTransform; Vector3 val = Vector3.ProjectOnPlane(rightmostSuitPosition.forward, elevatorTransform.up); Vector3 val2 = ((Vector3)(ref val)).normalized; if (((Vector3)(ref val2)).sqrMagnitude < 0.1f) { val2 = elevatorTransform.forward; } val = Vector3.Cross(elevatorTransform.up, val2); Vector3 val3 = ((Vector3)(ref val)).normalized; if (Vector3.Dot(elevatorTransform.position - rightmostSuitPosition.position, val3) < 0f) { val3 = -val3; } Vector3 val4 = rightmostSuitPosition.position + val2 * 0.45f + val3 * 0.55f - elevatorTransform.up * MountBelowAnchor.Value; Bounds bounds = lockerPrefab.GetComponent<MeshFilter>().sharedMesh.bounds; float num = ((Bounds)(ref bounds)).extents.z * Size.Value + 0.015f; float num2 = float.PositiveInfinity; val = Vector3.Cross(elevatorTransform.up, val3); Vector3 normalized = ((Vector3)(ref val)).normalized; float[] array = new float[3] { -0.45f, 0f, 0.45f }; foreach (float num3 in array) { Vector3 val5 = val4 + normalized * (((Bounds)(ref bounds)).size.x * Size.Value * num3); RaycastHit[] array2 = Physics.RaycastAll(val5, -val3, 3f, round.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); for (int j = 0; j < array2.Length; j++) { RaycastHit val6 = array2[j]; if (!(Vector3.Dot(((RaycastHit)(ref val6)).normal, val3) < 0.5f) && !(((RaycastHit)(ref val6)).distance < 0.02f)) { num2 = Mathf.Min(num2, ((RaycastHit)(ref val6)).distance); } } } val4 -= val3 * ((float.IsPositiveInfinity(num2) ? 0.7f : (num2 - num)) + 0.35f); Vector3 val7 = val4 - elevatorTransform.up * (1.95f * Size.Value * 0.5f); Quaternion val8 = Quaternion.LookRotation(val3, elevatorTransform.up) * Quaternion.Euler(0f, RotationOffset.Value, 0f); Locker = Object.Instantiate<GameObject>(lockerPrefab, val7 + val8 * PositionOffset.Value, val8, elevatorTransform); ((Object)Locker).name = "SuitLocker"; Locker.transform.localScale = Vector3.one * Size.Value; Material val9 = (from item in round.unlockablesList.unlockables where item != null && Object.op_Implicit((Object)(object)item.suitMaterial) select item.suitMaterial).FirstOrDefault((Func<Material, bool>)((Material material) => material.HasProperty("_BaseColorMap"))); if (!Object.op_Implicit((Object)(object)val9)) { throw new InvalidOperationException("No configured game material available for SuitLocker."); } Renderer[] componentsInChildren = Locker.GetComponentsInChildren<Renderer>(); foreach (Renderer val10 in componentsInChildren) { Material sharedMaterial = val10.sharedMaterial; Material val11 = new Material(val9) { name = "SuitLockerMetal" }; val11.SetColor("_BaseColor", Color.white); val11.SetTexture("_BaseColorMap", sharedMaterial.mainTexture); val11.SetFloat("_Smoothness", 0.18f); string[] array3 = new string[3] { "_NormalMap", "_MaskMap", "_EmissiveColorMap" }; foreach (string text in array3) { if (val11.HasProperty(text)) { val11.SetTexture(text, (Texture)null); } } string[] array4 = new string[4] { "_NORMALMAP", "_MASKMAP", "_EMISSIVE_COLOR_MAP", "_ALPHATEST_ON" }; foreach (string text2 in array4) { val11.DisableKeyword(text2); } if (val11.HasProperty("_AlphaCutoffEnable")) { val11.SetFloat("_AlphaCutoffEnable", 0f); } HDMaterial.ValidateMaterial(val11); val10.sharedMaterial = val11; val10.enabled = true; val10.forceRenderingOff = false; val10.renderingLayerMask = 257u; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Locker renderer: " + ((Object)val10).name + "; shader " + ((Object)val11.shader).name + "; bounds " + ((object)val10.bounds/*cast due to .constrained prefix*/).ToString())); } BoxCollider val12 = Locker.AddComponent<BoxCollider>(); val12.center = new Vector3(0f, 0.975f, 0f); val12.size = new Vector3(1.2f, 1.95f, 0.5f); GameObject val13 = new GameObject("SuitLockerInteraction"); val13.transform.SetParent(Locker.transform, false); val13.layer = 9; val13.tag = "InteractTrigger"; BoxCollider val14 = val13.AddComponent<BoxCollider>(); ((Collider)val14).isTrigger = true; val14.center = new Vector3(0f, 1.05f, 0.31f); val14.size = new Vector3(1.24f, 1.8f, 0.25f); InteractTrigger trigger = val13.AddComponent<InteractTrigger>(); trigger.hoverTip = "Open suit locker : [E]"; trigger.holdTip = "Opening suit locker"; trigger.holdInteraction = true; trigger.timeToHold = HoldSeconds.Value; trigger.timeToHoldSpeedMultiplier = 1f; trigger.interactCooldown = true; trigger.cooldownTime = 0.5f; trigger.disableTriggerMesh = false; trigger.oneHandedItemAllowed = true; trigger.twoHandedItemAllowed = true; trigger.onInteract = new InteractEvent(); trigger.onInteractEarly = new InteractEvent(); trigger.onInteractEarlyOtherClients = new InteractEvent(); trigger.onStopInteract = new InteractEvent(); trigger.onCancelAnimation = new InteractEvent(); trigger.holdingInteractEvent = new InteractEventFloat(); ((UnityEvent<PlayerControllerB>)(object)trigger.onInteract).AddListener((UnityAction<PlayerControllerB>)delegate(PlayerControllerB player) { Menu.Open(player); }); InteractTrigger val15 = ((IEnumerable<InteractTrigger>)Object.FindObjectsOfType<InteractTrigger>()).FirstOrDefault((Func<InteractTrigger, bool>)((InteractTrigger t) => (Object)(object)t != (Object)(object)trigger && Object.op_Implicit((Object)(object)t.hoverIcon))); if (Object.op_Implicit((Object)(object)val15)) { trigger.hoverIcon = val15.hoverIcon; } ManualLogSource logger = ((BaseUnityPlugin)this).Logger; string[] obj = new string[6] { "SuitLocker 1.0.9 wall-mounted at ", null, null, null, null, null }; val = elevatorTransform.InverseTransformPoint(Locker.transform.position); obj[1] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[2] = "; center "; val = elevatorTransform.InverseTransformPoint(val4); obj[3] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[4] = "; scale "; obj[5] = Size.Value.ToString(); logger.LogInfo((object)string.Concat(obj)); } internal bool CanUse(PlayerControllerB player) { //IL_002c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) return Object.op_Implicit((Object)(object)player) && player.isPlayerControlled && !player.isPlayerDead && Object.op_Implicit((Object)(object)Locker) && Vector3.Distance(((Component)player).transform.position, Locker.transform.position + Locker.transform.up) < 4.5f; } internal unsafe void SelectSuit(SuitEntry suit) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) NetworkManager val = registeredManager; PlayerControllerB localPlayer = LocalPlayer; if (!Object.op_Implicit((Object)(object)val) || !val.IsListening || !CanUse(localPlayer)) { Menu.Status = "Move closer to the locker."; return; } Menu.Status = "Requesting " + suit.Name + "…"; if (val.IsServer) { HandleRequest(val.LocalClientId, suit.Id, suit.Key); return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(256, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref suit.Id, default(ForPrimitives)); FixedString128Bytes val3 = new FixedString128Bytes(suit.Key); ((FastBufferWriter)(ref val2)).WriteValueSafe<FixedString128Bytes>(ref val3, default(ForFixedStrings)); val.CustomMessagingManager.SendNamedMessage("clair.suitlocker.request.v1", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void OnRequest(ulong sender, FastBufferReader reader) { //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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)registeredManager) || !registeredManager.IsServer || ((FastBufferReader)(ref reader)).Length > 256) { return; } try { int id = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref id, default(ForPrimitives)); FixedString128Bytes val = default(FixedString128Bytes); ((FastBufferReader)(ref reader)).ReadValueSafe<FixedString128Bytes>(ref val, default(ForFixedStrings)); HandleRequest(sender, id, ((object)(*(FixedString128Bytes*)(&val))/*cast due to .constrained prefix*/).ToString()); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ignored malformed suit request: " + ex.Message)); } } private void HandleRequest(ulong sender, int id, string key) { if (!requestTimes.TryGetValue(sender, out var value) || !(Time.unscaledTime - value < 0.2f)) { requestTimes[sender] = Time.unscaledTime; StartOfRound instance = StartOfRound.Instance; PlayerControllerB player = (Object.op_Implicit((Object)(object)instance) ? ((IEnumerable<PlayerControllerB>)instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => Object.op_Implicit((Object)(object)p) && p.isPlayerControlled && p.actualClientId == sender)) : null); if (!CanUse(player)) { SendFailure(sender); return; } if (!SuitCatalog.TryResolve(id, key, out var entry)) { SendFailure(sender); return; } ApplyToPlayer(sender, entry, sound: true); Broadcast(sender, entry, sound: true); } } private unsafe void SendFailure(ulong recipient) { //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0089: 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_00a7: Unknown result type (might be due to invalid IL or missing references) if (recipient == registeredManager.LocalClientId) { Menu.Status = "Unable to equip: move closer or check that the host has this suit installed."; return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref recipient, default(ForPrimitives)); int num = -1; ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); FixedString128Bytes val2 = new FixedString128Bytes(""); ((FastBufferWriter)(ref val)).WriteValueSafe<FixedString128Bytes>(ref val2, default(ForFixedStrings)); bool flag = false; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); registeredManager.CustomMessagingManager.SendNamedMessage("clair.suitlocker.apply.v1", recipient, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void Broadcast(ulong playerId, SuitEntry suit, bool sound) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(256, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref playerId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref suit.Id, default(ForPrimitives)); FixedString128Bytes val2 = new FixedString128Bytes(suit.Key); ((FastBufferWriter)(ref val)).WriteValueSafe<FixedString128Bytes>(ref val2, default(ForFixedStrings)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sound, default(ForPrimitives)); foreach (ulong connectedClientsId in registeredManager.ConnectedClientsIds) { if (connectedClientsId != registeredManager.LocalClientId) { registeredManager.CustomMessagingManager.SendNamedMessage("clair.suitlocker.apply.v1", connectedClientsId, val, (NetworkDelivery)3); } } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void OnApply(ulong sender, FastBufferReader reader) { //IL_0040: 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_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (sender != 0L || !Object.op_Implicit((Object)(object)registeredManager) || registeredManager.IsServer || ((FastBufferReader)(ref reader)).Length > 256) { return; } try { 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)); FixedString128Bytes val = default(FixedString128Bytes); ((FastBufferReader)(ref reader)).ReadValueSafe<FixedString128Bytes>(ref val, default(ForFixedStrings)); bool sound = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref sound, default(ForPrimitives)); SuitEntry entry; if (num2 < 0) { if (Object.op_Implicit((Object)(object)LocalPlayer) && LocalPlayer.actualClientId == num) { Menu.Status = "Unable to equip: move closer or install matching suits on the host."; } } else if (SuitCatalog.TryResolve(num2, ((object)(*(FixedString128Bytes*)(&val))/*cast due to .constrained prefix*/).ToString(), out entry)) { ApplyToPlayer(num, entry, sound); } else if (Object.op_Implicit((Object)(object)LocalPlayer) && LocalPlayer.actualClientId == num) { Menu.Status = "This suit is missing locally. Install the same suit packs as the host."; } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ignored malformed suit update: " + ex.Message)); } } private void ApplyToPlayer(ulong playerId, SuitEntry suit, bool sound) { StartOfRound instance = StartOfRound.Instance; PlayerControllerB val = (Object.op_Implicit((Object)(object)instance) ? ((IEnumerable<PlayerControllerB>)instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB p) => Object.op_Implicit((Object)(object)p) && p.actualClientId == playerId && p.isPlayerControlled)) : null); if (Object.op_Implicit((Object)(object)val)) { if (val.currentSuitID != suit.Id) { UnlockableSuit.SwitchSuitForPlayer(val, suit.Id, sound); } if ((Object)(object)val == (Object)(object)LocalPlayer) { Menu.Status = "Wearing " + suit.Name; } } } private void OnDestroy() { UnregisterMessages(); if (Object.op_Implicit((Object)(object)Menu)) { Menu.Close(); } if (Object.op_Implicit((Object)(object)Locker)) { Object.Destroy((Object)(object)Locker); } HiddenSuit[] array = Object.FindObjectsOfType<HiddenSuit>(true); foreach (HiddenSuit hiddenSuit in array) { Object.Destroy((Object)(object)hiddenSuit); } foreach (KeyValuePair<Renderer, bool> hiddenRackRenderer in hiddenRackRenderers) { if (Object.op_Implicit((Object)(object)hiddenRackRenderer.Key)) { hiddenRackRenderer.Key.enabled = hiddenRackRenderer.Value; } } foreach (KeyValuePair<Collider, bool> hiddenRackCollider in hiddenRackColliders) { if (Object.op_Implicit((Object)(object)hiddenRackCollider.Key)) { hiddenRackCollider.Key.enabled = hiddenRackCollider.Value; } } foreach (KeyValuePair<GameObject, bool> hiddenRackObject in hiddenRackObjects) { if (Object.op_Implicit((Object)(object)hiddenRackObject.Key)) { hiddenRackObject.Key.SetActive(hiddenRackObject.Value); } } Harmony.UnpatchID("clair.suitlocker"); } [HarmonyPatch(typeof(StartOfRound), "PositionSuitsOnRack")] [HarmonyPostfix] [HarmonyPriority(0)] private static void AfterPosition() { if (Object.op_Implicit((Object)(object)Instance)) { Instance.HideHangingSuits(); } } [HarmonyPatch(typeof(UnlockableSuit), "Update")] [HarmonyPostfix] [HarmonyPriority(0)] private static void AfterSuitUpdate(UnlockableSuit __instance) { //IL_0013: 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) if (!Object.op_Implicit((Object)(object)Instance)) { return; } Scene scene = ((Component)__instance).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { HiddenSuit hiddenSuit = ((Component)__instance).GetComponent<HiddenSuit>(); if (!Object.op_Implicit((Object)(object)hiddenSuit)) { hiddenSuit = ((Component)__instance).gameObject.AddComponent<HiddenSuit>(); } hiddenSuit.Enforce(); } } [HarmonyPatch(typeof(UnlockableSuit), "SwitchSuitToThis")] [HarmonyPrefix] private static bool BlockRackSelection() { return !Object.op_Implicit((Object)(object)Instance); } [HarmonyPatch(typeof(QuickMenuManager), "OpenQuickMenu")] [HarmonyPrefix] private static bool CloseLockerInsteadOfPause() { if (!Object.op_Implicit((Object)(object)Instance) || !Object.op_Implicit((Object)(object)Instance.Menu)) { return true; } if (Instance.Menu.IsOpen) { Instance.Menu.Close(); return false; } return Time.unscaledTime >= Instance.Menu.SuppressPauseUntil; } } [DefaultExecutionOrder(32000)] public sealed class HiddenSuit : MonoBehaviour { private Renderer[] renderers = Array.Empty<Renderer>(); private Collider[] colliders = Array.Empty<Collider>(); private InteractTrigger[] triggers = Array.Empty<InteractTrigger>(); private readonly Dictionary<Renderer, bool> originalRenderers = new Dictionary<Renderer, bool>(); private readonly Dictionary<Renderer, bool> originalForceRenderingOff = new Dictionary<Renderer, bool>(); private readonly Dictionary<Collider, bool> originalColliders = new Dictionary<Collider, bool>(); private readonly Dictionary<InteractTrigger, bool> originalTriggers = new Dictionary<InteractTrigger, bool>(); private float nextRefresh; internal void Enforce() { if (Time.unscaledTime >= nextRefresh) { nextRefresh = Time.unscaledTime + 0.5f; renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); colliders = ((Component)this).GetComponentsInChildren<Collider>(true); triggers = ((Component)this).GetComponentsInChildren<InteractTrigger>(true); Renderer[] array = renderers; foreach (Renderer val in array) { if (!originalRenderers.ContainsKey(val)) { originalRenderers[val] = val.enabled; originalForceRenderingOff[val] = val.forceRenderingOff; } } Collider[] array2 = colliders; foreach (Collider val2 in array2) { if (!originalColliders.ContainsKey(val2)) { originalColliders[val2] = val2.enabled; } } InteractTrigger[] array3 = triggers; foreach (InteractTrigger val3 in array3) { if (!originalTriggers.ContainsKey(val3)) { originalTriggers[val3] = val3.interactable; } } } Renderer[] array4 = renderers; foreach (Renderer val4 in array4) { if (Object.op_Implicit((Object)(object)val4)) { val4.enabled = false; val4.forceRenderingOff = true; } } Collider[] array5 = colliders; foreach (Collider val5 in array5) { if (Object.op_Implicit((Object)(object)val5)) { val5.enabled = false; } } InteractTrigger[] array6 = triggers; foreach (InteractTrigger val6 in array6) { if (Object.op_Implicit((Object)(object)val6)) { val6.interactable = false; } } } private void OnTransformChildrenChanged() { nextRefresh = 0f; Enforce(); } private void LateUpdate() { Enforce(); } private void OnEnable() { nextRefresh = 0f; Enforce(); } private void OnDestroy() { foreach (KeyValuePair<Renderer, bool> originalRenderer in originalRenderers) { if (Object.op_Implicit((Object)(object)originalRenderer.Key)) { originalRenderer.Key.enabled = originalRenderer.Value; } } foreach (KeyValuePair<Renderer, bool> item in originalForceRenderingOff) { if (Object.op_Implicit((Object)(object)item.Key)) { item.Key.forceRenderingOff = item.Value; } } foreach (KeyValuePair<Collider, bool> originalCollider in originalColliders) { if (Object.op_Implicit((Object)(object)originalCollider.Key)) { originalCollider.Key.enabled = originalCollider.Value; } } foreach (KeyValuePair<InteractTrigger, bool> originalTrigger in originalTriggers) { if (Object.op_Implicit((Object)(object)originalTrigger.Key)) { originalTrigger.Key.interactable = originalTrigger.Value; } } } } internal sealed class SuitEntry { public int Id; public string Name; public string Key; } internal static class SuitCatalog { private static List<SuitEntry> cached = new List<SuitEntry>(); private static StartOfRound cachedRound; private static int cachedCount = -1; private static float refreshAt; internal static List<SuitEntry> Read() { List<SuitEntry> list = new List<SuitEntry>(); StartOfRound instance = StartOfRound.Instance; if (!Object.op_Implicit((Object)(object)instance) || (Object)(object)instance.unlockablesList == (Object)null) { return list; } List<UnlockableItem> unlockables = instance.unlockablesList.unlockables; if ((Object)(object)instance == (Object)(object)cachedRound && unlockables.Count == cachedCount && Time.unscaledTime < refreshAt) { return cached; } using (SHA256 sHA = SHA256.Create()) { for (int i = 0; i < unlockables.Count; i++) { UnlockableItem val = unlockables[i]; if (val != null && Object.op_Implicit((Object)(object)val.suitMaterial)) { string text = (string.IsNullOrWhiteSpace(val.unlockableName) ? ("Suit " + i) : val.unlockableName); string s = text.Trim().ToLowerInvariant() + "\n" + ((Object)val.suitMaterial).name.Replace(" (Instance)", "").Trim().ToLowerInvariant(); string key = BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(s))).Replace("-", ""); list.Add(new SuitEntry { Id = i, Name = text, Key = key }); } } } cachedRound = instance; cachedCount = unlockables.Count; refreshAt = Time.unscaledTime + 1f; cached = list; return cached; } internal static bool TryById(int id, out SuitEntry entry) { entry = Read().FirstOrDefault((SuitEntry s) => s.Id == id); return entry != null; } internal static bool TryResolve(int hint, string key, out SuitEntry entry) { List<SuitEntry> source = Read(); entry = source.FirstOrDefault((SuitEntry s) => s.Id == hint && s.Key == key) ?? source.FirstOrDefault((SuitEntry s) => s.Key == key); return entry != null; } } public sealed class SuitMenu : MonoBehaviour { internal float SuppressPauseUntil; internal string Status = "Choose a suit to wear."; private PlayerControllerB owner; private bool previousMove; private bool previousLook; private bool previousInteract; private bool previousTerminal; private bool previousCursorVisible; private CursorLockMode previousCursorLock; private List<SuitEntry> suits = new List<SuitEntry>(); private List<SuitEntry> filtered = new List<SuitEntry>(); private string search = ""; private Vector2 scroll; private float nextRefresh; private GUIStyle title; private GUIStyle subtitle; private GUIStyle row; private GUIStyle label; private GUIStyle button; private GUIStyle field; private GUIStyle small; private GUIStyle selectedLabel; private Texture2D panelTexture; private Texture2D rowTexture; private Texture2D buttonTexture; private Texture2D selectedTexture; private Texture2D fieldTexture; public bool IsOpen { get; private set; } internal void Open(PlayerControllerB player) { //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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen && !((Object)(object)player != (Object)(object)SuitLockerPlugin.LocalPlayer) && SuitLockerPlugin.Instance.CanUse(player) && !player.inTerminalMenu && !player.isTypingChat && (!Object.op_Implicit((Object)(object)player.quickMenuManager) || !player.quickMenuManager.isMenuOpen)) { owner = player; previousMove = player.disableMoveInput; previousLook = player.disableLookInput; previousInteract = player.disableInteract; previousTerminal = player.inTerminalMenu; previousCursorLock = Cursor.lockState; previousCursorVisible = Cursor.visible; IsOpen = true; Status = "Choose a suit to wear."; search = ""; scroll = Vector2.zero; Refresh(); LockControls(); } } private void LockControls() { if (Object.op_Implicit((Object)(object)owner)) { owner.disableMoveInput = true; owner.disableLookInput = true; owner.disableInteract = true; owner.inTerminalMenu = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } public void Close() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (IsOpen) { IsOpen = false; SuppressPauseUntil = Time.unscaledTime + 0.2f; if (Object.op_Implicit((Object)(object)owner)) { owner.disableMoveInput = previousMove; owner.disableLookInput = previousLook; owner.disableInteract = previousInteract; owner.inTerminalMenu = previousTerminal; } Cursor.lockState = previousCursorLock; Cursor.visible = previousCursorVisible; owner = null; } } private void Update() { if (!IsOpen) { return; } if (!Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)SuitLockerPlugin.Instance) || !SuitLockerPlugin.Instance.CanUse(owner) || owner.isClimbingLadder || (Object.op_Implicit((Object)(object)owner.quickMenuManager) && owner.quickMenuManager.isMenuOpen)) { Close(); return; } if ((Keyboard.current != null && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame) || (Gamepad.current != null && Gamepad.current.buttonEast.wasPressedThisFrame)) { Close(); return; } LockControls(); if (Time.unscaledTime >= nextRefresh) { Refresh(); } } private void LateUpdate() { if (IsOpen) { LockControls(); } } private void OnDisable() { Close(); } private void Refresh() { nextRefresh = Time.unscaledTime + 1f; suits = SuitCatalog.Read().OrderBy<SuitEntry, string>((SuitEntry s) => s.Name, StringComparer.OrdinalIgnoreCase).ThenBy((SuitEntry s) => s.Id) .ToList(); Filter(); } private void Filter() { filtered = suits.Where((SuitEntry s) => string.IsNullOrWhiteSpace(search) || s.Name.IndexOf(search.Trim(), StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } private static Texture2D Solid(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false); val.SetPixel(0, 0, color); val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } private void CreateStyles() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_0186: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown if (title == null) { panelTexture = Solid(new Color(0.055f, 0.075f, 0.08f, 0.99f)); rowTexture = Solid(new Color(0.1f, 0.13f, 0.14f)); buttonTexture = Solid(new Color(0.16f, 0.3f, 0.28f)); selectedTexture = Solid(new Color(0.18f, 0.45f, 0.36f)); fieldTexture = Solid(new Color(0.025f, 0.04f, 0.045f)); GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 32, fontStyle = (FontStyle)1, richText = false }; val.normal.textColor = new Color(0.86f, 0.94f, 0.9f); title = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 15, richText = false }; val2.normal.textColor = new Color(0.62f, 0.72f, 0.7f); subtitle = val2; GUIStyle val3 = new GUIStyle(GUI.skin.box); val3.normal.background = rowTexture; val3.border = new RectOffset(); val3.padding = new RectOffset(); row = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 18, alignment = (TextAnchor)3, clipping = (TextClipping)1, richText = false }; val4.normal.textColor = Color.white; label = val4; small = new GUIStyle(subtitle) { fontSize = 14, alignment = (TextAnchor)3, wordWrap = true }; GUIStyle val5 = new GUIStyle(small) { alignment = (TextAnchor)4 }; val5.normal.textColor = new Color(0.6f, 1f, 0.77f); selectedLabel = val5; GUIStyle val6 = new GUIStyle(GUI.skin.button) { fontSize = 16, fontStyle = (FontStyle)1, richText = false }; val6.normal.background = buttonTexture; val6.normal.textColor = Color.white; val6.hover.background = selectedTexture; val6.hover.textColor = Color.white; val6.active.background = selectedTexture; val6.active.textColor = Color.white; button = val6; GUIStyle val7 = new GUIStyle(GUI.skin.textField) { fontSize = 18, padding = new RectOffset(12, 12, 8, 8) }; val7.normal.background = fieldTexture; val7.normal.textColor = Color.white; val7.focused.background = fieldTexture; val7.focused.textColor = Color.white; field = val7; } } private void OnGUI() { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Expected O, but got Unknown //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) if (!IsOpen || !Object.op_Implicit((Object)(object)owner)) { return; } CreateStyles(); GUI.depth = -1000; Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; float num = Mathf.Min((float)Screen.width / 1050f, (float)Screen.height / 780f); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * num); float num2 = (float)Screen.width / num; float num3 = (float)Screen.height / num; GUI.color = new Color(0f, 0f, 0f, 0.7f); GUI.DrawTexture(new Rect(0f, 0f, num2, num3), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; Rect val = default(Rect); ((Rect)(ref val))..ctor((num2 - 900f) / 2f, (num3 - 680f) / 2f, 900f, 680f); GUI.DrawTexture(val, (Texture)(object)panelTexture); GUI.BeginGroup(val); GUI.Label(new Rect(28f, 20f, 650f, 46f), "SUIT LOCKER", title); GUI.Label(new Rect(30f, 66f, 700f, 28f), suits.Count + " suits / Vanilla + modded / All available to wear", subtitle); if (GUI.Button(new Rect(790f, 26f, 82f, 38f), "Close", button)) { Close(); GUI.EndGroup(); GUI.matrix = matrix; GUI.color = color; return; } GUI.SetNextControlName("SuitLockerSearch"); string text = GUI.TextField(new Rect(30f, 109f, 840f, 42f), search, 100, field); if (text != search) { search = text; scroll = Vector2.zero; Filter(); } if (string.IsNullOrEmpty(search) && GUI.GetNameOfFocusedControl() != "SuitLockerSearch") { GUI.Label(new Rect(44f, 118f, 650f, 28f), "Search suits…", subtitle); } GUI.Label(new Rect(31f, 160f, 700f, 25f), filtered.Count + " results", small); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(30f, 192f, 840f, 394f); scroll = GUI.BeginScrollView(val2, scroll, new Rect(0f, 0f, 816f, Mathf.Max(((Rect)(ref val2)).height, (float)(filtered.Count * 54)))); int num4 = Mathf.Max(0, Mathf.FloorToInt(scroll.y / 54f)); int num5 = Mathf.Min(filtered.Count, num4 + Mathf.CeilToInt(((Rect)(ref val2)).height / 54f) + 1); for (int i = num4; i < num5; i++) { SuitEntry suitEntry = filtered[i]; bool flag = owner.currentSuitID == suitEntry.Id; float num6 = i * 54; GUI.Box(new Rect(0f, num6, 813f, 48f), GUIContent.none, row); GUI.Label(new Rect(15f, num6 + 4f, 635f, 40f), new GUIContent(suitEntry.Name, suitEntry.Name), label); if (flag) { GUI.Label(new Rect(675f, num6 + 6f, 122f, 36f), "WEARING", selectedLabel); } else if (GUI.Button(new Rect(686f, num6 + 7f, 110f, 34f), "Wear", button)) { SuitLockerPlugin.Instance.SelectSuit(suitEntry); } } if (filtered.Count == 0) { GUI.Label(new Rect(18f, 20f, 750f, 50f), "No matching suits. Clear your search or install a suit pack.", small); } GUI.EndScrollView(); GUI.Label(new Rect(30f, 600f, 835f, 42f), Status, small); GUI.Label(new Rect(30f, 648f, 835f, 24f), "Hold interact to open • Click Wear to change • Esc to close", subtitle); GUI.EndGroup(); GUI.matrix = matrix; GUI.color = color; } private void OnDestroy() { Close(); Texture2D[] array = (Texture2D[])(object)new Texture2D[5] { panelTexture, rowTexture, buttonTexture, selectedTexture, fieldTexture }; foreach (Texture2D val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } } }