using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using Rewired; using StarterAssets; using SupermarketTogetherAnyPlaceBuilder; using SupermarketTogetherFlyMod; using SupermarketTogetherMovementSpeedMenu; using SupermarketTogetherObjectManipulator; using SupermarketTogetherObjectSpawner; using SupermarketTogetherTeleportMenu; using UnityEngine; using UnityEngine.AI; [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("SupermarketTogetherMODMENU")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SupermarketTogetherMODMENU")] [assembly: AssemblyTitle("SupermarketTogetherMODMENU")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 SupermarketTogetherObjectManipulator { internal sealed class ObjectManipulatorMenu : MonoBehaviour { private enum PendingKeyBinding { None, Duplicate, Delete } private const float SpawnDistance = 3.5f; private const float DefaultObjectGrabReach = 4f; private const float ButtonHeight = 28f; private ManualLogSource? logger; private ObjectManipulatorSettings? settings; private PendingKeyBinding pendingKeyBinding; private string statusMessage = "Ready."; public void Initialize(ManualLogSource pluginLogger, ObjectManipulatorSettings manipulatorSettings) { logger = pluginLogger; settings = manipulatorSettings; } internal void ShowPanel() { pendingKeyBinding = PendingKeyBinding.None; } internal void HidePanel() { pendingKeyBinding = PendingKeyBinding.None; } private void Update() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (settings != null && settings.Enabled.Value && pendingKeyBinding == PendingKeyBinding.None) { if (Input.GetKeyDown(settings.DuplicateHeldItemKey.Value)) { DuplicateHeldItem(); } if (Input.GetKeyDown(settings.DeleteObjectKey.Value)) { DeleteLookTarget(); } } } internal void DrawPanelContent() { //IL_0051: 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) CapturePendingKey(Event.current); if (settings != null) { GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("現在のキー", Array.Empty()); GUILayout.Label($"Copy held item: {settings.DuplicateHeldItemKey.Value}", Array.Empty()); GUILayout.Label($"Delete look target: {settings.DeleteObjectKey.Value}", Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(10f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("キー設定", Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button(GetBindingButtonLabel(PendingKeyBinding.Duplicate), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { pendingKeyBinding = PendingKeyBinding.Duplicate; statusMessage = "Press a key for copy. Escape cancels."; } if (GUILayout.Button(GetBindingButtonLabel(PendingKeyBinding.Delete), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { pendingKeyBinding = PendingKeyBinding.Delete; statusMessage = "Press a key for delete. Escape cancels."; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Reset V / B", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) })) { settings.DuplicateHeldItemKey.Value = (KeyCode)118; settings.DeleteObjectKey.Value = (KeyCode)98; ((ConfigEntryBase)settings.DuplicateHeldItemKey).ConfigFile.Save(); statusMessage = "Reset copy to V and delete to B."; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label(statusMessage, Array.Empty()); GUILayout.EndVertical(); } } private string GetBindingButtonLabel(PendingKeyBinding binding) { if (pendingKeyBinding != binding) { if (binding != PendingKeyBinding.Duplicate) { return "Change Delete Key"; } return "Change Copy Key"; } return "Press key..."; } private void CapturePendingKey(Event currentEvent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_003e: 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_005a: 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_0073: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (settings == null || pendingKeyBinding == PendingKeyBinding.None || (int)currentEvent.type != 4) { return; } if ((int)currentEvent.keyCode == 27) { pendingKeyBinding = PendingKeyBinding.None; statusMessage = "Key change canceled."; currentEvent.Use(); } else { if ((int)currentEvent.keyCode == 0) { return; } KeyCode val = ((pendingKeyBinding == PendingKeyBinding.Duplicate) ? settings.DeleteObjectKey.Value : settings.DuplicateHeldItemKey.Value); if (currentEvent.keyCode == val) { statusMessage = $"{currentEvent.keyCode} is already used by the other action."; currentEvent.Use(); return; } if (pendingKeyBinding == PendingKeyBinding.Duplicate) { settings.DuplicateHeldItemKey.Value = currentEvent.keyCode; statusMessage = $"Copy key set to {currentEvent.keyCode}."; } else { settings.DeleteObjectKey.Value = currentEvent.keyCode; statusMessage = $"Delete key set to {currentEvent.keyCode}."; } ((ConfigEntryBase)settings.DuplicateHeldItemKey).ConfigFile.Save(); pendingKeyBinding = PendingKeyBinding.None; currentEvent.Use(); } } private void DuplicateHeldItem() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0069: 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_0235: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_01d3: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0106: 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_00e0: Unknown result type (might be due to invalid IL or missing references) PlayerNetwork localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { SetStatus("Local player was not found.", warning: true); return; } if (localPlayer.equippedItem <= 0 || localPlayer.equippedItem == 4) { SetStatus("No supported held item to copy.", warning: true); return; } GameData instance = GameData.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("GameData was not found.", warning: true); return; } Vector3 spawnPosition = GetSpawnPosition(localPlayer); Quaternion rotation = ((Component)localPlayer).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; NetworkSpawner component = ((Component)instance).GetComponent(); ManagerBlackboard component2 = ((Component)instance).GetComponent(); switch (localPlayer.equippedItem) { case 16: component2.CmdSpawnManufacturingBoxFromPlayer(spawnPosition, localPlayer.extraParameter1, localPlayer.extraParameter2, y, localPlayer.extraParameter3); break; case 13: case 14: case 15: component.CmdSpawnProp(localPlayer.equippedItem, spawnPosition, Vector3.zero); break; case 12: component.CmdSpawnOrderBoxFromPlayer(spawnPosition, y, localPlayer.orderNumberData, localPlayer.orderCustomerNameData, localPlayer.orderItemsInBoxData); break; case 11: component.CmdSpawnProp(11, spawnPosition, new Vector3(0f, y, 0f)); break; case 10: component.CmdSpawnProp(10, spawnPosition, new Vector3(180f, y, 0f)); break; case 9: component.CmdSpawnTrayFromPlayer(spawnPosition, localPlayer.trayData, y); break; case 8: component.CmdSpawnProp(8, spawnPosition, new Vector3(15f, y, 0f)); break; case 7: component.CmdSpawnProp(7, spawnPosition, new Vector3(0f, y, 0f)); break; case 6: component.CmdSpawnProp(6, spawnPosition, new Vector3(180f, y, 0f)); break; case 5: component.CmdSpawnProp(5, spawnPosition, new Vector3(270f, y, 0f)); break; case 3: component.CmdSpawnProp(3, spawnPosition, new Vector3(270f, y, 0f)); break; case 2: component.CmdSpawnProp(2, spawnPosition, new Vector3(0f, y, 90f)); break; case 1: component2.CmdSpawnBoxFromPlayer(spawnPosition, localPlayer.extraParameter1, localPlayer.extraParameter2, y); break; default: SetStatus($"Held item #{localPlayer.equippedItem} is not supported.", warning: true); return; } SetStatus($"Copied held item #{localPlayer.equippedItem}.", warning: false); } private void DeleteLookTarget() { GameData instance = GameData.Instance; if ((Object)(object)instance == (Object)null) { SetStatus("GameData was not found.", warning: true); return; } if (!TryGetLookTarget(out GameObject target)) { SetStatus("No deletable network object in sight.", warning: true); return; } ((Component)instance).GetComponent().CmdDestroyBox(target); SetStatus("Deleted " + CleanPrefabName(((Object)target).name) + ".", warning: false); } private static bool TryGetLookTarget(out GameObject target) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) target = null; Transform val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null); if ((Object)(object)val == (Object)null) { return false; } RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val.position, val.forward, ref val2, GetObjectGrabReach(), -1, (QueryTriggerInteraction)1)) { return false; } NetworkIdentity componentInParent = ((Component)((RaycastHit)(ref val2)).transform).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null || IsProtectedDeleteTarget(((Component)componentInParent).gameObject)) { return false; } target = ((Component)componentInParent).gameObject; return true; } private static float GetObjectGrabReach() { if ((Type.GetType("SupermarketTogetherMODMENU.PlayerReachPatch, SupermarketTogetherMODMENU")?.GetProperty("ReachDistance", BindingFlags.Static | BindingFlags.Public))?.GetValue(null) is float num) { return Mathf.Clamp(num, 0.5f, 100f); } return 4f; } private static bool IsProtectedDeleteTarget(GameObject target) { if (!((Object)(object)target.GetComponent() != (Object)null) && !((Object)(object)target.GetComponent() != (Object)null) && !((Object)(object)target.GetComponent() != (Object)null)) { return (Object)(object)target.GetComponent() != (Object)null; } return true; } private static Vector3 GetSpawnPosition(PlayerNetwork player) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_008f: 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_009a: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Transform val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : ((Component)player).transform.position); Vector3 val3 = (((Object)(object)val != (Object)null) ? val.forward : ((Component)player).transform.forward); RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val2, val3, ref val4, 3.5f, -1, (QueryTriggerInteraction)1)) { Vector3 point = ((RaycastHit)(ref val4)).point; Vector3 normal = ((RaycastHit)(ref val4)).normal; return point + ((Vector3)(ref normal)).normalized * 0.5f; } return val2 + val3 * 3.5f; } private static PlayerNetwork? GetLocalPlayer() { PlayerNetwork[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerNetwork val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).isLocalPlayer) { return val; } } return null; } private static string CleanPrefabName(string prefabName) { return prefabName.Replace("(Clone)", "").Trim(); } private void SetStatus(string message, bool warning) { statusMessage = message; if (warning) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)message); } } else { ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)message); } } } } internal sealed class ObjectManipulatorSettings { public ConfigEntry Enabled { get; } public ConfigEntry DuplicateHeldItemKey { get; } public ConfigEntry DeleteObjectKey { get; } public ObjectManipulatorSettings(ConfigEntry enabled, ConfigEntry duplicateHeldItemKey, ConfigEntry deleteObjectKey) { Enabled = enabled; DuplicateHeldItemKey = duplicateHeldItemKey; DeleteObjectKey = deleteObjectKey; } } } namespace SupermarketTogetherObjectSpawner { internal static class NoCostPlaceableSpawnPatch { [HarmonyPatch(typeof(NetworkSpawner), "UserCode_CmdSpawn__Int32__Vector3__Vector3")] [HarmonyPrefix] private static bool SpawnBuildableWithoutCost(NetworkSpawner __instance, int prefabID, Vector3 pos, Vector3 rot) { //IL_0051: 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_0053: Unknown result type (might be due to invalid IL or missing references) if (!ObjectSpawnerFeatureState.NoCostPlaceableSpawnEnabled) { return true; } if (__instance.buildables == null || prefabID < 0 || prefabID >= __instance.buildables.Length) { return false; } GameObject val = __instance.buildables[prefabID]; if ((Object)(object)val == (Object)null) { return false; } Data_Container component = val.GetComponent(); int num = (((Object)(object)component != (Object)null) ? component.parentIndex : 0); GameObject obj = Object.Instantiate(val, pos, Quaternion.Euler(rot)); obj.transform.SetParent(__instance.levelPropsOBJ.transform.GetChild(num)); NetworkServer.Spawn(obj, (NetworkConnection)null); return false; } [HarmonyPatch(typeof(NetworkSpawner), "UserCode_CmdSpawnManufacturing__Int32__Vector3__Vector3")] [HarmonyPrefix] private static bool SpawnManufacturingWithoutCost(NetworkSpawner __instance, int prefabID, Vector3 pos, Vector3 rot) { //IL_0052: 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_0054: Unknown result type (might be due to invalid IL or missing references) if (!ObjectSpawnerFeatureState.NoCostPlaceableSpawnEnabled) { return true; } if (__instance.manufacturingBuildables == null || prefabID < 0 || prefabID >= __instance.manufacturingBuildables.Length) { return false; } GameObject val = __instance.manufacturingBuildables[prefabID]; if ((Object)(object)val == (Object)null) { return false; } ManufacturingContainer component = val.GetComponent(); int num = (((Object)(object)component != (Object)null) ? component.parentIndex : 10); GameObject obj = Object.Instantiate(val, pos, Quaternion.Euler(rot)); obj.transform.SetParent(__instance.levelPropsOBJ.transform.GetChild(num)); NetworkServer.Spawn(obj, (NetworkConnection)null); return false; } } internal sealed class ObjectSpawnCatalog { public bool TryBuildEntries(out List entries) { entries = new List(); NetworkSpawner networkSpawner = GetNetworkSpawner(); if ((Object)(object)networkSpawner == (Object)null) { return false; } AddProductBoxEntries(entries); AddHeldItemEntries(entries, networkSpawner.props); AddPlaceableObjectEntries(entries, "Buildable", networkSpawner.buildables); AddPlaceableObjectEntries(entries, "Manufacturing", networkSpawner.manufacturingBuildables); AddPlaceableObjectEntries(entries, "Decoration", networkSpawner.decorationProps); AddSceneOutdoorTrashCanEntries(entries); AddNpcEntries(entries); return true; } private static void AddProductBoxEntries(List entries) { ProductListing instance = ProductListing.Instance; if (instance?.productsData == null) { return; } for (int i = 0; i < instance.productsData.Length; i++) { ProductData val = instance.productsData[i]; if (val != null) { string localizedText = GetLocalizedText($"product{i}"); string displayName = (string.IsNullOrWhiteSpace(localizedText) ? $"Product {i}" : localizedText); entries.Add(ObjectSpawnEntry.ProductBox(i, displayName, val.maxItemsPerBox)); } } } private static void AddHeldItemEntries(List entries, GameObject[]? prefabs) { if (prefabs == null) { return; } for (int i = 0; i < prefabs.Length; i++) { GameObject val = prefabs[i]; if (!((Object)(object)val == (Object)null)) { entries.Add(ObjectSpawnEntry.HeldItem(i, CleanPrefabName(((Object)val).name))); } } } private static void AddPlaceableObjectEntries(List entries, string source, GameObject[]? prefabs) { if (prefabs == null) { return; } for (int i = 0; i < prefabs.Length; i++) { GameObject val = prefabs[i]; if (!((Object)(object)val == (Object)null)) { string placeableDisplayName = GetPlaceableDisplayName(val, source); entries.Add(ObjectSpawnEntry.PlaceableObject(i, placeableDisplayName, source, val)); if ((Object)(object)val.GetComponent() != (Object)null) { entries.Add(ObjectSpawnEntry.OutdoorTrashCan(i, placeableDisplayName, source, val)); } } } } private static void AddSceneOutdoorTrashCanEntries(List entries) { TrashPlace[] array = Object.FindObjectsByType((FindObjectsSortMode)0); int num = 0; TrashPlace[] array2 = array; foreach (TrashPlace val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent() != (Object)null)) { GameObject gameObject = ((Component)val).gameObject; entries.Add(ObjectSpawnEntry.SceneOutdoorTrashCan(num, CleanPrefabName(((Object)gameObject).name) + " [Scene]", gameObject)); num++; } } } private static void AddNpcEntries(List entries) { entries.Add(ObjectSpawnEntry.Npc(0, "客", ObjectSpawnNpcKind.Customer)); entries.Add(ObjectSpawnEntry.Npc(1, "通行人", ObjectSpawnNpcKind.Bystander)); entries.Add(ObjectSpawnEntry.Npc(2, "泥棒客", ObjectSpawnNpcKind.ThiefCustomer)); entries.Add(ObjectSpawnEntry.Npc(3, "Mister Grusch", ObjectSpawnNpcKind.MisterGrusch)); } private static string GetPlaceableDisplayName(GameObject prefab, string source) { string text = source switch { "Buildable" => GetBuildableLocalizedName(prefab), "Manufacturing" => GetManufacturingLocalizedName(prefab), "Decoration" => GetDecorationLocalizedName(prefab), _ => "", }; return (string.IsNullOrWhiteSpace(text) ? CleanPrefabName(((Object)prefab).name) : text) + " [" + GetPlaceableSourceLabel(source) + "]"; } private static string GetBuildableLocalizedName(GameObject prefab) { Data_Container component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { return ""; } return FirstLocalizedText(component.buildableTag, $"buildable{component.containerID}", $"container{component.containerID}", $"furniture{component.containerID}"); } private static string GetManufacturingLocalizedName(GameObject prefab) { ManufacturingContainer component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { return ""; } return FirstLocalizedText($"manufacturing{component.containerID}", $"manufacturingcontainer{component.containerID}", $"mcontainer{component.containerID}", $"buildable{component.containerID}"); } private static string GetDecorationLocalizedName(GameObject prefab) { BuildableInfo component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { return ""; } return FirstLocalizedText($"decoration{component.decorationID}", $"decoprop{component.decorationID}", $"deco{component.decorationID}", $"buildable{component.decorationID}"); } private static string FirstLocalizedText(params string[] keys) { for (int i = 0; i < keys.Length; i++) { string localizedTextOrEmpty = GetLocalizedTextOrEmpty(keys[i]); if (!string.IsNullOrWhiteSpace(localizedTextOrEmpty)) { return localizedTextOrEmpty; } } return ""; } private static string GetPlaceableSourceLabel(string source) { return source switch { "Buildable" => "設置物", "Manufacturing" => "製造", "Decoration" => "装飾", _ => source, }; } private static string GetLocalizedText(string key) { if ((Object)(object)LocalizationManager.instance == (Object)null) { return ""; } return LocalizationManager.instance.GetLocalizationString(key); } private static string GetLocalizedTextOrEmpty(string key) { if (string.IsNullOrWhiteSpace(key) || (Object)(object)LocalizationManager.instance == (Object)null) { return ""; } string localizationString = LocalizationManager.instance.GetLocalizationString(key); if (string.IsNullOrWhiteSpace(localizationString) || localizationString == key || localizationString.Equals("locError", StringComparison.OrdinalIgnoreCase)) { return ""; } return localizationString; } private static NetworkSpawner? GetNetworkSpawner() { if (!((Object)(object)GameData.Instance != (Object)null)) { return Object.FindFirstObjectByType(); } return ((Component)GameData.Instance).GetComponent(); } private static string CleanPrefabName(string prefabName) { return prefabName.Replace("(Clone)", "").Trim(); } } internal enum ObjectSpawnEntryKind { ProductBox, HeldItem, PlaceableObject, OutdoorTrashCan, Npc } internal enum ObjectSpawnNpcKind { None, Customer, Bystander, ThiefCustomer, MisterGrusch } internal enum ObjectSpawnPlaceableSource { None, Buildable, Manufacturing, Decoration, SceneClone } internal sealed class ObjectSpawnEntry { public ObjectSpawnEntryKind Kind { get; } public int Id { get; } public string DisplayName { get; } public int Quantity { get; } public ObjectSpawnPlaceableSource PlaceableSource { get; } public ObjectSpawnNpcKind NpcKind { get; } public GameObject? Prefab { get; } private ObjectSpawnEntry(ObjectSpawnEntryKind kind, int id, string displayName, int quantity, ObjectSpawnPlaceableSource placeableSource, ObjectSpawnNpcKind npcKind, GameObject? prefab) { Kind = kind; Id = id; DisplayName = displayName; Quantity = quantity; PlaceableSource = placeableSource; NpcKind = npcKind; Prefab = prefab; } public static ObjectSpawnEntry ProductBox(int productId, string displayName, int quantity) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.ProductBox, productId, displayName, quantity, ObjectSpawnPlaceableSource.None, ObjectSpawnNpcKind.None, null); } public static ObjectSpawnEntry HeldItem(int itemId, string displayName) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.HeldItem, itemId, displayName, 1, ObjectSpawnPlaceableSource.None, ObjectSpawnNpcKind.None, null); } public static ObjectSpawnEntry PlaceableObject(int objectId, string displayName, string source, GameObject prefab) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.PlaceableObject, objectId, displayName, 0, ParsePlaceableSource(source), ObjectSpawnNpcKind.None, prefab); } public static ObjectSpawnEntry OutdoorTrashCan(int objectId, string displayName, string source, GameObject prefab) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.OutdoorTrashCan, objectId, displayName, 0, ParsePlaceableSource(source), ObjectSpawnNpcKind.None, prefab); } public static ObjectSpawnEntry SceneOutdoorTrashCan(int objectId, string displayName, GameObject template) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.OutdoorTrashCan, objectId, displayName, 0, ObjectSpawnPlaceableSource.SceneClone, ObjectSpawnNpcKind.None, template); } public static ObjectSpawnEntry Npc(int npcId, string displayName, ObjectSpawnNpcKind npcKind) { return new ObjectSpawnEntry(ObjectSpawnEntryKind.Npc, npcId, displayName, 0, ObjectSpawnPlaceableSource.None, npcKind, null); } private static ObjectSpawnPlaceableSource ParsePlaceableSource(string source) { return source switch { "Buildable" => ObjectSpawnPlaceableSource.Buildable, "Manufacturing" => ObjectSpawnPlaceableSource.Manufacturing, "Decoration" => ObjectSpawnPlaceableSource.Decoration, _ => ObjectSpawnPlaceableSource.None, }; } } internal sealed class ObjectSpawnerMenu : MonoBehaviour { private readonly struct CategoryTab { public ObjectSpawnEntryKind Kind { get; } public string Label { get; } public CategoryTab(ObjectSpawnEntryKind kind, string label) { Kind = kind; Label = label; } } private const float ButtonHeight = 28f; private const float CategoryButtonWidth = 142f; private const float EntryRowHeight = 30f; private const float EntryListHeight = 430f; private readonly List entries = new List(); private readonly CategoryTab[] categories = new CategoryTab[5] { new CategoryTab(ObjectSpawnEntryKind.ProductBox, "商品箱"), new CategoryTab(ObjectSpawnEntryKind.HeldItem, "手持ちアイテム"), new CategoryTab(ObjectSpawnEntryKind.PlaceableObject, "設置オブジェクト"), new CategoryTab(ObjectSpawnEntryKind.OutdoorTrashCan, "店外ゴミ箱"), new CategoryTab(ObjectSpawnEntryKind.Npc, "NPC") }; private ManualLogSource? logger; private ObjectSpawnCatalog? catalog; private ObjectSpawnExecutor? executor; private Font? japaneseFont; private Vector2 scrollPosition; private ObjectSpawnEntryKind selectedCategory; private string searchText = ""; private string statusMessage = "ゲームに入ってから「更新」を押してください。"; private bool hasLoadedEntries; private readonly List visibleEntries = new List(); private ObjectSpawnEntryKind cachedCategory; private string cachedSearchText = ""; private int entriesVersion; private int cachedEntriesVersion = -1; public void Initialize(ManualLogSource pluginLogger, ObjectSpawnerSettings objectSpawnerSettings) { logger = pluginLogger; catalog = new ObjectSpawnCatalog(); executor = new ObjectSpawnExecutor(pluginLogger, objectSpawnerSettings); } internal void ShowPanel() { if (!hasLoadedEntries) { RefreshEntries(); } } internal void DrawPanelContent() { ApplyJapaneseFont(); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("カテゴリ", Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); CategoryTab[] array = categories; for (int i = 0; i < array.Length; i++) { CategoryTab categoryTab = array[i]; bool num = selectedCategory == categoryTab.Kind; string text = $"{categoryTab.Label} ({CountEntries(categoryTab.Kind)})"; if (GUILayout.Toggle(num, text, GUIStyle.op_Implicit("Button"), (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(142f), GUILayout.Height(28f) })) { selectedCategory = categoryTab.Kind; } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("検索と更新", Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("検索", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(52f) }); searchText = GUILayout.TextField(searchText, 64, Array.Empty()); if (GUILayout.Button("クリア", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(72f), GUILayout.Height(28f) })) { searchText = ""; } if (GUILayout.Button("更新", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(96f), GUILayout.Height(28f) })) { RefreshEntries(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(6f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); DrawEntries(); GUILayout.EndVertical(); GUILayout.Space(6f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label(statusMessage, Array.Empty()); GUILayout.EndVertical(); } private void DrawEntries() { //IL_0090: 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) RebuildVisibleEntriesIfNeeded(); GUILayout.Label($"{GetCategoryLabel(selectedCategory)}: {visibleEntries.Count}", Array.Empty()); if (visibleEntries.Count == 0) { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(430f) }); GUILayout.Space(16f); GUILayout.Label(string.IsNullOrWhiteSpace(searchText) ? "表示できる項目がありません。必要なら「更新」を押してください。" : "検索条件に一致する項目がありません。", Array.Empty()); GUILayout.EndVertical(); return; } scrollPosition = GUILayout.BeginScrollView(scrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(430f) }); int num = Mathf.Clamp((int)(scrollPosition.y / 30f), 0, visibleEntries.Count - 1); int num2 = Mathf.CeilToInt(14.333333f) + 2; int num3 = Mathf.Min(visibleEntries.Count, num + num2); GUILayout.Space((float)num * 30f); for (int i = num; i < num3; i++) { ObjectSpawnEntry objectSpawnEntry = visibleEntries[i]; GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label($"#{objectSpawnEntry.Id}", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(48f), GUILayout.Height(30f) }); GUILayout.Label(objectSpawnEntry.DisplayName, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(260f), GUILayout.Height(30f) }); if (GUILayout.Button("召喚", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(96f), GUILayout.Height(28f) })) { SpawnSelectedEntry(objectSpawnEntry); } GUILayout.EndHorizontal(); } GUILayout.Space((float)(visibleEntries.Count - num3) * 30f); GUILayout.EndScrollView(); } private void RefreshEntries() { if (catalog == null) { return; } entries.Clear(); if (!catalog.TryBuildEntries(out List collection)) { hasLoadedEntries = false; statusMessage = "NetworkSpawner が見つかりません。セーブデータに入ってから実行してください。"; ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)statusMessage); } return; } entries.AddRange(collection); entriesVersion++; hasLoadedEntries = true; statusMessage = $"{entries.Count} 件を読み込みました。"; ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)statusMessage); } } private void RebuildVisibleEntriesIfNeeded() { if (cachedEntriesVersion == entriesVersion && cachedCategory == selectedCategory && string.Equals(cachedSearchText, searchText, StringComparison.Ordinal)) { return; } visibleEntries.Clear(); foreach (ObjectSpawnEntry entry in entries) { if (entry.Kind == selectedCategory && (string.IsNullOrWhiteSpace(searchText) || entry.DisplayName.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) >= 0)) { visibleEntries.Add(entry); } } cachedEntriesVersion = entriesVersion; cachedCategory = selectedCategory; cachedSearchText = searchText; } private void SpawnSelectedEntry(ObjectSpawnEntry entry) { if (executor == null) { return; } statusMessage = executor.Spawn(entry); if (!statusMessage.StartsWith("召喚しました:", StringComparison.Ordinal)) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)statusMessage); } } } private int CountEntries(ObjectSpawnEntryKind kind) { int num = 0; foreach (ObjectSpawnEntry entry in entries) { if (entry.Kind == kind) { num++; } } return num; } private void ApplyJapaneseFont() { if (japaneseFont == null) { japaneseFont = Font.CreateDynamicFontFromOSFont(new string[4] { "Yu Gothic UI", "Yu Gothic", "Meiryo", "MS Gothic" }, 14); } if (!((Object)(object)japaneseFont == (Object)null) && !((Object)(object)GUI.skin.font == (Object)(object)japaneseFont)) { GUI.skin.font = japaneseFont; GUI.skin.label.font = japaneseFont; GUI.skin.button.font = japaneseFont; GUI.skin.toggle.font = japaneseFont; GUI.skin.textField.font = japaneseFont; GUI.skin.window.font = japaneseFont; } } private string GetCategoryLabel(ObjectSpawnEntryKind kind) { CategoryTab[] array = categories; for (int i = 0; i < array.Length; i++) { CategoryTab categoryTab = array[i]; if (categoryTab.Kind == kind) { return categoryTab.Label; } } return kind.ToString(); } } internal sealed class ObjectSpawnerSettings { public ConfigEntry NoCostPlaceableSpawnEnabled { get; } public ConfigEntry SpawnDistance { get; } public ObjectSpawnerSettings(ConfigEntry noCostPlaceableSpawnEnabled, ConfigEntry spawnDistance) { NoCostPlaceableSpawnEnabled = noCostPlaceableSpawnEnabled; SpawnDistance = spawnDistance; ObjectSpawnerFeatureState.NoCostPlaceableSpawnEnabled = noCostPlaceableSpawnEnabled.Value; noCostPlaceableSpawnEnabled.SettingChanged += delegate { ObjectSpawnerFeatureState.NoCostPlaceableSpawnEnabled = noCostPlaceableSpawnEnabled.Value; }; } } internal static class ObjectSpawnerFeatureState { public static bool NoCostPlaceableSpawnEnabled { get; set; } = true; } internal sealed class ObjectSpawnExecutor { private readonly ManualLogSource logger; private readonly ObjectSpawnerSettings settings; public ObjectSpawnExecutor(ManualLogSource logger, ObjectSpawnerSettings settings) { this.logger = logger; this.settings = settings; } public string Spawn(ObjectSpawnEntry entry) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_008e: 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) GameData instance = GameData.Instance; if ((Object)(object)instance == (Object)null) { return "GameData が見つかりません。"; } Vector3 spawnPosition = GetSpawnPosition(GetLocalPlayer()); float spawnYRotation = GetSpawnYRotation(); switch (entry.Kind) { case ObjectSpawnEntryKind.ProductBox: ((Component)instance).GetComponent().CmdSpawnBoxFromPlayer(spawnPosition, entry.Id, entry.Quantity, spawnYRotation); break; case ObjectSpawnEntryKind.HeldItem: ((Component)instance).GetComponent().CmdSpawnProp(entry.Id, spawnPosition, GetHeldItemRotation(entry.Id, spawnYRotation)); break; case ObjectSpawnEntryKind.PlaceableObject: case ObjectSpawnEntryKind.OutdoorTrashCan: { string text2 = SpawnPlaceableObject(((Component)instance).GetComponent(), entry, spawnPosition, spawnYRotation); if (!string.IsNullOrWhiteSpace(text2)) { return text2; } break; } case ObjectSpawnEntryKind.Npc: { string text = SpawnNpc(entry, spawnPosition); if (!string.IsNullOrWhiteSpace(text)) { return text; } break; } } string text3 = "召喚しました: " + entry.DisplayName; logger.LogInfo((object)text3); return text3; } private static string SpawnPlaceableObject(NetworkSpawner spawner, ObjectSpawnEntry entry, Vector3 spawnPosition, float yRotation) { //IL_000a: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0071: Unknown result type (might be due to invalid IL or missing references) if (entry.PlaceableSource == ObjectSpawnPlaceableSource.SceneClone) { return SpawnSceneClone(entry, spawnPosition, yRotation); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, yRotation, 0f); switch (entry.PlaceableSource) { case ObjectSpawnPlaceableSource.Buildable: spawner.CmdSpawn(entry.Id, spawnPosition, val); return ""; case ObjectSpawnPlaceableSource.Manufacturing: spawner.CmdSpawnManufacturing(entry.Id, spawnPosition, val); return ""; case ObjectSpawnPlaceableSource.Decoration: spawner.CmdSpawnDecoration(entry.Id, spawnPosition, val); return ""; default: return "未対応の設置オブジェクトです。"; } } private static string SpawnSceneClone(ObjectSpawnEntry entry, Vector3 spawnPosition, float yRotation) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entry.Prefab == (Object)null) { return "複製元の店外ゴミ箱が見つかりません。"; } GameObject val = Object.Instantiate(entry.Prefab, spawnPosition, Quaternion.Euler(0f, yRotation, 0f)); if ((Object)(object)entry.Prefab.transform.parent != (Object)null) { val.transform.SetParent(entry.Prefab.transform.parent); } if (NetworkServer.active && (Object)(object)val.GetComponent() != (Object)null) { NetworkServer.Spawn(val, (NetworkConnection)null); } return ""; } private static string SpawnNpc(ObjectSpawnEntry entry, Vector3 spawnPosition) { //IL_0044: 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_006c: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return "NPC召喚はホスト/サーバーでのみ実行できます。"; } NPC_Manager instance = NPC_Manager.Instance; if ((Object)(object)instance == (Object)null) { return "NPC_Manager が見つかりません。"; } switch (entry.NpcKind) { case ObjectSpawnNpcKind.Customer: SpawnCustomerNpc(instance, spawnPosition, isThief: false); return ""; case ObjectSpawnNpcKind.Bystander: SpawnBystanderNpc(instance, spawnPosition); return ""; case ObjectSpawnNpcKind.ThiefCustomer: SpawnCustomerNpc(instance, spawnPosition, isThief: true); return ""; case ObjectSpawnNpcKind.MisterGrusch: SpawnMisterGrusch(spawnPosition); return ""; default: return "未対応のNPCです。"; } } private static void SpawnCustomerNpc(NPC_Manager npcManager, Vector3 spawnPosition, bool isThief) { //IL_0001: 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_0052: Unknown result type (might be due to invalid IL or missing references) GameObject val = InstantiateNpcAgent(npcManager, spawnPosition, npcManager.customersnpcParentOBJ.transform); NPC_Info component = val.GetComponent(); component.NetworkNPCID = GetRandomNpcId(npcManager); component.NetworkisCustomer = true; component.isAThief = isThief; component.productItemPlaceWait = 0.5f; AddRandomProductsToBuy(component); NavMeshAgent component2 = val.GetComponent(); ConfigureNpcAgent(component2); component2.destination = GetCustomerDestination(npcManager, spawnPosition); component.state = 0; NetworkServer.Spawn(val, (NetworkConnection)null); } private static void SpawnBystanderNpc(NPC_Manager npcManager, Vector3 spawnPosition) { //IL_0001: 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) GameObject obj = InstantiateNpcAgent(npcManager, spawnPosition, npcManager.dummynpcParentOBJ.transform); NPC_Info component = obj.GetComponent(); component.NetworkNPCID = GetRandomNpcId(npcManager); component.isBystander = true; NavMeshAgent component2 = obj.GetComponent(); ConfigureNpcAgent(component2); component2.destination = GetRandomChildPosition(npcManager.randomPointsOBJ, spawnPosition); NetworkServer.Spawn(obj, (NetworkConnection)null); } private static void SpawnMisterGrusch(Vector3 spawnPosition) { //IL_0024: 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) NetworkSpawner networkSpawner = GetNetworkSpawner(); if (!((Object)(object)networkSpawner == (Object)null) && !((Object)(object)networkSpawner.misterGruschPrefabOBJ == (Object)null)) { GameObject val = Object.Instantiate(networkSpawner.misterGruschPrefabOBJ, spawnPosition, Quaternion.identity); if ((Object)(object)networkSpawner.gruschesParentOBJ != (Object)null) { val.transform.SetParent(networkSpawner.gruschesParentOBJ.transform); } InitializeMisterGruschFields(val); NetworkServer.Spawn(val, (NetworkConnection)null); } } private static void InitializeMisterGruschFields(GameObject grusch) { MisterGrusch component = grusch.GetComponent(); if (!((Object)(object)component == (Object)null)) { Transform obj = grusch.transform.Find("Pivot_MisterGrusch"); SetPrivateField(component, "pivotAnimator", (obj != null) ? ((Component)obj).GetComponent() : null); SetPrivateField(component, "speedComponent", grusch.GetComponent()); Transform obj2 = grusch.transform.Find("BoinkAudio"); SetPrivateField(component, "boinkAudioOBJ", (obj2 != null) ? ((Component)obj2).gameObject : null); Transform obj3 = grusch.transform.Find("OtherScreams"); SetPrivateField(component, "screamAudioSource", (obj3 != null) ? ((Component)obj3).GetComponent() : null); Transform obj4 = grusch.transform.Find("Pivot_MisterGrusch/NumberCanvas/Number"); SetPrivateField(component, "numberField", (obj4 != null) ? ((Component)obj4).GetComponent("TextMeshProUGUI") : null); SetPrivateField(component, "shelvesOBJ", NPC_Manager.Instance?.shelvesOBJ); SetPrivateField(component, "storageOBJ", NPC_Manager.Instance?.storageOBJ); NavMeshAgent component2 = grusch.GetComponent(); if ((Object)(object)component2 != (Object)null) { ((Behaviour)component2).enabled = true; SetPrivateField(component, "agent", component2); } } } private static void SetPrivateField(object target, string fieldName, object? value) { if (value != null) { target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(target, value); } } private static GameObject InstantiateNpcAgent(NPC_Manager npcManager, Vector3 spawnPosition, Transform parent) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(npcManager.npcAgentPrefab, spawnPosition, Quaternion.identity); obj.transform.SetParent(parent); return obj; } private static int GetRandomNpcId(NPC_Manager npcManager) { if (npcManager.NPCsArray == null || npcManager.NPCsArray.Length == 0) { return 0; } return Random.Range(0, npcManager.NPCsArray.Length); } private static void AddRandomProductsToBuy(NPC_Info npcInfo) { List list = ProductListing.Instance?.availableProducts; if (list != null && list.Count != 0) { int num = Mathf.Clamp(Random.Range(1, 4), 1, list.Count); for (int i = 0; i < num; i++) { npcInfo.productsIDToBuy.Add(list[Random.Range(0, list.Count)]); } npcInfo.productsIDToBuy.Sort(); } } private static void ConfigureNpcAgent(NavMeshAgent agent) { ((Behaviour)agent).enabled = true; agent.stoppingDistance = 1f; agent.speed = 2.2f; agent.angularSpeed = 140f; agent.acceleration = 10f; } private static Vector3 GetCustomerDestination(NPC_Manager npcManager, Vector3 fallback) { //IL_0071: 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_0065: 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) if ((Object)(object)npcManager.shelvesOBJ != (Object)null && npcManager.shelvesOBJ.transform.childCount > 0) { Transform child = npcManager.shelvesOBJ.transform.GetChild(Random.Range(0, npcManager.shelvesOBJ.transform.childCount)); Transform val = child.Find("Standspot"); if (!((Object)(object)val != (Object)null)) { return child.position; } return val.position; } return GetRandomChildPosition(npcManager.randomPointsOBJ, fallback); } private static Vector3 GetRandomChildPosition(GameObject parentObject, Vector3 fallback) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parentObject == (Object)null || parentObject.transform.childCount == 0) { return fallback; } return parentObject.transform.GetChild(Random.Range(0, parentObject.transform.childCount)).position; } private Vector3 GetSpawnPosition(PlayerNetwork? player) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_007b: 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_00be: 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_00c1: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(settings.SpawnDistance.Value, 1f, 20f); Transform val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null); Vector3 val2 = (((Object)(object)val != (Object)null) ? val.position : ((player != null) ? ((Component)player).transform.position : Vector3.zero)); Vector3 val3 = (((Object)(object)val != (Object)null) ? val.forward : ((player != null) ? ((Component)player).transform.forward : Vector3.forward)); RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val2, val3, ref val4, num, -1, (QueryTriggerInteraction)1)) { Vector3 point = ((RaycastHit)(ref val4)).point; Vector3 normal = ((RaycastHit)(ref val4)).normal; return point + ((Vector3)(ref normal)).normalized * 0.5f; } return val2 + val3 * num; } private static float GetSpawnYRotation() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) PlayerNetwork localPlayer = GetLocalPlayer(); Quaternion rotation; if ((Object)(object)localPlayer != (Object)null) { rotation = ((Component)localPlayer).transform.rotation; return ((Quaternion)(ref rotation)).eulerAngles.y; } if (!((Object)(object)Camera.main != (Object)null)) { return 0f; } rotation = ((Component)Camera.main).transform.rotation; return ((Quaternion)(ref rotation)).eulerAngles.y; } private static Vector3 GetHeldItemRotation(int itemId, float yRotation) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) switch (itemId) { case 6: case 10: return new Vector3(180f, yRotation, 0f); case 8: return new Vector3(15f, yRotation, 0f); case 3: case 5: return new Vector3(270f, yRotation, 0f); case 2: return new Vector3(0f, yRotation, 90f); case 13: case 14: case 15: return Vector3.zero; default: return new Vector3(0f, yRotation, 0f); } } private static NetworkSpawner? GetNetworkSpawner() { if (!((Object)(object)GameData.Instance != (Object)null)) { return Object.FindFirstObjectByType(); } return ((Component)GameData.Instance).GetComponent(); } private static PlayerNetwork? GetLocalPlayer() { PlayerNetwork[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerNetwork val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).isLocalPlayer) { return val; } } return null; } } } namespace SupermarketTogetherAnyPlaceBuilder { internal sealed class AnyPlaceBuilderController : MonoBehaviour { private static readonly FieldInfo? MainDummyField = Field(typeof(Builder_Main), "dummyOBJ"); private static readonly FieldInfo? MainCurrentElementIndexField = Field(typeof(Builder_Main), "currentElementIndex"); private static readonly FieldInfo? MainCurrentPropIndexField = Field(typeof(Builder_Main), "currentPropIndex"); private static readonly FieldInfo? MainCurrentTabIndexField = Field(typeof(Builder_Main), "currentTabIndex"); private static readonly FieldInfo? DecorationDummyField = Field(typeof(Builder_Decoration), "dummyOBJ"); private static readonly FieldInfo? DecorationCurrentIndexField = Field(typeof(Builder_Decoration), "currentIndex"); private ManualLogSource? logger; private AnyPlaceBuilderSettings? settings; public void Initialize(ManualLogSource pluginLogger, AnyPlaceBuilderSettings anyPlaceBuilderSettings) { logger = pluginLogger; settings = anyPlaceBuilderSettings; } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (settings != null && settings.Enabled.Value && !settings.SuppressPlacePreviewInput && Input.GetKeyDown(settings.PlacePreviewKey.Value) && !TryPlaceFromMainBuilder() && !TryPlaceFromDecorationBuilder()) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)"No active placeable preview was found. Open the builder and select an object first."); } } } private bool TryPlaceFromMainBuilder() { //IL_00af: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) Builder_Main val = Object.FindObjectOfType(); if ((Object)(object)val == (Object)null || (Object)(object)val.canvasBuilderOBJ == (Object)null || !val.canvasBuilderOBJ.activeInHierarchy) { return false; } GameObject fieldValue = GetFieldValue(MainDummyField, val); if ((Object)(object)fieldValue == (Object)null) { return false; } if (GetFieldValue(MainCurrentElementIndexField, val) <= 1) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)"Current builder mode is move/delete, not a new object placement."); } return true; } NetworkSpawner networkSpawner = GetNetworkSpawner(); if ((Object)(object)networkSpawner == (Object)null) { ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogWarning((object)"NetworkSpawner was not found. Load into a save before placing objects."); } return true; } int fieldValue2 = GetFieldValue(MainCurrentPropIndexField, val); int fieldValue3 = GetFieldValue(MainCurrentTabIndexField, val); Quaternion rotation = fieldValue.transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; if (val.furnitureTabsIndexes != null && val.furnitureTabsIndexes.Contains(fieldValue3)) { networkSpawner.CmdSpawn(fieldValue2, fieldValue.transform.position, eulerAngles); LogPlaced("Buildable", fieldValue2, fieldValue.transform); return true; } if (fieldValue3 == 2) { networkSpawner.CmdSpawnManufacturing(fieldValue2, fieldValue.transform.position, eulerAngles); LogPlaced("Manufacturing", fieldValue2, fieldValue.transform); return true; } networkSpawner.CmdSpawnDecoration(fieldValue2, fieldValue.transform.position, eulerAngles); LogPlaced("Decoration", fieldValue2, fieldValue.transform); return true; } private bool TryPlaceFromDecorationBuilder() { //IL_006f: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Builder_Decoration val = Object.FindObjectOfType(); if ((Object)(object)val == (Object)null || !((Behaviour)val).isActiveAndEnabled) { return false; } GameObject fieldValue = GetFieldValue(DecorationDummyField, val); int fieldValue2 = GetFieldValue(DecorationCurrentIndexField, val); if ((Object)(object)fieldValue == (Object)null || fieldValue2 <= 0) { return false; } NetworkSpawner networkSpawner = GetNetworkSpawner(); if ((Object)(object)networkSpawner == (Object)null) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)"NetworkSpawner was not found. Load into a save before placing objects."); } return true; } Vector3 position = fieldValue.transform.position; Quaternion rotation = fieldValue.transform.rotation; networkSpawner.CmdSpawnDecoration(fieldValue2, position, ((Quaternion)(ref rotation)).eulerAngles); LogPlaced("Decoration", fieldValue2, fieldValue.transform); return true; } private void LogPlaced(string source, int prefabId, Transform transform) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) ManualLogSource? obj = logger; if (obj != null) { object[] obj2 = new object[4] { source, prefabId, FormatVector(transform.position), null }; Quaternion rotation = transform.rotation; obj2[3] = FormatVector(((Quaternion)(ref rotation)).eulerAngles); obj.LogInfo((object)string.Format("Placed {0} #{1} at {2} rot {3}.", obj2)); } } private static NetworkSpawner? GetNetworkSpawner() { if (!((Object)(object)GameData.Instance != (Object)null)) { return Object.FindObjectOfType(); } return ((Component)GameData.Instance).GetComponent(); } private static T GetFieldValue(FieldInfo? field, object target) { if (field == null) { return default(T); } object value = field.GetValue(target); if (value is T) { return (T)value; } return default(T); } private static FieldInfo? Field(Type type, string name) { return type.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); } private static string FormatVector(Vector3 value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"({value.x:0.###}, {value.y:0.###}, {value.z:0.###})"; } } internal sealed class AnyPlaceBuilderSettings { public ConfigEntry Enabled { get; } public ConfigEntry PlacePreviewKey { get; } public bool SuppressPlacePreviewInput { get; set; } public AnyPlaceBuilderSettings(ConfigEntry enabled, ConfigEntry placePreviewKey) { Enabled = enabled; PlacePreviewKey = placePreviewKey; } } } namespace SupermarketTogetherTeleportMenu { [Serializable] internal sealed class TeleportLocationData { public string Id = ""; public string Name = ""; public float X; public float Y; public float Z; public float Yaw; public KeyCode ShortcutKey; public Vector3 Position => new Vector3(X, Y, Z); public TeleportLocationData() { } public TeleportLocationData(string id, string name, Vector3 position, float yaw, KeyCode shortcutKey = (KeyCode)0) { //IL_002b: 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_0043: 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_0059: Unknown result type (might be due to invalid IL or missing references) Id = id; Name = name; X = position.x; Y = position.y; Z = position.z; Yaw = yaw; ShortcutKey = shortcutKey; } public TeleportLocationData WithName(string name) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return new TeleportLocationData(Id, name, Position, Yaw, ShortcutKey); } public TeleportLocationData WithShortcutKey(KeyCode shortcutKey) { //IL_000d: 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) return new TeleportLocationData(Id, Name, Position, Yaw, shortcutKey); } } [Serializable] internal sealed class TeleportLocationCollection { public List Locations = new List(); } internal sealed class TeleportLocationStorage { private readonly string filePath; private readonly ManualLogSource logger; public TeleportLocationStorage(string configPath, ManualLogSource pluginLogger) { filePath = Path.Combine(configPath, "uta_a.supermarkettogether.teleportmenu.locations.json"); logger = pluginLogger; } public List Load() { if (!File.Exists(filePath)) { return new List(); } try { string text = File.ReadAllText(filePath); if (string.IsNullOrWhiteSpace(text)) { return new List(); } return JsonUtility.FromJson(text)?.Locations ?? new List(); } catch (Exception ex) { logger.LogError((object)("Failed to load teleport locations: " + ex.Message)); return new List(); } } public void Save(IReadOnlyList locations) { try { Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? "."); string contents = JsonUtility.ToJson((object)new TeleportLocationCollection { Locations = new List(locations) }, true); File.WriteAllText(filePath, contents); } catch (Exception ex) { logger.LogError((object)("Failed to save teleport locations: " + ex.Message)); } } } internal sealed class TeleportMenu : MonoBehaviour { private enum TeleportTab { Locations, Players, LookTeleport } private enum ShortcutTargetKind { None, Location, Player, LookTeleport } private sealed class RowDraft { public string Name { get; set; } public RowDraft(string name) { Name = name; } } private const string WindowTitle = "Teleport Menu"; private const string LocalPlayerObjectName = "LocalGamePlayer"; private const float ButtonHeight = 28f; private const float HeaderDragHeight = 34f; private const float SmallButtonWidth = 64f; private const float MediumButtonWidth = 84f; private const float PlayerOffsetDistance = 1.5f; private const float LookTeleportMaxDistance = 1000f; private const float LookTeleportSurfaceOffset = 0.15f; private const int DefaultMaxLocations = 20; private static readonly KeyCode[] ShortcutKeyCandidates = Enum.GetValues(typeof(KeyCode)).Cast().Where(IsAllowedShortcutKey) .ToArray(); private readonly List locations = new List(); private readonly List playerShortcuts = new List(); private readonly Dictionary drafts = new Dictionary(); private ManualLogSource? logger; private TeleportMenuSettings? settings; private TeleportLocationStorage? locationStorage; private TeleportShortcutStorage? shortcutStorage; private FirstPersonController? cachedFirstPersonController; private PlayerObjectController? cachedLocalPlayer; private Vector2 locationScrollPosition; private Vector2 playerScrollPosition; private TeleportTab activeTab; private ShortcutTargetKind listeningKind; private string listeningTargetId = ""; private string listeningTargetName = ""; private string newLocationName = ""; private KeyCode lookTeleportKey; private string statusMessage = "Load into a save, then save your current position."; public void Initialize(ManualLogSource pluginLogger, TeleportMenuSettings menuSettings, string configPath) { //IL_0072: 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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) logger = pluginLogger; settings = menuSettings; locationStorage = new TeleportLocationStorage(configPath, pluginLogger); shortcutStorage = new TeleportShortcutStorage(configPath, pluginLogger); locations.AddRange(NormalizeLoadedLocations(locationStorage.Load()).Take(GetMaxLocations())); TeleportShortcutCollection teleportShortcutCollection = shortcutStorage.Load(); playerShortcuts.AddRange(NormalizeLoadedPlayerShortcuts(teleportShortcutCollection.PlayerShortcuts)); lookTeleportKey = (KeyCode)(IsAllowedShortcutKey(teleportShortcutCollection.LookTeleportKey) ? ((int)teleportShortcutCollection.LookTeleportKey) : 0); EnforceGlobalShortcutUniqueness(); RebuildDrafts(); } internal void ShowPanel() { RefreshPlayerReferences(); RebuildDrafts(); } private void Update() { if (settings != null && (listeningKind == ShortcutTargetKind.None || !TryCaptureShortcutKey()) && settings.ShortcutsEnabled.Value) { HandleShortcuts(); } } internal void DrawPanel(float availableHeight) { GUILayout.Label("Teleport Menu", Array.Empty()); GUILayout.Space(8f); DrawTabs(); GUILayout.Space(8f); switch (activeTab) { case TeleportTab.Locations: DrawLocationsTab(availableHeight); break; case TeleportTab.Players: DrawPlayersTab(availableHeight); break; case TeleportTab.LookTeleport: DrawLookTeleportTab(); break; } GUILayout.Space(8f); GUILayout.Label(statusMessage, Array.Empty()); } private void DrawTabs() { GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); DrawTabButton(TeleportTab.Locations, "Locations"); DrawTabButton(TeleportTab.Players, "Players"); DrawTabButton(TeleportTab.LookTeleport, "Look TP"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void DrawTabButton(TeleportTab tab, string label) { GUI.enabled = activeTab != tab; if (GUILayout.Button(label, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(120f), GUILayout.Height(32f) })) { activeTab = tab; } GUI.enabled = true; } private void DrawLocationsTab(float availableHeight) { DrawSaveCurrentSection(); GUILayout.Space(10f); GUILayout.Label($"Saved locations: {locations.Count}/{GetMaxLocations()}", Array.Empty()); DrawLocationRows(Mathf.Max(180f, availableHeight - 130f)); } private void DrawPlayersTab(float availableHeight) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Players", Array.Empty()); playerScrollPosition = GUILayout.BeginScrollView(playerScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(Mathf.Max(180f, availableHeight - 80f)) }); DrawPlayerRows(); GUILayout.EndScrollView(); } private void DrawLookTeleportTab() { GUILayout.Label("Teleport to the point you are looking at.", Array.Empty()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(GetLookTeleportShortcutLabel(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { BeginListening(ShortcutTargetKind.LookTeleport, "", "Look TP"); } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { SetLookTeleportShortcut((KeyCode)0); } if (GUILayout.Button("TP", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { TeleportToLookPoint(); } GUILayout.EndHorizontal(); } private void DrawSaveCurrentSection() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) FirstPersonController firstPersonController = GetFirstPersonController(); string text = (((Object)(object)firstPersonController != (Object)null) ? FormatPosition(((Component)firstPersonController).transform.position) : "(player not found)"); GUILayout.Label("Current position: " + text, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Name", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) }); newLocationName = GUILayout.TextField(newLocationName, 32, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }); if (GUILayout.Button("Save Current", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(120f), GUILayout.Height(28f) })) { SaveCurrentLocation(); } GUILayout.EndHorizontal(); } private void DrawLocationRows(float scrollHeight) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) locationScrollPosition = GUILayout.BeginScrollView(locationScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(scrollHeight) }); foreach (TeleportLocationData item in locations.ToList()) { if (!drafts.TryGetValue(item.Id, out RowDraft value)) { value = new RowDraft(item.Name); drafts[item.Id] = value; } GUILayout.BeginHorizontal(Array.Empty()); value.Name = GUILayout.TextField(value.Name, 32, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) }); GUILayout.Label(FormatLocation(item), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }); GUILayout.Label(GetShortcutLabel(item.ShortcutKey), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { BeginListening(ShortcutTargetKind.Location, item.Id, item.Name); } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { SetLocationShortcut(item.Id, (KeyCode)0); } if (GUILayout.Button("Save", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { SaveRow(item, value); } if (GUILayout.Button("TP", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { TeleportTo(item); } if (GUILayout.Button("Delete", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(84f), GUILayout.Height(28f) })) { DeleteLocation(item); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } private void DrawPlayerRows() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Invalid comparison between Unknown and I4 IReadOnlyList players = GetPlayers(); if (players.Count == 0) { GUILayout.Label("(no players found)", Array.Empty()); return; } PlayerObjectController localPlayer = GetLocalPlayer(); foreach (PlayerObjectController item in players) { if (!((Object)(object)item == (Object)null)) { string playerId = GetPlayerId(item); string text = GetPlayerDisplayName(item); KeyCode playerShortcutKey = GetPlayerShortcutKey(playerId); bool flag = (Object)(object)item == (Object)(object)localPlayer; if (flag) { text += " (self)"; } GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) }); GUILayout.Label(GetShortcutLabel(playerShortcutKey), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUI.enabled = !flag; if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { BeginListening(ShortcutTargetKind.Player, playerId, text); UpsertPlayerShortcutName(playerId, GetPlayerDisplayName(item)); } GUI.enabled = !flag || (int)playerShortcutKey > 0; if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(64f), GUILayout.Height(28f) })) { SetPlayerShortcut(playerId, GetPlayerDisplayName(item), (KeyCode)0); } GUI.enabled = !flag; if (GUILayout.Button("TP To", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(84f), GUILayout.Height(28f) })) { TeleportSelfToPlayer(item); } if (GUILayout.Button("Bring", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(84f), GUILayout.Height(28f) })) { TeleportPlayerToSelf(item); } GUI.enabled = true; GUILayout.EndHorizontal(); } } } private void SaveCurrentLocation() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) FirstPersonController firstPersonController = GetFirstPersonController(); if ((Object)(object)firstPersonController == (Object)null) { statusMessage = "Player controller was not found. Load into a save first."; ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)statusMessage); } return; } if (locations.Count >= GetMaxLocations()) { statusMessage = $"Cannot save more than {GetMaxLocations()} locations."; return; } string name = (string.IsNullOrWhiteSpace(newLocationName) ? $"Point {locations.Count + 1}" : newLocationName.Trim()); string id = Guid.NewGuid().ToString("N"); Vector3 position = ((Component)firstPersonController).transform.position; Quaternion rotation = ((Component)firstPersonController).transform.rotation; TeleportLocationData teleportLocationData = new TeleportLocationData(id, name, position, ((Quaternion)(ref rotation)).eulerAngles.y, (KeyCode)0); locations.Add(teleportLocationData); drafts[teleportLocationData.Id] = new RowDraft(teleportLocationData.Name); SaveLocations(); newLocationName = ""; statusMessage = "Saved location: " + teleportLocationData.Name; ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)statusMessage); } } private void SaveRow(TeleportLocationData location, RowDraft draft) { string text = draft.Name.Trim(); if (string.IsNullOrWhiteSpace(text)) { statusMessage = "Name cannot be empty. Example: Storage"; return; } int num = locations.FindIndex((TeleportLocationData item) => item.Id == location.Id); if (num < 0) { statusMessage = "Location was not found."; return; } TeleportLocationData teleportLocationData = location.WithName(text); locations[num] = teleportLocationData; drafts[teleportLocationData.Id] = new RowDraft(teleportLocationData.Name); SaveLocations(); statusMessage = "Saved changes: " + teleportLocationData.Name; } private void DeleteLocation(TeleportLocationData location) { locations.RemoveAll((TeleportLocationData item) => item.Id == location.Id); drafts.Remove(location.Id); SaveLocations(); statusMessage = "Deleted location: " + location.Name; } private void TeleportTo(TeleportLocationData location) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) FirstPersonController firstPersonController = GetFirstPersonController(); if ((Object)(object)firstPersonController == (Object)null) { statusMessage = "Player controller was not found. Load into a save first."; ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)statusMessage); } return; } MoveTransform(((Component)firstPersonController).transform, location.Position, Quaternion.Euler(0f, location.Yaw, 0f)); statusMessage = "Teleported to: " + location.Name; ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)statusMessage); } } private void TeleportSelfToPlayer(PlayerObjectController targetPlayer) { //IL_0022: 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_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_0041: 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_004f: Unknown result type (might be due to invalid IL or missing references) FirstPersonController firstPersonController = GetFirstPersonController(); if ((Object)(object)firstPersonController == (Object)null) { statusMessage = "Player controller was not found."; return; } Vector3 destination = ((Component)targetPlayer).transform.position - ((Component)targetPlayer).transform.forward * 1.5f; MoveTransform(((Component)firstPersonController).transform, destination, ((Component)firstPersonController).transform.rotation); statusMessage = "Teleported to " + GetPlayerDisplayName(targetPlayer) + "."; ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)statusMessage); } } private void TeleportPlayerToSelf(PlayerObjectController targetPlayer) { //IL_0022: 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_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_0041: 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_004f: Unknown result type (might be due to invalid IL or missing references) PlayerObjectController localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { statusMessage = "Local player was not found."; return; } Vector3 destination = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 1.5f; MoveTransform(((Component)targetPlayer).transform, destination, ((Component)targetPlayer).transform.rotation); statusMessage = "Teleported " + GetPlayerDisplayName(targetPlayer) + " to you."; ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)statusMessage); } } private void TeleportToLookPoint() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_007a: 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_0084: 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_0094: Unknown result type (might be due to invalid IL or missing references) FirstPersonController firstPersonController = GetFirstPersonController(); if ((Object)(object)firstPersonController == (Object)null) { statusMessage = "Player controller was not found. Load into a save first."; return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { statusMessage = "Main camera was not found."; return; } Transform transform = ((Component)main).transform; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(transform.position, transform.forward, ref val, 1000f, -5, (QueryTriggerInteraction)1)) { statusMessage = "No surface found in view."; return; } Vector3 destination = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.15f; MoveTransform(((Component)firstPersonController).transform, destination, ((Component)firstPersonController).transform.rotation); statusMessage = "Teleported to look point."; ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)statusMessage); } } private void HandleShortcuts() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) foreach (TeleportLocationData location in locations) { if ((int)location.ShortcutKey != 0 && Input.GetKeyDown(location.ShortcutKey)) { TeleportTo(location); return; } } foreach (PlayerShortcutData playerShortcut in playerShortcuts) { if ((int)playerShortcut.ShortcutKey != 0 && Input.GetKeyDown(playerShortcut.ShortcutKey)) { PlayerObjectController val = FindPlayerById(playerShortcut.PlayerId); if ((Object)(object)val == (Object)null) { statusMessage = "Player is not online: " + playerShortcut.PlayerName; } else if ((Object)(object)val == (Object)(object)GetLocalPlayer()) { statusMessage = "Shortcut points to yourself: " + playerShortcut.PlayerName; } else { TeleportSelfToPlayer(val); } return; } } if ((int)lookTeleportKey != 0 && Input.GetKeyDown(lookTeleportKey)) { TeleportToLookPoint(); } } private bool TryCaptureShortcutKey() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0079: Unknown result type (might be due to invalid IL or missing references) if (settings != null && Input.GetKeyDown(settings.ToggleMenuKey.Value)) { statusMessage = $"{settings.ToggleMenuKey.Value} is reserved for the menu."; return true; } if (Input.GetKeyDown((KeyCode)27)) { ClearListening(); statusMessage = "Shortcut setup cancelled."; return true; } KeyCode[] shortcutKeyCandidates = ShortcutKeyCandidates; foreach (KeyCode val in shortcutKeyCandidates) { if (Input.GetKeyDown(val)) { ApplyCapturedShortcut(val); ClearListening(); return true; } } return false; } private void ApplyCapturedShortcut(KeyCode shortcutKey) { //IL_0023: 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_003f: Unknown result type (might be due to invalid IL or missing references) switch (listeningKind) { case ShortcutTargetKind.Location: SetLocationShortcut(listeningTargetId, shortcutKey); break; case ShortcutTargetKind.Player: SetPlayerShortcut(listeningTargetId, listeningTargetName, shortcutKey); break; case ShortcutTargetKind.LookTeleport: SetLookTeleportShortcut(shortcutKey); break; } } private void SetLocationShortcut(string locationId, KeyCode shortcutKey) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) int num = locations.FindIndex((TeleportLocationData location) => location.Id == locationId); if (num < 0) { statusMessage = "Location was not found."; return; } if ((int)shortcutKey != 0) { ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.Location, locationId); } TeleportLocationData teleportLocationData = locations[num]; locations[num] = teleportLocationData.WithShortcutKey(shortcutKey); SaveLocations(); SaveShortcuts(); statusMessage = (((int)shortcutKey == 0) ? ("Cleared shortcut: " + teleportLocationData.Name) : $"Set shortcut {shortcutKey}: {teleportLocationData.Name}"); } private void SetPlayerShortcut(string playerId, string playerName, KeyCode shortcutKey) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00bd: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(playerId)) { statusMessage = "Player was not found."; return; } if ((int)shortcutKey != 0) { ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.Player, playerId); } int num = playerShortcuts.FindIndex((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId); if ((int)shortcutKey == 0) { if (num >= 0) { playerShortcuts.RemoveAt(num); } SaveShortcuts(); statusMessage = "Cleared shortcut: " + playerName; } else { if (num >= 0) { playerShortcuts[num] = new PlayerShortcutData(playerId, playerName, shortcutKey); } else { playerShortcuts.Add(new PlayerShortcutData(playerId, playerName, shortcutKey)); } SaveShortcuts(); statusMessage = $"Set shortcut {shortcutKey}: {playerName}"; } } private void SetLookTeleportShortcut(KeyCode shortcutKey) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0004: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((int)shortcutKey != 0) { ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.LookTeleport, ""); } lookTeleportKey = shortcutKey; SaveLocations(); SaveShortcuts(); statusMessage = (((int)shortcutKey == 0) ? "Cleared shortcut: Look TP" : $"Set shortcut {shortcutKey}: Look TP"); } private void ClearShortcutKeyFromOtherActions(KeyCode shortcutKey, ShortcutTargetKind exceptKind, string exceptId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < locations.Count; i++) { TeleportLocationData teleportLocationData = locations[i]; if ((exceptKind != ShortcutTargetKind.Location || !(teleportLocationData.Id == exceptId)) && teleportLocationData.ShortcutKey == shortcutKey) { locations[i] = teleportLocationData.WithShortcutKey((KeyCode)0); } } for (int j = 0; j < playerShortcuts.Count; j++) { PlayerShortcutData playerShortcutData = playerShortcuts[j]; if ((exceptKind != ShortcutTargetKind.Player || !(playerShortcutData.PlayerId == exceptId)) && playerShortcutData.ShortcutKey == shortcutKey) { playerShortcuts[j] = new PlayerShortcutData(playerShortcutData.PlayerId, playerShortcutData.PlayerName, (KeyCode)0); } } playerShortcuts.RemoveAll((PlayerShortcutData shortcut) => (int)shortcut.ShortcutKey == 0); if (exceptKind != ShortcutTargetKind.LookTeleport && lookTeleportKey == shortcutKey) { lookTeleportKey = (KeyCode)0; } } private void EnforceGlobalShortcutUniqueness() { //IL_001a: 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_006c: 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_00e6: 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_00fd: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); bool flag = false; for (int i = 0; i < locations.Count; i++) { TeleportLocationData teleportLocationData = locations[i]; if ((int)teleportLocationData.ShortcutKey != 0 && !hashSet.Add(teleportLocationData.ShortcutKey)) { locations[i] = teleportLocationData.WithShortcutKey((KeyCode)0); flag = true; } } for (int j = 0; j < playerShortcuts.Count; j++) { PlayerShortcutData playerShortcutData = playerShortcuts[j]; if ((int)playerShortcutData.ShortcutKey != 0 && !hashSet.Add(playerShortcutData.ShortcutKey)) { playerShortcuts[j] = new PlayerShortcutData(playerShortcutData.PlayerId, playerShortcutData.PlayerName, (KeyCode)0); flag = true; } } playerShortcuts.RemoveAll((PlayerShortcutData shortcut) => (int)shortcut.ShortcutKey == 0); if ((int)lookTeleportKey != 0 && !hashSet.Add(lookTeleportKey)) { lookTeleportKey = (KeyCode)0; flag = true; } if (flag) { SaveLocations(); SaveShortcuts(); } } private void BeginListening(ShortcutTargetKind kind, string targetId, string targetName) { listeningKind = kind; listeningTargetId = targetId; listeningTargetName = targetName; statusMessage = "Press a key for: " + targetName + ". Esc cancels."; } private void ClearListening() { listeningKind = ShortcutTargetKind.None; listeningTargetId = ""; listeningTargetName = ""; } private void UpsertPlayerShortcutName(string playerId, string playerName) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) int num = playerShortcuts.FindIndex((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId); if (num >= 0) { PlayerShortcutData playerShortcutData = playerShortcuts[num]; playerShortcuts[num] = new PlayerShortcutData(playerId, playerName, playerShortcutData.ShortcutKey); SaveShortcuts(); } } private void SaveLocations() { locationStorage?.Save(locations); } private void SaveShortcuts() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) shortcutStorage?.Save(playerShortcuts, lookTeleportKey); } private void RebuildDrafts() { drafts.Clear(); foreach (TeleportLocationData location in locations) { drafts[location.Id] = new RowDraft(location.Name); } } private static IEnumerable NormalizeLoadedLocations(IEnumerable loadedLocations) { HashSet usedIds = new HashSet(StringComparer.OrdinalIgnoreCase); HashSet usedShortcutKeys = new HashSet(); int index = 1; foreach (TeleportLocationData loadedLocation in loadedLocations) { string text = ((string.IsNullOrWhiteSpace(loadedLocation.Id) || usedIds.Contains(loadedLocation.Id)) ? Guid.NewGuid().ToString("N") : loadedLocation.Id); usedIds.Add(text); string name = (string.IsNullOrWhiteSpace(loadedLocation.Name) ? $"Point {index}" : loadedLocation.Name.Trim()); KeyCode shortcutKey = (KeyCode)((IsAllowedShortcutKey(loadedLocation.ShortcutKey) && usedShortcutKeys.Add(loadedLocation.ShortcutKey)) ? ((int)loadedLocation.ShortcutKey) : 0); yield return new TeleportLocationData(text, name, loadedLocation.Position, loadedLocation.Yaw, shortcutKey); index++; } } private static IEnumerable NormalizeLoadedPlayerShortcuts(IEnumerable loadedShortcuts) { HashSet usedPlayerIds = new HashSet(StringComparer.OrdinalIgnoreCase); HashSet usedShortcutKeys = new HashSet(); foreach (PlayerShortcutData loadedShortcut in loadedShortcuts) { if (!string.IsNullOrWhiteSpace(loadedShortcut.PlayerId) && usedPlayerIds.Add(loadedShortcut.PlayerId) && IsAllowedShortcutKey(loadedShortcut.ShortcutKey) && usedShortcutKeys.Add(loadedShortcut.ShortcutKey)) { string playerName = (string.IsNullOrWhiteSpace(loadedShortcut.PlayerName) ? loadedShortcut.PlayerId : loadedShortcut.PlayerName.Trim()); yield return new PlayerShortcutData(loadedShortcut.PlayerId, playerName, loadedShortcut.ShortcutKey); } } } private void RefreshPlayerReferences() { if (!((Object)(object)GetFirstPersonController() == (Object)null)) { cachedLocalPlayer = null; } } private FirstPersonController? GetFirstPersonController() { if ((Object)(object)cachedFirstPersonController != (Object)null) { return cachedFirstPersonController; } cachedFirstPersonController = FirstPersonController.Instance; return cachedFirstPersonController; } private PlayerObjectController? GetLocalPlayer() { if ((Object)(object)cachedLocalPlayer != (Object)null) { return cachedLocalPlayer; } GameObject val = GameObject.Find("LocalGamePlayer"); if ((Object)(object)val == (Object)null) { return null; } cachedLocalPlayer = val.GetComponent(); return cachedLocalPlayer; } private static IReadOnlyList GetPlayers() { NetworkManager singleton = NetworkManager.singleton; CustomNetworkManager val = (CustomNetworkManager)(object)((singleton is CustomNetworkManager) ? singleton : null); if (val == null || val.GamePlayers == null) { return Array.Empty(); } return val.GamePlayers; } private PlayerObjectController? FindPlayerById(string playerId) { return ((IEnumerable)GetPlayers()).FirstOrDefault((Func)((PlayerObjectController player) => (Object)(object)player != (Object)null && GetPlayerId(player) == playerId)); } private KeyCode GetPlayerShortcutKey(string playerId) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) return (KeyCode)(((??)playerShortcuts.FirstOrDefault((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId)?.ShortcutKey) ?? 0); } private int GetMaxLocations() { return Mathf.Clamp(settings?.MaxLocations.Value ?? 20, 1, 20); } private static void MoveTransform(Transform target, Vector3 destination, Quaternion rotation) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) CharacterController component = ((Component)target).GetComponent(); bool enabled = (Object)(object)component == (Object)null || ((Collider)component).enabled; if ((Object)(object)component != (Object)null) { ((Collider)component).enabled = false; } target.SetPositionAndRotation(destination, rotation); if ((Object)(object)component != (Object)null) { ((Collider)component).enabled = enabled; } } private static string GetPlayerId(PlayerObjectController player) { if (player.PlayerSteamID == 0) { return $"connection:{player.ConnectionID}"; } return $"steam:{player.PlayerSteamID}"; } private static string GetPlayerDisplayName(PlayerObjectController player) { if (!string.IsNullOrWhiteSpace(player.PlayerName)) { return player.PlayerName; } return $"Player {player.ConnectionID}"; } private static string FormatLocation(TeleportLocationData location) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return FormatPosition(location.Position); } private static string GetShortcutLabel(KeyCode shortcutKey) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if ((int)shortcutKey != 0) { return $"Key: {shortcutKey}"; } return "Key: None"; } private string GetLookTeleportShortcutLabel() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetShortcutLabel(lookTeleportKey); } private static string FormatPosition(Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"X:{position.x:0.##} Y:{position.y:0.##} Z:{position.z:0.##}"; } private static bool IsAllowedShortcutKey(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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 ((int)keyCode != 0 && (int)keyCode != 27 && !IsMouseButton(keyCode) && !IsJoystickButton(keyCode)) { return !IsModifierKey(keyCode); } return false; } private static bool IsMouseButton(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)keyCode >= 323) { return (int)keyCode <= 329; } return false; } private static bool IsJoystickButton(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 if ((int)keyCode >= 330) { return (int)keyCode <= 509; } return false; } private static bool IsModifierKey(KeyCode keyCode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if (keyCode - 303 <= 7) { return true; } return false; } } internal sealed class TeleportMenuSettings { public ConfigEntry ShortcutsEnabled { get; } public ConfigEntry ToggleMenuKey { get; } public ConfigEntry MaxLocations { get; } public TeleportMenuSettings(ConfigEntry shortcutsEnabled, ConfigEntry toggleMenuKey, ConfigEntry maxLocations) { ShortcutsEnabled = shortcutsEnabled; ToggleMenuKey = toggleMenuKey; MaxLocations = maxLocations; } } [Serializable] internal sealed class PlayerShortcutData { public string PlayerId = ""; public string PlayerName = ""; public KeyCode ShortcutKey; public PlayerShortcutData() { } public PlayerShortcutData(string playerId, string playerName, KeyCode shortcutKey) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) PlayerId = playerId; PlayerName = playerName; ShortcutKey = shortcutKey; } } [Serializable] internal sealed class TeleportShortcutCollection { public List PlayerShortcuts = new List(); public KeyCode LookTeleportKey; } internal sealed class TeleportShortcutStorage { private readonly string filePath; private readonly ManualLogSource logger; public TeleportShortcutStorage(string configPath, ManualLogSource pluginLogger) { filePath = Path.Combine(configPath, "uta_a.supermarkettogether.teleportmenu.shortcuts.json"); logger = pluginLogger; } public TeleportShortcutCollection Load() { if (!File.Exists(filePath)) { return new TeleportShortcutCollection(); } try { string text = File.ReadAllText(filePath); if (string.IsNullOrWhiteSpace(text)) { return new TeleportShortcutCollection(); } return JsonUtility.FromJson(text) ?? new TeleportShortcutCollection(); } catch (Exception ex) { logger.LogError((object)("Failed to load teleport shortcuts: " + ex.Message)); return new TeleportShortcutCollection(); } } public void Save(IReadOnlyList playerShortcuts, KeyCode lookTeleportKey) { //IL_002c: 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) try { Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? "."); string contents = JsonUtility.ToJson((object)new TeleportShortcutCollection { PlayerShortcuts = new List(playerShortcuts), LookTeleportKey = lookTeleportKey }, true); File.WriteAllText(filePath, contents); } catch (Exception ex) { logger.LogError((object)("Failed to save teleport shortcuts: " + ex.Message)); } } } } namespace SupermarketTogetherMovementSpeedMenu { internal sealed class MovementSpeedMenu : MonoBehaviour { private const string WindowTitle = "Movement Speed"; private const float MinSpeed = 0.1f; private const float MaxSpeed = 100f; private const float ButtonMinWidth = 96f; private ManualLogSource? logger; private MovementSpeedSettings? settings; private FirstPersonController? cachedFirstPersonController; private string moveSpeedInput = "5"; private string sprintSpeedInput = "10"; private string statusMessage = "Waiting for player controller..."; public void Initialize(ManualLogSource pluginLogger, MovementSpeedSettings speedSettings) { logger = pluginLogger; settings = speedSettings; moveSpeedInput = speedSettings.DefaultMoveSpeed.Value.ToString("0.###"); sprintSpeedInput = speedSettings.DefaultSprintSpeed.Value.ToString("0.###"); } internal void ShowPanel() { SyncInputsWithCurrentSpeeds(); } internal void DrawPanel() { GUILayout.Label("Movement Speed", Array.Empty()); FirstPersonController firstPersonController = GetFirstPersonController(); string text = (((Object)(object)firstPersonController != (Object)null) ? firstPersonController.MoveSpeed.ToString("0.###") : "(player controller not found)"); string text2 = (((Object)(object)firstPersonController != (Object)null) ? firstPersonController.SprintSpeed.ToString("0.###") : "(player controller not found)"); GUILayout.Label("Current move speed: " + text, Array.Empty()); GUILayout.Label("New move speed", Array.Empty()); moveSpeedInput = GUILayout.TextField(moveSpeedInput, 16, Array.Empty()); GUILayout.Space(8f); GUILayout.Label("Current sprint speed: " + text2, Array.Empty()); GUILayout.Label("New sprint speed", Array.Empty()); sprintSpeedInput = GUILayout.TextField(sprintSpeedInput, 16, Array.Empty()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Apply", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(96f), GUILayout.Height(28f) })) { ApplySpeeds(); } if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(96f), GUILayout.Height(28f) })) { cachedFirstPersonController = null; SyncInputsWithCurrentSpeeds(); } GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.Label(statusMessage, Array.Empty()); } private void ApplySpeeds() { FirstPersonController firstPersonController = GetFirstPersonController(); float speed; float speed2; if ((Object)(object)firstPersonController == (Object)null) { statusMessage = "Player controller was not found. Load into the game first."; ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)statusMessage); } } else if (TryParseSpeed(moveSpeedInput, "Move speed", out speed) && TryParseSpeed(sprintSpeedInput, "Sprint speed", out speed2)) { firstPersonController.MoveSpeed = speed; firstPersonController.SprintSpeed = speed2; moveSpeedInput = speed.ToString("0.###"); sprintSpeedInput = speed2.ToString("0.###"); statusMessage = "Applied move: " + moveSpeedInput + ", sprint: " + sprintSpeedInput; ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)statusMessage); } } } private bool TryParseSpeed(string input, string label, out float speed) { if (!float.TryParse(input, out speed)) { statusMessage = label + " must be a number. Example: 12"; return false; } speed = Mathf.Clamp(speed, 0.1f, 100f); return true; } private void SyncInputsWithCurrentSpeeds() { FirstPersonController firstPersonController = GetFirstPersonController(); if ((Object)(object)firstPersonController == (Object)null) { moveSpeedInput = settings?.DefaultMoveSpeed.Value.ToString("0.###") ?? "5"; sprintSpeedInput = settings?.DefaultSprintSpeed.Value.ToString("0.###") ?? "10"; statusMessage = "Waiting for player controller..."; } else { moveSpeedInput = firstPersonController.MoveSpeed.ToString("0.###"); sprintSpeedInput = firstPersonController.SprintSpeed.ToString("0.###"); statusMessage = "Ready."; } } private FirstPersonController? GetFirstPersonController() { if ((Object)(object)cachedFirstPersonController != (Object)null) { return cachedFirstPersonController; } cachedFirstPersonController = FirstPersonController.Instance; return cachedFirstPersonController; } } internal sealed class MovementSpeedSettings { public ConfigEntry ToggleKey { get; } public ConfigEntry DefaultMoveSpeed { get; } public ConfigEntry DefaultSprintSpeed { get; } public MovementSpeedSettings(ConfigEntry toggleKey, ConfigEntry defaultMoveSpeed, ConfigEntry defaultSprintSpeed) { ToggleKey = toggleKey; DefaultMoveSpeed = defaultMoveSpeed; DefaultSprintSpeed = defaultSprintSpeed; } } } namespace SupermarketTogetherFlyMod { internal sealed class FlyModeController : MonoBehaviour { private ManualLogSource? logger; private FlyModeSettings? settings; private FirstPersonController? firstPersonController; private CharacterController? characterController; private bool flyModeEnabled; private bool originalFirstPersonEnabled; private bool originalCharacterControllerEnabled; internal bool IsFlyModeEnabled => flyModeEnabled; public void Initialize(ManualLogSource pluginLogger, FlyModeSettings flySettings) { logger = pluginLogger; settings = flySettings; } internal void ToggleFlyModeFromMenu() { RefreshPlayerReferences(); ToggleFlyMode(); } private void Update() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (settings == null) { return; } if (!settings.Enabled.Value) { if (flyModeEnabled) { ToggleFlyMode(); } return; } RefreshPlayerReferences(); if (Input.GetKeyDown(settings.ToggleKey.Value)) { ToggleFlyMode(); } if (flyModeEnabled && !((Object)(object)firstPersonController == (Object)null)) { MovePlayer(); } } private void RefreshPlayerReferences() { if ((Object)(object)firstPersonController != (Object)null) { return; } firstPersonController = FirstPersonController.Instance; if (!((Object)(object)firstPersonController == (Object)null)) { characterController = ((Component)firstPersonController).GetComponent(); originalFirstPersonEnabled = ((Behaviour)firstPersonController).enabled; originalCharacterControllerEnabled = (Object)(object)characterController == (Object)null || ((Collider)characterController).enabled; ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)"Found local FirstPersonController."); } } } private void ToggleFlyMode() { FlyModeSettings? flyModeSettings = settings; if (flyModeSettings == null || !flyModeSettings.Enabled.Value) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)"Fly mode is disabled in MODMENU."); } return; } if ((Object)(object)firstPersonController == (Object)null) { ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogWarning((object)"Cannot toggle fly mode because the local player is not available yet."); } return; } flyModeEnabled = !flyModeEnabled; if (flyModeEnabled) { originalFirstPersonEnabled = ((Behaviour)firstPersonController).enabled; originalCharacterControllerEnabled = (Object)(object)characterController == (Object)null || ((Collider)characterController).enabled; ((Behaviour)firstPersonController).enabled = false; if ((Object)(object)characterController != (Object)null) { ((Collider)characterController).enabled = false; } } else { ((Behaviour)firstPersonController).enabled = originalFirstPersonEnabled; if ((Object)(object)characterController != (Object)null) { ((Collider)characterController).enabled = originalCharacterControllerEnabled; } } ManualLogSource? obj3 = logger; if (obj3 != null) { obj3.LogInfo((object)("Fly mode " + (flyModeEnabled ? "enabled" : "disabled") + ".")); } } private void MovePlayer() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008e: 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_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_009f: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0117: 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_0126: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (settings != null && !((Object)(object)firstPersonController == (Object)null)) { Transform obj = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : ((Component)firstPersonController).transform); Vector3 val = Vector3.ProjectOnPlane(obj.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.ProjectOnPlane(obj.right, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.zero; if (Input.GetKey((KeyCode)119)) { val2 += normalized; } if (Input.GetKey((KeyCode)115)) { val2 -= normalized; } if (Input.GetKey((KeyCode)100)) { val2 += normalized2; } if (Input.GetKey((KeyCode)97)) { val2 -= normalized2; } if (Input.GetKey((KeyCode)32)) { val2 += Vector3.up; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { val2 -= Vector3.up; } if (!(((Vector3)(ref val2)).sqrMagnitude <= 0f)) { Vector3 val3 = ((Vector3)(ref val2)).normalized * settings.FlySpeed.Value * Time.deltaTime; Transform transform = ((Component)firstPersonController).transform; transform.position += val3; } } } private void OnDestroy() { if (flyModeEnabled && (Object)(object)firstPersonController != (Object)null) { ((Behaviour)firstPersonController).enabled = originalFirstPersonEnabled; if ((Object)(object)characterController != (Object)null) { ((Collider)characterController).enabled = originalCharacterControllerEnabled; } } } } internal sealed class FlyModeSettings { public ConfigEntry Enabled { get; } public ConfigEntry ToggleKey { get; } public ConfigEntry FlySpeed { get; } public FlyModeSettings(ConfigEntry enabled, ConfigEntry toggleKey, ConfigEntry flySpeed) { Enabled = enabled; ToggleKey = toggleKey; FlySpeed = flySpeed; } } } namespace SupermarketTogetherMODMENU { internal sealed class GameplayToolsModule : MonoBehaviour { private const int BroomItemId = 7; private ManualLogSource? logger; private ConfigFile? config; private GameplayToolsSettings? settings; private Player? rewiredPlayer; private float nextAllowedHitTime; private AudioSource? localAudioSource; private AudioSource? broomPrefabAudioSource; internal static GameplayToolsModule? Instance { get; private set; } internal bool SuppressNeedBroomNotification => settings?.SuppressNeedBroomNotification.Value ?? false; public void Initialize(ManualLogSource pluginLogger, ConfigFile configFile, GameplayToolsSettings gameplaySettings) { Instance = this; logger = pluginLogger; config = configFile; settings = gameplaySettings; } private void Update() { if (settings != null && settings.Enabled.Value && ShouldProcessInput() && !(Time.time < nextAllowedHitTime) && WasHitInputPressed()) { nextAllowedHitTime = Time.time + Mathf.Max(0.01f, settings.CooldownSeconds.Value); TrySlapForward(); } } internal void SaveConfig() { ConfigFile? obj = config; if (obj != null) { obj.Save(); } } internal void ReloadConfig() { ConfigFile? obj = config; if (obj != null) { obj.Reload(); } } private bool ShouldProcessInput() { if (settings == null || (Object)(object)FirstPersonController.Instance == (Object)null || (Object)(object)Camera.main == (Object)null) { return false; } if (!FirstPersonController.Instance.allowPlayerInput) { return false; } PlayerNetwork component = ((Component)FirstPersonController.Instance).GetComponent(); if ((Object)(object)component == (Object)null || component.equippedItem == 7) { return false; } if (settings.RequireEmptyHands.Value) { return component.equippedItem == 0; } return true; } private bool WasHitInputPressed() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (settings == null) { return false; } KeyboardShortcut value = settings.ModifierShortcut.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0 && !((KeyboardShortcut)(ref value)).IsPressed()) { return false; } if (settings.UseRewiredMainAction.Value) { try { if (rewiredPlayer == null) { rewiredPlayer = ReInput.players.GetPlayer(0); } if (rewiredPlayer != null && rewiredPlayer.GetButtonDown("Main Action")) { return true; } } catch { ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogDebug((object)"Rewired is not ready. Falling back to Unity Input."); } } } return Input.GetKeyDown(settings.FallbackKey.Value); } private void TrySlapForward() { //IL_0022: 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_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) if (settings == null || (Object)(object)Camera.main == (Object)null) { return; } Transform transform = ((Component)Camera.main).transform; RaycastHit[] array = Physics.SphereCastAll(transform.position, Mathf.Clamp(settings.HitRadius.Value, 0.01f, 1.5f), transform.forward, Mathf.Max(0.1f, settings.Reach.Value), -1, (QueryTriggerInteraction)2); if (array == null || array.Length == 0) { return; } Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; if (TryHitNpc(((RaycastHit)(ref val)).transform) || TryHitPlayer(((RaycastHit)(ref val)).transform)) { PlayLocalHitFeedback(); break; } } } private void PlayLocalHitFeedback() { if (settings == null) { return; } PlayerNetwork val = (((Object)(object)FirstPersonController.Instance != (Object)null) ? ((Component)FirstPersonController.Instance).GetComponent() : null); if (val != null) { val.CmdPlayAnimation(1); } if (!settings.PlayBroomSound.Value) { return; } AudioSource val2 = GetBroomPrefabAudioSource(val); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.clip != (Object)null) { AudioSource obj = GetLocalAudioSource(); obj.clip = val2.clip; obj.volume = val2.volume; obj.pitch = val2.pitch; obj.spatialBlend = 0f; obj.Play(); } else { GameData instance = GameData.Instance; if (instance != null) { instance.PlayBroomSound(); } } } private AudioSource? GetBroomPrefabAudioSource(PlayerNetwork? playerNetwork) { if ((Object)(object)broomPrefabAudioSource != (Object)null) { return broomPrefabAudioSource; } if ((Object)(object)playerNetwork == (Object)null || playerNetwork.equippedPrefabs == null || playerNetwork.equippedPrefabs.Length <= 7 || (Object)(object)playerNetwork.equippedPrefabs[7] == (Object)null) { return null; } broomPrefabAudioSource = playerNetwork.equippedPrefabs[7].GetComponent(); return broomPrefabAudioSource; } private AudioSource GetLocalAudioSource() { if ((Object)(object)localAudioSource != (Object)null) { return localAudioSource; } localAudioSource = ((Component)this).gameObject.AddComponent(); localAudioSource.playOnAwake = false; return localAudioSource; } private static bool TryHitNpc(Transform hitTransform) { if ((Object)(object)hitTransform == (Object)null || ((Object)hitTransform).name != "HitTrigger" || !((Component)hitTransform).CompareTag("Interactable") || (Object)(object)hitTransform.parent == (Object)null) { return false; } NPC_Info component = ((Component)hitTransform.parent).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } component.CmdAnimationPlay(0); return true; } private static bool TryHitPlayer(Transform hitTransform) { //IL_00c5: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hitTransform == (Object)null || (Object)(object)FirstPersonController.Instance == (Object)null) { return false; } PlayerNetwork val = null; if (((Component)hitTransform).CompareTag("Player")) { val = ((Component)hitTransform).GetComponent(); } else if (((Object)hitTransform).name == "HitTrigger" && (Object)(object)hitTransform.parent != (Object)null && (Object)(object)hitTransform.parent.parent != (Object)null) { val = ((Component)hitTransform.parent.parent).GetComponent(); } if ((Object)(object)val == (Object)null) { return false; } GameObject gameObject = ((Component)FirstPersonController.Instance).gameObject; if ((Object)(object)((Component)val).gameObject == (Object)(object)gameObject || (Object)(object)((Component)val).transform == (Object)(object)gameObject.transform || (Object)(object)((Component)val).GetComponent() == (Object)(object)FirstPersonController.Instance) { return false; } Vector3 val2 = ((Component)val).transform.position - ((Component)FirstPersonController.Instance).transform.position; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = ((Component)FirstPersonController.Instance).transform.forward; } val.PushPlayer(((Vector3)(ref val2)).normalized); return true; } } [HarmonyPatch(typeof(GameCanvas), "CreateCanvasNotification")] internal static class GameCanvasCreateCanvasNotificationPatch { private static bool Prefix(string hash) { if (!((Object)(object)GameplayToolsModule.Instance == (Object)null) && GameplayToolsModule.Instance.SuppressNeedBroomNotification) { return hash != "message14"; } return true; } } internal sealed class GameplayToolsSettings { public ConfigEntry Enabled { get; } public ConfigEntry Reach { get; } public ConfigEntry HitRadius { get; } public ConfigEntry CooldownSeconds { get; } public ConfigEntry RequireEmptyHands { get; } public ConfigEntry PlayBroomSound { get; } public ConfigEntry SuppressNeedBroomNotification { get; } public ConfigEntry UseRewiredMainAction { get; } public ConfigEntry FallbackKey { get; } public ConfigEntry ModifierShortcut { get; } public GameplayToolsSettings(ConfigEntry enabled, ConfigEntry reach, ConfigEntry hitRadius, ConfigEntry cooldownSeconds, ConfigEntry requireEmptyHands, ConfigEntry playBroomSound, ConfigEntry suppressNeedBroomNotification, ConfigEntry useRewiredMainAction, ConfigEntry fallbackKey, ConfigEntry modifierShortcut) { Enabled = enabled; Reach = reach; HitRadius = hitRadius; CooldownSeconds = cooldownSeconds; RequireEmptyHands = requireEmptyHands; PlayBroomSound = playBroomSound; SuppressNeedBroomNotification = suppressNeedBroomNotification; UseRewiredMainAction = useRewiredMainAction; FallbackKey = fallbackKey; ModifierShortcut = modifierShortcut; } } internal sealed class ModMenuPanel : MonoBehaviour { private const float HeaderDragHeight = 30f; private const float TargetWindowWidth = 1080f; private const float TargetWindowHeight = 760f; private const float MinimumWindowWidth = 820f; private const float MinimumWindowHeight = 580f; private const float ScreenMargin = 36f; private const float SidebarWidth = 170f; private const float ButtonHeight = 30f; private const float MinFlySpeed = 0.1f; private const float MaxFlySpeed = 100f; private static readonly string[] Categories = new string[3] { "Gameplay", "Movement", "Object" }; private static readonly string[] GameplayTabs = new string[2] { "NoBroomSlap", "Player Anim" }; private static readonly string[] MovementTabs = new string[3] { "Fly", "Speed", "Teleport" }; private static readonly string[] ObjectTabs = new string[3] { "Builder", "Spawner", "Manipulator" }; private ManualLogSource? logger; private ConfigFile? config; private ModMenuSettings? menuSettings; private GameplayToolsModule? gameplayModule; private PlayerAnimationModule? playerAnimationModule; private GameplayToolsSettings? gameplaySettings; private FlyModeController? flyController; private FlyModeSettings? flySettings; private MovementSpeedSettings? speedSettings; private TeleportMenuSettings? teleportSettings; private AnyPlaceBuilderSettings? builderSettings; private ObjectSpawnerSettings? spawnerSettings; private ObjectManipulatorSettings? manipulatorSettings; private MovementSpeedMenu? speedMenu; private TeleportMenu? teleportMenu; private ObjectSpawnerMenu? spawnerMenu; private ObjectManipulatorMenu? manipulatorMenu; private Rect windowRect = new Rect(40f, 60f, 1080f, 760f); private bool visible; private int selectedCategory; private readonly int[] selectedSubTabs = new int[Categories.Length]; private readonly Vector2[] subTabScrollPositions = (Vector2[])(object)new Vector2[Categories.Length]; private readonly Vector2[][] contentScrollPositions = new Vector2[3][] { (Vector2[])(object)new Vector2[GameplayTabs.Length], (Vector2[])(object)new Vector2[MovementTabs.Length], (Vector2[])(object)new Vector2[ObjectTabs.Length] }; private string reachInput = "3"; private string hitRadiusInput = "0.35"; private string cooldownInput = "0.35"; private string flySpeedInput = "10"; private bool pendingBuilderKeyBinding; private string statusMessage = "MODMENU ready."; private Font? japaneseFont; private GUIStyle? sidebarButtonStyle; private GUIStyle? sidebarSelectedStyle; private GUIStyle? subTabStyle; private GUIStyle? subTabSelectedStyle; private GUIStyle? panelStyle; private GUIStyle? titleStyle; private GUIStyle? enabledStatusStyle; private GUIStyle? disabledStatusStyle; public void Initialize(ManualLogSource pluginLogger, ConfigFile configFile, ModMenuSettings settings, GameplayToolsModule gameplay, PlayerAnimationModule playerAnimation, GameplayToolsSettings gameplayConfig, FlyModeController fly, FlyModeSettings flyConfig, MovementSpeedSettings speedConfig, TeleportMenuSettings teleportConfig, AnyPlaceBuilderSettings builderConfig, ObjectSpawnerSettings spawnerConfig, ObjectManipulatorSettings manipulatorConfig, MovementSpeedMenu movementSpeed, TeleportMenu teleport, ObjectSpawnerMenu objectSpawner, ObjectManipulatorMenu objectManipulator) { logger = pluginLogger; config = configFile; menuSettings = settings; gameplayModule = gameplay; playerAnimationModule = playerAnimation; gameplaySettings = gameplayConfig; flyController = fly; flySettings = flyConfig; speedSettings = speedConfig; teleportSettings = teleportConfig; builderSettings = builderConfig; spawnerSettings = spawnerConfig; manipulatorSettings = manipulatorConfig; speedMenu = movementSpeed; teleportMenu = teleport; spawnerMenu = objectSpawner; manipulatorMenu = objectManipulator; SyncGameplayInputs(); SyncFlySpeedInput(); } private void Update() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (menuSettings != null && Input.GetKeyDown(menuSettings.ToggleMenuKey.Value)) { visible = !visible; if (visible) { PrepareCurrentView(); } else { ClearPendingInput(); } } } private void OnGUI() { //IL_0023: 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_003e: Expected O, but got Unknown //IL_0039: 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) if (visible) { ApplyJapaneseFont(); EnsureStyles(); ResizeWindowToScreen(); windowRect = GUI.Window(((Object)this).GetInstanceID(), windowRect, new WindowFunction(DrawWindow), "MODMENU"); ((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref windowRect)).width)); ((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - 30f)); } } private void DrawWindow(int windowId) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty()); DrawSidebar(); GUILayout.Space(10f); DrawContent(); GUILayout.EndHorizontal(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 30f)); } private void DrawSidebar() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(170f), GUILayout.ExpandHeight(true) }); GUILayout.Label("MODMENU", titleStyle, Array.Empty()); GUILayout.Label($"Toggle: {menuSettings?.ToggleMenuKey.Value}", Array.Empty()); GUILayout.Space(12f); for (int i = 0; i < Categories.Length; i++) { GUIStyle val = ((selectedCategory == i) ? sidebarSelectedStyle : sidebarButtonStyle); if (GUILayout.Button(Categories[i], val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { selectedCategory = i; ClearPendingInput(); PrepareCurrentView(); } } GUILayout.FlexibleSpace(); GUILayout.Label(statusMessage, Array.Empty()); if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { visible = false; ClearPendingInput(); } GUILayout.EndVertical(); } private void DrawContent() { //IL_007f: 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_009a: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); GUILayout.Label(Categories[selectedCategory], titleStyle, Array.Empty()); DrawSubTabs(GetCurrentSubTabs()); GUILayout.Space(10f); int num = selectedSubTabs[selectedCategory]; contentScrollPositions[selectedCategory][num] = GUILayout.BeginScrollView(contentScrollPositions[selectedCategory][num], false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); switch (selectedCategory) { case 0: DrawGameplayContent(); break; case 1: DrawMovementContent(); break; default: DrawObjectContent(); break; } GUILayout.EndScrollView(); GUILayout.EndVertical(); } private void DrawSubTabs(string[] tabs) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) subTabScrollPositions[selectedCategory] = GUILayout.BeginScrollView(subTabScrollPositions[selectedCategory], false, false, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(52f) }); GUILayout.BeginHorizontal(Array.Empty()); for (int i = 0; i < tabs.Length; i++) { GUIStyle val = ((selectedSubTabs[selectedCategory] == i) ? subTabSelectedStyle : subTabStyle); float num = Mathf.Max(112f, val.CalcSize(new GUIContent(tabs[i])).x + 28f); if (GUILayout.Button(tabs[i], val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(num), GUILayout.Height(34f) })) { selectedSubTabs[selectedCategory] = i; ClearPendingInput(); PrepareCurrentView(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndScrollView(); } private void DrawGameplayContent() { //IL_0282: 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) if (gameplaySettings == null) { GUILayout.Label("Gameplay settings were not initialized.", Array.Empty()); return; } if (selectedSubTabs[0] == 1) { playerAnimationModule?.DrawPanel(); return; } GUILayout.BeginVertical(gameplaySettings.Enabled.Value ? enabledStatusStyle : disabledStatusStyle, Array.Empty()); GUILayout.Label(gameplaySettings.Enabled.Value ? "NoBroomSlap: ON" : "NoBroomSlap: OFF", titleStyle, Array.Empty()); GUILayout.Label(gameplaySettings.Enabled.Value ? "ほうきを持っていない状態でも、指定入力でNPCやプレイヤーを叩けます。" : "NoBroomSlapの入力処理を停止しています。", Array.Empty()); if (GUILayout.Button(gameplaySettings.Enabled.Value ? "Disable NoBroomSlap" : "Enable NoBroomSlap", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { gameplaySettings.Enabled.Value = !gameplaySettings.Enabled.Value; ConfigFile? obj = config; if (obj != null) { obj.Save(); } statusMessage = (gameplaySettings.Enabled.Value ? "NoBroomSlap enabled." : "NoBroomSlap disabled."); } GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("基本設定", Array.Empty()); GUILayout.Label("当たり判定の距離、半径、連続実行の間隔を調整します。", Array.Empty()); gameplaySettings.RequireEmptyHands.Value = GUILayout.Toggle(gameplaySettings.RequireEmptyHands.Value, "Only slap with empty hands", Array.Empty()); DrawTextField("Reach", ref reachInput); DrawTextField("Hit radius", ref hitRadiusInput); DrawTextField("Cooldown seconds", ref cooldownInput); DrawApplyReloadRow(ApplyGameplayInputs, ReloadGameplayInputs); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("入力設定", Array.Empty()); GUILayout.Label("ゲーム本来のMain Actionを使うか、代替キーを使うかを確認します。", Array.Empty()); gameplaySettings.UseRewiredMainAction.Value = GUILayout.Toggle(gameplaySettings.UseRewiredMainAction.Value, "Use game's Main Action input", Array.Empty()); GUILayout.Label($"Fallback key: {gameplaySettings.FallbackKey.Value}", Array.Empty()); GUILayout.Label($"Modifier shortcut: {gameplaySettings.ModifierShortcut.Value}", Array.Empty()); GUILayout.Label("Detailed key edits are still handled through the config file.", Array.Empty()); DrawSaveButton("Save Input Settings"); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("フィードバック", Array.Empty()); GUILayout.Label("ヒット時の音や、ほうき要求通知の表示を管理します。", Array.Empty()); gameplaySettings.PlayBroomSound.Value = GUILayout.Toggle(gameplaySettings.PlayBroomSound.Value, "Play broom sound on hit", Array.Empty()); gameplaySettings.SuppressNeedBroomNotification.Value = GUILayout.Toggle(gameplaySettings.SuppressNeedBroomNotification.Value, "Hide broom-required notification", Array.Empty()); DrawSaveButton("Save Feedback Settings"); GUILayout.EndVertical(); } private void DrawMovementContent() { switch (selectedSubTabs[1]) { case 0: DrawFlyContent(); break; case 1: GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("Speed", Array.Empty()); GUILayout.Label("プレイヤーの移動速度とスプリント速度を現在値から調整します。", Array.Empty()); speedMenu?.DrawPanel(); GUILayout.EndVertical(); break; default: GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); DrawFeatureToggle(teleportSettings.ShortcutsEnabled, "Teleport Shortcuts", "保存地点、プレイヤー、視線テレポートのショートカットキーが有効です。", "ショートカットキーだけ停止します。UI上のTPボタンは使えます。"); GUILayout.Space(8f); GUILayout.Label("Teleport", Array.Empty()); GUILayout.Label("地点保存、プレイヤーへの移動、視線先への移動を管理します。", Array.Empty()); GUILayout.Label($"Max saved locations: {teleportSettings?.MaxLocations.Value}", Array.Empty()); teleportMenu?.DrawPanel(((Rect)(ref windowRect)).height - 180f); GUILayout.EndVertical(); break; } } private void DrawFlyContent() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (flySettings != null) { DrawFeatureToggle(flySettings.Enabled, "Fly Controls", "Fly切替キーと飛行中の移動入力が有効です。", "Fly切替キーと飛行移動を停止しています。"); GUILayout.Space(8f); } GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("Fly", Array.Empty()); GUILayout.Label("プレイヤー操作を一時的に切り替え、カメラ方向基準で自由移動します。", Array.Empty()); FlyModeController? flyModeController = flyController; GUILayout.Label((flyModeController != null && flyModeController.IsFlyModeEnabled) ? "Fly mode: ON" : "Fly mode: OFF", Array.Empty()); GUILayout.Label($"Shortcut: {flySettings?.ToggleKey.Value}", Array.Empty()); GUILayout.Label($"Current fly speed: {flySettings?.FlySpeed.Value:0.###}", Array.Empty()); GUILayout.Space(6f); DrawTextField("New fly speed", ref flySpeedInput); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Apply Speed", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { ApplyFlySpeed(); } if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { SyncFlySpeedInput(); statusMessage = "Fly speed reloaded."; } GUILayout.EndHorizontal(); FlyModeController? flyModeController2 = flyController; if (GUILayout.Button((flyModeController2 != null && flyModeController2.IsFlyModeEnabled) ? "Turn Fly Off" : "Turn Fly On", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { flyController?.ToggleFlyModeFromMenu(); FlyModeController? flyModeController3 = flyController; statusMessage = ((flyModeController3 != null && flyModeController3.IsFlyModeEnabled) ? "Fly mode turned on." : "Fly mode turned off."); ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)statusMessage); } } GUILayout.EndVertical(); } private void DrawObjectContent() { switch (selectedSubTabs[2]) { case 0: DrawBuilderContent(); break; case 1: GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); if (spawnerSettings != null) { DrawFeatureToggle(spawnerSettings.NoCostPlaceableSpawnEnabled, "No-cost Placeable Spawn", "設置物と製造設備の配置コストを無視するパッチが有効です。", "ゲーム本来の配置コスト処理を使います。"); GUILayout.Space(8f); } GUILayout.Label($"Spawn distance: {spawnerSettings?.SpawnDistance.Value:0.###}", Array.Empty()); GUILayout.Label("Object Spawnerは、ゲーム内オブジェクトを一覧から選んで前方へスポーンします。", Array.Empty()); spawnerMenu?.DrawPanelContent(); GUILayout.EndVertical(); break; default: GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); if (manipulatorSettings != null) { DrawFeatureToggle(manipulatorSettings.Enabled, "Object Manipulator", "手持ちアイテム複製と視線先削除のホットキーが有効です。", "複製/削除ホットキーを停止しています。"); GUILayout.Space(8f); } manipulatorMenu?.DrawPanelContent(); GUILayout.EndVertical(); break; } } private void DrawBuilderContent() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) CaptureBuilderKey(Event.current); if (builderSettings != null) { DrawFeatureToggle(builderSettings.Enabled, "Any-place Builder", "建築プレビューを通常制限に関係なく配置するキーが有効です。", "Any-place Builderの配置キーを停止しています。"); GUILayout.Space(8f); } GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("Any-place builder", Array.Empty()); GUILayout.Label("ゲーム側で配置不可になっている建築プレビューを、現在位置へ配置します。", Array.Empty()); GUILayout.Label($"Build key: {builderSettings?.PlacePreviewKey.Value}", Array.Empty()); GUILayout.Label("Open the game's build preview first, then press the key above.", Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("Key binding", Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button(pendingBuilderKeyBinding ? "Press key..." : "Change Build Key", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { pendingBuilderKeyBinding = true; if (builderSettings != null) { builderSettings.SuppressPlacePreviewInput = true; } statusMessage = "Press a key for any-place build. Escape cancels."; } if (GUILayout.Button("Reset V", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { if (builderSettings != null) { builderSettings.PlacePreviewKey.Value = (KeyCode)118; ((ConfigEntryBase)builderSettings.PlacePreviewKey).ConfigFile.Save(); } ClearPendingInput(); statusMessage = "Any-place build key reset to V."; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void CaptureBuilderKey(Event currentEvent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_003d: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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) if (builderSettings == null || !pendingBuilderKeyBinding || (int)currentEvent.type != 4) { return; } if ((int)currentEvent.keyCode == 27) { ClearPendingInput(); statusMessage = "Any-place build key change canceled."; currentEvent.Use(); } else if ((int)currentEvent.keyCode != 0) { if (menuSettings != null && currentEvent.keyCode == menuSettings.ToggleMenuKey.Value) { statusMessage = $"{currentEvent.keyCode} is reserved for MODMENU."; currentEvent.Use(); return; } builderSettings.PlacePreviewKey.Value = currentEvent.keyCode; ((ConfigEntryBase)builderSettings.PlacePreviewKey).ConfigFile.Save(); ClearPendingInput(); statusMessage = $"Any-place build key set to {currentEvent.keyCode}."; currentEvent.Use(); } } private void DrawApplyReloadRow(Action apply, Action reload) { GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Apply", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { apply(); } if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { reload(); } GUILayout.EndHorizontal(); } private void DrawSaveButton(string label) { GUILayout.Space(8f); if (GUILayout.Button(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { ConfigFile? obj = config; if (obj != null) { obj.Save(); } statusMessage = "Settings saved."; } } private void DrawFeatureToggle(ConfigEntry entry, string label, string enabledText, string disabledText) { GUILayout.BeginVertical(entry.Value ? enabledStatusStyle : disabledStatusStyle, Array.Empty()); GUILayout.Label(label + ": " + (entry.Value ? "ON" : "OFF"), titleStyle, Array.Empty()); GUILayout.Label(entry.Value ? enabledText : disabledText, Array.Empty()); if (GUILayout.Button(entry.Value ? ("Disable " + label) : ("Enable " + label), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { entry.Value = !entry.Value; ((ConfigEntryBase)entry).ConfigFile.Save(); statusMessage = label + " " + (entry.Value ? "enabled" : "disabled") + "."; } GUILayout.EndVertical(); } private static void DrawTextField(string label, ref string input) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); input = GUILayout.TextField(input, 16, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) }); GUILayout.EndHorizontal(); } private void PrepareCurrentView() { if (selectedCategory == 0) { SyncGameplayInputs(); } else if (selectedCategory == 1) { if (selectedSubTabs[1] == 0) { SyncFlySpeedInput(); } else if (selectedSubTabs[1] == 1) { speedMenu?.ShowPanel(); } else { teleportMenu?.ShowPanel(); } } else if (selectedCategory == 2) { if (selectedSubTabs[2] == 1) { spawnerMenu?.ShowPanel(); } else if (selectedSubTabs[2] == 2) { manipulatorMenu?.ShowPanel(); } } } private string[] GetCurrentSubTabs() { return selectedCategory switch { 0 => GameplayTabs, 1 => MovementTabs, _ => ObjectTabs, }; } private void ApplyGameplayInputs() { if (gameplaySettings != null && TryParseFloat(reachInput, "Reach", 0.1f, 20f, out var value) && TryParseFloat(hitRadiusInput, "Hit radius", 0.01f, 1.5f, out var value2) && TryParseFloat(cooldownInput, "Cooldown", 0.01f, 10f, out var value3)) { gameplaySettings.Reach.Value = value; gameplaySettings.HitRadius.Value = value2; gameplaySettings.CooldownSeconds.Value = value3; gameplayModule?.SaveConfig(); SyncGameplayInputs(); statusMessage = "Gameplay settings applied."; } } private void ReloadGameplayInputs() { gameplayModule?.ReloadConfig(); SyncGameplayInputs(); statusMessage = "Gameplay settings reloaded."; } private void ApplyFlySpeed() { float value; if (flySettings == null) { statusMessage = "Fly settings were not found."; } else if (TryParseFloat(flySpeedInput, "Fly speed", 0.1f, 100f, out value)) { flySettings.FlySpeed.Value = value; flySpeedInput = value.ToString("0.###"); statusMessage = "Applied fly speed: " + flySpeedInput; ManualLogSource? obj = logger; if (obj != null) { obj.LogInfo((object)statusMessage); } } } private bool TryParseFloat(string input, string label, float min, float max, out float value) { if (!float.TryParse(input, out value)) { statusMessage = $"{label} must be a number. Example: {min:0.###}"; return false; } value = Mathf.Clamp(value, min, max); return true; } private void SyncGameplayInputs() { if (gameplaySettings != null) { reachInput = gameplaySettings.Reach.Value.ToString("0.###"); hitRadiusInput = gameplaySettings.HitRadius.Value.ToString("0.###"); cooldownInput = gameplaySettings.CooldownSeconds.Value.ToString("0.###"); } } private void SyncFlySpeedInput() { flySpeedInput = flySettings?.FlySpeed.Value.ToString("0.###") ?? "10"; } private void ClearPendingInput() { pendingBuilderKeyBinding = false; if (builderSettings != null) { builderSettings.SuppressPlacePreviewInput = false; } manipulatorMenu?.HidePanel(); } private void ResizeWindowToScreen() { float num = Mathf.Max(820f, (float)Screen.width - 36f); float num2 = Mathf.Max(580f, (float)Screen.height - 36f); ((Rect)(ref windowRect)).width = Mathf.Min(1080f, num); ((Rect)(ref windowRect)).height = Mathf.Min(760f, num2); } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0031: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0064: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (panelStyle == null) { panelStyle = new GUIStyle(GUI.skin.box) { padding = new RectOffset(12, 12, 12, 12) }; titleStyle = new GUIStyle(GUI.skin.label) { fontSize = 18, fontStyle = (FontStyle)1, margin = new RectOffset(4, 4, 4, 8) }; sidebarButtonStyle = CreateButtonStyle(new Color(0.22f, 0.24f, 0.27f), Color.white, (TextAnchor)3); sidebarSelectedStyle = CreateButtonStyle(new Color(0.13f, 0.38f, 0.55f), Color.white, (TextAnchor)3); subTabStyle = CreateButtonStyle(new Color(0.26f, 0.26f, 0.26f), Color.white, (TextAnchor)4); subTabSelectedStyle = CreateButtonStyle(new Color(0.12f, 0.48f, 0.34f), Color.white, (TextAnchor)4); enabledStatusStyle = CreatePanelStyle(new Color(0.08f, 0.28f, 0.18f)); disabledStatusStyle = CreatePanelStyle(new Color(0.32f, 0.12f, 0.12f)); } } private void ApplyJapaneseFont() { if (japaneseFont == null) { japaneseFont = Font.CreateDynamicFontFromOSFont(new string[4] { "Yu Gothic UI", "Yu Gothic", "Meiryo", "MS Gothic" }, 14); } if (!((Object)(object)japaneseFont == (Object)null) && !((Object)(object)GUI.skin.font == (Object)(object)japaneseFont)) { GUI.skin.font = japaneseFont; GUI.skin.label.font = japaneseFont; GUI.skin.button.font = japaneseFont; GUI.skin.toggle.font = japaneseFont; GUI.skin.textField.font = japaneseFont; GUI.skin.window.font = japaneseFont; GUI.skin.box.font = japaneseFont; } } private static GUIStyle CreatePanelStyle(Color backgroundColor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0065: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, backgroundColor); val.Apply(); GUIStyle val2 = new GUIStyle(GUI.skin.box); val2.normal.background = val; val2.normal.textColor = Color.white; val2.padding = new RectOffset(12, 12, 10, 10); val2.margin = new RectOffset(4, 4, 4, 8); return val2; } private static GUIStyle CreateButtonStyle(Color backgroundColor, Color textColor, TextAnchor alignment) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004a: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00b5: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, backgroundColor); val.Apply(); GUIStyle val2 = new GUIStyle(GUI.skin.button); val2.normal.background = val; val2.normal.textColor = textColor; val2.hover.background = val; val2.hover.textColor = textColor; val2.active.background = val; val2.active.textColor = textColor; val2.focused.background = val; val2.focused.textColor = textColor; val2.alignment = alignment; val2.fontStyle = (FontStyle)1; val2.padding = new RectOffset(12, 12, 6, 6); val2.margin = new RectOffset(4, 4, 4, 4); return val2; } } [BepInPlugin("uta_a.supermarkettogether.modmenu", "MODMENU", "0.1.0")] public sealed class ModMenuPlugin : BaseUnityPlugin { public const string PluginGuid = "uta_a.supermarkettogether.modmenu"; public const string PluginName = "MODMENU"; public const string PluginVersion = "0.1.0"; private Harmony? harmony; private void Awake() { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Expected O, but got Unknown //IL_05cc: Unknown result type (might be due to invalid IL or missing references) ModMenuSettings modMenuSettings = new ModMenuSettings(((BaseUnityPlugin)this).Config.Bind("Menu", "ToggleMenuKey", (KeyCode)303, "Key used to show or hide MODMENU.")); GameplayToolsSettings gameplayToolsSettings = new GameplayToolsSettings(((BaseUnityPlugin)this).Config.Bind("Gameplay.NoBroomSlap", "Enabled", true, "Enable NoBroomSlap."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "Reach", 3f, "Bare-hand slap reach distance."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "HitRadius", 0.35f, "Forward hit detection radius."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "CooldownSeconds", 0.35f, "Seconds between slap attempts."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "RequireEmptyHands", true, "Only trigger when holding nothing."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "PlayBroomSound", true, "Play broom sound when a hit succeeds."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.General", "SuppressNeedBroomNotification", true, "Hide broom-required notification."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.Input", "UseRewiredMainAction", true, "Use the game's Main Action input."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.Input", "FallbackKey", (KeyCode)323, "Fallback key when Rewired is unavailable."), ((BaseUnityPlugin)this).Config.Bind("Gameplay.Input", "ModifierShortcut", new KeyboardShortcut((KeyCode)0, Array.Empty()), "Optional modifier shortcut.")); PlayerAnimationSettings animationSettings = new PlayerAnimationSettings(new NetworkPlayerAnimationBinding[6] { new NetworkPlayerAnimationBinding(0, "Network Animation 0", "装備アイテム側の AnimationFloat=0 をネットワーク再生します。キャラ本体はゲーム側仕様でAction再生になります。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation0Key", (KeyCode)0, "Shortcut for network animation index 0.")), new NetworkPlayerAnimationBinding(1, "Action Animation 1", "解体ハンマーでも使われている CmdPlayAnimation(1) です。キャラ本体のAction再生に使います。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation1Key", (KeyCode)0, "Shortcut for network animation index 1.")), new NetworkPlayerAnimationBinding(2, "Network Animation 2", "装備アイテム側の AnimationFloat=2 をネットワーク再生します。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation2Key", (KeyCode)0, "Shortcut for network animation index 2.")), new NetworkPlayerAnimationBinding(3, "Network Animation 3", "装備アイテム側の AnimationFloat=3 をネットワーク再生します。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation3Key", (KeyCode)0, "Shortcut for network animation index 3.")), new NetworkPlayerAnimationBinding(4, "Network Animation 4", "装備アイテム側の AnimationFloat=4 をネットワーク再生します。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation4Key", (KeyCode)0, "Shortcut for network animation index 4.")), new NetworkPlayerAnimationBinding(5, "Network Animation 5", "装備アイテム側の AnimationFloat=5 をネットワーク再生します。", ((BaseUnityPlugin)this).Config.Bind("Gameplay.PlayerAnimation", "NetworkAnimation5Key", (KeyCode)0, "Shortcut for network animation index 5.")) }); FlyModeSettings flyModeSettings = new FlyModeSettings(((BaseUnityPlugin)this).Config.Bind("Movement.Fly", "Enabled", true, "Enable fly mode controls."), ((BaseUnityPlugin)this).Config.Bind("Movement.Fly", "ToggleKey", (KeyCode)103, "Key used to toggle fly mode."), ((BaseUnityPlugin)this).Config.Bind("Movement.Fly", "FlySpeed", 10f, "Fly movement speed in meters per second.")); MovementSpeedSettings movementSpeedSettings = new MovementSpeedSettings(((BaseUnityPlugin)this).Config.Bind("Movement.Speed", "ToggleKey", (KeyCode)0, "Legacy shortcut slot. MODMENU opens with Right Shift only."), ((BaseUnityPlugin)this).Config.Bind("Movement.Speed", "DefaultMoveSpeed", 5f, "Move speed shown before the player controller is found."), ((BaseUnityPlugin)this).Config.Bind("Movement.Speed", "DefaultSprintSpeed", 10f, "Sprint speed shown before the player controller is found.")); TeleportMenuSettings teleportMenuSettings = new TeleportMenuSettings(((BaseUnityPlugin)this).Config.Bind("Movement.Teleport", "ShortcutsEnabled", true, "Enable teleport shortcuts while the menu is closed."), ((BaseUnityPlugin)this).Config.Bind("Movement.Teleport", "ToggleMenuKey", (KeyCode)0, "Legacy shortcut slot. MODMENU opens with Right Shift only."), ((BaseUnityPlugin)this).Config.Bind("Movement.Teleport", "MaxLocations", 20, "Maximum number of saved teleport locations.")); NormalizeMenuShortcuts(modMenuSettings, movementSpeedSettings, teleportMenuSettings); AnyPlaceBuilderSettings anyPlaceBuilderSettings = new AnyPlaceBuilderSettings(((BaseUnityPlugin)this).Config.Bind("Object.Builder", "Enabled", true, "Enable any-place builder input."), ((BaseUnityPlugin)this).Config.Bind("Object.Builder", "PlacePreviewKey", (KeyCode)118, "Key used to place the current translucent builder preview without placement validation.")); ObjectSpawnerSettings objectSpawnerSettings = new ObjectSpawnerSettings(((BaseUnityPlugin)this).Config.Bind("Object.Spawner", "NoCostPlaceableSpawnEnabled", true, "Enable no-cost placeable spawn patch."), ((BaseUnityPlugin)this).Config.Bind("Object.Spawner", "SpawnDistance", 3.5f, "Distance in front of the camera used when no surface is hit.")); ObjectManipulatorSettings objectManipulatorSettings = new ObjectManipulatorSettings(((BaseUnityPlugin)this).Config.Bind("Object.Manipulator", "Enabled", true, "Enable object manipulator hotkeys."), ((BaseUnityPlugin)this).Config.Bind("Object.Manipulator", "DuplicateHeldItemKey", (KeyCode)118, "Key used to spawn a copy of the currently held item."), ((BaseUnityPlugin)this).Config.Bind("Object.Manipulator", "DeleteObjectKey", (KeyCode)98, "Key used to delete the networked object you are looking at.")); harmony = new Harmony("uta_a.supermarkettogether.modmenu"); harmony.PatchAll(typeof(ModMenuPlugin).Assembly); GameplayToolsModule gameplayToolsModule = ((Component)this).gameObject.AddComponent(); PlayerAnimationModule playerAnimationModule = ((Component)this).gameObject.AddComponent(); FlyModeController flyModeController = ((Component)this).gameObject.AddComponent(); MovementSpeedMenu movementSpeedMenu = ((Component)this).gameObject.AddComponent(); TeleportMenu teleportMenu = ((Component)this).gameObject.AddComponent(); AnyPlaceBuilderController anyPlaceBuilderController = ((Component)this).gameObject.AddComponent(); ObjectSpawnerMenu objectSpawnerMenu = ((Component)this).gameObject.AddComponent(); ObjectManipulatorMenu objectManipulatorMenu = ((Component)this).gameObject.AddComponent(); gameplayToolsModule.Initialize(((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config, gameplayToolsSettings); playerAnimationModule.Initialize(((BaseUnityPlugin)this).Logger, animationSettings); flyModeController.Initialize(((BaseUnityPlugin)this).Logger, flyModeSettings); movementSpeedMenu.Initialize(((BaseUnityPlugin)this).Logger, movementSpeedSettings); teleportMenu.Initialize(((BaseUnityPlugin)this).Logger, teleportMenuSettings, Paths.ConfigPath); anyPlaceBuilderController.Initialize(((BaseUnityPlugin)this).Logger, anyPlaceBuilderSettings); objectSpawnerMenu.Initialize(((BaseUnityPlugin)this).Logger, objectSpawnerSettings); objectManipulatorMenu.Initialize(((BaseUnityPlugin)this).Logger, objectManipulatorSettings); ((Component)this).gameObject.AddComponent().Initialize(((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config, modMenuSettings, gameplayToolsModule, playerAnimationModule, gameplayToolsSettings, flyModeController, flyModeSettings, movementSpeedSettings, teleportMenuSettings, anyPlaceBuilderSettings, objectSpawnerSettings, objectManipulatorSettings, movementSpeedMenu, teleportMenu, objectSpawnerMenu, objectManipulatorMenu); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Press {2} to open MODMENU.", "MODMENU", "0.1.0", modMenuSettings.ToggleMenuKey.Value)); } private void OnDestroy() { Harmony? obj = harmony; if (obj != null) { obj.UnpatchSelf(); } harmony = null; } private void NormalizeMenuShortcuts(ModMenuSettings menuSettings, MovementSpeedSettings speedSettings, TeleportMenuSettings teleportSettings) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Invalid comparison between Unknown and I4 //IL_002c: 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) bool flag = false; if ((int)menuSettings.ToggleMenuKey.Value != 303) { menuSettings.ToggleMenuKey.Value = (KeyCode)303; flag = true; } if ((int)speedSettings.ToggleKey.Value != 0) { speedSettings.ToggleKey.Value = (KeyCode)0; flag = true; } if ((int)teleportSettings.ToggleMenuKey.Value != 0) { teleportSettings.ToggleMenuKey.Value = (KeyCode)0; flag = true; } if (flag) { ((BaseUnityPlugin)this).Config.Save(); } } } internal sealed class ModMenuSettings { public ConfigEntry ToggleMenuKey { get; } public ModMenuSettings(ConfigEntry toggleMenuKey) { ToggleMenuKey = toggleMenuKey; } } internal sealed class PlayerAnimationModule : MonoBehaviour { private const float ButtonHeight = 30f; private ManualLogSource? logger; private PlayerAnimationSettings? settings; private NetworkPlayerAnimationBinding? listeningBinding; private string statusMessage = "待機中。"; public void Initialize(ManualLogSource pluginLogger, PlayerAnimationSettings animationSettings) { logger = pluginLogger; settings = animationSettings; } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (settings == null || listeningBinding != null) { return; } foreach (NetworkPlayerAnimationBinding animation in settings.Animations) { if ((int)animation.ShortcutKey.Value != 0 && Input.GetKeyDown(animation.ShortcutKey.Value)) { PlayNetworkAnimation(animation); break; } } } internal void DrawPanel() { if (settings == null) { GUILayout.Label("Player Animation settings were not initialized.", Array.Empty()); return; } TryCaptureShortcutKey(Event.current); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label("Player Animation", Array.Empty()); GUILayout.Label("analysisで確認できた PlayerNetwork.CmdPlayAnimation(int) だけを使います。ローカルだけの見た目変更は表示しません。", Array.Empty()); GUILayout.Label("各行で再生ボタン、キー設定、キー解除を管理できます。", Array.Empty()); GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); foreach (NetworkPlayerAnimationBinding animation in settings.Animations) { DrawAnimationRow(animation); } GUILayout.EndVertical(); GUILayout.Space(8f); GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label(statusMessage, Array.Empty()); GUILayout.EndVertical(); } private void DrawAnimationRow(NetworkPlayerAnimationBinding animation) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(GUI.skin.box, Array.Empty()); GUILayout.Label($"{animation.Label} / index {animation.AnimationIndex}", Array.Empty()); GUILayout.Label(animation.Description, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Key: " + GetShortcutLabel(animation.ShortcutKey.Value), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); if (GUILayout.Button("Play", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(86f), GUILayout.Height(30f) })) { PlayNetworkAnimation(animation); } if (GUILayout.Button((listeningBinding == animation) ? "Press key..." : "Set Key", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(110f), GUILayout.Height(30f) })) { listeningBinding = animation; statusMessage = animation.Label + " に割り当てるキーを押してください。Escでキャンセル。"; } if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(86f), GUILayout.Height(30f) })) { animation.ShortcutKey.Value = (KeyCode)0; ((ConfigEntryBase)animation.ShortcutKey).ConfigFile.Save(); if (listeningBinding == animation) { listeningBinding = null; } statusMessage = animation.Label + " のキー設定を解除しました。"; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void PlayNetworkAnimation(NetworkPlayerAnimationBinding animation) { PlayerNetwork localPlayerNetwork = GetLocalPlayerNetwork(); if ((Object)(object)localPlayerNetwork == (Object)null) { SetStatus("ローカルプレイヤーが見つかりません。セーブデータに入ってから実行してください。", warning: true); return; } localPlayerNetwork.CmdPlayAnimation(animation.AnimationIndex); SetStatus(animation.Label + " をネットワーク再生しました。", warning: false); } private bool TryCaptureShortcutKey(Event currentEvent) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0038: 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_004c: Invalid comparison between Unknown and I4 //IL_006a: 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_00a3: Unknown result type (might be due to invalid IL or missing references) if (listeningBinding == null || (int)currentEvent.type != 4) { return false; } if ((int)currentEvent.keyCode == 27) { statusMessage = "キー設定をキャンセルしました。"; listeningBinding = null; currentEvent.Use(); return true; } if ((int)currentEvent.keyCode == 0) { return false; } if ((int)currentEvent.keyCode == 303) { statusMessage = "RightShift はMODMENUの予約キーです。別のキーを押してください。"; currentEvent.Use(); return true; } NetworkPlayerAnimationBinding networkPlayerAnimationBinding = listeningBinding; ClearDuplicateShortcut(currentEvent.keyCode, networkPlayerAnimationBinding); networkPlayerAnimationBinding.ShortcutKey.Value = currentEvent.keyCode; ((ConfigEntryBase)networkPlayerAnimationBinding.ShortcutKey).ConfigFile.Save(); statusMessage = $"{networkPlayerAnimationBinding.Label} のキーを {currentEvent.keyCode} に設定しました。"; listeningBinding = null; currentEvent.Use(); return true; } private void ClearDuplicateShortcut(KeyCode keyCode, NetworkPlayerAnimationBinding except) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (settings == null) { return; } foreach (NetworkPlayerAnimationBinding animation in settings.Animations) { if (animation != except && animation.ShortcutKey.Value == keyCode) { animation.ShortcutKey.Value = (KeyCode)0; } } } private static PlayerNetwork? GetLocalPlayerNetwork() { if ((Object)(object)FirstPersonController.Instance == (Object)null) { return null; } return ((Component)FirstPersonController.Instance).GetComponent(); } private void SetStatus(string message, bool warning) { statusMessage = message; if (warning) { ManualLogSource? obj = logger; if (obj != null) { obj.LogWarning((object)message); } } else { ManualLogSource? obj2 = logger; if (obj2 != null) { obj2.LogInfo((object)message); } } } private unsafe static string GetShortcutLabel(KeyCode shortcutKey) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)shortcutKey != 0) { return ((object)(*(KeyCode*)(&shortcutKey))/*cast due to .constrained prefix*/).ToString(); } return "None"; } } internal sealed class PlayerAnimationSettings { public IReadOnlyList Animations { get; } public PlayerAnimationSettings(IReadOnlyList animations) { Animations = animations; } } internal sealed class NetworkPlayerAnimationBinding { public int AnimationIndex { get; } public string Label { get; } public string Description { get; } public ConfigEntry ShortcutKey { get; } public NetworkPlayerAnimationBinding(int animationIndex, string label, string description, ConfigEntry shortcutKey) { AnimationIndex = animationIndex; Label = label; Description = description; ShortcutKey = shortcutKey; } } }