Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of M182AdminPannel v2.2.0
M182AdminPanel.dll
Decompiled a month agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("M182AdminPanel")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("M182AdminPanel")] [assembly: AssemblyTitle("M182AdminPanel")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace M182AdminPanel { public static class AdminStatus { [CompilerGenerated] private static class <>O { public static CoroutineHandler <0>__OnServerReceive; public static CoroutineHandler <1>__OnClientReceive; } private const float RetryInterval = 3f; private static CustomRPC _rpc; private static bool _requestInFlight; private static bool _hasAnswer; private static float _requestSentAt; public static bool IsAdmin { get; private set; } public static void Init() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown NetworkManager instance = NetworkManager.Instance; object obj = <>O.<0>__OnServerReceive; if (obj == null) { CoroutineHandler val = OnServerReceive; <>O.<0>__OnServerReceive = val; obj = (object)val; } object obj2 = <>O.<1>__OnClientReceive; if (obj2 == null) { CoroutineHandler val2 = OnClientReceive; <>O.<1>__OnClientReceive = val2; obj2 = (object)val2; } _rpc = instance.AddRPC("M182AdminPanel_AmIAdmin", (CoroutineHandler)obj, (CoroutineHandler)obj2); } public static void RequestStatus() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown if ((Object)(object)ZNet.instance == (Object)null) { return; } if (ZNet.instance.IsServer()) { IsAdmin = true; _hasAnswer = true; } else { if (_hasAnswer) { return; } if (_requestInFlight) { if (Time.time - _requestSentAt < 3f) { return; } Plugin.Log.LogInfo((object)"Reintentando consulta de estado de admin."); } ZNetPeer val = RpcHelper.FindServerPeer(); if (val != null && _rpc != null) { _requestInFlight = true; _requestSentAt = Time.time; _rpc.SendPackage(new List<ZNetPeer> { val }, new ZPackage()); } } } private static IEnumerator OnServerReceive(long sender, ZPackage package) { ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(sender) : null); string text = ((val != null && val.m_socket != null) ? val.m_socket.GetHostName() : null); bool flag = text != null && RpcHelper.IsAdminId(text); if ((Object)(object)ZNet.instance != (Object)null) { Plugin.Log.LogInfo((object)("Lista de admins del servidor: [" + string.Join(", ", ZNet.instance.GetAdminList()) + "]")); } Plugin.Log.LogInfo((object)("Peticion de AmIAdmin de sender=" + sender + " senderId='" + text + "' -> isAdmin=" + flag)); ZPackage val2 = new ZPackage(); val2.Write(flag); if (val != null) { _rpc.SendPackage(new List<ZNetPeer> { val }, val2); } yield break; } private static IEnumerator OnClientReceive(long sender, ZPackage package) { IsAdmin = package.ReadBool(); _requestInFlight = false; _hasAnswer = true; yield break; } } public static class AdminToggles { private static readonly FieldInfo NoPlacementCostField = AccessTools.Field(typeof(Player), "m_noPlacementCost"); public static bool NoStaminaCost; public static bool InfiniteWeight; public static bool IsGodMode { get { if ((Object)(object)Player.m_localPlayer != (Object)null) { return ((Character)Player.m_localPlayer).InGodMode(); } return false; } } public static bool IsFlying { get { if ((Object)(object)Player.m_localPlayer != (Object)null) { return Player.m_localPlayer.InDebugFlyMode(); } return false; } } public static bool IsFreeBuild { get { if ((Object)(object)Player.m_localPlayer != (Object)null && NoPlacementCostField != null) { return (bool)NoPlacementCostField.GetValue(Player.m_localPlayer); } return false; } } public static void ToggleGodMode() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { Player.m_localPlayer.SetGodMode(!((Character)Player.m_localPlayer).InGodMode()); } } public static void ToggleFlying() { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { localPlayer.ToggleDebugFly(); } } public static void ToggleNoStaminaCost() { NoStaminaCost = !NoStaminaCost; } public static void ToggleInfiniteWeight() { InfiniteWeight = !InfiniteWeight; } public static void ToggleFreeBuild() { if (!((Object)(object)Player.m_localPlayer == (Object)null) && !(NoPlacementCostField == null)) { bool flag = (bool)NoPlacementCostField.GetValue(Player.m_localPlayer); NoPlacementCostField.SetValue(Player.m_localPlayer, !flag); } } public static void RevealMap() { if (!((Object)(object)Minimap.instance == (Object)null)) { Minimap.instance.ExploreAll(); } } } [HarmonyPatch(typeof(Player), "UseStamina")] public static class NoStaminaCostPatch { private static bool Prefix(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } return !AdminToggles.NoStaminaCost; } } [HarmonyPatch(typeof(Player), "GetMaxCarryWeight")] public static class InfiniteWeightPatch { private static void Postfix(Player __instance, ref float __result) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && AdminToggles.InfiniteWeight) { __result = 999999f; } } } public static class ArmedAction { public enum ActionType { None, Creature, Raid } private static string _creatureName; private static int _starLevel; private static int _quantity; private static string _raidName; public static ActionType Type { get; private set; } public static bool IsArmed => Type != ActionType.None; public static void ArmCreature(string name, int starLevel, int quantity) { Type = ActionType.Creature; _creatureName = name; _starLevel = starLevel; _quantity = quantity; } public static void ArmRaid(string name) { Type = ActionType.Raid; _raidName = name; } public static void Clear() { Type = ActionType.None; _creatureName = null; _raidName = null; } public static string GetHudText() { if (Type == ActionType.Creature) { return "Ready to spawn: " + _creatureName + " (" + _starLevel + " stars) x" + _quantity + " - Shift+Click anywhere on the map to spawn (repeatable), Esc to stop"; } if (Type == ActionType.Raid) { return "Ready to trigger: " + _raidName + " - Shift+Click on the map to confirm, Esc to cancel"; } return ""; } public static void Execute(Vector3 worldPosition) { //IL_0033: 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) if (!AdminStatus.IsAdmin) { Plugin.Log.LogWarning((object)"Accion bloqueada: el jugador local no es admin."); Clear(); } else if (Type == ActionType.Creature) { NativeRpc.RequestSpawn(_creatureName, _starLevel, _quantity, worldPosition); Toast.Show("Spawned: " + _creatureName + " x" + _quantity); } else if (Type == ActionType.Raid) { NativeRpc.RequestRaid(_raidName, worldPosition); Toast.Show("Raid triggered: " + _raidName); Clear(); } } } public static class CreatureList { private static List<string> _cachedNames; public static List<string> GetAllCreatureNames() { if (_cachedNames != null) { return _cachedNames; } if ((Object)(object)ZNetScene.instance == (Object)null) { return new List<string>(); } _cachedNames = new List<string>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!((Object)(object)prefab == (Object)null) && !((Object)(object)prefab.GetComponent<Player>() != (Object)null) && !((Object)(object)prefab.GetComponent<Character>() == (Object)null)) { _cachedNames.Add(((Object)prefab).name); } } _cachedNames.Sort(); return _cachedNames; } public static void InvalidateCache() { _cachedNames = null; } public static List<string> Filter(string search) { List<string> allCreatureNames = GetAllCreatureNames(); if (string.IsNullOrEmpty(search)) { return allCreatureNames; } string lowered = search.ToLowerInvariant(); return allCreatureNames.Where((string n) => n.ToLowerInvariant().Contains(lowered)).ToList(); } } public enum ItemCategory { All, Weapons, Armor, Consumables, Tools, Materials, Misc } public struct ItemEntry { public string InternalName; public string DisplayName; public ItemCategory Category; } public static class ItemList { private static List<ItemEntry> _cachedEntries; public static List<ItemEntry> GetAllItems() { //IL_0082: Unknown result type (might be due to invalid IL or missing references) if (_cachedEntries != null) { return _cachedEntries; } if ((Object)(object)ZNetScene.instance == (Object)null) { return new List<ItemEntry>(); } _cachedEntries = new List<ItemEntry>(); foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab == (Object)null) { continue; } ItemDrop component = prefab.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null)) { ItemCategory category = ItemCategory.Misc; if (component.m_itemData != null && component.m_itemData.m_shared != null) { category = Categorize(component.m_itemData.m_shared.m_itemType); } _cachedEntries.Add(new ItemEntry { InternalName = ((Object)prefab).name, DisplayName = Prettify(((Object)prefab).name), Category = category }); } } _cachedEntries.Sort((ItemEntry a, ItemEntry b) => string.Compare(a.DisplayName, b.DisplayName)); return _cachedEntries; } private static ItemCategory Categorize(ItemType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected I4, but got Unknown switch (type - 1) { case 2: case 3: case 4: case 13: case 19: case 21: return ItemCategory.Weapons; case 5: case 6: case 10: case 11: case 16: return ItemCategory.Armor; case 1: case 20: return ItemCategory.Consumables; case 14: case 17: case 18: return ItemCategory.Tools; case 0: case 8: case 12: case 22: return ItemCategory.Materials; default: return ItemCategory.Misc; } } public static string Prettify(string internalName) { if (string.IsNullOrEmpty(internalName)) { return internalName; } return Regex.Replace(internalName, "(?<!^)([A-Z])", " $1"); } public static void InvalidateCache() { _cachedEntries = null; } public static List<ItemEntry> Filter(string search, ItemCategory category) { IEnumerable<ItemEntry> source = GetAllItems(); if (category != ItemCategory.All) { source = source.Where((ItemEntry e) => e.Category == category); } if (!string.IsNullOrEmpty(search)) { string lowered = search.ToLowerInvariant(); source = source.Where((ItemEntry e) => e.DisplayName.ToLowerInvariant().Contains(lowered) || e.InternalName.ToLowerInvariant().Contains(lowered)); } return source.ToList(); } } public static class ItemNetworking { public static void GiveToSelf(string itemName, int stack, int quality) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(itemName) : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null || val2.m_itemData == null) { Plugin.Log.LogWarning((object)("No se encontro el item '" + itemName + "'.")); return; } ItemData val3 = val2.m_itemData.Clone(); val3.m_dropPrefab = val; val3.m_stack = Mathf.Clamp(stack, 1, Mathf.Max(1, val3.m_shared.m_maxStackSize)); val3.m_quality = Mathf.Clamp(quality, 1, Mathf.Max(1, val3.m_shared.m_maxQuality)); val3.m_durability = val3.GetMaxDurability(); ((Humanoid)localPlayer).GetInventory().AddItem(val3); Plugin.Log.LogInfo((object)("Dado " + itemName + " x" + val3.m_stack)); Toast.Show("Gave " + itemName + " x" + val3.m_stack); } } } public static class MapCoordinateHelper { private static readonly MethodInfo ScreenToWorldPointMethod = AccessTools.Method(typeof(Minimap), "ScreenToWorldPoint", new Type[1] { typeof(Vector3) }, (Type[])null); public static bool TryGetWorldPositionUnderMouse(out Vector3 worldPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) worldPosition = Vector3.zero; if ((Object)(object)Minimap.instance == (Object)null) { return false; } if ((int)Minimap.instance.m_mode != 2) { return false; } if (ScreenToWorldPointMethod == null) { Plugin.Log.LogWarning((object)"No se encontro el metodo Minimap.ScreenToWorldPoint por reflexion."); return false; } worldPosition = (Vector3)ScreenToWorldPointMethod.Invoke(Minimap.instance, new object[1] { Input.mousePosition }); if ((Object)(object)ZoneSystem.instance != (Object)null) { worldPosition.y = ZoneSystem.instance.GetGroundHeight(worldPosition); } return true; } } [HarmonyPatch(typeof(Minimap), "Update")] public static class MapTogglePatch { private static void Postfix(Minimap __instance) { //IL_0014: 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_0030: Invalid comparison between Unknown and I4 if ((Object)(object)__instance == (Object)null) { return; } AdminStatus.RequestStatus(); if (Input.GetKeyDown(Plugin.ToggleKey.Value) && AdminStatus.IsAdmin) { if ((int)__instance.m_mode != 2) { Plugin.Log.LogInfo((object)"Tecla presionada pero el mapa grande no esta abierto."); } else { SpawnerPanel.Instance?.TogglePanel(); } } } } [HarmonyPatch(typeof(Minimap), "Update")] public static class MapScrollBlockPatch { private static readonly FieldInfo LargeZoomField = AccessTools.Field(typeof(Minimap), "m_largeZoom"); private static readonly FieldInfo SmallZoomField = AccessTools.Field(typeof(Minimap), "m_smallZoom"); private static float _previousLargeZoom; private static float _previousSmallZoom; private static void Prefix(Minimap __instance) { if (!((Object)(object)__instance == (Object)null) && !(LargeZoomField == null) && !(SmallZoomField == null)) { _previousLargeZoom = (float)LargeZoomField.GetValue(__instance); _previousSmallZoom = (float)SmallZoomField.GetValue(__instance); } } private static void Postfix(Minimap __instance) { if (!((Object)(object)__instance == (Object)null) && !(LargeZoomField == null) && !(SmallZoomField == null) && !((Object)(object)SpawnerPanel.Instance == (Object)null) && SpawnerPanel.Instance.IsMouseOverPanel()) { LargeZoomField.SetValue(__instance, _previousLargeZoom); SmallZoomField.SetValue(__instance, _previousSmallZoom); } } } [HarmonyPatch(typeof(Minimap), "Update")] public static class MapSelfTeleportPatch { private static void Postfix(Minimap __instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_006b: 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) if (!((Object)(object)__instance == (Object)null) && (int)__instance.m_mode == 2 && Input.GetKeyDown((KeyCode)116) && AdminStatus.IsAdmin && (!((Object)(object)SpawnerPanel.Instance != (Object)null) || !SpawnerPanel.Instance.IsMouseOverPanel())) { if (!MapCoordinateHelper.TryGetWorldPositionUnderMouse(out var worldPosition)) { Plugin.Log.LogWarning((object)"No se pudo calcular la posicion para el teletransporte."); } else if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).TeleportTo(worldPosition, ((Component)Player.m_localPlayer).transform.rotation, true); Toast.Show("Teleported to map point"); } } } } [HarmonyPatch(typeof(ZInput), "GetButtonDown", new Type[] { typeof(string) })] public static class SuppressGameHotkeyDownWhileTypingPatch { private static bool Prefix(ref bool __result) { if ((Object)(object)SpawnerPanel.Instance == (Object)null || !SpawnerPanel.Instance.IsAnyTextFieldFocused()) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ZInput), "GetButtonUp", new Type[] { typeof(string) })] public static class SuppressGameHotkeyUpWhileTypingPatch { private static bool Prefix(ref bool __result) { if ((Object)(object)SpawnerPanel.Instance == (Object)null || !SpawnerPanel.Instance.IsAnyTextFieldFocused()) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ZInput), "GetButton", new Type[] { typeof(string) })] public static class SuppressGameHotkeyHeldWhileTypingPatch { private static bool Prefix(ref bool __result) { if ((Object)(object)SpawnerPanel.Instance == (Object)null || !SpawnerPanel.Instance.IsAnyTextFieldFocused()) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Minimap), "OnMapLeftDown")] public static class MapLeftDownPatch { private static bool Prefix() { if (!((Object)(object)SpawnerPanel.Instance == (Object)null)) { return !SpawnerPanel.Instance.IsMouseOverPanel(); } return true; } } [HarmonyPatch(typeof(Minimap), "OnMapLeftUp")] public static class MapLeftUpPatch { private static bool Prefix() { if (!((Object)(object)SpawnerPanel.Instance == (Object)null)) { return !SpawnerPanel.Instance.IsMouseOverPanel(); } return true; } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] public static class MapLeftClickPatch { private static void Postfix() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((!((Object)(object)SpawnerPanel.Instance != (Object)null) || !SpawnerPanel.Instance.IsMouseOverPanel()) && ArmedAction.IsArmed && (!Plugin.RequireShift.Value || Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { if (!MapCoordinateHelper.TryGetWorldPositionUnderMouse(out var worldPosition)) { Plugin.Log.LogWarning((object)"No se pudo calcular la posicion para la accion armada."); } else { ArmedAction.Execute(worldPosition); } } } } [HarmonyPatch(typeof(ZNet), "Awake")] public static class NativeRpcRegistrationPatch { private static void Postfix() { NativeRpc.Register(); } } public static class NativeRpc { private const string SpawnRpcName = "M182_SpawnCreature"; private const string RaidRpcName = "M182_TriggerRaid"; private static bool _registered; public static void Register() { if (!_registered && ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("M182_SpawnCreature", (Action<long, ZPackage>)OnServerSpawn); ZRoutedRpc.instance.Register<ZPackage>("M182_TriggerRaid", (Action<long, ZPackage>)OnServerRaid); _registered = true; Plugin.Log.LogInfo((object)"RPC nativo registrado (spawn y raid, sin Jotunn)."); } } public static void RequestSpawn(string creatureName, int starLevel, int quantity, Vector3 position) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ApplySpawn(0L, creatureName, starLevel, quantity, position); } else if (ZRoutedRpc.instance != null) { ZPackage val = new ZPackage(); val.Write(creatureName); val.Write(starLevel); val.Write(quantity); val.Write(position); ZRoutedRpc.instance.InvokeRoutedRPC(RpcHelper.GetServerPeerId(), "M182_SpawnCreature", new object[1] { val }); } } public static void RequestRaid(string raidName, Vector3 position) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ApplyRaid(0L, raidName, position); } else if (ZRoutedRpc.instance != null) { ZPackage val = new ZPackage(); val.Write(raidName); val.Write(position); ZRoutedRpc.instance.InvokeRoutedRPC(RpcHelper.GetServerPeerId(), "M182_TriggerRaid", new object[1] { val }); } } private static void OnServerSpawn(long sender, ZPackage package) { //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_0029: Unknown result type (might be due to invalid IL or missing references) string creatureName = package.ReadString(); int starLevel = package.ReadInt(); int quantity = package.ReadInt(); Vector3 position = package.ReadVector3(); if (SenderIsAuthorized(sender)) { ApplySpawn(sender, creatureName, starLevel, quantity, position); } } private static void OnServerRaid(long sender, ZPackage package) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) string raidName = package.ReadString(); Vector3 position = package.ReadVector3(); if (SenderIsAuthorized(sender)) { ApplyRaid(sender, raidName, position); } } private static bool SenderIsAuthorized(long sender) { if (sender == 0L) { return true; } ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(sender) : null); string text = ((val != null && val.m_socket != null) ? val.m_socket.GetHostName() : null); if (text == null || !RpcHelper.IsAdminId(text)) { Plugin.Log.LogWarning((object)"Solicitud RPC nativa rechazada: el remitente no es admin."); return false; } return true; } private unsafe static void ApplySpawn(long sender, string creatureName, int starLevel, int quantity, Vector3 position) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) if (SpawnLogic.TrySpawn(creatureName, starLevel, quantity, position, out var error)) { ManualLogSource log = Plugin.Log; Vector3 val = position; log.LogInfo((object)("Spawneado (rpc nativo) " + creatureName + " en " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); } else { Plugin.Log.LogWarning((object)error); } } private unsafe static void ApplyRaid(long sender, string raidName, Vector3 position) { //IL_0013: 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_002a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)RandEventSystem.instance != (Object)null) { RandEventSystem.instance.SetRandomEventByName(raidName, position); ManualLogSource log = Plugin.Log; Vector3 val = position; log.LogInfo((object)("Raid invocada (rpc nativo) " + raidName + " en " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); } } } [BepInPlugin("m182.valheim.adminpanel", "M182 Admin Panel", "3.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "m182.valheim.adminpanel"; public const string PluginName = "M182 Admin Panel"; public const string PluginVersion = "3.0.0"; public static ConfigEntry<KeyCode> ToggleKey; public static ConfigEntry<int> MaxStarLevel; public static ConfigEntry<int> MaxQuantity; public static ConfigEntry<bool> RequireShift; public static ConfigEntry<float> PanelPosX; public static ConfigEntry<float> PanelPosY; public static ConfigEntry<string> LastCreatureName; public static ConfigEntry<int> LastStarLevel; public static ConfigEntry<int> LastQuantity; public static ConfigEntry<string> LastRaidName; public static ConfigEntry<int> MaxItemQuality; public static ConfigEntry<int> MaxItemStack; public static ConfigEntry<string> LastItemName; public static ConfigEntry<int> LastItemQuality; public static ConfigEntry<int> LastItemStack; public static ManualLogSource Log; private Harmony _harmony; private void Awake() { //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)287, "Tecla para abrir/cerrar el panel mientras el mapa esta abierto."); MaxStarLevel = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxStarLevel", 4, "Maximo nivel de estrellas asignable. El juego no lo bloquea por codigo, pero la mayoria de criaturas solo tienen efecto visual definido hasta 2 estrellas."); MaxQuantity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxQuantity", 10, "Cantidad maxima de criaturas que se pueden spawnear de una vez."); RequireShift = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RequireShiftToConfirm", true, "Si esta activo, hay que mantener Shift presionado al hacer clic en el mapa para confirmar el spawn o la raid armada."); PanelPosX = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "PosX", -1f, "Ultima posicion X del panel. -1 significa centrado."); PanelPosY = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "PosY", -1f, "Ultima posicion Y del panel. -1 significa centrado."); LastCreatureName = ((BaseUnityPlugin)this).Config.Bind<string>("Ultimo", "CreatureName", "", "Ultima criatura seleccionada."); LastStarLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Ultimo", "StarLevel", 0, "Ultimo nivel de estrellas seleccionado."); LastQuantity = ((BaseUnityPlugin)this).Config.Bind<int>("Ultimo", "Quantity", 1, "Ultima cantidad seleccionada."); LastRaidName = ((BaseUnityPlugin)this).Config.Bind<string>("Ultimo", "RaidName", "", "Ultima raid seleccionada."); MaxItemQuality = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxItemQuality", 4, "Maximo nivel de calidad asignable a un item."); MaxItemStack = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxItemStack", 100, "Cantidad maxima por stack que se puede dar de una vez."); LastItemName = ((BaseUnityPlugin)this).Config.Bind<string>("Ultimo", "ItemName", "", "Ultimo item seleccionado."); LastItemQuality = ((BaseUnityPlugin)this).Config.Bind<int>("Ultimo", "ItemQuality", 1, "Ultima calidad de item seleccionada."); LastItemStack = ((BaseUnityPlugin)this).Config.Bind<int>("Ultimo", "ItemStack", 1, "Ultimo stack de item seleccionado."); _harmony = new Harmony("m182.valheim.adminpanel"); _harmony.PatchAll(); WeatherNetworking.Init(); AdminStatus.Init(); GameObject val = new GameObject("M182AdminPanelPanel"); val.AddComponent<SpawnerPanel>(); Object.DontDestroyOnLoad((Object)val); Log.LogInfo((object)("M182AdminPanel cargado. Abre el mapa grande y presiona " + ((object)ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + ".")); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public static class RaidList { private static List<string> _cachedNames; public static List<string> GetAllRaidNames() { if (_cachedNames != null) { return _cachedNames; } if ((Object)(object)RandEventSystem.instance == (Object)null) { return new List<string>(); } _cachedNames = new List<string>(); foreach (RandomEvent @event in RandEventSystem.instance.m_events) { if (@event != null && @event.m_enabled && !@event.m_devDisabled) { _cachedNames.Add(@event.m_name); } } _cachedNames.Sort(); return _cachedNames; } public static void InvalidateCache() { _cachedNames = null; } public static List<string> Filter(string search) { List<string> allRaidNames = GetAllRaidNames(); if (string.IsNullOrEmpty(search)) { return allRaidNames; } string lowered = search.ToLowerInvariant(); return allRaidNames.Where((string n) => n.ToLowerInvariant().Contains(lowered)).ToList(); } } public static class RpcHelper { private static readonly MethodInfo GetServerPeerIdMethod = AccessTools.Method(typeof(ZRoutedRpc), "GetServerPeerID", (Type[])null, (Type[])null); public static ZNetPeer FindServerPeer() { if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null || GetServerPeerIdMethod == null) { return null; } long serverPeerId = GetServerPeerId(); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer.m_uid == serverPeerId) { return peer; } } return null; } public static long GetServerPeerId() { if (ZRoutedRpc.instance == null || GetServerPeerIdMethod == null) { return 0L; } return (long)GetServerPeerIdMethod.Invoke(ZRoutedRpc.instance, null); } public static string BareId(string id) { if (string.IsNullOrEmpty(id)) { return id; } int num = id.IndexOf('_'); if (num < 0) { return id; } return id.Substring(num + 1); } public static bool IsAdminId(string id) { if ((Object)(object)ZNet.instance == (Object)null || string.IsNullOrEmpty(id)) { return false; } string text = BareId(id); List<string> adminList = ZNet.instance.GetAdminList(); bool result = adminList.Contains(id) || adminList.Contains(text); Plugin.Log.LogInfo((object)("Chequeo de admin para id '" + id + "' (sin prefijo: '" + text + "') contra lista [" + string.Join(", ", adminList) + "]: " + result)); return result; } } public class SpawnerPanel : MonoBehaviour { private enum Tab { Criaturas, Raids, Items, Admin } private bool _visible; private bool _mapWasOpen; private Tab _activeTab; private Rect _windowRect; private float _windowWidth; private float _windowHeight; private GUIStyle _opaqueWindowStyle; private GUIStyle _labelStyle; private GUIStyle _buttonStyle; private GUIStyle _textFieldStyle; private GUIStyle _headerStyle; private GUIStyle _subHeaderStyle; private GUIStyle _bannerStyle; private Texture2D _armedBannerBackground; private Texture2D _toastBannerBackground; private string _creatureSearchText = ""; private List<string> _filteredCreatures = new List<string>(); private string _selectedCreatureName; private int _starLevel; private int _quantity = 1; private Vector2 _creatureScrollPosition; private string _raidSearchText = ""; private List<string> _filteredRaids = new List<string>(); private string _selectedRaidName; private Vector2 _raidScrollPosition; private string _itemSearchText = ""; private List<ItemEntry> _filteredItems = new List<ItemEntry>(); private string _selectedItemName; private string _selectedItemDisplayName; private int _itemQuality = 1; private int _itemStack = 1; private Vector2 _itemScrollPosition; private ItemCategory _itemCategory; private string _weatherSearchText = ""; private List<string> _filteredWeather = new List<string>(); private string _selectedWeatherName; private Vector2 _weatherScrollPosition; public static SpawnerPanel Instance { get; private set; } private void Awake() { Instance = this; if (!string.IsNullOrEmpty(Plugin.LastCreatureName.Value)) { _selectedCreatureName = Plugin.LastCreatureName.Value; _starLevel = Plugin.LastStarLevel.Value; _quantity = Plugin.LastQuantity.Value; } if (!string.IsNullOrEmpty(Plugin.LastRaidName.Value)) { _selectedRaidName = Plugin.LastRaidName.Value; } if (!string.IsNullOrEmpty(Plugin.LastItemName.Value)) { _selectedItemName = Plugin.LastItemName.Value; _selectedItemDisplayName = Plugin.LastItemName.Value; _itemQuality = Plugin.LastItemQuality.Value; _itemStack = Plugin.LastItemStack.Value; } } private void Update() { if (ArmedAction.IsArmed && Input.GetKeyDown((KeyCode)27)) { ArmedAction.Clear(); } } public bool IsMouseOverPanel() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!_visible) { return false; } Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Input.mousePosition.x, (float)Screen.height - Input.mousePosition.y); return ((Rect)(ref _windowRect)).Contains(val); } public bool IsAnyTextFieldFocused() { if (!_visible) { return false; } string nameOfFocusedControl = GUI.GetNameOfFocusedControl(); if (!string.IsNullOrEmpty(nameOfFocusedControl)) { return nameOfFocusedControl.StartsWith("MCS_"); } return false; } public void TogglePanel() { if (_visible) { HidePanel(); } else { ShowPanel(); } } private void ShowPanel() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) _visible = true; _windowWidth = Mathf.Min(960f, (float)Screen.width * 0.9f); _windowHeight = Mathf.Min(1120f, (float)Screen.height * 0.9f); if (Plugin.PanelPosX.Value >= 0f && Plugin.PanelPosY.Value >= 0f) { float num = Mathf.Clamp(Plugin.PanelPosX.Value, 0f, Mathf.Max(0f, (float)Screen.width - _windowWidth)); float num2 = Mathf.Clamp(Plugin.PanelPosY.Value, 0f, Mathf.Max(0f, (float)Screen.height - _windowHeight)); _windowRect = new Rect(num, num2, _windowWidth, _windowHeight); } else { _windowRect = new Rect(20f, 20f, _windowWidth, _windowHeight); } CreatureList.InvalidateCache(); RaidList.InvalidateCache(); ItemList.InvalidateCache(); WeatherList.InvalidateCache(); RefreshCreatureList(); RefreshRaidList(); RefreshItemList(); RefreshWeatherList(); } private void HidePanel() { if (_visible) { Plugin.PanelPosX.Value = ((Rect)(ref _windowRect)).x; Plugin.PanelPosY.Value = ((Rect)(ref _windowRect)).y; } _visible = false; GUI.FocusControl((string)null); } private void RefreshCreatureList() { _filteredCreatures = CreatureList.Filter(_creatureSearchText); } private void RefreshRaidList() { _filteredRaids = RaidList.Filter(_raidSearchText); } private void RefreshItemList() { _filteredItems = ItemList.Filter(_itemSearchText, _itemCategory); } private void RefreshWeatherList() { _filteredWeather = WeatherList.Filter(_weatherSearchText); } 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_0026: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) if (_labelStyle == null) { _labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 18 }; _buttonStyle = new GUIStyle(GUI.skin.button) { fontSize = 18 }; _textFieldStyle = new GUIStyle(GUI.skin.textField) { fontSize = 18 }; _headerStyle = new GUIStyle(GUI.skin.label); _headerStyle.fontSize = 30; _headerStyle.fontStyle = (FontStyle)1; _headerStyle.alignment = (TextAnchor)4; _headerStyle.normal.textColor = new Color(0.85f, 0.65f, 0.15f); _subHeaderStyle = new GUIStyle(GUI.skin.label); _subHeaderStyle.fontSize = 16; _subHeaderStyle.alignment = (TextAnchor)4; _subHeaderStyle.normal.textColor = Color.white; Texture2D background = MakeSolidTexture(new Color(0.12f, 0.12f, 0.12f, 1f)); _opaqueWindowStyle = new GUIStyle(GUI.skin.window); _opaqueWindowStyle.normal.background = background; _opaqueWindowStyle.onNormal.background = background; _opaqueWindowStyle.focused.background = background; _opaqueWindowStyle.onFocused.background = background; _opaqueWindowStyle.hover.background = background; _opaqueWindowStyle.onHover.background = background; _opaqueWindowStyle.active.background = background; _opaqueWindowStyle.onActive.background = background; _bannerStyle = new GUIStyle(GUI.skin.box); _bannerStyle.alignment = (TextAnchor)4; _bannerStyle.fontSize = 18; _armedBannerBackground = MakeSolidTexture(new Color(0.12f, 0.12f, 0.12f, 1f)); _toastBannerBackground = MakeSolidTexture(new Color(0.05f, 0.3f, 0.05f, 1f)); } } private static Texture2D MakeSolidTexture(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); val.Apply(); return val; } private void OnGUI() { //IL_0000: 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_0028: Invalid comparison between Unknown and I4 //IL_009e: 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_00e1: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) GUI.color = Color.white; EnsureStyles(); bool flag = (Object)(object)Minimap.instance != (Object)null && (int)Minimap.instance.m_mode == 2; if (flag && !_mapWasOpen) { ShowPanel(); } else if (!flag && _mapWasOpen) { HidePanel(); } _mapWasOpen = flag; if (Toast.IsVisible) { DrawBanner(Toast.Message, _toastBannerBackground); } else if (ArmedAction.IsArmed) { DrawBanner(ArmedAction.GetHudText(), _armedBannerBackground); } if (_visible && flag) { _windowRect = GUILayout.Window(182001, _windowRect, new WindowFunction(DrawWindow), "", _opaqueWindowStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(_windowWidth), GUILayout.Height(_windowHeight) }); } } private void DrawBanner(string text, Texture2D background) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) float num = 700f; float num2 = 38f; Rect val = new Rect(((float)Screen.width - num) / 2f, 16f, num, num2); _bannerStyle.normal.background = background; GUI.Box(val, text, _bannerStyle); } private void DrawWindow(int id) { //IL_0057: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Label("M182", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.Label("M182AdminPanel", _subHeaderStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.color = ((_activeTab == Tab.Criaturas) ? Color.yellow : Color.white); if (GUILayout.Button("Creatures", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { _activeTab = Tab.Criaturas; } GUI.color = ((_activeTab == Tab.Raids) ? Color.yellow : Color.white); if (GUILayout.Button("Raids", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { _activeTab = Tab.Raids; } GUI.color = ((_activeTab == Tab.Items) ? Color.yellow : Color.white); if (GUILayout.Button("Items", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { _activeTab = Tab.Items; } GUI.color = ((_activeTab == Tab.Admin) ? Color.yellow : Color.white); if (GUILayout.Button("Admin", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { _activeTab = Tab.Admin; } GUI.color = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(10f); if (_activeTab == Tab.Criaturas) { DrawCreatureTab(); } else if (_activeTab == Tab.Raids) { DrawRaidTab(); } else if (_activeTab == Tab.Items) { DrawItemsTab(); } else { DrawAdminTab(); } GUILayout.EndVertical(); GUI.DragWindow(); } private void DrawCreatureTab() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Search creature:", _labelStyle, Array.Empty<GUILayoutOption>()); GUI.SetNextControlName("MCS_CreatureSearch"); string text = GUILayout.TextField(_creatureSearchText, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }); if (text != _creatureSearchText) { _creatureSearchText = text; RefreshCreatureList(); } float num = Mathf.Max(160f, _windowHeight - 430f); _creatureScrollPosition = GUILayout.BeginScrollView(_creatureScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) }); foreach (string filteredCreature in _filteredCreatures) { GUI.color = ((filteredCreature == _selectedCreatureName) ? Color.yellow : Color.white); if (GUILayout.Button(filteredCreature, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _selectedCreatureName = filteredCreature; } } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.Label("Selected: " + (_selectedCreatureName ?? "(none)"), _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.Label("Stars: " + _starLevel, _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i <= Plugin.MaxStarLevel.Value; i++) { GUI.color = ((_starLevel == i) ? Color.yellow : Color.white); if (GUILayout.Button(i.ToString(), _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) })) { _starLevel = i; } } GUI.color = Color.white; GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.Label("Quantity: " + _quantity, _labelStyle, Array.Empty<GUILayoutOption>()); _quantity = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)_quantity, 1f, (float)Plugin.MaxQuantity.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })); GUILayout.Space(14f); GUI.enabled = _selectedCreatureName != null; if (GUILayout.Button("Ready to spawn", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(44f) })) { Plugin.LastCreatureName.Value = _selectedCreatureName; Plugin.LastStarLevel.Value = _starLevel; Plugin.LastQuantity.Value = _quantity; ArmedAction.ArmCreature(_selectedCreatureName, _starLevel, _quantity); HidePanel(); } GUI.enabled = true; GUILayout.Space(6f); GUILayout.Label("Then hold Shift and click anywhere on the map. Repeat as many times as you want, Esc to stop.", _labelStyle, Array.Empty<GUILayoutOption>()); } private void DrawRaidTab() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Search raid:", _labelStyle, Array.Empty<GUILayoutOption>()); GUI.SetNextControlName("MCS_RaidSearch"); string text = GUILayout.TextField(_raidSearchText, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }); if (text != _raidSearchText) { _raidSearchText = text; RefreshRaidList(); } float num = Mathf.Max(160f, _windowHeight - 300f); _raidScrollPosition = GUILayout.BeginScrollView(_raidScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) }); foreach (string filteredRaid in _filteredRaids) { GUI.color = ((filteredRaid == _selectedRaidName) ? Color.yellow : Color.white); if (GUILayout.Button(filteredRaid, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _selectedRaidName = filteredRaid; } } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.Label("Selected: " + (_selectedRaidName ?? "(none)"), _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(14f); GUI.enabled = _selectedRaidName != null; if (GUILayout.Button("Ready to trigger", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(44f) })) { Plugin.LastRaidName.Value = _selectedRaidName; ArmedAction.ArmRaid(_selectedRaidName); HidePanel(); } GUI.enabled = true; GUILayout.Space(6f); GUILayout.Label("Then hold Shift and click on the map to confirm.", _labelStyle, Array.Empty<GUILayoutOption>()); } private void DrawCategoryButton(ItemCategory category, string label) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) GUI.color = ((_itemCategory == category) ? Color.yellow : Color.white); if (GUILayout.Button(label, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _itemCategory = category; RefreshItemList(); } GUI.color = Color.white; } private void DrawItemsTab() { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Search item:", _labelStyle, Array.Empty<GUILayoutOption>()); GUI.SetNextControlName("MCS_ItemSearch"); string text = GUILayout.TextField(_itemSearchText, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }); if (text != _itemSearchText) { _itemSearchText = text; RefreshItemList(); } GUILayout.Space(6f); GUILayout.Label("Category:", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawCategoryButton(ItemCategory.All, "All"); DrawCategoryButton(ItemCategory.Weapons, "Weapons"); DrawCategoryButton(ItemCategory.Armor, "Armor"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawCategoryButton(ItemCategory.Consumables, "Food"); DrawCategoryButton(ItemCategory.Tools, "Tools"); DrawCategoryButton(ItemCategory.Materials, "Materials"); DrawCategoryButton(ItemCategory.Misc, "Misc"); GUILayout.EndHorizontal(); float num = Mathf.Max(120f, _windowHeight - 660f); _itemScrollPosition = GUILayout.BeginScrollView(_itemScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num) }); foreach (ItemEntry filteredItem in _filteredItems) { GUI.color = ((filteredItem.InternalName == _selectedItemName) ? Color.yellow : Color.white); if (GUILayout.Button(filteredItem.DisplayName, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { _selectedItemName = filteredItem.InternalName; _selectedItemDisplayName = filteredItem.DisplayName; } } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.Label("Selected: " + (_selectedItemDisplayName ?? "(none)"), _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUILayout.Label("Quality: " + _itemQuality, _labelStyle, Array.Empty<GUILayoutOption>()); _itemQuality = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)_itemQuality, 1f, (float)Plugin.MaxItemQuality.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })); GUILayout.Space(6f); GUILayout.Label("Stack: " + _itemStack, _labelStyle, Array.Empty<GUILayoutOption>()); _itemStack = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)_itemStack, 1f, (float)Plugin.MaxItemStack.Value, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(24f) })); GUILayout.Space(14f); GUI.enabled = _selectedItemName != null; if (GUILayout.Button("Give to myself", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(44f) })) { Plugin.LastItemName.Value = _selectedItemName; Plugin.LastItemQuality.Value = _itemQuality; Plugin.LastItemStack.Value = _itemStack; ItemNetworking.GiveToSelf(_selectedItemName, _itemStack, _itemQuality); } GUI.enabled = true; } private void DrawToggleRow(string label, bool isOn, Action onToggle) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(_windowWidth - 160f) }); GUI.color = (isOn ? Color.green : Color.red); if (GUILayout.Button(isOn ? "ON" : "OFF", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Height(34f), GUILayout.Width(90f) })) { onToggle(); } GUI.color = Color.white; GUILayout.EndHorizontal(); } private void DrawAdminTab() { //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Self toggles", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); DrawToggleRow("God Mode", AdminToggles.IsGodMode, AdminToggles.ToggleGodMode); GUILayout.Space(4f); DrawToggleRow("Flying", AdminToggles.IsFlying, AdminToggles.ToggleFlying); GUILayout.Space(4f); DrawToggleRow("No Stamina Cost", AdminToggles.NoStaminaCost, AdminToggles.ToggleNoStaminaCost); GUILayout.Space(4f); DrawToggleRow("Infinite Carry Weight", AdminToggles.InfiniteWeight, AdminToggles.ToggleInfiniteWeight); GUILayout.Space(4f); DrawToggleRow("Free Building", AdminToggles.IsFreeBuild, AdminToggles.ToggleFreeBuild); GUILayout.Space(10f); if (GUILayout.Button("Reveal Entire Map (self only)", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { AdminToggles.RevealMap(); Toast.Show("Map fully revealed"); } GUILayout.Space(20f); GUILayout.Label("Weather", _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(6f); GUI.SetNextControlName("MCS_WeatherSearch"); string text = GUILayout.TextField(_weatherSearchText, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) }); if (text != _weatherSearchText) { _weatherSearchText = text; RefreshWeatherList(); } _weatherScrollPosition = GUILayout.BeginScrollView(_weatherScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(140f) }); foreach (string item in _filteredWeather) { GUI.color = ((item == _selectedWeatherName) ? Color.yellow : Color.white); if (GUILayout.Button(item, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) })) { _selectedWeatherName = item; } } GUI.color = Color.white; GUILayout.EndScrollView(); GUILayout.Space(6f); GUILayout.Label("Selected: " + (_selectedWeatherName ?? "(none)"), _labelStyle, Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.enabled = _selectedWeatherName != null; if (GUILayout.Button("Set Weather", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { WeatherNetworking.RequestSetWeather(_selectedWeatherName); } GUI.enabled = true; if (GUILayout.Button("Clear Override", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) })) { WeatherNetworking.RequestClearWeather(); } GUILayout.EndHorizontal(); } } public static class SpawnLogic { public static bool TrySpawn(string prefabName, int starLevel, int quantity, Vector3 centerPosition, out string error) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) error = null; GameObject val = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab(prefabName) : null); if ((Object)(object)val == (Object)null) { error = "No se encontro la criatura '" + prefabName + "'."; return false; } int num = Mathf.Clamp(starLevel, 0, Plugin.MaxStarLevel.Value); int num2 = Mathf.Clamp(quantity, 1, Plugin.MaxQuantity.Value); for (int i = 0; i < num2; i++) { Vector3 val2 = (Vector3)((num2 == 1) ? Vector3.zero : new Vector3(Random.Range(-2.5f, 2.5f), 0f, Random.Range(-2.5f, 2.5f))); Vector3 val3 = centerPosition + val2; if ((Object)(object)ZoneSystem.instance != (Object)null) { val3.y = ZoneSystem.instance.GetGroundHeight(val3); } Character component = Object.Instantiate<GameObject>(val, val3, Quaternion.identity).GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.SetLevel(num + 1); } } return true; } } public static class Toast { private static string _message = ""; private static float _hideTime; public static bool IsVisible => Time.time < _hideTime; public static string Message => _message; public static void Show(string message, float duration = 3f) { _message = message; _hideTime = Time.time + duration; } } public static class WeatherList { private static List<string> _cachedNames; public static List<string> GetAllWeatherNames() { if (_cachedNames != null) { return _cachedNames; } if ((Object)(object)EnvMan.instance == (Object)null) { return new List<string>(); } _cachedNames = new List<string>(); foreach (EnvSetup environment in EnvMan.instance.m_environments) { if (environment != null) { _cachedNames.Add(environment.m_name); } } _cachedNames.Sort(); return _cachedNames; } public static void InvalidateCache() { _cachedNames = null; } public static List<string> Filter(string search) { List<string> allWeatherNames = GetAllWeatherNames(); if (string.IsNullOrEmpty(search)) { return allWeatherNames; } string lowered = search.ToLowerInvariant(); return allWeatherNames.Where((string n) => n.ToLowerInvariant().Contains(lowered)).ToList(); } } public static class WeatherNetworking { [CompilerGenerated] private static class <>O { public static CoroutineHandler <0>__OnServerReceive; public static CoroutineHandler <1>__OnClientReceive; } private static CustomRPC _rpc; public static void Init() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown NetworkManager instance = NetworkManager.Instance; object obj = <>O.<0>__OnServerReceive; if (obj == null) { CoroutineHandler val = OnServerReceive; <>O.<0>__OnServerReceive = val; obj = (object)val; } object obj2 = <>O.<1>__OnClientReceive; if (obj2 == null) { CoroutineHandler val2 = OnClientReceive; <>O.<1>__OnClientReceive = val2; obj2 = (object)val2; } _rpc = instance.AddRPC("M182AdminPanel_SetWeather", (CoroutineHandler)obj, (CoroutineHandler)obj2); } public static void RequestSetWeather(string weatherName) { ApplyLocally(weatherName); BroadcastRequest(weatherName); } public static void RequestClearWeather() { ApplyLocally(""); BroadcastRequest(""); } private static void ApplyLocally(string weatherName) { if ((Object)(object)EnvMan.instance == (Object)null) { Plugin.Log.LogWarning((object)"EnvMan.instance es null, no se pudo aplicar el clima localmente."); return; } EnvMan.instance.SetForceEnvironment(weatherName); EnvMan.instance.ForceInstantEnvironmentSwitch(); Plugin.Log.LogInfo((object)(string.IsNullOrEmpty(weatherName) ? "Clima liberado (local)" : ("Clima forzado (local): " + weatherName))); Toast.Show(string.IsNullOrEmpty(weatherName) ? "Weather override cleared" : ("Weather set: " + weatherName)); } private static void BroadcastRequest(string weatherName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(weatherName ?? ""); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { RelayToOtherPeers(0L, val); return; } ZNetPeer val2 = RpcHelper.FindServerPeer(); if (val2 == null || _rpc == null) { Plugin.Log.LogWarning((object)"No se pudo enviar el clima a los demas jugadores."); return; } _rpc.SendPackage(new List<ZNetPeer> { val2 }, val); } private static IEnumerator OnServerReceive(long sender, ZPackage package) { RelayToOtherPeers(sender, package); yield break; } private static void RelayToOtherPeers(long sender, ZPackage package) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown string text = package.ReadString(); if (sender != 0L) { ZNetPeer val = (((Object)(object)ZNet.instance != (Object)null) ? ZNet.instance.GetPeer(sender) : null); string text2 = ((val != null && val.m_socket != null) ? val.m_socket.GetHostName() : null); if ((Object)(object)ZNet.instance == (Object)null || text2 == null || !RpcHelper.IsAdminId(text2)) { Plugin.Log.LogWarning((object)"Solicitud de clima rechazada: el remitente no es admin."); return; } } if ((Object)(object)ZNet.instance == (Object)null) { return; } ZPackage val2 = new ZPackage(); val2.Write(text); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer.m_uid != sender) { _rpc.SendPackage(new List<ZNetPeer> { peer }, val2); } } } private static IEnumerator OnClientReceive(long sender, ZPackage package) { ApplyLocally(package.ReadString()); yield break; } } }