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 Valheim Admin Tool v0.4.0
ValheimAdminTool.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; using ValheimAdminTool.Patches; using ValheimAdminTool.Protocol; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Valheim Admin Tool")] [assembly: AssemblyDescription("A 2D admin menu mod for Valheim.")] [assembly: AssemblyCompany("icecub")] [assembly: AssemblyProduct("Valheim Admin Tool")] [assembly: AssemblyCopyright("")] [assembly: ComVisible(false)] [assembly: Guid("e851069a-4938-47f0-9c1a-7e16b9bf622c")] [assembly: AssemblyFileVersion("0.4.0")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.4.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 ValheimAdminTool { internal sealed class AdminAccessState { private string nonce = string.Empty; private float started; private float toolsSeen; private float guardSeen; private bool toolsAdmin; private bool guardAdmin; internal float Now { get; set; } internal bool Connected { get; private set; } internal bool Host { get; private set; } internal bool ToolsPresent { get; private set; } internal bool GuardPresent { get; private set; } internal bool Discovering { get { if (Connected && !Host && !GuardPresent) { return Now - started < 5f; } return false; } } internal bool Allowed { get { if (Connected) { if (!Host) { if (!Discovering) { if (GuardPresent) { if (guardAdmin) { return Now - guardSeen <= 10f; } return false; } return true; } return false; } return true; } return false; } } internal bool ServerTools { get { if (Allowed) { if (!Host) { if (ToolsPresent && toolsAdmin) { return Now - toolsSeen <= 10f; } return false; } return true; } return false; } } internal bool LocalResets { get { if (Allowed && !Host) { return !ToolsPresent; } return false; } } internal bool ResourceResets { get { if (!ServerTools) { return LocalResets; } return true; } } internal void Begin(string sessionNonce, bool host, float now) { Reset(); nonce = sessionNonce; Connected = true; Host = host; float num = (Now = now); started = num; } internal bool Receive(bool guard, int version, string sessionNonce, bool admin, float now) { if (!Connected || Host || nonce != sessionNonce) { return false; } Now = now; if (guard) { GuardPresent = true; guardAdmin = version == 1 && admin; guardSeen = now; } else { ToolsPresent = true; toolsAdmin = version == 1 && admin; toolsSeen = now; } return true; } internal void Reset() { bool flag = (GuardPresent = (toolsAdmin = (guardAdmin = false))); bool flag3 = (ToolsPresent = flag); bool connected = (Host = flag3); Connected = connected; nonce = string.Empty; float num = (Now = 0f); started = (toolsSeen = (guardSeen = num)); } } internal static class AdminActions { private static readonly Dictionary<Collider, bool> SavedNoClipColliderStates = new Dictionary<Collider, bool>(); private static readonly MethodInfo GetSkillMethod = AccessTools.Method(typeof(Skills), "GetSkill", new Type[1] { typeof(SkillType) }, (Type[])null); private static readonly MethodInfo RebalanceSkillsMethod = AccessTools.Method(typeof(Skills), "RebalanceSkills", new Type[1] { typeof(SkillType) }, (Type[])null); private static readonly MethodInfo TameMethod = AccessTools.Method(typeof(Tameable), "Tame", (Type[])null, (Type[])null); private static readonly FieldRef<Skill, float> SkillLevelRef = AccessTools.FieldRefAccess<Skill, float>("m_level"); private static readonly FieldRef<Skill, float> SkillAccumulatorRef = AccessTools.FieldRefAccess<Skill, float>("m_accumulator"); private static readonly FieldRef<Skills, bool> UseSkillCapRef = AccessTools.FieldRefAccess<Skills, bool>("m_useSkillCap"); private static readonly FieldRef<Player, int> ComfortLevelRef = AccessTools.FieldRefAccess<Player, int>("m_comfortLevel"); private static bool requestedUnlimitedStamina; private static bool requestedUnlimitedEitr; private static bool requestedNoCarryLimit; private static bool requestedBuildEverywhere; private static bool requestedNoStructuralDamage; private static bool requestedDisableItemLoss; private static bool requestedDisableFoodLoss; private static bool requestedDisableStatusLoss; private static bool requestedDisableSkillLoss; private static bool requestedEnableWindInBack; private static bool requestedEnableShipSpeedHack; private static bool ownedGodMode; private static bool ownedDebugMode; private static bool ownedFlyMode; private static bool ownedNoClipMode; private static bool ownedFreeCamMode; private static bool ownedGhostMode; private static bool ownedNoBuildCost; private static readonly FieldInfo DevCommandsField = typeof(Terminal).GetField("m_cheat", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new MissingFieldException("Terminal", "m_cheat"); private static bool ownedDevCommands; private static bool requestedDisableDurabilityLoss; private static bool requestedDisableFoodDegradation; private static bool requestedMoonGravity; private static bool requestedSuperKnockback; private static bool requestedBouncyMode; private static bool requestedPartyHits; private static bool requestedInfiniteJumps; private static bool requestedMapTeleport; private static bool requestedUnrestrictedPortals; internal static bool UnlimitedStamina { get { if (AdminNetworkAccess.Allowed) { return requestedUnlimitedStamina; } return false; } private set { requestedUnlimitedStamina = value && AdminNetworkAccess.Allowed; } } internal static bool UnlimitedEitr { get { if (AdminNetworkAccess.Allowed) { return requestedUnlimitedEitr; } return false; } private set { requestedUnlimitedEitr = value && AdminNetworkAccess.Allowed; } } internal static bool NoCarryLimit { get { if (AdminNetworkAccess.Allowed) { return requestedNoCarryLimit; } return false; } private set { requestedNoCarryLimit = value && AdminNetworkAccess.Allowed; } } internal static bool BuildEverywhere { get { if (AdminNetworkAccess.Allowed) { return requestedBuildEverywhere; } return false; } private set { requestedBuildEverywhere = value && AdminNetworkAccess.Allowed; } } internal static bool NoStructuralDamage { get { if (AdminNetworkAccess.Allowed) { return requestedNoStructuralDamage; } return false; } private set { requestedNoStructuralDamage = value && AdminNetworkAccess.Allowed; } } internal static bool DisableItemLoss { get { if (AdminNetworkAccess.Allowed) { return requestedDisableItemLoss; } return false; } private set { requestedDisableItemLoss = value && AdminNetworkAccess.Allowed; } } internal static bool DisableFoodLoss { get { if (AdminNetworkAccess.Allowed) { return requestedDisableFoodLoss; } return false; } private set { requestedDisableFoodLoss = value && AdminNetworkAccess.Allowed; } } internal static bool DisableStatusLoss { get { if (AdminNetworkAccess.Allowed) { return requestedDisableStatusLoss; } return false; } private set { requestedDisableStatusLoss = value && AdminNetworkAccess.Allowed; } } internal static bool DisableSkillLoss { get { if (AdminNetworkAccess.Allowed) { return requestedDisableSkillLoss; } return false; } private set { requestedDisableSkillLoss = value && AdminNetworkAccess.Allowed; } } internal static bool EnableWindInBack { get { if (AdminNetworkAccess.Allowed) { return requestedEnableWindInBack; } return false; } private set { requestedEnableWindInBack = value && AdminNetworkAccess.Allowed; } } internal static bool EnableShipSpeedHack { get { if (AdminNetworkAccess.Allowed) { return requestedEnableShipSpeedHack; } return false; } private set { requestedEnableShipSpeedHack = value && AdminNetworkAccess.Allowed; } } internal static bool DisableDurabilityLoss { get { if (AdminNetworkAccess.Allowed) { return requestedDisableDurabilityLoss; } return false; } } internal static bool DisableFoodDegradation { get { if (AdminNetworkAccess.Allowed) { return requestedDisableFoodDegradation; } return false; } } internal static bool MoonGravity { get { if (AdminNetworkAccess.Allowed) { return requestedMoonGravity; } return false; } } internal static bool SuperKnockback { get { if (AdminNetworkAccess.Allowed) { return requestedSuperKnockback; } return false; } } internal static bool BouncyMode { get { if (AdminNetworkAccess.Allowed) { return requestedBouncyMode; } return false; } } internal static bool PartyHits { get { if (AdminNetworkAccess.Allowed) { return requestedPartyHits; } return false; } } internal static bool InfiniteJumps { get { if (AdminNetworkAccess.Allowed) { return requestedInfiniteJumps; } return false; } } internal static bool MapTeleport { get { if (AdminNetworkAccess.Allowed) { return requestedMapTeleport; } return false; } } internal static bool UnrestrictedPortals { get { if (AdminNetworkAccess.Allowed) { return requestedUnrestrictedPortals; } return false; } } internal static void ResetActiveCheats() { ResetMapTeleport(); ResetUnrestrictedPortals(); ResetFoodDegradation(); ResetDurabilityLoss(); ResetInfiniteJumps(); ResetFun(); AdminSpeeds.Reset(); if (ownedGodMode) { OnGodModeToggled(enabled: false); } if (ownedDebugMode) { OnDebugModeToggled(enabled: false); } if (ownedFlyMode) { OnFlyModeToggled(enabled: false); } if (ownedNoClipMode) { OnNoClipModeToggled(enabled: false); } if (ownedFreeCamMode) { OnFreeCamModeToggled(enabled: false); } if (ownedGhostMode) { OnGhostModeToggled(enabled: false); } if (ownedNoBuildCost) { OnNoBuildCostToggled(enabled: false); } requestedUnlimitedStamina = false; requestedUnlimitedEitr = false; requestedNoCarryLimit = false; requestedBuildEverywhere = false; requestedNoStructuralDamage = false; requestedDisableItemLoss = false; requestedDisableFoodLoss = false; requestedDisableStatusLoss = false; requestedDisableSkillLoss = false; requestedEnableWindInBack = false; requestedEnableShipSpeedHack = false; RestoreColliders(); EnvManSetTargetWindPatch.RestoreAllShipForces(); PlayerOnDeathPatch.ClearSnapshots(); } public static void OnGodModeToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { ownedGodMode = enabled; Player? localPlayer = GetLocalPlayer(); if (localPlayer != null) { localPlayer.SetGodMode(enabled); } } } public static void OnUnlimitedStaminaToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { UnlimitedStamina = enabled; } } public static void OnUnlimitedEitrToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { UnlimitedEitr = enabled; } } public static void OnFlyModeToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { ownedFlyMode = enabled; SetDebugFly(enabled); } } public static void OnNoClipModeToggled(bool enabled) { if (enabled && !AdminNetworkAccess.Allowed) { return; } ownedNoClipMode = enabled; Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { return; } SetDebugFly(enabled); if (enabled) { SavedNoClipColliderStates.Clear(); Collider[] componentsInChildren = ((Component)localPlayer).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { SavedNoClipColliderStates[val] = val.enabled; val.enabled = false; } } else { RestoreColliders(); } } private static void RestoreColliders() { foreach (KeyValuePair<Collider, bool> savedNoClipColliderState in SavedNoClipColliderStates) { if ((Object)(object)savedNoClipColliderState.Key != (Object)null) { savedNoClipColliderState.Key.enabled = savedNoClipColliderState.Value; } } SavedNoClipColliderStates.Clear(); } public static void OnFreeCamModeToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { ownedFreeCamMode = enabled; if (!((Object)(object)GameCamera.instance == (Object)null) && GameCamera.InFreeFly() != enabled) { GameCamera.instance.ToggleFreeFly(); } } } public static void OnGhostModeToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { ownedGhostMode = enabled; Player? localPlayer = GetLocalPlayer(); if (localPlayer != null) { localPlayer.SetGhostMode(enabled); } } } public static void OnNoCarryLimitToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { NoCarryLimit = enabled; } } public static void OnNoBuildCostToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { ownedNoBuildCost = enabled; Player? localPlayer = GetLocalPlayer(); if (localPlayer != null) { localPlayer.SetNoPlacementCost(enabled); } } } public static void OnBuildEverywhereToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { BuildEverywhere = enabled; } } public static void OnNoStructuralDamageToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { NoStructuralDamage = enabled; } } public static void OnDisableItemLossToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { DisableItemLoss = enabled; } } public static void OnDisableFoodLossToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { DisableFoodLoss = enabled; } } public static void OnDisableStatusLossToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { DisableStatusLoss = enabled; } } public static void OnDisableSkillLossToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { DisableSkillLoss = enabled; } } public static void OnEnableWindInBackToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { EnableWindInBack = enabled; } } public static void OnEnableShipSpeedHackToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { EnableShipSpeedHack = enabled; if (!enabled) { EnvManSetTargetWindPatch.RestoreLocalShipSailForce(); } } } public static void OnQuickHealClicked() { if (AdminNetworkAccess.Allowed) { Player localPlayer = GetLocalPlayer(); if (localPlayer != null) { ((Character)localPlayer).SetHealth(((Character)localPlayer).GetMaxHealth()); } } } public static void OnGiveOneHourRestedClicked() { if (AdminNetworkAccess.Allowed) { Player localPlayer = GetLocalPlayer(); if (!((Object)(object)localPlayer == (Object)null)) { int num = ComfortLevelRef.Invoke(localPlayer); ComfortLevelRef.Invoke(localPlayer) = 53; ((Character)localPlayer).GetSEMan().AddStatusEffect(SEMan.s_statusEffectRested, true, 0, 0f, (short)(-1)); ComfortLevelRef.Invoke(localPlayer) = num; } } } public static void OnExploreMapClicked() { if (AdminNetworkAccess.Allowed) { Minimap instance = Minimap.instance; if (instance != null) { instance.ExploreAll(); } } } public static void OnResetMapClicked() { if (AdminNetworkAccess.Allowed) { Minimap instance = Minimap.instance; if (instance != null) { instance.Reset(); } } } public static void OnBossPowerClicked(string statusEffectName) { if (AdminNetworkAccess.Allowed) { Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { ShowCenterMessage("Player is not ready yet."); return; } ((Character)localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode(statusEffectName), true, 0, 0f, (short)(-1)); ShowCenterMessage("Boss power activated."); } } public static void OnRunSkillChanged(int value) { SetSkill((SkillType)102, value); } public static void OnBowsSkillChanged(int value) { SetSkill((SkillType)8, value); } public static void OnSwordsSkillChanged(int value) { SetSkill((SkillType)1, value); } public static void OnCraftingSkillChanged(int value) { SetSkill((SkillType)107, value); } public static void OnFistsSkillChanged(int value) { SetSkill((SkillType)11, value); } public static void OnAxesSkillChanged(int value) { SetSkill((SkillType)7, value); } public static void OnBlockingSkillChanged(int value) { SetSkill((SkillType)6, value); } public static void OnClubsSkillChanged(int value) { SetSkill((SkillType)3, value); } public static void OnFarmingSkillChanged(int value) { SetSkill((SkillType)106, value); } public static void OnSneakSkillChanged(int value) { SetSkill((SkillType)101, value); } public static void OnJumpSkillChanged(int value) { SetSkill((SkillType)100, value); } public static void OnWoodCuttingSkillChanged(int value) { SetSkill((SkillType)13, value); } public static void OnCookingSkillChanged(int value) { SetSkill((SkillType)105, value); } public static void OnSwimSkillChanged(int value) { SetSkill((SkillType)103, value); } public static void OnKnivesSkillChanged(int value) { SetSkill((SkillType)2, value); } public static void OnPickaxesSkillChanged(int value) { SetSkill((SkillType)12, value); } public static void OnPolearmsSkillChanged(int value) { SetSkill((SkillType)4, value); } public static void OnCrossbowsSkillChanged(int value) { SetSkill((SkillType)14, value); } public static void OnResetDungeonsClicked() { AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Dungeons); } public static void OnResetResourcesClicked() { AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Resources); } public static void OnRegenerateNatureClicked() { AdminToolRpcs.RequestWorldReset(AdminToolRpcs.WorldResetKind.Nature); } public static void OnTeleportToPlayerClicked(string playerName) { AdminToolRpcs.RequestTool(ServerToolAction.TeleportToPlayer, playerName); } public static void OnTeleportPlayerToMeClicked(string playerName) { AdminToolRpcs.RequestTool(ServerToolAction.TeleportPlayerHere, playerName); } public static void OnKickPlayerClicked(string playerName) { AdminToolRpcs.RequestTool(ServerToolAction.KickPlayer, playerName); } public static void OnBanPlayerClicked(string playerName) { AdminToolRpcs.RequestTool(ServerToolAction.BanPlayer, playerName); } public static List<string> GetOnlinePlayerNames() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); if ((Object)(object)ZNet.instance == (Object)null) { return list; } foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { if (!string.IsNullOrWhiteSpace(player.m_name)) { list.Add(player.m_name); } } return (from name in list.Distinct() orderby name select name).ToList(); } public static List<AdminCreatureInfo> GetSpawnableCreatures() { return AdminCatalog.GetCreatures(); } public static void SpawnCreature(AdminCreatureInfo? creature, int level, bool tamed) { //IL_009a: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c8: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!AdminNetworkAccess.Allowed) { return; } Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null || creature == null) { ShowCenterMessage("Select a creature first."); return; } if ((Object)(object)ZNetScene.instance == (Object)null) { ShowCenterMessage("Creature database is not ready yet."); return; } GameObject prefab = ZNetScene.instance.GetPrefab(creature.PrefabName); if ((Object)(object)prefab == (Object)null) { ShowCenterMessage("Creature prefab was not found."); return; } if (tamed && (Object)(object)prefab.GetComponent<Tameable>() == (Object)null) { ShowCenterMessage(creature.DisplayName + " cannot be spawned as tamed."); return; } int num = Mathf.Clamp(level, 1, 3); Transform transform = ((Component)localPlayer).transform; Vector3 val = transform.position + transform.forward * 3f + Vector3.up * 0.5f; GameObject val2 = Object.Instantiate<GameObject>(prefab, val, Quaternion.LookRotation(transform.forward)); Character component = val2.GetComponent<Character>(); if ((Object)(object)component != (Object)null) { component.SetLevel(num); } if (tamed) { Tameable component2 = val2.GetComponent<Tameable>(); if ((Object)(object)component2 != (Object)null) { TameMethod.Invoke(component2, null); } } ShowCenterMessage($"Spawned level {num} {creature.DisplayName}."); } public static bool TryGetSkillLevel(SkillType skillType, out int level) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) level = 0; Skills localSkills = GetLocalSkills(); if ((Object)(object)localSkills == (Object)null || (int)skillType == 0 || (int)skillType == 999) { return false; } Skill skill = GetSkill(localSkills, skillType); if (skill == null) { return false; } level = Mathf.RoundToInt(Mathf.Clamp(SkillLevelRef.Invoke(skill), 0f, 100f)); return true; } public static void SetSkill(string name, float value) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) string text = name.Replace(" ", string.Empty); if (text.Equals("Fists", StringComparison.OrdinalIgnoreCase)) { text = "Unarmed"; } foreach (SkillType value2 in Enum.GetValues(typeof(SkillType))) { if (((object)value2/*cast due to .constrained prefix*/).ToString().Equals(text, StringComparison.OrdinalIgnoreCase)) { SetSkill(value2, value); break; } } } public static void LogPlaceholder(string actionName) { Plugin.Instance.Log.LogInfo((object)(actionName + " clicked.")); } private static bool TryGetOnlinePlayer(string playerName, out PlayerInfo playerInfo) { //IL_0001: 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_0038: 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) playerInfo = default(PlayerInfo); if ((Object)(object)ZNet.instance == (Object)null || string.IsNullOrWhiteSpace(playerName)) { return false; } foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { if (player.m_name.Equals(playerName, StringComparison.OrdinalIgnoreCase)) { playerInfo = player; return true; } } return false; } private static Player? GetLoadedPlayerByName(string playerName) { foreach (Player allPlayer in Player.GetAllPlayers()) { if (allPlayer.GetPlayerName().Equals(playerName, StringComparison.OrdinalIgnoreCase)) { return allPlayer; } } return null; } public static void SetSkill(SkillType skillType, float value) { //IL_0017: 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_0020: Invalid comparison between Unknown and I4 //IL_0024: 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) if (!AdminNetworkAccess.Allowed) { return; } Skills localSkills = GetLocalSkills(); if ((Object)(object)localSkills == (Object)null || (int)skillType == 0 || (int)skillType == 999) { return; } Skill skill = GetSkill(localSkills, skillType); if (skill != null) { SkillLevelRef.Invoke(skill) = Mathf.Clamp(value, 0f, 100f); SkillAccumulatorRef.Invoke(skill) = 0f; if (UseSkillCapRef.Invoke(localSkills)) { RebalanceSkillsMethod.Invoke(localSkills, new object[1] { skillType }); } } } private static Skill? GetSkill(Skills skills, SkillType skillType) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) object? obj = GetSkillMethod.Invoke(skills, new object[1] { skillType }); return (Skill?)((obj is Skill) ? obj : null); } private static Player? GetLocalPlayer() { return Player.m_localPlayer; } private static bool TryGetItemCategory(ItemType itemType, out AdminItemCategory category) { //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_0068: Expected I4, but got Unknown switch (itemType - 1) { case 8: case 22: category = AdminItemCategory.Ammo; return true; case 2: case 13: case 14: case 19: case 21: category = AdminItemCategory.Weapons; return true; case 3: category = AdminItemCategory.Bows; return true; case 5: case 6: case 10: case 11: case 16: category = AdminItemCategory.Armor; return true; case 4: category = AdminItemCategory.Shields; return true; case 18: category = AdminItemCategory.Tools; return true; case 1: case 20: category = AdminItemCategory.Food; return true; case 0: category = AdminItemCategory.Materials; return true; case 12: category = AdminItemCategory.Trophies; return true; case 17: case 23: category = AdminItemCategory.Accessories; return true; default: category = AdminItemCategory.Other; return true; } } private static Sprite? TryGetItemIcon(ItemData itemData) { Sprite[] icons = itemData.m_shared.m_icons; int variant = itemData.m_variant; if (icons == null || icons.Length == 0) { return null; } if (variant < 0 || variant >= icons.Length) { return icons[0]; } return icons[variant]; } private static void ShowCenterMessage(string message) { Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false); } else { Plugin.Instance.Log.LogInfo((object)message); } } private static Skills? GetLocalSkills() { Player? localPlayer = GetLocalPlayer(); if (localPlayer == null) { return null; } return ((Character)localPlayer).GetSkills(); } private static void SetDebugFly(bool enabled) { Player localPlayer = GetLocalPlayer(); if (!((Object)(object)localPlayer == (Object)null) && ((Character)localPlayer).IsDebugFlying() != enabled) { localPlayer.ToggleDebugFly(); } } public static void OnDebugModeToggled(bool enabled) { if (enabled && !AdminNetworkAccess.Allowed) { return; } if (enabled) { if (!(bool)DevCommandsField.GetValue(null)) { DevCommandsField.SetValue(null, true); ownedDevCommands = true; } } else if (ownedDevCommands) { DevCommandsField.SetValue(null, false); ownedDevCommands = false; } ownedDebugMode = enabled; Player.m_debugMode = enabled; } internal static void TrackNativeDebugFly(Player player, bool enabled) { if ((Object)(object)player == (Object)(object)Player.m_localPlayer && ownedDebugMode && AdminNetworkAccess.Allowed) { ownedFlyMode = enabled; } } internal static void TrackNativeDebugBuild(Player player, bool enabled) { if ((Object)(object)player == (Object)(object)Player.m_localPlayer && ownedDebugMode && AdminNetworkAccess.Allowed) { ownedNoBuildCost = enabled; } } public static void OnDisableDurabilityLossToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedDisableDurabilityLoss = enabled; } } internal static void ResetDurabilityLoss() { requestedDisableDurabilityLoss = false; } public static void OnDisableFoodDegradationToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedDisableFoodDegradation = enabled; } } internal static void ResetFoodDegradation() { requestedDisableFoodDegradation = false; } public static void OnMoonGravityToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedMoonGravity = enabled; } } public static void OnSuperKnockbackToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedSuperKnockback = enabled; } } public static void OnBouncyModeToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedBouncyMode = enabled; AdminFun.ResetBounce(); } } public static void OnPartyHitsToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedPartyHits = enabled; if (!enabled) { AdminPartyHits.Clear(); } } } internal static void ResetFun() { requestedMoonGravity = (requestedSuperKnockback = (requestedBouncyMode = (requestedPartyHits = false))); AdminFun.Reset(); AdminPartyHits.Clear(); } internal static List<AdminCheatCommand> CreateCheatCommands() { return new List<AdminCheatCommand> { new AdminCheatCommand("GodMode", "God Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InGodMode(), OnGodModeToggled), new AdminCheatCommand("DebugMode", "Debug Mode", "Cheats", () => Player.m_debugMode, OnDebugModeToggled), new AdminCheatCommand("UnlimitedStamina", "Unlimited Stamina", "Cheats", () => UnlimitedStamina, OnUnlimitedStaminaToggled), new AdminCheatCommand("UnlimitedEitr", "Unlimited Eitr", "Cheats", () => UnlimitedEitr, OnUnlimitedEitrToggled), new AdminCheatCommand("FlyMode", "Fly Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.InDebugFlyMode(), OnFlyModeToggled), new AdminCheatCommand("InfiniteJumps", "Infinite Jumps", "Cheats", () => InfiniteJumps, OnInfiniteJumpsToggled), new AdminCheatCommand("NoClipMode", "NoClip Mode", "Cheats", () => ownedNoClipMode, OnNoClipModeToggled), new AdminCheatCommand("FreeCamMode", "FreeCam Mode", "Cheats", () => GameCamera.InFreeFly(), OnFreeCamModeToggled), new AdminCheatCommand("GhostMode", "Ghost Mode", "Cheats", () => (Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).InGhostMode(), OnGhostModeToggled), new AdminCheatCommand("NoCarryLimit", "No Carry Limit", "Cheats", () => NoCarryLimit, OnNoCarryLimitToggled), new AdminCheatCommand("NoBuildCost", "No Build Cost", "Cheats", () => ownedNoBuildCost, OnNoBuildCostToggled), new AdminCheatCommand("BuildEverywhere", "Build Everywhere", "Cheats", () => BuildEverywhere, OnBuildEverywhereToggled), new AdminCheatCommand("NoStructuralDamage", "No Structural Damage", "Cheats", () => NoStructuralDamage, OnNoStructuralDamageToggled), new AdminCheatCommand("MapTeleport", "Map Teleport", "Cheats", () => MapTeleport, OnMapTeleportToggled), new AdminCheatCommand("UnrestrictedPortals", "Unrestricted Portals", "Cheats", () => UnrestrictedPortals, OnUnrestrictedPortalsToggled), new AdminCheatCommand("DisableFoodDegradation", "Disable Food Degradation", "Cheats", () => DisableFoodDegradation, OnDisableFoodDegradationToggled), new AdminCheatCommand("DisableDurabilityLoss", "Disable Durability Loss", "Cheats", () => DisableDurabilityLoss, OnDisableDurabilityLossToggled), new AdminCheatCommand("DisableItemLoss", "Disable Item Loss", "Death protection", () => DisableItemLoss, OnDisableItemLossToggled), new AdminCheatCommand("DisableFoodLoss", "Disable Food Loss", "Death protection", () => DisableFoodLoss, OnDisableFoodLossToggled), new AdminCheatCommand("DisableStatusLoss", "Disable Status Loss", "Death protection", () => DisableStatusLoss, OnDisableStatusLossToggled), new AdminCheatCommand("DisableSkillLoss", "Disable Skill Loss", "Death protection", () => DisableSkillLoss, OnDisableSkillLossToggled), new AdminCheatCommand("MoonGravity", "Moon Gravity", "Fun", () => MoonGravity, OnMoonGravityToggled), new AdminCheatCommand("SuperKnockback", "Super Knockback", "Fun", () => SuperKnockback, OnSuperKnockbackToggled), new AdminCheatCommand("BouncyMode", "Bouncy Mode", "Fun", () => BouncyMode, OnBouncyModeToggled), new AdminCheatCommand("PartyHits", "Party Hits", "Fun", () => PartyHits, OnPartyHitsToggled), new AdminCheatCommand("WindInBack", "Wind in back", "Ship", () => EnableWindInBack, OnEnableWindInBackToggled), new AdminCheatCommand("ShipSpeed", "Speed hack", "Ship", () => EnableShipSpeedHack, OnEnableShipSpeedHackToggled), new AdminCheatCommand("QuickHeal", "Quick Heal", "Quick actions", OnQuickHealClicked), new AdminCheatCommand("Rested", "Give 1H Rested", "Quick actions", OnGiveOneHourRestedClicked), new AdminCheatCommand("ExploreMap", "Explore Map", "Quick actions", OnExploreMapClicked), new AdminCheatCommand("ResetMap", "Reset Map", "Quick actions", OnResetMapClicked), new AdminCheatCommand("BossPowerEikthyr", "Eikthyr", "Boss powers", delegate { OnBossPowerClicked("GP_Eikthyr"); }), new AdminCheatCommand("BossPowerElder", "The Elder", "Boss powers", delegate { OnBossPowerClicked("GP_TheElder"); }), new AdminCheatCommand("BossPowerBonemass", "Bonemass", "Boss powers", delegate { OnBossPowerClicked("GP_Bonemass"); }), new AdminCheatCommand("BossPowerModer", "Moder", "Boss powers", delegate { OnBossPowerClicked("GP_Moder"); }), new AdminCheatCommand("BossPowerYagluth", "Yagluth", "Boss powers", delegate { OnBossPowerClicked("GP_Yagluth"); }), new AdminCheatCommand("BossPowerQueen", "The Queen", "Boss powers", delegate { OnBossPowerClicked("GP_Queen"); }), new AdminCheatCommand("BossPowerFader", "Fader", "Boss powers", delegate { OnBossPowerClicked("GP_Fader"); }) }; } public static List<AdminItemInfo> GetSpawnableItems() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) List<AdminItemInfo> list = new List<AdminItemInfo>(); if ((Object)(object)ObjectDB.instance == (Object)null) { return list; } IEnumerable<GameObject> enumerable = ObjectDB.instance.m_items; if ((Object)(object)ZNetScene.instance != (Object)null) { enumerable = enumerable.Concat(from name in ZNetScene.instance.GetPrefabNames() select ZNetScene.instance.GetPrefab(name)); } foreach (GameObject item in enumerable.Distinct()) { if (!((Object)(object)item == (Object)null)) { ItemDrop component = item.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && TryGetItemCategory(component.m_itemData.m_shared.m_itemType, out var category)) { string displayName = AdminCatalog.DisplayName(component.m_itemData.m_shared.m_name, ((Object)item).name); Sprite icon = TryGetItemIcon(component.m_itemData); list.Add(new AdminItemInfo(((Object)item).name, displayName, category, icon, component.m_itemData.m_shared.m_maxQuality)); } } } return (from item in list group item by item.PrefabName into @group select @group.First() into item orderby item.DisplayName select item).ToList(); } public static void SpawnItemInWorld(AdminItemInfo? item, int amount, int quality = 1) { //IL_00d2: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (!AdminNetworkAccess.Allowed) { return; } Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null || item == null) { ShowCenterMessage("Select an item first."); return; } if ((Object)(object)ObjectDB.instance == (Object)null) { ShowCenterMessage("Item database is not ready yet."); return; } object obj = ObjectDB.instance.GetItemPrefab(item.PrefabName); if (obj == null) { ZNetScene instance = ZNetScene.instance; obj = ((instance != null) ? instance.GetPrefab(item.PrefabName) : null); } GameObject val = (GameObject)obj; ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { ShowCenterMessage("Item prefab was not found."); return; } int num = Mathf.Clamp(amount, 1, 100); int num2 = num; int num3 = ClampItemQuality(val2.m_itemData, quality); int num4 = Mathf.Max(1, val2.m_itemData.m_shared.m_maxStackSize); Vector3 val3 = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 2f + Vector3.up; while (num2 > 0) { int num5 = Mathf.Min(num2, num4); Vector3 val4 = val3 + Random.insideUnitSphere * 0.35f; val4.y = val3.y; ItemDrop component = Object.Instantiate<GameObject>(val, val4, Quaternion.identity).GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { component.SetQuality(num3); component.SetStack(num5); RepairItem(component.m_itemData); component.Save(); } num2 -= num5; } ShowCenterMessage($"Spawned {num} x {item.DisplayName} (quality {num3})."); } public static void SpawnItemInInventory(AdminItemInfo? item, int amount, int quality = 1) { if (!AdminNetworkAccess.Allowed) { return; } Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null || item == null) { ShowCenterMessage("Select an item first."); return; } if ((Object)(object)ObjectDB.instance == (Object)null) { ShowCenterMessage("Item database is not ready yet."); return; } object obj = ObjectDB.instance.GetItemPrefab(item.PrefabName); if (obj == null) { ZNetScene instance = ZNetScene.instance; obj = ((instance != null) ? instance.GetPrefab(item.PrefabName) : null); } GameObject val = (GameObject)obj; ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { ShowCenterMessage("Item prefab was not found."); return; } int num = Mathf.Clamp(amount, 1, 100); ItemData val3 = val2.m_itemData.Clone(); val3.m_dropPrefab = val; val3.m_quality = ClampItemQuality(val3, quality); val3.m_worldLevel = (byte)Game.m_worldLevel; RepairItem(val3); Inventory inventory = ((Humanoid)localPlayer).GetInventory(); if (!CanFitItemQuality(inventory, val3, num)) { ShowCenterMessage("Not enough inventory space."); return; } int num2 = num; while (num2 > 0) { ItemData val4 = val3.Clone(); val4.m_stack = Mathf.Min(num2, Mathf.Max(1, val4.m_shared.m_maxStackSize)); int stack = val4.m_stack; if (!inventory.AddItem(val4)) { ShowCenterMessage("Could not add all items to inventory."); return; } num2 -= stack; } ShowCenterMessage($"Added {num} x {item.DisplayName} (quality {val3.m_quality})."); } private static int ClampItemQuality(ItemData item, int quality) { return Mathf.Clamp(quality, 1, Mathf.Max(1, item.m_shared.m_maxQuality)); } private static bool CanFitItemQuality(Inventory inventory, ItemData item, int amount) { if (!inventory.CanAddItem(item, amount)) { return false; } long num = (long)Mathf.Max(0, inventory.GetEmptySlots()) * (long)Mathf.Max(1, item.m_shared.m_maxStackSize); if (item.m_shared.m_maxStackSize > 1) { foreach (ItemData allItem in inventory.GetAllItems()) { if (allItem.m_shared.m_name == item.m_shared.m_name && allItem.m_quality == item.m_quality && allItem.m_worldLevel == item.m_worldLevel) { num += Mathf.Max(0, allItem.m_shared.m_maxStackSize - allItem.m_stack); } } } return num >= amount; } private static void RepairItem(ItemData itemData) { if (itemData.m_shared.m_useDurability) { itemData.m_durability = itemData.GetMaxDurability(); } } public static void OnInfiniteJumpsToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedInfiniteJumps = enabled; } } internal static void ResetInfiniteJumps() { requestedInfiniteJumps = false; } public static void OnMapTeleportToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedMapTeleport = enabled; AdminMapTeleport.ResetClick(); } } private static void ResetMapTeleport() { requestedMapTeleport = false; AdminMapTeleport.ResetClick(); } public static void OnUnrestrictedPortalsToggled(bool enabled) { if (!enabled || AdminNetworkAccess.Allowed) { requestedUnrestrictedPortals = enabled; } } internal static void ResetUnrestrictedPortals() { requestedUnrestrictedPortals = false; } } internal static class AdminCatalog { public static string DisplayName(string token, string fallback) { string text = ((Localization.instance != null) ? Localization.instance.Localize(token) : token); if (!string.IsNullOrWhiteSpace(text) && !text.StartsWith("$")) { return text; } return fallback; } public static List<SkillType> GetSkills() { Player localPlayer = Player.m_localPlayer; Skills val = ((localPlayer != null) ? ((Character)localPlayer).GetSkills() : null); return (((Object)(object)val != (Object)null) ? val.m_skills.Select((SkillDef def) => def.m_skill) : Enum.GetValues(typeof(SkillType)).Cast<SkillType>()).Where((SkillType type) => (int)type != 0 && (int)type != 999).Distinct().ToList(); } public unsafe static string SkillName(SkillType type) { return DisplayName("$skill_" + ((object)(*(SkillType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant(), Regex.Replace(((object)(*(SkillType*)(&type))/*cast due to .constrained prefix*/).ToString(), "([a-z])([A-Z])", "$1 $2")); } public static List<AdminCreatureInfo> GetCreatures() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) ZNetScene scene = ZNetScene.instance; if ((Object)(object)scene == (Object)null) { return new List<AdminCreatureInfo>(); } Dictionary<string, Biome> dictionary = new Dictionary<string, Biome>(AdminCreatureBiomes.Memberships); IEnumerable<SpawnSystem> enumerable = Object.FindObjectsByType<SpawnSystem>((FindObjectsSortMode)0); if ((Object)(object)ZoneSystem.instance != (Object)null && (Object)(object)ZoneSystem.instance.m_zoneCtrlPrefab != (Object)null) { enumerable = enumerable.Concat(ZoneSystem.instance.m_zoneCtrlPrefab.GetComponents<SpawnSystem>()); } foreach (SpawnSystemList item in enumerable.SelectMany((SpawnSystem system) => system.m_spawnLists).Distinct()) { foreach (SpawnData spawner in item.m_spawners) { AddSpawn(spawner, spawner.m_biome, dictionary); } } foreach (AltBiome item2 in AltBiomeList.m_altBiomes.Where((AltBiome alt) => alt.m_enabled)) { foreach (SpawnData item3 in item2.m_spawn) { AddSpawn(item3, (Biome)(item3.m_biome & item2.m_biome), dictionary); } } List<AdminCreatureInfo> list = new List<AdminCreatureInfo>(); foreach (GameObject item4 in (from name in scene.GetPrefabNames() select scene.GetPrefab(name)).Distinct()) { if ((Object)(object)item4 == (Object)null || (Object)(object)item4.GetComponent<Player>() != (Object)null) { continue; } Character component = item4.GetComponent<Character>(); Fish component2 = item4.GetComponent<Fish>(); if ((Object)(object)component == (Object)null && (Object)(object)component2 == (Object)null && (Object)(object)item4.GetComponent<RandomFlyingBird>() == (Object)null && (Object)(object)item4.GetComponent<Leviathan>() == (Object)null) { continue; } string displayName = DisplayName(((Object)(object)component != (Object)null) ? component.m_name : (((Object)(object)component2 != (Object)null) ? component2.m_name : ""), ((Object)item4).name); bool canSpawnTamed = (Object)(object)item4.GetComponent<Tameable>() != (Object)null; dictionary.TryGetValue(((Object)item4).name, out var value); bool flag = false; foreach (AdminCreatureBiome value2 in Enum.GetValues(typeof(AdminCreatureBiome))) { if (Enum.TryParse<Biome>(value2.ToString(), ignoreCase: true, out Biome result) && value2 != AdminCreatureBiome.All && (value & result) != 0) { list.Add(new AdminCreatureInfo(((Object)item4).name, displayName, value2, canSpawnTamed)); flag = true; } } if (!flag) { list.Add(new AdminCreatureInfo(((Object)item4).name, displayName, AdminCreatureBiome.Other, canSpawnTamed)); } } return (from creature in list orderby creature.DisplayName, creature.PrefabName select creature).ToList(); } private static void AddSpawn(SpawnData spawn, Biome mask, Dictionary<string, Biome> memberships) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (spawn.m_enabled && !spawn.m_devDisabled && !((Object)(object)spawn.m_prefab == (Object)null) && (int)mask != 895 && (int)mask != -1) { AddSpawnPrefab(spawn.m_prefab, mask, memberships, new HashSet<GameObject>()); } } private static void AddSpawnPrefab(GameObject prefab, Biome mask, Dictionary<string, Biome> memberships, HashSet<GameObject> visited) { //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) //IL_002b: 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_00a4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)prefab == (Object)null || !visited.Add(prefab)) { return; } memberships.TryGetValue(((Object)prefab).name, out var value); memberships[((Object)prefab).name] = (Biome)(value | mask); CreatureSpawner[] componentsInChildren = prefab.GetComponentsInChildren<CreatureSpawner>(true); for (int i = 0; i < componentsInChildren.Length; i++) { AddSpawnPrefab(componentsInChildren[i].m_creaturePrefab, mask, memberships, visited); } SpawnArea[] componentsInChildren2 = prefab.GetComponentsInChildren<SpawnArea>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { foreach (SpawnData item in componentsInChildren2[i].m_prefabs.Where((SpawnData entry) => entry.m_weight > 0f)) { AddSpawnPrefab(item.m_prefab, mask, memberships, visited); } } } public static List<AdminItemInfo> FilterItems(IEnumerable<AdminItemInfo> items, AdminItemCategory category, string query) { string search = query.Trim(); return (from item in items where (search.Length != 0) ? Matches(item.DisplayName, item.PrefabName, search) : (item.Category == category) group item by item.PrefabName into @group select @group.First()).ToList(); } public static List<AdminCreatureInfo> FilterCreatures(IEnumerable<AdminCreatureInfo> creatures, AdminCreatureBiome biome, string query) { string search = query.Trim(); return (from creature in creatures.Where(delegate(AdminCreatureInfo creature) { if (search.Length != 0) { return Matches(creature.DisplayName, creature.PrefabName, search); } return biome == AdminCreatureBiome.All || creature.Biome == biome; }) group creature by creature.PrefabName into @group select @group.First()).ToList(); } private static bool Matches(string displayName, string prefabName, string search) { if (displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) < 0) { return prefabName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0; } return true; } } internal sealed class AdminCheatCommand { private readonly Func<bool>? read; private readonly Action<bool>? write; private readonly Action? action; internal string Id { get; } internal string Name { get; } internal string Group { get; } internal bool IsToggle => read != null; internal bool Enabled { get { if (AdminNetworkAccess.Allowed) { return read?.Invoke() ?? false; } return false; } } internal AdminCheatCommand(string id, string name, string group, Func<bool> read, Action<bool> write) { Id = id; Name = name; Group = group; this.read = read; this.write = write; } internal AdminCheatCommand(string id, string name, string group, Action action) { Id = id; Name = name; Group = group; this.action = action; } internal void Execute() { if (AdminNetworkAccess.Allowed) { if (IsToggle) { write(!Enabled); AdminNetworkAccess.ShowMessage(Name + ": " + (Enabled ? "On" : "Off")); } else { action(); } } } internal bool ApplySavedState(bool enabled) { if (!IsToggle || !AdminNetworkAccess.Allowed) { return false; } write(enabled); return true; } } internal static class AdminCreatureBiomes { internal static readonly Dictionary<string, Biome> Memberships = new Dictionary<string, Biome> { ["Abomination"] = (Biome)2, ["AshCrow"] = (Biome)32, ["Asksvin"] = (Biome)32, ["Asksvin_hatchling"] = (Biome)32, ["Barka"] = (Biome)64, ["Bat"] = (Biome)4, ["Bjorn"] = (Biome)8, ["Bjorn_sleeping"] = (Biome)8, ["Blob"] = (Biome)2, ["BlobElite"] = (Biome)2, ["BlobLava"] = (Biome)32, ["BlobMork"] = (Biome)64, ["BlobTar"] = (Biome)16, ["Boar"] = (Biome)1, ["Boar_piggy"] = (Biome)1, ["BogWitchKvastur"] = (Biome)2, ["Bonemass"] = (Biome)2, ["BonemawSerpent"] = (Biome)32, ["Charred_Archer"] = (Biome)63, ["Charred_Mage"] = (Biome)32, ["Charred_Melee"] = (Biome)63, ["Charred_Melee_Dyrnwyn"] = (Biome)32, ["Charred_Twitcher"] = (Biome)32, ["Crow"] = (Biome)10, ["Deathsquito"] = (Biome)16, ["Deer"] = (Biome)9, ["Dragon"] = (Biome)4, ["Draugr"] = (Biome)31, ["Draugr_Elite"] = (Biome)3, ["Draugr_Ranged"] = (Biome)3, ["Dverger"] = (Biome)512, ["DvergerAshlands"] = (Biome)32, ["DvergerDeepNorth"] = (Biome)64, ["DvergerMage"] = (Biome)512, ["Eikthyr"] = (Biome)1, ["Elaking"] = (Biome)64, ["ElakingLantern"] = (Biome)64, ["ElakingMole"] = (Biome)64, ["Fader"] = (Biome)32, ["FallenValkyrie"] = (Biome)32, ["FallenWarrior"] = (Biome)64, ["Fenring"] = (Biome)4, ["Fenring_Cultist"] = (Biome)4, ["Fenring_Cultist_Hildir"] = (Biome)4, ["Fish1"] = (Biome)25, ["Fish10"] = (Biome)64, ["Fish11"] = (Biome)32, ["Fish12"] = (Biome)768, ["Fish2"] = (Biome)25, ["Fish3"] = (Biome)256, ["Fish4_cave"] = (Biome)4, ["Fish5"] = (Biome)8, ["Fish6"] = (Biome)2, ["Fish7"] = (Biome)16, ["Fish8"] = (Biome)256, ["Fish9"] = (Biome)512, ["FrozenKing"] = (Biome)64, ["Ghost"] = (Biome)8, ["Gjall"] = (Biome)512, ["Goblin"] = (Biome)29, ["GoblinArcher"] = (Biome)16, ["GoblinBrute"] = (Biome)16, ["GoblinBruteBros"] = (Biome)16, ["GoblinDeepNorth"] = (Biome)64, ["GoblinKing"] = (Biome)16, ["GoblinShaman"] = (Biome)16, ["Greydwarf"] = (Biome)9, ["Greydwarf_Elite"] = (Biome)9, ["Greydwarf_Frozen"] = (Biome)64, ["Greydwarf_Shaman"] = (Biome)9, ["Greydwarf_Shaman_Frozen"] = (Biome)64, ["Greyling"] = (Biome)1, ["Hare"] = (Biome)512, ["Hatchling"] = (Biome)4, ["JotunWarrior"] = (Biome)64, ["JotunWarriorDualWield"] = (Biome)64, ["JotunWitch"] = (Biome)64, ["Leech"] = (Biome)2, ["Leviathan"] = (Biome)256, ["LeviathanLava"] = (Biome)32, ["Lox"] = (Biome)16, ["Lox_Calf"] = (Biome)16, ["Moose"] = (Biome)64, ["Moose_calf"] = (Biome)64, ["Morgen"] = (Biome)32, ["Morgen_NonSleeping"] = (Biome)32, ["Neck"] = (Biome)1, ["Seagal"] = (Biome)281, ["Seal"] = (Biome)64, ["Seal_Pup"] = (Biome)64, ["Seeker"] = (Biome)543, ["SeekerBrood"] = (Biome)512, ["SeekerBrute"] = (Biome)512, ["SeekerQueen"] = (Biome)512, ["Serpent"] = (Biome)256, ["ShadowPerson"] = (Biome)64, ["Skeleton"] = (Biome)31, ["Skeleton_DeepNorth"] = (Biome)64, ["Skeleton_Hildir"] = (Biome)8, ["Skeleton_Meadows_noarcher"] = (Biome)9, ["Skeleton_Mountains"] = (Biome)4, ["Skeleton_Poison"] = (Biome)8, ["Skeleton_Swamps"] = (Biome)2, ["StoneGolem"] = (Biome)4, ["Surtling"] = (Biome)2, ["Tick"] = (Biome)512, ["Troll"] = (Biome)8, ["TrollFrost"] = (Biome)64, ["Ulv"] = (Biome)4, ["Unbjorn"] = (Biome)16, ["Volture"] = (Biome)32, ["Wolf"] = (Biome)4, ["Wolf_cub"] = (Biome)4, ["Wraith"] = (Biome)2, ["Writhan"] = (Biome)2, ["gd_king"] = (Biome)8 }; } internal enum AdminCreatureBiome { Meadows, BlackForest, Ocean, Swamp, Mountain, Plains, Mistlands, Ashlands, DeepNorth, All, Other } internal sealed class AdminCreatureInfo { public string PrefabName { get; } public string DisplayName { get; } public AdminCreatureBiome Biome { get; } public bool CanSpawnTamed { get; } public AdminCreatureInfo(string prefabName, string displayName, AdminCreatureBiome biome, bool canSpawnTamed) { PrefabName = prefabName; DisplayName = displayName; Biome = biome; CanSpawnTamed = canSpawnTamed; } } internal enum AdminEspCategory { Players, Creatures, DroppedItems, Resources, Pickables, Dungeons } internal static class AdminEsp { private readonly struct EspTarget { private readonly string searchLabel; private readonly string searchPrefab; private readonly string searchName; public Transform Target { get; } public string Label { get; } public Color Color { get; } public bool DrawBox { get; } public EspTarget(Transform target, string label, Color color, bool drawBox, string rawName, string prefabName) { //IL_000f: 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) Target = target; Label = label; Color = color; DrawBox = drawBox; searchLabel = AdminEspNames.NormalizeSearch(label); searchPrefab = AdminEspNames.NormalizeSearch(prefabName); searchName = AdminEspNames.NormalizeSearch(rawName); } internal bool MatchesSearch(string query) { if (query.Length != 0 && !AdminEspNames.Contains(searchLabel, query) && !AdminEspNames.Contains(searchPrefab, query)) { return AdminEspNames.Contains(searchName, query); } return true; } } private const float RefreshInterval = 1.5f; private const float MinDrawDistance = 2f; private static readonly Dictionary<AdminEspCategory, bool> CategoryStates = new Dictionary<AdminEspCategory, bool> { [AdminEspCategory.Players] = false, [AdminEspCategory.Creatures] = false, [AdminEspCategory.DroppedItems] = false, [AdminEspCategory.Resources] = false, [AdminEspCategory.Pickables] = false, [AdminEspCategory.Dungeons] = false }; private static readonly FieldRef<LocationProxy, GameObject> LocationInstanceRef = AccessTools.FieldRefAccess<LocationProxy, GameObject>("m_instance"); private static readonly List<EspTarget> Targets = new List<EspTarget>(); private static Texture2D? pixelTexture; private static GUIStyle? labelStyle; private static float nextRefreshTime; private static string searchText = string.Empty; private static string searchQuery = string.Empty; public static string SearchText { get { return searchText; } set { searchText = value ?? string.Empty; searchQuery = AdminEspNames.NormalizeSearch(searchText); } } public static int MaxDistance { get; set; } = 300; public static bool IsEnabled { get { if (AdminNetworkAccess.Allowed) { return CategoryStates.Values.Any((bool enabled) => enabled); } return false; } } public static bool GetCategoryEnabled(AdminEspCategory category) { bool value; return CategoryStates.TryGetValue(category, out value) && value; } public static void SetCategoryEnabled(AdminEspCategory category, bool enabled) { CategoryStates[category] = enabled && AdminNetworkAccess.Allowed; InvalidateTargets(); } internal static void Reset() { AdminEspCategory[] array = CategoryStates.Keys.ToArray(); foreach (AdminEspCategory key in array) { CategoryStates[key] = false; } InvalidateTargets(); } internal static void InvalidateTargets() { Targets.Clear(); nextRefreshTime = 0f; } public static void Update() { if (IsEnabled && !(Time.time < nextRefreshTime)) { nextRefreshTime = Time.time + 1.5f; RefreshTargets(); } } public static void Draw() { //IL_0074: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00b3: 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) //IL_00e6: 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) if (!IsEnabled || (Object)(object)Camera.main == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } EnsureGuiResources(); Camera main = Camera.main; EspTarget[] array = Targets.ToArray(); for (int i = 0; i < array.Length; i++) { EspTarget espTarget = array[i]; if ((Object)(object)espTarget.Target == (Object)null || !espTarget.MatchesSearch(searchQuery)) { continue; } float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, espTarget.Target.position); if (num < 2f || num > (float)MaxDistance) { continue; } Vector3 val = main.WorldToScreenPoint(espTarget.Target.position); if (!(val.z <= 0f)) { string text = $"{espTarget.Label} [{Mathf.RoundToInt(num)}m]"; DrawLabel(val, text, espTarget.Color); if (espTarget.DrawBox) { DrawBox(main, espTarget.Target, espTarget.Color); } } } } private static void RefreshTargets() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_00a2: 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_0083: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) Targets.Clear(); Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 position = ((Component)localPlayer).transform.position; if (GetCategoryEnabled(AdminEspCategory.Players) || GetCategoryEnabled(AdminEspCategory.Creatures)) { foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)null) { continue; } if (allCharacter.IsPlayer()) { if (GetCategoryEnabled(AdminEspCategory.Players) && !((Object)(object)allCharacter == (Object)(object)localPlayer)) { AddTarget(((Component)allCharacter).transform, allCharacter.GetHoverName(), position, Color.magenta, drawBox: true); } } else if (GetCategoryEnabled(AdminEspCategory.Creatures)) { Color color = (Color)(allCharacter.IsTamed() ? new Color(1f, 0.45f, 0f, 1f) : Color.red); AddTarget(((Component)allCharacter).transform, allCharacter.GetHoverName(), position, color, drawBox: true, allCharacter.m_name); } } } if (GetCategoryEnabled(AdminEspCategory.DroppedItems)) { ItemDrop[] array = Object.FindObjectsByType<ItemDrop>((FindObjectsSortMode)0); foreach (ItemDrop val in array) { AddTarget(((Component)val).transform, val.GetHoverName(), position, new Color(0.13f, 0.72f, 0.11f, 1f), drawBox: false); } } if (GetCategoryEnabled(AdminEspCategory.Resources)) { MineRock5[] array2 = Object.FindObjectsByType<MineRock5>((FindObjectsSortMode)0); foreach (MineRock5 val2 in array2) { string hoverName = val2.GetHoverName(); if (AdminEspNames.IsMineResource(hoverName)) { AddTarget(((Component)val2).transform, hoverName, position, Color.yellow, drawBox: false); } } MineRock[] array3 = Object.FindObjectsByType<MineRock>((FindObjectsSortMode)0); foreach (MineRock val3 in array3) { string hoverName2 = val3.GetHoverName(); if (AdminEspNames.IsMineResource(hoverName2)) { AddTarget(((Component)val3).transform, hoverName2, position, Color.yellow, drawBox: false); } } Destructible[] array4 = Object.FindObjectsByType<Destructible>((FindObjectsSortMode)0); foreach (Destructible val4 in array4) { HoverText component = ((Component)val4).GetComponent<HoverText>(); if (!((Object)(object)component == (Object)null)) { string text = component.m_text; if (AdminEspNames.IsDeposit(text, ((Object)((Component)val4).gameObject).name)) { AddTarget(((Component)val4).transform, text, position, Color.yellow, drawBox: false); } } } } if (GetCategoryEnabled(AdminEspCategory.Pickables)) { Pickable[] array5 = Object.FindObjectsByType<Pickable>((FindObjectsSortMode)0); foreach (Pickable val5 in array5) { AddTarget(((Component)val5).transform, val5.GetHoverName(), position, new Color(0.13f, 0.58f, 0.89f, 1f), drawBox: false); } PickableItem[] array6 = Object.FindObjectsByType<PickableItem>((FindObjectsSortMode)0); foreach (PickableItem val6 in array6) { AddTarget(((Component)val6).transform, val6.GetHoverName(), position, new Color(0.13f, 0.58f, 0.89f, 1f), drawBox: false); } } if (!GetCategoryEnabled(AdminEspCategory.Dungeons)) { return; } LocationProxy[] array7 = Object.FindObjectsByType<LocationProxy>((FindObjectsSortMode)0); foreach (LocationProxy val7 in array7) { string locationName = GetLocationName(val7); if (IsDungeonName(locationName)) { AddTarget(((Component)val7).transform, GetDungeonDisplayName(locationName), position, Color.cyan, drawBox: false, null, locationName); } } } private static void AddTarget(Transform transform, string rawLabel, Vector3 playerPosition, Color color, bool drawBox, string? rawName = null, string? prefabName = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { return; } float num = Vector3.Distance(playerPosition, transform.position); if (!(num < 2f) && !(num > (float)MaxDistance)) { string text = (prefabName ?? ((Object)((Component)transform).gameObject).name).Replace("(Clone)", string.Empty); string text2 = CleanLabel(rawLabel ?? string.Empty); if (string.IsNullOrWhiteSpace(text2)) { text2 = text; } Targets.Add(new EspTarget(transform, text2, color, drawBox, rawName ?? rawLabel ?? string.Empty, text)); } } private static string CleanLabel(string value) { string text = value; if (Localization.instance != null) { text = Localization.instance.Localize(text); } return text.Replace("(Clone)", string.Empty).Replace("$enemy_", string.Empty).Replace("$item_", string.Empty) .Replace("$piece_", string.Empty) .Trim(); } private static string GetLocationName(LocationProxy proxy) { GameObject val = LocationInstanceRef.Invoke(proxy); if ((Object)(object)val != (Object)null) { return ((Object)val).name; } return ((Object)((Component)proxy).gameObject).name; } private static bool IsDungeonName(string name) { string text = name.ToLowerInvariant(); if (!text.Contains("crypt") && !text.Contains("cave")) { return text.Contains("dungeon"); } return true; } private static string GetDungeonDisplayName(string name) { string text = name.Replace("(Clone)", string.Empty); if (text.IndexOf("sunken", StringComparison.OrdinalIgnoreCase) >= 0) { return "Sunken Crypt"; } if (text.IndexOf("troll", StringComparison.OrdinalIgnoreCase) >= 0) { return "Troll Cave"; } if (text.IndexOf("mountain", StringComparison.OrdinalIgnoreCase) >= 0) { return "Mountain Cave"; } if (text.IndexOf("crypt", StringComparison.OrdinalIgnoreCase) >= 0) { return "Crypt"; } if (text.IndexOf("cave", StringComparison.OrdinalIgnoreCase) >= 0) { return "Cave"; } return text; } private static void EnsureGuiResources() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0022: 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_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown if ((Object)(object)pixelTexture == (Object)null) { pixelTexture = new Texture2D(1, 1, (TextureFormat)5, false); pixelTexture.SetPixel(0, 0, Color.white); pixelTexture.Apply(); Object.DontDestroyOnLoad((Object)(object)pixelTexture); } if (labelStyle == null) { labelStyle = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)3 }; } } private static void DrawLabel(Vector3 screenPoint, string text, Color color) { //IL_0008: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (labelStyle != null) { float num = screenPoint.x + 6f; float num2 = (float)Screen.height - screenPoint.y - 11f; Rect val = new Rect(num + 1f, num2 + 1f, 260f, 24f); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num, num2, 260f, 24f); labelStyle.normal.textColor = Color.black; GUI.Label(val, text, labelStyle); labelStyle.normal.textColor = color; GUI.Label(val2, text, labelStyle); } } private static void DrawBox(Camera camera, Transform target, Color color) { //IL_0017: 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_0021: 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_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) //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_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_0054: 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_006f: 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_0094: 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_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_00b9: 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) if ((Object)(object)pixelTexture == (Object)null) { return; } Character component = ((Component)target).GetComponent<Character>(); Vector3 val = camera.WorldToScreenPoint(target.position); Vector3 val2 = camera.WorldToScreenPoint(((Object)(object)component != (Object)null) ? component.GetEyePoint() : (target.position + Vector3.up * 2f)); if (!(val.z <= 0f) && !(val2.z <= 0f)) { float num = Mathf.Abs(val2.y - val.y); if (!(num < 18f)) { float num2 = num * 0.55f; float num3 = val.x - num2 / 2f; float num4 = (float)Screen.height - val2.y; Color color2 = GUI.color; GUI.color = color; DrawRect(num3, num4, num2, 1f); DrawRect(num3, num4 + num, num2, 1f); DrawRect(num3, num4, 1f, num); DrawRect(num3 + num2, num4, 1f, num); GUI.color = color2; } } } private static void DrawRect(float x, float y, float width, float height) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(x, y, width, height), (Texture)(object)pixelTexture); } } internal static class AdminEspNames { internal static bool IsDeposit(string? rawName, string? prefabName) { if (!Contains(rawName, "deposit") && !Contains(rawName, "mudpile") && !Contains(prefabName, "deposit")) { return Contains(prefabName, "mudpile"); } return true; } internal static bool IsMineResource(string? rawName) { if (!string.IsNullOrWhiteSpace(rawName) && !rawName.Equals("rock", StringComparison.OrdinalIgnoreCase)) { return !rawName.Equals("$piece_rock", StringComparison.OrdinalIgnoreCase); } return false; } internal static string NormalizeSearch(string? value) { if (string.IsNullOrWhiteSpace(value)) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(value.Length); string text = value.Normalize(NormalizationForm.FormD); foreach (char c in text) { if (CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark && !char.IsWhiteSpace(c) && c != '_' && c != '-') { stringBuilder.Append(char.ToUpperInvariant(c)); } } return stringBuilder.ToString(); } internal static bool Contains(string? value, string query) { if (value != null) { return value.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } } internal enum AdminFunSlider { SuperJump, Size } internal static class AdminFun { internal const int MinimumPercent = 25; private static int jumpPercent = 100; private static int sizePercent = 100; private static Player? bouncePlayer; private static bool airborne; private static Transform? scaledPlayer; private static Vector3 originalScale; private static Vector3 appliedScale; private static float appliedFactor = 1f; private static readonly Func<Character, bool> InSwimDepth = (Func<Character, bool>)(typeof(Character).GetMethod("InLiquidSwimDepth", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null) ?? throw new MissingMethodException("Character", "InLiquidSwimDepth")).CreateDelegate(typeof(Func<Character, bool>)); private static readonly Func<Character, bool> TakeInput = (Func<Character, bool>)(typeof(Character).GetMethod("TakeInput", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null) ?? throw new MissingMethodException("Character", "TakeInput")).CreateDelegate(typeof(Func<Character, bool>)); internal static int MaximumPercent(AdminFunSlider slider) { if (slider != AdminFunSlider.SuperJump) { return 300; } return 500; } internal static int GetPercent(AdminFunSlider slider) { if (AdminNetworkAccess.Allowed) { return slider switch { AdminFunSlider.Size => sizePercent, AdminFunSlider.SuperJump => jumpPercent, _ => 100, }; } return 100; } internal static void SetPercent(AdminFunSlider slider, int value) { if (AdminNetworkAccess.Allowed) { int num = Math.Max(25, Math.Min(MaximumPercent(slider), value)); switch (slider) { case AdminFunSlider.SuperJump: jumpPercent = num; break; case AdminFunSlider.Size: sizePercent = num; UpdateSize(); break; } } } private static bool IsLocal(Character character) { if (AdminNetworkAccess.Allowed && (Object)(object)character != (Object)null && (Object)(object)character == (Object)(object)Player.m_localPlayer && character.IsOwner()) { return !character.IsDead(); } return false; } private static bool CanMove(Character character) { if (IsLocal(character) && !character.IsAttached() && !character.IsDebugFlying() && !character.InIntro() && !character.IsTeleporting() && !InSwimDepth(character)) { return (Object)(object)GrapplingPoint.m_localGrappler == (Object)null; } return false; } internal static float JumpForce(float force, Character character) { if (!CanMove(character) || jumpPercent == 100) { return force; } return force * ((float)GetPercent(AdminFunSlider.SuperJump) / 100f); } internal static void AfterMotion(Character character) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)character != (Object)(object)Player.m_localPlayer) { return; } if (!CanMove(character)) { ResetBounce(); return; } Rigidbody component = ((Component)character).GetComponent<Rigidbody>(); if ((Object)(object)component == (Object)null || component.isKinematic) { ResetBounce(); return; } if (AdminActions.MoonGravity && component.useGravity) { component.AddForce(-Physics.gravity * 0.8f, (ForceMode)5); } Player localPlayer = Player.m_localPlayer; if (!AdminActions.BouncyMode || !Application.isFocused || (Object)(object)Hud.instance == (Object)null || !TakeInput((Character)(object)localPlayer)) { ResetBounce(); return; } if ((Object)(object)bouncePlayer != (Object)(object)localPlayer) { bouncePlayer = localPlayer; airborne = false; } bool flag = ((Character)localPlayer).IsOnGround(); bool num = airborne && flag; airborne = !flag; if (num) { ((Character)localPlayer).Jump(false); } } internal static void ResetBounce() { bouncePlayer = null; airborne = false; } internal static void UpdateSize() { //IL_0097: 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_00ac: 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_0085: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; Transform val = (((Object)(object)localPlayer != (Object)null && IsLocal((Character)(object)localPlayer) && CanScaleAttachment(localPlayer) && !((Character)localPlayer).InCutscene() && !((Character)localPlayer).IsTeleporting()) ? ((Component)localPlayer).transform : null); int percent = GetPercent(AdminFunSlider.Size); if ((Object)(object)val != (Object)(object)scaledPlayer || percent == 100) { RestoreSize(); } if (!((Object)(object)val == (Object)null) && percent != 100) { if ((Object)(object)scaledPlayer == (Object)null) { scaledPlayer = val; originalScale = val.localScale; } appliedFactor = (float)percent / 100f; appliedScale = originalScale * appliedFactor; val.localScale = appliedScale; } } private static bool CanScaleAttachment(Player player) { if (!((Character)player).IsAttached()) { return true; } if (((Character)player).IsAttachedToShip() || ((Character)player).IsRiding() || ((Character)player).InBed()) { return false; } Transform attachPoint = player.GetAttachPoint(); Chair val = (((Object)(object)attachPoint != (Object)null) ? ((Component)attachPoint).GetComponentInParent<Chair>() : null); if ((Object)(object)val != (Object)null && (Object)(object)val.m_attachPoint == (Object)(object)attachPoint) { return !val.m_inShip; } return false; } internal static float BodyDimension(float value, Character character) { if (!IsLocal(character) || !((Object)(object)scaledPlayer != (Object)null) || !((Object)(object)((Component)character).transform == (Object)(object)scaledPlayer)) { return value; } return value * appliedFactor; } internal static void RestoreSize() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)scaledPlayer != (Object)null && scaledPlayer.localScale == appliedScale) { scaledPlayer.localScale = originalScale; } scaledPlayer = null; appliedFactor = 1f; } internal static void PrepareCreatureHit(Character target, ref HitData hit) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if ((!AdminActions.SuperKnockback && !AdminActions.PartyHits) || hit == null || (Object)(object)target == (Object)null || target is Player || (Object)(object)target.GetBaseAI() == (Object)null || target.IsDead()) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && IsLocal((Character)(object)localPlayer) && !((Object)(object)hit.GetAttacker() != (Object)(object)localPlayer) && !(((DamageTypes)(ref hit.m_damage)).GetTotalDamage() <= 0f)) { if (AdminActions.SuperKnockback && hit.m_pushForce > 0f && !float.IsInfinity(hit.m_pushForce)) { HitData val = hit.Clone(); val.m_pushForce = Math.Max(hit.m_pushForce, Math.Min(1000f, hit.m_pushForce * 12f)); hit = val; } if (AdminActions.PartyHits) { AdminPartyHits.Burst(hit.m_point); } } } internal static void Reset() { jumpPercent = (sizePercent = 100); ResetBounce(); RestoreSize(); } } internal sealed class AdminGui { private Font? regularFont; private Font? boldFont; internal static AdminGui Instance { get; } = new AdminGui(); internal static GameObject? CustomGUIFront { get; private set; } internal static bool InputBlocked { get; private set; } internal Font AveriaSerif { get { if (!((Object)(object)regularFont != (Object)null)) { return regularFont = FindFont(bold: false); } return regularFont; } } internal Font AveriaSerifBold { get { if (!((Object)(object)boldFont != (Object)null)) { return boldFont = FindFont(bold: true); } return boldFont; } } internal Color ValheimOrange => new Color(1f, 0.63f, 0.15f, 1f); internal static bool EnsureCanvas() { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null || (Object)(object)EventSystem.current == (Object)null) { return false; } if ((Object)(object)CustomGUIFront != (Object)null) { return true; } CustomGUIFront = new GameObject("ValheimAdminToolUI", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)CustomGUIFront); Canvas component = CustomGUIFront.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 2500; CanvasScaler component2 = CustomGUIFront.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.screenMatchMode = (ScreenMatchMode)0; component2.matchWidthOrHeight = 0.5f; return true; } internal static void BlockInput(bool blocked) { if (InputBlocked != blocked) { InputBlocked = blocked; if ((Object)(object)EventSystem.current != (Object)null) { EventSystem.current.SetSelectedGameObject((GameObject)null); } if (blocked) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } else if ((Object)(object)GameCamera.instance != (Object)null) { GameCamera.instance.UpdateMouseCapture(); } } } internal static void Dispose() { BlockInput(blocked: false); if ((Object)(object)CustomGUIFront != (Object)null) { Object.Destroy((Object)(object)CustomGUIFront); } CustomGUIFront = null; } private static Font FindFont(bool bold) { Font[] source = Resources.FindObjectsOfTypeAll<Font>(); return ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font font) => ((Object)font).name.Contains("Averia") && ((Object)font).name.ToLowerInvariant().Contains(bold ? "bold" : "regular"))) ?? ((IEnumerable<Font>)source).FirstOrDefault((Func<Font, bool>)((Font font) => ((Object)font).name.Contains("Averia"))) ?? Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); } private static GameObject Rect(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, float width, float height) { //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: 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_0034: 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_0050: 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_0066: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = position; component.sizeDelta = new Vector2(width, height); return val; } internal GameObject CreateWoodpanel(Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, float width, float height, bool draggable) { //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) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0067: 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_0099: 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_00bf: Unknown result type (might be due to invalid IL or missing references) GameObject val = Rect("AdminPanel", parent, anchorMin, anchorMax, position, width, height); ((Graphic)val.AddComponent<Image>()).color = new Color(0.13f, 0.1f, 0.07f, 0.98f); Outline obj = val.AddComponent<Outline>(); ((Shadow)obj).effectColor = new Color(0.6f, 0.38f, 0.16f, 1f); ((Shadow)obj).effectDistance = new Vector2(2f, -2f); if (draggable) { GameObject obj2 = Rect("DragHeader", val.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -30f), width, 60f); ((Graphic)obj2.AddComponent<Image>()).color = Color.clear; obj2.AddComponent<AdminPanelDrag>(); } return val; } internal GameObject CreateText(string text, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, Font font, int fontSize, Color color, bool outline, Color outlineColor, float width, float height, bool addContentSizeFitter) { //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) //IL_0009: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) GameObject val = Rect("Text", parent, anchorMin, anchorMax, position, width, height); Text obj = val.AddComponent<Text>(); obj.text = text; obj.font = font; obj.fontSize = fontSize; ((Graphic)obj).color = color; obj.alignment = (TextAnchor)4; ((Graphic)obj).raycastTarget = false; if (outline) { Outline obj2 = val.AddComponent<Outline>(); ((Shadow)obj2).effectColor = outlineColor; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); } if (addContentSizeFitter) { val.AddComponent<ContentSizeFitter>().horizontalFit = (FitMode)2; } return val; } internal GameObject CreateButton(string text, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 position, float width, float height) { //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) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0060: 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_0085: 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_00ac: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = Rect("Button", parent, anchorMin, anchorMax, position, width, height); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.35f, 0.26f, 0.15f, 1f); Button obj = val.AddComponent<Button>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)obj).colors; ((ColorBlock)(ref colors)).highlightedColor = new Color(1.3f, 1.2f, 1.1f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.65f, 0.65f, 0.65f); ((Selectable)obj).colors = colors; CreateText(text, val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, AveriaSerifBold, 16, Color.white, outline: true, Color.black, width - 8f, height, addContentSizeFitter: false); return val; } internal GameObject CreateToggle(Transform parent, float width, float height) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) GameObject val = Rect("Toggle", parent, Vector2.zero, Vector2.zero, Vector2.zero, width, height); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.3f, 0.25f, 0.2f, 1f); Image val3 = Rect("Checkmark", val.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, width - 10f, height - 10f).AddComponent<Image>(); ((Graphic)val3).color = ValheimOrange; ((Graphic)val3).raycastTarget = false; Toggle obj = val.AddComponent<Toggle>(); ((Selectable)obj).targetGraphic = (Graphic)(object)val2; obj.graphic = (Graphic)(object)val3; obj.isOn = false; return val; } } internal sealed class AdminPanelDrag : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler { private Vector2 grabOffset; public void OnBeginDrag(PointerEventData eventData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: 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_002f: Expected O, but got Unknown //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_0038: 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) RectTransform val = (RectTransform)((Component)this).transform.parent; Vector2 val2 = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)val).parent, eventData.position, eventData.pressEventCamera, ref val2); grabOffset = val.anchoredPosition - val2; } public void OnDrag(PointerEventData eventData) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0017: 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_002f: Expected O, but got Unknown //IL_0032: 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) RectTransform val = (RectTransform)((Component)this).transform.parent; Vector2 val2 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)val).parent, eventData.position, eventData.pressEventCamera, ref val2)) { val.anchoredPosition = val2 + grabOffset; } } } internal interface IAdminKeyInput { bool Down(KeyCode key); bool Held(KeyCode key); } internal sealed class AdminKeyInput : IAdminKeyInput { internal static readonly AdminKeyInput Instance = new AdminKeyInput(); public bool Down(KeyCode key) { //IL_0005: Unknown result type (might