using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BGMod.Config; using BGMod.Core; using BGMod.ESP; using BGMod.Features; using BGMod.HUD; using BGMod.Patches; using BGMod.Performance; using BGMod.UI; using BGMod.Utils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Lightbug.CharacterControllerPro.Core; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Joive")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A BepInEx version of BGMod for Burglin Gnomes by Joive.")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1")] [assembly: AssemblyProduct("BGMod")] [assembly: AssemblyTitle("BGMod-BepInEx-Joive")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BGMod { [BepInPlugin("joive.bgmod", "BGMod", "1.3.1")] public sealed class BGModPlugin : BaseUnityPlugin { private Harmony harmony; private bool shuttingDown; public static BGModPlugin Instance { get; private set; } public ModuleManager Modules { get; private set; } public MenuModule Menu { get; private set; } private void Awake() { Instance = this; ModLog.Initialize(((BaseUnityPlugin)this).Logger); ModConfig.Initialize(((BaseUnityPlugin)this).Config); Modules = new ModuleManager(); Modules.Register(new PerformanceModule()); Modules.Register(new HUDModule()); Modules.Register(new ESPModule()); Modules.Register(new GnomeModule()); Modules.Register(new OnlineModule()); Modules.Register(new GameModule()); Modules.Register(new ItemGiverModule()); Modules.Register(new SpawnerModule()); Modules.Register(new ResourcesModule()); Modules.Register(new WorldModule()); Modules.Register(new ItemESPModule()); Modules.Register(new HumanESPModule()); Modules.Register(new ChaosModule()); Menu = new MenuModule(Modules); Modules.Register(Menu); Modules.Initialize(); ApplyPatches(); SceneManager.sceneLoaded += OnSceneLoaded; ModLog.Msg("BGMod BepInEx 1.3.1 initialized."); ModLog.Msg("Game version: " + VersionInfo.GetGameVersionString()); ModLog.Msg("Loaded modules: " + string.Join(", ", Modules.EnabledModuleNames)); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Modules?.OnSceneWasInitialized(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name); } private void Update() { try { if (!ModConfig.EnableMod.Value) { Menu?.OnUpdate(); } else { Modules?.OnUpdate(); } } catch (Exception ex) { ModLog.Error("Update failed: " + ex.Message); } } private void OnGUI() { try { if (!ModConfig.EnableMod.Value) { Menu?.OnGUI(); } else { Modules?.OnGUI(); } } catch (Exception ex) { ModLog.Error("OnGUI failed: " + ex.Message); } } private void OnApplicationQuit() { Shutdown(); } private void OnDestroy() { Shutdown(); } public void StartPluginCoroutine(IEnumerator routine) { ((MonoBehaviour)this).StartCoroutine(routine); } private void Shutdown() { if (!shuttingDown) { shuttingDown = true; SceneManager.sceneLoaded -= OnSceneLoaded; Modules?.OnApplicationQuit(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } private void ApplyPatches() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown harmony = new Harmony("joive.bgmod"); PatchManager.Apply(harmony); } } } namespace BGMod.Utils { public static class GameAccess { public static PlayerNetworking LocalPlayer() { try { return ((IEnumerable)Object.FindObjectsByType((FindObjectsSortMode)0)).FirstOrDefault((Func)((PlayerNetworking p) => (Object)(object)p != (Object)null && ((NetworkBehaviour)p).IsLocalPlayer)); } catch (Exception ex) { ModLog.Warning("Local player lookup failed: " + ex.Message); return null; } } public static List AllPlayers() { try { return (from p in Object.FindObjectsByType((FindObjectsSortMode)0) where (Object)(object)p != (Object)null select p).ToList(); } catch { return new List(); } } public static string PlayerName(PlayerNetworking player) { if ((Object)(object)player == (Object)null || (Object)(object)player.SteamPlayer == (Object)null) { return "Player"; } try { string text = "Player"; player.SteamPlayer.TryGetName(ref text); return string.IsNullOrEmpty(text) ? "Player" : text; } catch { return "Player"; } } public static Vector3 Position(Component component) { //IL_0015: 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) if (!((Object)(object)component != (Object)null)) { return Vector3.zero; } return component.transform.position; } public static float DistanceFromLocal(Component component) { //IL_0024: 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) PlayerNetworking val = LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)component == (Object)null) { return float.MaxValue; } return Vector3.Distance(((Component)val).transform.position, component.transform.position); } } public static class GuiStyles { private static bool initialized; private static Texture2D panelTexture; private static Texture2D buttonTexture; private static Texture2D buttonHoverTexture; private static Texture2D activeTexture; private static Texture2D activeHoverTexture; private static Texture2D boxTexture; private static Texture2D toggleOffTexture; private static Texture2D toggleOnTexture; private static Texture2D sliderTexture; private static Texture2D sliderThumbTexture; public static GUIStyle Window; public static GUIStyle Title; public static GUIStyle Tab; public static GUIStyle TabActive; public static GUIStyle Section; public static GUIStyle Label; public static GUIStyle SmallLabel; public static GUIStyle Toggle; public static GUIStyle Button; public static GUIStyle Box; public static GUIStyle TextField; public static GUIStyle Slider; public static GUIStyle SliderThumb; public static void Ensure() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00a8: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Expected O, but got Unknown //IL_019c: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_0203: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Expected O, but got Unknown //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Expected O, but got Unknown //IL_03c2: Expected O, but got Unknown //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Expected O, but got Unknown //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Expected O, but got Unknown //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Expected O, but got Unknown //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Expected O, but got Unknown //IL_04c3: Expected O, but got Unknown //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Expected O, but got Unknown //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_059b: Expected O, but got Unknown //IL_05b4: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Expected O, but got Unknown //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Expected O, but got Unknown //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Expected O, but got Unknown //IL_0670: Expected O, but got Unknown //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Expected O, but got Unknown //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_06ee: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Expected O, but got Unknown if (!initialized) { panelTexture = MakeTexture(new Color(0.018f, 0.026f, 0.038f, 0.98f)); buttonTexture = MakeTexture(new Color(0.045f, 0.07f, 0.1f, 1f)); buttonHoverTexture = MakeTexture(new Color(0.07f, 0.12f, 0.17f, 1f)); activeTexture = MakeTexture(new Color(0.06f, 0.32f, 0.46f, 1f)); activeHoverTexture = MakeTexture(new Color(0.08f, 0.43f, 0.62f, 1f)); boxTexture = MakeTexture(new Color(0.012f, 0.018f, 0.027f, 1f)); toggleOffTexture = MakeTexture(new Color(0.055f, 0.082f, 0.115f, 1f)); toggleOnTexture = MakeTexture(new Color(0.08f, 0.42f, 0.34f, 1f)); sliderTexture = MakeTexture(new Color(0.05f, 0.08f, 0.11f, 1f)); sliderThumbTexture = MakeTexture(new Color(0.12f, 0.66f, 0.9f, 1f)); Window = new GUIStyle(GUI.skin.window) { padding = new RectOffset(16, 16, 12, 14), border = new RectOffset(1, 1, 1, 1) }; SetAllStates(Window, panelTexture, Color.white); Title = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, fontSize = 18, fontStyle = (FontStyle)1, fixedHeight = 30f, margin = new RectOffset(0, 0, 0, 6), padding = new RectOffset(8, 0, 0, 0) }; SetTextStates(Title, new Color(0.92f, 0.98f, 1f)); Tab = new GUIStyle(GUI.skin.button) { fontSize = 12, fontStyle = (FontStyle)1, fixedHeight = 30f, margin = new RectOffset(2, 2, 2, 2), padding = new RectOffset(8, 8, 6, 6), alignment = (TextAnchor)4 }; SetAllStates(Tab, buttonTexture, new Color(0.68f, 0.77f, 0.86f)); Tab.hover.background = buttonHoverTexture; Tab.hover.textColor = Color.white; Tab.active.background = buttonHoverTexture; Tab.active.textColor = Color.white; Tab.focused.background = buttonTexture; Tab.focused.textColor = Color.white; TabActive = new GUIStyle(Tab); SetAllStates(TabActive, activeTexture, Color.white); TabActive.hover.background = activeHoverTexture; TabActive.active.background = activeHoverTexture; TabActive.focused.background = activeTexture; Section = new GUIStyle(GUI.skin.box) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)3, fixedHeight = 24f, margin = new RectOffset(0, 0, 8, 5), padding = new RectOffset(9, 6, 4, 4) }; SetAllStates(Section, MakeTexture(new Color(0.028f, 0.052f, 0.075f, 1f)), new Color(0.34f, 0.78f, 1f)); GUIStyle val = new GUIStyle(GUI.skin.label); val.normal.textColor = new Color(0.8f, 0.88f, 0.94f); val.fontSize = 12; val.richText = true; Label = val; GUIStyle val2 = new GUIStyle(Label) { fontSize = 11 }; val2.normal.textColor = new Color(0.55f, 0.66f, 0.76f); SmallLabel = val2; Toggle = new GUIStyle(GUI.skin.button) { fontSize = 12, fixedHeight = 27f, alignment = (TextAnchor)3, margin = new RectOffset(2, 2, 3, 3), padding = new RectOffset(10, 8, 5, 5) }; SetAllStates(Toggle, toggleOffTexture, new Color(0.74f, 0.74f, 0.8f)); Toggle.onNormal.background = toggleOnTexture; Toggle.onNormal.textColor = Color.white; Toggle.onHover.background = toggleOnTexture; Toggle.onHover.textColor = Color.white; Toggle.hover.background = buttonHoverTexture; Toggle.hover.textColor = Color.white; Button = new GUIStyle(GUI.skin.button) { fontSize = 12, fixedHeight = 27f, margin = new RectOffset(2, 2, 3, 3), alignment = (TextAnchor)4 }; SetAllStates(Button, buttonTexture, new Color(0.86f, 0.92f, 0.98f)); Button.hover.background = buttonHoverTexture; Button.active.background = buttonHoverTexture; Button.focused.background = buttonTexture; Box = new GUIStyle(GUI.skin.box) { padding = new RectOffset(10, 10, 8, 8), richText = true }; SetAllStates(Box, boxTexture, Color.white); TextField = new GUIStyle(GUI.skin.textField) { fontSize = 12, fixedHeight = 27f, padding = new RectOffset(7, 7, 5, 5) }; SetAllStates(TextField, boxTexture, Color.white); Slider = new GUIStyle(GUI.skin.horizontalSlider) { fixedHeight = 8f }; Slider.normal.background = sliderTexture; Slider.hover.background = sliderTexture; Slider.active.background = sliderTexture; SliderThumb = new GUIStyle(GUI.skin.horizontalSliderThumb) { fixedWidth = 14f, fixedHeight = 14f }; SliderThumb.normal.background = sliderThumbTexture; SliderThumb.hover.background = activeHoverTexture; SliderThumb.active.background = activeHoverTexture; initialized = true; } } public static Texture2D MakeTexture(Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); val.Apply(); return val; } private static void SetAllStates(GUIStyle style, Texture2D background, Color textColor) { //IL_0012: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) style.normal.background = background; style.normal.textColor = textColor; style.hover.background = background; style.hover.textColor = textColor; style.active.background = background; style.active.textColor = textColor; style.focused.background = background; style.focused.textColor = textColor; style.onNormal.background = background; style.onNormal.textColor = textColor; style.onHover.background = background; style.onHover.textColor = textColor; style.onActive.background = background; style.onActive.textColor = textColor; style.onFocused.background = background; style.onFocused.textColor = textColor; } private static void SetTextStates(GUIStyle style, Color textColor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) style.normal.textColor = textColor; style.hover.textColor = Color.white; style.active.textColor = Color.white; style.focused.textColor = textColor; style.onNormal.textColor = textColor; style.onHover.textColor = Color.white; style.onActive.textColor = Color.white; style.onFocused.textColor = textColor; } } public static class ModLog { private static ManualLogSource logger; public static void Initialize(ManualLogSource source) { logger = source; } public static void Msg(string message) { ManualLogSource obj = logger; if (obj != null) { obj.LogInfo((object)message); } } public static void Warning(string message) { ManualLogSource obj = logger; if (obj != null) { obj.LogWarning((object)message); } } public static void Error(string message) { ManualLogSource obj = logger; if (obj != null) { obj.LogError((object)message); } } } public static class ReflectionUtils { public const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; public const BindingFlags AnyStatic = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; public static object GetMemberValue(object target, string name) { if (target == null || string.IsNullOrEmpty(name)) { return null; } Type type = target.GetType(); PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.GetIndexParameters().Length == 0) { return property.GetValue(target, null); } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field != null)) { return null; } return field.GetValue(target); } public static bool TrySetMemberValue(object target, string name, object value) { if (target == null || string.IsNullOrEmpty(name)) { return false; } Type type = target.GetType(); PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite && property.GetIndexParameters().Length == 0) { property.SetValue(target, value, null); return true; } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(target, value); return true; } return false; } public static bool GetBool(object target, string name) { object memberValue = GetMemberValue(target, name); if (memberValue is bool) { return (bool)memberValue; } return false; } } public static class VersionInfo { public static string GetGameVersionString() { try { Bootstrap val = Object.FindFirstObjectByType(); if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(val.GameVersionString)) { return val.GameVersionString; } return Application.version; } catch { return "unknown"; } } } } namespace BGMod.UI { public class MenuModule : ModuleBase { private readonly string[] tabs = new string[13] { "Main", "Player", "Online", "Potions", "ESP", "Items", "Spawn", "World", "Resources", "Game", "Chaos", "Performance", "Debug" }; private Rect windowRect; private Vector2 scroll; private int selectedTab; private int itemMode; private int spawnMode; private string onlineMinutesText = "1"; private string potionMinutesText = "1"; private string potionSearchText = ""; private string potionLastMessage = ""; private int selectedPotionTargetIndex; private string npcMinutesText = "1"; private string roundMinutesText = "20"; private string chaosRadiusText = "12"; private string chaosMinutesText = "0.25"; private KeyCode cachedMenuKey = (KeyCode)277; private bool centered; private bool modalActive; private bool timeScalePaused; private bool oldCursorVisible; private CursorLockMode oldCursorLock; private float oldTimeScale = 1f; private PlayerController modalController; private bool hadModalControllerState; private bool oldControllerUiOpen; private bool confirmReset; private bool showSpawnItems = true; private bool showSpawnObjects = true; private bool showSpawnNpcs = true; private bool showExistingUnits; private bool startupOpenChecked; private Texture2D dimTexture; public override string Id => "menu"; public override string DisplayName => "Menu"; public override bool Enabled { get { return true; } set { } } public bool Visible { get; private set; } private static bool IsRussian => ((ModConfig.MenuLanguage != null) ? ModConfig.MenuLanguage.Value : "English")?.StartsWith("Russian", StringComparison.OrdinalIgnoreCase) ?? false; public MenuModule(ModuleManager modules) { }//IL_00d7: Unknown result type (might be due to invalid IL or missing references) public override void Initialize(ModuleManager modules) { //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) base.Initialize(modules); cachedMenuKey = ParseKey(ModConfig.MenuKey.Value, (KeyCode)277); } public unsafe override void OnUpdate() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!startupOpenChecked) { startupOpenChecked = true; if (ModConfig.OpenMenuOnStart.Value) { SetVisible(visible: true); ModLog.Msg("Menu opened on startup."); } } if (WasMenuTogglePressed(cachedMenuKey = ParseKey(ModConfig.MenuKey.Value, cachedMenuKey), out var pressedKey)) { ModLog.Msg("Menu toggle pressed: " + ((object)(*(KeyCode*)(&pressedKey))/*cast due to .constrained prefix*/).ToString()); SetVisible(!Visible); } if (Visible) { KeepModalState(); } } public override void OnGUI() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00ae: 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) if (Visible) { GuiStyles.Ensure(); EnsureWindowRect(); GUI.depth = -10000; if ((Object)(object)dimTexture == (Object)null) { dimTexture = GuiStyles.MakeTexture(new Color(0f, 0f, 0f, 0.55f)); } GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)dimTexture); windowRect = GUI.Window(3310, windowRect, new WindowFunction(DrawWindow), "", GuiStyles.Window); windowRect = ClampToScreen(windowRect); } } public override void OnApplicationQuit() { SetVisible(visible: false); } private void SetVisible(bool visible) { if (Visible != visible) { Visible = visible; ModLog.Msg(Visible ? "Menu opened." : "Menu closed."); if (Visible) { centered = false; EnableModalMode(); } else { DisableModalMode(); } } } private static bool WasMenuTogglePressed(KeyCode configuredKey, out KeyCode pressedKey) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002c: Expected I4, but got Unknown KeyCode[] array = new KeyCode[6]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); array[0] = (KeyCode)(int)configuredKey; KeyCode[] array2 = (KeyCode[])(object)array; foreach (KeyCode val in array2) { if ((int)val != 0 && Input.GetKeyDown(val)) { pressedKey = (KeyCode)(int)val; return true; } } pressedKey = (KeyCode)0; return false; } private void DrawWindow(int id) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("BGMod", GuiStyles.Title, Array.Empty()); string headerStatus = GetHeaderStatus(); if (!string.IsNullOrEmpty(headerStatus)) { GUILayout.Space(12f); GUILayout.Label(headerStatus, GuiStyles.SmallLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(260f) }); } GUILayout.FlexibleSpace(); GUILayout.Label("Joive build", GuiStyles.SmallLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); DrawTabs(); GUILayout.Space(8f); scroll = GUILayout.BeginScrollView(scroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); switch (selectedTab) { case 0: DrawMainTab(); break; case 1: DrawPlayerTab(); break; case 2: DrawOnlineTab(); break; case 3: DrawPotionsTab(); break; case 4: DrawEspTab(); break; case 5: DrawItemsTab(); break; case 6: DrawSpawnTab(); break; case 7: DrawWorldTab(); break; case 8: DrawResourcesTab(); break; case 9: DrawGameTab(); break; case 10: DrawChaosTab(); break; case 11: DrawPerformanceTab(); break; case 12: DrawDebugTab(); break; } GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("BGMod by Joive", GuiStyles.SmallLabel, Array.Empty()); GUILayout.FlexibleSpace(); if (GUILayout.Button("Close", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { SetVisible(visible: false); } GUILayout.EndHorizontal(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 26f)); GUILayout.EndVertical(); } private string GetHeaderStatus() { List list = new List(); GameModule gameModule = base.Modules.Get(); if (gameModule != null && !string.IsNullOrEmpty(gameModule.RoundStatusText)) { list.Add(gameModule.RoundStatusText); } if (ModConfig.EnableESP.Value) { list.Add("ESP"); } if (ModConfig.EnableGnomeFeatures.Value) { list.Add("Player"); } if (ModConfig.FlyMode.Value) { list.Add("Fly exp"); } if (ModConfig.Noclip.Value) { list.Add("Noclip exp"); } if (ModConfig.WalkNoclip.Value) { list.Add("Walk noclip exp"); } if (list.Count != 0) { return string.Join(" | ", list.ToArray()); } return ""; } private void DrawTabs() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < tabs.Length; i++) { if (i % 6 == 0) { if (i > 0) { GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); } if (GUILayout.Button(L(tabs[i]), (selectedTab == i) ? GuiStyles.TabActive : GuiStyles.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) })) { selectedTab = i; scroll = Vector2.zero; confirmReset = false; } } GUILayout.EndHorizontal(); } private void DrawMainTab() { GUILayout.Label("BGMod by Joive", GuiStyles.Label, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(L("Language"), GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); if (GUILayout.Button("English", IsRussian ? GuiStyles.Tab : GuiStyles.TabActive, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { ModConfig.MenuLanguage.Value = "English"; } if (GUILayout.Button("Русский", IsRussian ? GuiStyles.TabActive : GuiStyles.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { ModConfig.MenuLanguage.Value = "Russian"; } GUILayout.EndHorizontal(); Toggle(ModConfig.EnableMod, L("Enable BGMod")); Toggle(ModConfig.EnableHUD, L("Enable HUD")); Toggle(ModConfig.EnableESP, L("Enable ESP")); Toggle(ModConfig.EnableGnomeFeatures, L("Enable player features")); Toggle(ModConfig.EnableChaos, L("Enable chaos features")); Toggle(ModConfig.EnablePerformanceMode, L("Enable FPS optimizations")); Toggle(ModConfig.DebugMode, L("Show debug info")); Toggle(ModConfig.UsePauseTimeScale, L("Pause game time while menu is open")); GUILayout.Space(8f); Toggle(ModConfig.OpenMenuOnStart, "Open menu after launch"); GUILayout.Label(L("Menu key") + ": " + ModConfig.MenuKey.Value + " / F1 / Home / F10 / KeypadMinus", GuiStyles.SmallLabel, Array.Empty()); if (GUILayout.Button(L("Save config"), GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { ModConfig.Save(); } GUILayout.Space(4f); if (GUILayout.Button(confirmReset ? L("Confirm reset") : L("Reset config"), GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { if (confirmReset) { ModConfig.ResetToDefaults(); confirmReset = false; } else { confirmReset = true; } } if (confirmReset) { GUILayout.Label(L("Click Confirm reset to restore BGMod defaults."), GuiStyles.SmallLabel, Array.Empty()); } } private void DrawPlayerTab() { GnomeModule gnomeModule = base.Modules.Get(); Section("Player"); GUILayout.BeginHorizontal(Array.Empty()); Toggle(ModConfig.EnableGnomeFeatures, L("Enable player features")); Toggle(ModConfig.GodMode, L("God mode")); Toggle(ModConfig.InfiniteStamina, L("Infinite stamina")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button(L("Full heal"), GuiStyles.Button, Array.Empty())) { gnomeModule?.HealLocal(); } if (GUILayout.Button(L("Kill player"), GuiStyles.Button, Array.Empty())) { gnomeModule?.KillLocal(); } if (GUILayout.Button(L("Force ragdoll"), GuiStyles.Button, Array.Empty())) { gnomeModule?.ForceLocalRagdoll(); } if (GUILayout.Button(L("Unragdoll"), GuiStyles.Button, Array.Empty())) { gnomeModule?.UnragdollLocal(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); Toggle(ModConfig.NoFallDamage, L("No fall damage")); Toggle(ModConfig.AntiKidnap, L("Anti kidnap")); Toggle(ModConfig.LongHands, L("Long hands")); GUILayout.EndHorizontal(); Section("Movement"); GUILayout.BeginHorizontal(Array.Empty()); Toggle(ModConfig.EnableFlyNoclipHotkeys, L("Movement hotkeys")); Toggle(ModConfig.FlyMode, L("Fly (Experimental)")); Toggle(ModConfig.Noclip, L("Noclip (Experimental)")); Toggle(ModConfig.WalkNoclip, L("Walk noclip (Experimental)")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.BeginVertical(Array.Empty()); Slider(ModConfig.SpeedMultiplier, L("Speed multiplier"), 0.25f, 6f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("1x", GuiStyles.Button, Array.Empty())) { ModConfig.SpeedMultiplier.Value = 1f; } if (GUILayout.Button("2x", GuiStyles.Button, Array.Empty())) { ModConfig.SpeedMultiplier.Value = 2f; } if (GUILayout.Button("3x", GuiStyles.Button, Array.Empty())) { ModConfig.SpeedMultiplier.Value = 3f; } if (GUILayout.Button("5x", GuiStyles.Button, Array.Empty())) { ModConfig.SpeedMultiplier.Value = 5f; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(12f); GUILayout.BeginVertical(Array.Empty()); Slider(ModConfig.FlySpeed, L("Fly speed"), 1f, 60f); Slider(ModConfig.InteractionDistance, L("Interaction distance"), 1f, 12f); Slider(ModConfig.PlayerScale, L("Player scale"), 0.2f, 3f); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Label(L("Experimental movement note"), GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(L("Hotkeys") + ": Fly " + ModConfig.FlyToggleKey.Value + ", Noclip " + ModConfig.NoclipToggleKey.Value + ", Walk " + ModConfig.WalkNoclipToggleKey.Value + ", TP G", GuiStyles.SmallLabel, Array.Empty()); } private void DrawOnlineTab() { OnlineModule onlineModule = base.Modules.Get(); if (onlineModule == null) { GUILayout.Label("Online module not loaded", GuiStyles.Label, Array.Empty()); return; } if (onlineModule.Players.Count == 0) { onlineModule.RefreshPlayers(); } Section("Online players"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh players", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { onlineModule.RefreshPlayers(); } GUILayout.Label("Total players: " + onlineModule.Players.Count, GuiStyles.Label, Array.Empty()); GUILayout.EndHorizontal(); for (int i = 0; i < onlineModule.Players.Count; i++) { if (GUILayout.Button(onlineModule.PlayerLabel(i), (onlineModule.SelectedPlayerIndex == i) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { onlineModule.SelectedPlayerIndex = i; } } Section("Actions"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Heal", GuiStyles.Button, Array.Empty())) { onlineModule.HealSelected(); } if (GUILayout.Button("Kill", GuiStyles.Button, Array.Empty())) { onlineModule.KillSelected(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Ragdoll", GuiStyles.Button, Array.Empty())) { onlineModule.RagdollSelected(ragdoll: true); } if (GUILayout.Button("Unragdoll", GuiStyles.Button, Array.Empty())) { onlineModule.RagdollSelected(ragdoll: false); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Teleport to me", GuiStyles.Button, Array.Empty())) { onlineModule.TeleportSelectedToMe(); } if (GUILayout.Button("Teleport me to them", GuiStyles.Button, Array.Empty())) { onlineModule.TeleportMeToSelected(); } GUILayout.EndHorizontal(); Section("Effects"); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Minutes (0 = infinity)", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); onlineMinutesText = GUILayout.TextField(onlineMinutesText ?? "1", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); float num = ParsePositiveFloat(onlineMinutesText, 1f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Stun", GuiStyles.Button, Array.Empty())) { onlineModule.StunSelected(num); } if (GUILayout.Button("Tie", GuiStyles.Button, Array.Empty())) { onlineModule.TieSelected(num); } if (GUILayout.Button("Fire", GuiStyles.Button, Array.Empty())) { onlineModule.SetFireSelected(num); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Explode", GuiStyles.Button, Array.Empty())) { onlineModule.ExplodeSelected(); } if (GUILayout.Button("Clear effects", GuiStyles.Button, Array.Empty())) { onlineModule.ClearEffectsSelected(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Launch", GuiStyles.Button, Array.Empty())) { onlineModule.LaunchSelected(); } if (GUILayout.Button("Spin", GuiStyles.Button, Array.Empty())) { onlineModule.SpinSelected(); } if (GUILayout.Button("Freeze", GuiStyles.Button, Array.Empty())) { onlineModule.FreezeSelected(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Dismember head", GuiStyles.Button, Array.Empty())) { onlineModule.DismemberSelected(head: true); } if (GUILayout.Button("Dismember legs", GuiStyles.Button, Array.Empty())) { onlineModule.DismemberSelected(head: false); } GUILayout.EndHorizontal(); Section("Friend tools"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("God on", GuiStyles.Button, Array.Empty())) { onlineModule.SetGodSelected(enabled: true); } if (GUILayout.Button("God off", GuiStyles.Button, Array.Empty())) { onlineModule.SetGodSelected(enabled: false); } if (GUILayout.Button("Give buffs", GuiStyles.Button, Array.Empty())) { onlineModule.GiveBuffsSelected(num); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Give resources", GuiStyles.Button, Array.Empty())) { onlineModule.GiveResourcesSelected(ModConfig.ResourceGiveAmount.Value); } if (GUILayout.Button("Support pack", GuiStyles.Button, Array.Empty())) { onlineModule.GiveSupportPackSelected(num, ModConfig.ResourceGiveAmount.Value); } GUILayout.Label("Resources x" + ModConfig.ResourceGiveAmount.Value, GuiStyles.SmallLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); GUILayout.EndHorizontal(); GUILayout.Label("Host/server is needed for most online actions to replicate correctly.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(onlineModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawPotionsTab() { ESPModule eSPModule = base.Modules.Get(); if (eSPModule == null) { GUILayout.Label("ESP module not loaded", GuiStyles.Label, Array.Empty()); return; } GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh ESP targets", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) })) { eSPModule.RefreshNow(); } GUILayout.Label("Uses currently scanned ESP players and units.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); potionSearchText = GUILayout.TextField(potionSearchText ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); GUILayout.Label("Minutes (0 = infinity)", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); potionMinutesText = GUILayout.TextField(potionMinutesText ?? "1", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); List potionTargets = GetPotionTargets(eSPModule); selectedPotionTargetIndex = Mathf.Clamp(selectedPotionTargetIndex, 0, Math.Max(potionTargets.Count - 1, 0)); Section("Targets"); if (potionTargets.Count == 0) { GUILayout.Label("No ESP potion targets. Enable ESP humans/players or press Refresh ESP targets.", GuiStyles.SmallLabel, Array.Empty()); } else { int num = Math.Min(potionTargets.Count, 80); for (int i = 0; i < num; i++) { ESPTarget eSPTarget = potionTargets[i]; if (GUILayout.Button(eSPTarget.Label + " [" + eSPTarget.Distance.ToString("F0") + "m]", (selectedPotionTargetIndex == i) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { selectedPotionTargetIndex = i; } } GUILayout.Label("Showing " + num + " / " + potionTargets.Count + " potion targets.", GuiStyles.SmallLabel, Array.Empty()); } ESPTarget target = ((potionTargets.Count > 0) ? potionTargets[selectedPotionTargetIndex] : null); float minutes = ParsePositiveFloat(potionMinutesText, 1f); Section("Effects"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Stun", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)0, minutes); } if (GUILayout.Button("Fire", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)1, minutes); } if (GUILayout.Button("Tie", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)2, minutes); } if (GUILayout.Button("Electrocute", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)4, minutes); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Slip", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)5, minutes); } if (GUILayout.Button("Poop", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)3, minutes); } if (GUILayout.Button("Sleep", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)10, minutes); } if (GUILayout.Button("Confuse", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)13, minutes); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Stamina", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)7, minutes); } if (GUILayout.Button("Mobility", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)6, minutes); } if (GUILayout.Button("Strength", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)12, minutes); } if (GUILayout.Button("Flight", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)8, minutes); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Fart", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)9, minutes); } if (GUILayout.Button("Health", GuiStyles.Button, Array.Empty())) { ApplyPotion(target, (Type)11, 0.02f); } if (GUILayout.Button("Clear all", GuiStyles.Button, Array.Empty())) { ClearPotionEffects(target); } GUILayout.EndHorizontal(); GUILayout.Label("Host/server is needed for most effects to replicate correctly.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(potionLastMessage, GuiStyles.SmallLabel, Array.Empty()); } private List GetPotionTargets(ESPModule esp) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) List list = new List(); HashSet hashSet = new HashSet(); string value = potionSearchText ?? ""; foreach (ESPTarget target in esp.Targets) { if (target != null && !((Object)(object)target.StatusHandler == (Object)null) && (string.IsNullOrEmpty(value) || (target.Label != null && target.Label.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0))) { list.Add(target); hashSet.Add(target.StatusHandler); } } foreach (PlayerNetworking item in GameAccess.AllPlayers()) { if (!((Object)(object)item == (Object)null) && !((Object)(object)((GameEntityBase)item).StatusEffectHandler == (Object)null) && !hashSet.Contains(((GameEntityBase)item).StatusEffectHandler)) { string text = "Player: " + GameAccess.PlayerName(item); if (string.IsNullOrEmpty(value) || text.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { list.Add(new ESPTarget { Label = text, Color = new Color(0.45f, 1f, 0.55f), Position = ((Component)item).transform.position, Height = 1.8f, Distance = GameAccess.DistanceFromLocal((Component)(object)item), DrawBox = true, DrawTracer = false, TargetObject = ((Component)item).gameObject, StatusHandler = ((GameEntityBase)item).StatusEffectHandler }); } } } return list; } private unsafe void ApplyPotion(ESPTarget target, Type type, float minutes) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (target == null || (Object)(object)target.StatusHandler == (Object)null) { potionLastMessage = "Select a valid ESP target first"; return; } try { float num = ((minutes <= 0f) ? float.PositiveInfinity : (Mathf.Clamp(minutes, 0.02f, 120f) * 60f)); target.StatusHandler.AddStatus(type, num); potionLastMessage = "Applied " + ((object)(*(Type*)(&type))/*cast due to .constrained prefix*/).ToString() + " to " + target.Label; } catch (Exception ex) { potionLastMessage = "Potion failed: " + ex.Message; } } private void ClearPotionEffects(ESPTarget target) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (target == null || (Object)(object)target.StatusHandler == (Object)null) { potionLastMessage = "Select a valid ESP target first"; return; } try { foreach (object value in Enum.GetValues(typeof(Type))) { target.StatusHandler.RemoveStatus((Type)value); } potionLastMessage = "Cleared effects on " + target.Label; } catch (Exception ex) { potionLastMessage = "Clear failed: " + ex.Message; } } private void DrawEspTab() { Toggle(ModConfig.EnableESP, "Enable ESP"); Toggle(ModConfig.EnableItemESP, "Enable Item ESP"); Toggle(ModConfig.EnableLevelItemESP, "Enable Level Item ESP"); Toggle(ModConfig.EnableHumanESP, "Enable Human ESP"); Toggle(ModConfig.EnableRobotESP, "Enable Robot / Machine ESP"); Toggle(ModConfig.EnableInteractableESP, "Enable Interactable ESP"); Toggle(ModConfig.EnableGnomeESP, "Enable Player ESP"); Slider(ModConfig.ESPRefreshRate, "ESP refresh", 0.1f, 3f); Slider(ModConfig.MaxESPDistance, "Max distance", 10f, 250f); IntSlider(ModConfig.MaxESPObjects, "Max objects", 5, 150); Toggle(ModConfig.ShowPlayerInventoryOnESP, "Show player inventory"); Toggle(ModConfig.ShowNpcHeldItemOnESP, "Show NPC held item"); DrawConfigTextField(ModConfig.ESPItemFilter, "Item filter"); DrawConfigTextField(ModConfig.ESPHumanFilter, "Human / unit filter"); DrawConfigTextField(ModConfig.ESPPlayerFilter, "Player filter"); GUILayout.Label("Filters accept comma-separated text. Empty filter shows everything.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label("Cached targets: " + (base.Modules.Get()?.Targets.Count ?? 0), GuiStyles.SmallLabel, Array.Empty()); } private void DrawItemsTab() { ItemGiverModule itemGiverModule = base.Modules.Get(); if (itemGiverModule == null) { GUILayout.Label("Item module not loaded", GuiStyles.Label, Array.Empty()); return; } GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Inventory Items", (itemMode == 0) ? GuiStyles.TabActive : GuiStyles.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { itemMode = 0; } if (GUILayout.Button("Level / ESP Items", (itemMode == 1) ? GuiStyles.TabActive : GuiStyles.Tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) })) { itemMode = 1; if (itemGiverModule.LevelItems.Count == 0) { itemGiverModule.RefreshLevelItems(); } } GUILayout.EndHorizontal(); GUILayout.Space(6f); if (itemMode == 1) { DrawLevelItemsTab(itemGiverModule); } else { DrawInventoryItemsTab(itemGiverModule); } } private void DrawInventoryItemsTab(ItemGiverModule items) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string text = GUILayout.TextField(items.SearchTerm ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (text != items.SearchTerm) { items.SearchTerm = text; items.UpdateSearch(); } if (GUILayout.Button("Refresh", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { items.RefreshItems(); } GUILayout.EndHorizontal(); IntSlider(ModConfig.ItemGiveAmount, "Amount", 1, 999); GUILayout.Space(6f); IReadOnlyList matches = items.Matches; int num = Math.Min(matches.Count, 80); for (int i = 0; i < num; i++) { ItemData val = matches[i]; GUILayout.BeginHorizontal(GuiStyles.Box, Array.Empty()); if (GUILayout.Toggle(items.SelectedIndex == i, ((CraftableItemBase)val).Name, GuiStyles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(330f) })) { items.SelectedIndex = i; } if (GUILayout.Button("Give", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) })) { items.SelectedIndex = i; items.GiveSelected(ModConfig.ItemGiveAmount.Value); } if (GUILayout.Button("Spawn", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) })) { items.SelectedIndex = i; items.SpawnSelectedNearPlayer(ModConfig.ItemGiveAmount.Value); } GUILayout.EndHorizontal(); } DrawQuickItemButtons(items); GUILayout.Label("Showing " + num + " / " + matches.Count + " matches. Give uses inventory rules; Spawn creates the item nearby.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(items.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawLevelItemsTab(ItemGiverModule items) { GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh level items", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) })) { items.RefreshLevelItems(); } if (GUILayout.Button("Find key/remote", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { items.RefreshQuestObjects(); } if (GUILayout.Button("Teleport item to player", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) })) { items.TeleportSelectedItemToPlayer(); } if (GUILayout.Button("Teleport player to item", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) })) { items.TeleportPlayerToSelectedItem(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Collect / Pick up", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { items.CollectSelectedLevelItem(); } if (GUILayout.Button("Spawn copy near player", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) })) { items.SpawnCopyOfSelectedLevelItem(); } GUILayout.EndHorizontal(); GUILayout.Space(6f); IReadOnlyList levelItems = items.LevelItems; int num = Math.Min(levelItems.Count, 28); for (int i = 0; i < num; i++) { ItemGiverModule.LevelItemTarget levelItemTarget = levelItems[i]; GUILayout.BeginHorizontal(GuiStyles.Box, Array.Empty()); string text = levelItemTarget.Name + " [" + levelItemTarget.ComponentName + "] " + levelItemTarget.Distance.ToString("F1") + "m"; if (GUILayout.Toggle(items.LevelSelectedIndex == i, text, GuiStyles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(480f) })) { items.LevelSelectedIndex = i; } GUILayout.EndHorizontal(); } GUILayout.Label(items.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawQuickItemButtons(ItemGiverModule items) { GUILayout.Space(8f); GUILayout.Label("Quick", GuiStyles.Label, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); string[] array = new string[6] { "gnomium", "metal", "fabric", "ceramics", "plastic", "chemicals" }; foreach (string text in array) { if (GUILayout.Button(text, GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(86f) })) { items.Give(text, ModConfig.ItemGiveAmount.Value); } } GUILayout.EndHorizontal(); } private void DrawSpawnTab() { SpawnerModule spawnerModule = base.Modules.Get(); if (spawnerModule == null) { GUILayout.Label("Spawner module not loaded", GuiStyles.Label, Array.Empty()); return; } if (spawnerModule.ItemMatches.Count == 0 && spawnerModule.PrefabMatches.Count == 0 && string.IsNullOrEmpty(spawnerModule.LastMessage)) { spawnerModule.Refresh(); } GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh lists", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { spawnerModule.Refresh(); } if (GUILayout.Button("Refresh units", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) })) { spawnerModule.RefreshExistingUnits(); } IntFieldLikeSlider(ref spawnerModule.SpawnAmount, "Amount", 1, 50); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Spawn RC Car", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { spawnerModule.SpawnRCCar(); } GUILayout.Label("For the Mountain garage vehicle, try Objects search: rc, car, vehicle.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Items", (spawnMode == 0) ? GuiStyles.TabActive : GuiStyles.Tab, Array.Empty())) { spawnMode = 0; } if (GUILayout.Button("Objects", (spawnMode == 1) ? GuiStyles.TabActive : GuiStyles.Tab, Array.Empty())) { spawnMode = 1; } if (GUILayout.Button("NPCs", (spawnMode == 2) ? GuiStyles.TabActive : GuiStyles.Tab, Array.Empty())) { spawnMode = 2; } GUILayout.EndHorizontal(); if (spawnMode == 0) { DrawSpawnItems(spawnerModule); } else if (spawnMode == 1) { DrawSpawnObjects(spawnerModule); } else { DrawSpawnNpcs(spawnerModule); } GUILayout.Label(spawnerModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label("Network spawns need host/server. If a prefab cannot be safely created, BGMod reports unavailable.", GuiStyles.SmallLabel, Array.Empty()); } private void DrawSpawnItems(SpawnerModule spawner) { Section("Spawn items"); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string text = GUILayout.TextField(spawner.ItemSearchTerm ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (text != spawner.ItemSearchTerm) { spawner.ItemSearchTerm = text; spawner.UpdateItemSearch(); } GUILayout.EndHorizontal(); IReadOnlyList itemMatches = spawner.ItemMatches; string text2 = ((itemMatches.Count > 0 && spawner.SelectedItemIndex >= 0 && spawner.SelectedItemIndex < itemMatches.Count) ? ((CraftableItemBase)itemMatches[spawner.SelectedItemIndex]).Name : "None"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button((showSpawnItems ? "Hide list" : "Show list") + " (" + itemMatches.Count + ")", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { showSpawnItems = !showSpawnItems; } GUILayout.Label("Selected: " + text2, GuiStyles.Label, Array.Empty()); if (GUILayout.Button("Spawn selected", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { spawner.SpawnSelectedItem(); } if (GUILayout.Button("Human hands", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { spawner.SpawnSelectedItemInHumanHands(); } GUILayout.EndHorizontal(); if (!showSpawnItems) { return; } int count = itemMatches.Count; for (int i = 0; i < count; i++) { if (GUILayout.Button(((CraftableItemBase)itemMatches[i]).Name, (spawner.SelectedItemIndex == i) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { spawner.SelectedItemIndex = i; } } GUILayout.Label("Showing " + count + " / " + itemMatches.Count + ". Search narrows the list.", GuiStyles.SmallLabel, Array.Empty()); } private void DrawSpawnObjects(SpawnerModule spawner) { Section("Spawn objects"); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string text = GUILayout.TextField(spawner.PrefabSearchTerm ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (text != spawner.PrefabSearchTerm) { spawner.PrefabSearchTerm = text; spawner.UpdatePrefabSearch(); } GUILayout.EndHorizontal(); IReadOnlyList prefabMatches = spawner.PrefabMatches; string text2 = ((prefabMatches.Count > 0 && spawner.SelectedPrefabIndex >= 0 && spawner.SelectedPrefabIndex < prefabMatches.Count) ? (prefabMatches[spawner.SelectedPrefabIndex].Name + " [" + prefabMatches[spawner.SelectedPrefabIndex].Kind + "]") : "None"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button((showSpawnObjects ? "Hide list" : "Show list") + " (" + prefabMatches.Count + ")", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { showSpawnObjects = !showSpawnObjects; } GUILayout.Label("Selected: " + text2, GuiStyles.Label, Array.Empty()); if (GUILayout.Button("Spawn selected", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { spawner.SpawnSelectedPrefab(); } if (GUILayout.Button("Human hands", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { spawner.SpawnSelectedPrefabInHumanHands(); } GUILayout.EndHorizontal(); if (!showSpawnObjects) { return; } int count = prefabMatches.Count; for (int i = 0; i < count; i++) { if (GUILayout.Button(prefabMatches[i].Name + " [" + prefabMatches[i].Kind + "]", (spawner.SelectedPrefabIndex == i) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { spawner.SelectedPrefabIndex = i; } } GUILayout.Label("Showing " + count + " / " + prefabMatches.Count + ". Search narrows the list.", GuiStyles.SmallLabel, Array.Empty()); } private void DrawSpawnNpcs(SpawnerModule spawner) { Section("Spawn NPCs"); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string text = GUILayout.TextField(spawner.NpcSearchTerm ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (text != spawner.NpcSearchTerm) { spawner.NpcSearchTerm = text; spawner.UpdateNpcSearch(); } GUILayout.EndHorizontal(); IReadOnlyList npcMatches = spawner.NpcMatches; string text2 = ((npcMatches.Count > 0 && spawner.SelectedNpcIndex >= 0 && spawner.SelectedNpcIndex < npcMatches.Count) ? (npcMatches[spawner.SelectedNpcIndex].Name + " [" + npcMatches[spawner.SelectedNpcIndex].Source + "]") : "None"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button((showSpawnNpcs ? "Hide list" : "Show list") + " (" + npcMatches.Count + ")", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { showSpawnNpcs = !showSpawnNpcs; } GUILayout.Label("Selected: " + text2, GuiStyles.Label, Array.Empty()); if (GUILayout.Button("Spawn selected", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { spawner.SpawnSelectedNpc(); } GUILayout.EndHorizontal(); if (showSpawnNpcs) { int count = npcMatches.Count; for (int i = 0; i < count; i++) { if (GUILayout.Button(npcMatches[i].Name + " [" + npcMatches[i].Source + "]", (spawner.SelectedNpcIndex == i) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { spawner.SelectedNpcIndex = i; } } GUILayout.Label("Showing " + count + " / " + npcMatches.Count + ". Search narrows the list.", GuiStyles.SmallLabel, Array.Empty()); } Section("Existing units"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Teleport unit to me", GuiStyles.Button, Array.Empty())) { spawner.TeleportSelectedUnitToPlayer(); } if (GUILayout.Button("Teleport me to unit", GuiStyles.Button, Array.Empty())) { spawner.TeleportPlayerToSelectedUnit(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Kill selected NPC", GuiStyles.Button, Array.Empty())) { spawner.KillSelectedUnit(); } GUILayout.Label("Minutes (0 = infinity)", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) }); npcMinutesText = GUILayout.TextField(npcMinutesText ?? "1", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.EndHorizontal(); float minutes = ParsePositiveFloat(npcMinutesText, 1f); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Stun NPC", GuiStyles.Button, Array.Empty())) { spawner.ApplyStatusToSelectedUnit((Type)0, minutes); } if (GUILayout.Button("Tie NPC", GuiStyles.Button, Array.Empty())) { spawner.ApplyStatusToSelectedUnit((Type)2, minutes); } if (GUILayout.Button("Fire NPC", GuiStyles.Button, Array.Empty())) { spawner.ApplyStatusToSelectedUnit((Type)1, minutes); } GUILayout.EndHorizontal(); IReadOnlyList existingUnits = spawner.ExistingUnits; GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button((showExistingUnits ? "Hide units" : "Show units") + " (" + existingUnits.Count + ")", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { showExistingUnits = !showExistingUnits; } GUILayout.EndHorizontal(); if (!showExistingUnits) { return; } int count2 = existingUnits.Count; for (int j = 0; j < count2; j++) { if (GUILayout.Button(existingUnits[j].Name + " [" + existingUnits[j].TypeName + "] " + existingUnits[j].Distance.ToString("F1") + "m", (spawner.SelectedExistingUnitIndex == j) ? GuiStyles.TabActive : GuiStyles.Button, Array.Empty())) { spawner.SelectedExistingUnitIndex = j; } } GUILayout.Label("Showing " + count2 + " / " + existingUnits.Count + ".", GuiStyles.SmallLabel, Array.Empty()); } private void DrawWorldTab() { WorldModule worldModule = base.Modules.Get(); if (worldModule == null) { GUILayout.Label("World module not loaded", GuiStyles.Label, Array.Empty()); return; } if (worldModule.Levels.Count == 0 && string.IsNullOrEmpty(worldModule.LastMessage)) { worldModule.Refresh(); } GUILayout.Label("Current scene: " + worldModule.CurrentScene, GuiStyles.Label, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh levels", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { worldModule.Refresh(); } if (GUILayout.Button("Start selected", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { worldModule.LoadSelected(); } GUILayout.EndHorizontal(); Section("Home repair"); GUILayout.Label("House stage buttons were removed because forced stages can delete/rebuild the home.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Repair missing home", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) })) { worldModule.RepairMissingHome(); } GUILayout.EndHorizontal(); GUILayout.Label("Use only in lobby/plateau, as host, when the home is missing.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Search", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); string text = GUILayout.TextField(worldModule.SearchTerm ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(260f) }); if (text != worldModule.SearchTerm) { worldModule.SearchTerm = text; worldModule.ApplySearch(); } GUILayout.EndHorizontal(); IReadOnlyList levels = worldModule.Levels; int num = Math.Min(levels.Count, 60); for (int i = 0; i < num; i++) { WorldModule.WorldTarget worldTarget = levels[i]; GUILayout.BeginHorizontal(GuiStyles.Box, Array.Empty()); string text2 = worldTarget.DisplayName + " [" + worldTarget.Source + "]"; if (GUILayout.Toggle(worldModule.SelectedIndex == i, text2, GuiStyles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(520f) })) { worldModule.SelectedIndex = i; } GUILayout.EndHorizontal(); } GUILayout.Label("Showing " + num + " / " + levels.Count + " levels.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(worldModule.MethodInfo, GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(worldModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawResourcesTab() { ResourcesModule resourcesModule = base.Modules.Get(); if (resourcesModule == null) { GUILayout.Label("Resources module not loaded", GuiStyles.Label, Array.Empty()); return; } GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Refresh resources", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { resourcesModule.Refresh(); } if (GUILayout.Button("Add all carried", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) })) { resourcesModule.AddAll(ModConfig.ResourceGiveAmount.Value); } if (GUILayout.Button("Add all stockpile", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(135f) })) { resourcesModule.AddAllStockpile(ModConfig.ResourceGiveAmount.Value); } if (GUILayout.Button("Add all both", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(115f) })) { resourcesModule.AddAllBoth(ModConfig.ResourceGiveAmount.Value); } GUILayout.EndHorizontal(); IntSlider(ModConfig.ResourceGiveAmount, "Amount", 1, 9999); string[] array = new string[6] { "ceramics", "metal", "fabric", "plastic", "chemicals", "gnomium" }; for (int i = 0; i < array.Length; i++) { GUILayout.BeginHorizontal(GuiStyles.Box, Array.Empty()); GUILayout.Label(array[i], GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); GUILayout.Label("carried " + resourcesModule.GetCount(i), GuiStyles.SmallLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(105f) }); GUILayout.Label("stockpile " + resourcesModule.GetStockpileCount(i), GuiStyles.SmallLabel, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }); if (GUILayout.Button("Carried", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(85f) })) { resourcesModule.AddCarriedResource(i, ModConfig.ResourceGiveAmount.Value); } if (GUILayout.Button("Stockpile", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { resourcesModule.AddStockpileResource(i, ModConfig.ResourceGiveAmount.Value); } if (GUILayout.Button("Both", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) })) { resourcesModule.AddBoth(i, ModConfig.ResourceGiveAmount.Value); } GUILayout.EndHorizontal(); } GUILayout.Label("Carried is what you hold. Stockpile is the home/deposit inventory and can have game limits.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(resourcesModule.CurrentValuesText, GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label(resourcesModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawGameTab() { GameModule gameModule = base.Modules.Get(); if (gameModule == null) { GUILayout.Label("Game module not loaded", GuiStyles.Label, Array.Empty()); return; } Section("Round"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Game start", GuiStyles.Button, Array.Empty())) { gameModule.StartGame(); } if (GUILayout.Button("Game end", GuiStyles.Button, Array.Empty())) { gameModule.EndGame(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Round minutes", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) }); roundMinutesText = GUILayout.TextField(roundMinutesText ?? "20", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); if (GUILayout.Button("Set remaining", GuiStyles.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { gameModule.SetRemainingMinutes(ParsePositiveFloat(roundMinutesText, 20f)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Infinity round", GuiStyles.Button, Array.Empty())) { gameModule.FreezeRoundTime(frozen: true); } if (GUILayout.Button("Timer on", GuiStyles.Button, Array.Empty())) { gameModule.FreezeRoundTime(frozen: false); } GUILayout.EndHorizontal(); Section("Complete tasks"); GUILayout.BeginHorizontal(Array.Empty()); for (int i = 1; i <= 5; i++) { int taskNumber = i; if (GUILayout.Button(taskNumber.ToString(), GuiStyles.Button, Array.Empty())) { gameModule.CompleteTask(taskNumber); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Complete 1-3", GuiStyles.Button, Array.Empty())) { gameModule.CompleteTasksUpTo(3); } if (GUILayout.Button("Complete all 5", GuiStyles.Button, Array.Empty())) { gameModule.CompleteTasksUpTo(5); } GUILayout.EndHorizontal(); GUILayout.Label(gameModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } private void DrawChaosTab() { ChaosModule chaosModule = base.Modules.Get(); Toggle(ModConfig.EnableChaos, "Enable chaos features"); Toggle(ModConfig.PoltergeistMode, "Poltergeist mode"); GUILayout.Label("Poltergeist extends possession. TP stays on G in the Player tab.", GuiStyles.SmallLabel, Array.Empty()); GUILayout.Space(8f); GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label("Radius", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); chaosRadiusText = GUILayout.TextField(chaosRadiusText ?? "12", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); GUILayout.Label("Minutes", GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }); chaosMinutesText = GUILayout.TextField(chaosMinutesText ?? "0.25", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(80f) }); GUILayout.EndHorizontal(); float radius = ParsePositiveFloat(chaosRadiusText, 12f); float minutes = ParsePositiveFloat(chaosMinutesText, 0.25f); Section("Local chaos"); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Throw nearby props", GuiStyles.Button, Array.Empty())) { chaosModule?.ThrowNearbyProps(radius, 22f); } if (GUILayout.Button("Bring units to me", GuiStyles.Button, Array.Empty())) { chaosModule?.BringNearbyUnits(radius); } if (GUILayout.Button("Kill nearby units", GuiStyles.Button, Array.Empty())) { chaosModule?.KillNearbyUnits(radius); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Launch nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.LaunchNearbyUnits(radius); } if (GUILayout.Button("Clear nearby effects", GuiStyles.Button, Array.Empty())) { chaosModule?.ClearNearbyEffects(radius); } if (GUILayout.Button("Despawn enemies", GuiStyles.Button, Array.Empty())) { chaosModule?.DespawnEnemies(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Stun nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.ApplyNearbyStatus((Type)0, radius, minutes); } if (GUILayout.Button("Tie nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.ApplyNearbyStatus((Type)2, radius, minutes); } if (GUILayout.Button("Fire nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.ApplyNearbyStatus((Type)1, radius, minutes); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty()); if (GUILayout.Button("Confuse nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.ApplyNearbyStatus((Type)13, radius, minutes); } if (GUILayout.Button("Sleep nearby", GuiStyles.Button, Array.Empty())) { chaosModule?.ApplyNearbyStatus((Type)10, radius, minutes); } GUILayout.EndHorizontal(); GUILayout.Label("Some chaos actions need host/server to replicate for everyone.", GuiStyles.SmallLabel, Array.Empty()); if (chaosModule != null) { GUILayout.Label(chaosModule.LastMessage, GuiStyles.SmallLabel, Array.Empty()); } } private void DrawPerformanceTab() { Toggle(ModConfig.LowFPSMode, "Low FPS mode"); Toggle(ModConfig.DisableExpensiveScans, "Disable expensive scans"); Slider(ModConfig.CacheLifetime, "Cache lifetime", 0.5f, 10f); PerformanceModule performanceModule = base.Modules.Get(); if (performanceModule != null) { GUILayout.Label("Effective ESP refresh: " + performanceModule.EspRefreshRate.ToString("F2"), GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label("Effective max objects: " + performanceModule.MaxEspObjects, GuiStyles.SmallLabel, Array.Empty()); } } private void DrawDebugTab() { GUILayout.Label("BGMod by Joive", GuiStyles.Label, Array.Empty()); GUILayout.Label("Local player: " + ((Object)(object)GameAccess.LocalPlayer() != (Object)null), GuiStyles.SmallLabel, Array.Empty()); GUILayout.Label("Time scale: " + Time.timeScale.ToString("F2"), GuiStyles.SmallLabel, Array.Empty()); GnomeModule gnomeModule = base.Modules.Get(); if (gnomeModule != null && !string.IsNullOrEmpty(gnomeModule.LastMovementMessage)) { GUILayout.Label(gnomeModule.LastMovementMessage, GuiStyles.SmallLabel, Array.Empty()); } GUILayout.Space(8f); foreach (IModModule allModule in base.Modules.AllModules) { GUILayout.Label(allModule.DisplayName + ": " + (allModule.Enabled ? "on" : "off"), GuiStyles.SmallLabel, Array.Empty()); } } private void EnableModalMode() { //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) if (!modalActive) { modalActive = true; oldCursorVisible = Cursor.visible; oldCursorLock = Cursor.lockState; oldTimeScale = Time.timeScale; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; timeScalePaused = ModConfig.UsePauseTimeScale.Value; if (timeScalePaused) { Time.timeScale = 0f; } SetGameplayUiOpen(open: true); } } private void DisableModalMode() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (modalActive) { modalActive = false; if (timeScalePaused) { Time.timeScale = ((oldTimeScale <= 0f) ? 1f : oldTimeScale); } timeScalePaused = false; SetGameplayUiOpen(open: false); Cursor.visible = oldCursorVisible; Cursor.lockState = oldCursorLock; } } private void KeepModalState() { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; SetGameplayUiOpen(open: true); if (ModConfig.UsePauseTimeScale.Value) { if (!timeScalePaused) { oldTimeScale = Time.timeScale; timeScalePaused = true; } if (Time.timeScale != 0f) { Time.timeScale = 0f; } } else if (timeScalePaused) { Time.timeScale = ((oldTimeScale <= 0f) ? 1f : oldTimeScale); timeScalePaused = false; } } private void SetGameplayUiOpen(bool open) { if (!open) { RestoreGameplayUiOpen(); return; } PlayerController val = FindLocalController(); if (!((Object)(object)val == (Object)null)) { if ((Object)(object)modalController != (Object)(object)val) { RestoreGameplayUiOpen(); modalController = val; oldControllerUiOpen = ReflectionUtils.GetBool(val, "isUiOpen"); hadModalControllerState = true; } ReflectionUtils.TrySetMemberValue(val, "isUiOpen", true); val.RefreshMouseState(); } } private void RestoreGameplayUiOpen() { if ((Object)(object)modalController == (Object)null || !hadModalControllerState) { modalController = null; hadModalControllerState = false; return; } ReflectionUtils.TrySetMemberValue(modalController, "isUiOpen", oldControllerUiOpen); modalController.RefreshMouseState(); modalController = null; hadModalControllerState = false; } private static PlayerController FindLocalController() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { return null; } PlayerController val2 = null; try { val2 = val.Controller; } catch { } if (!((Object)(object)val2 != (Object)null)) { return ((Component)val).GetComponentInChildren(true); } return val2; } private void EnsureWindowRect() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_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) float num = Mathf.Min(760f, Mathf.Max(460f, (float)Screen.width - 32f)); float num2 = Mathf.Min(520f, Mathf.Max(360f, (float)Screen.height - 32f)); if (!centered || ((Rect)(ref windowRect)).width <= 0f || ((Rect)(ref windowRect)).height <= 0f) { windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2); centered = true; } else { ((Rect)(ref windowRect)).width = num; ((Rect)(ref windowRect)).height = num2; windowRect = ClampToScreen(windowRect); } } private static Rect ClampToScreen(Rect rect) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) ((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, 8f, Mathf.Max(8f, (float)Screen.width - ((Rect)(ref rect)).width - 8f)); ((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, 8f, Mathf.Max(8f, (float)Screen.height - ((Rect)(ref rect)).height - 8f)); return rect; } private static void Toggle(ConfigEntry entry, string label) { bool flag = GUILayout.Toggle(entry.Value, label, GuiStyles.Toggle, Array.Empty()); if (flag != entry.Value) { entry.Value = flag; } } private static void Section(string label) { GUILayout.Label(label, GuiStyles.Section, Array.Empty()); } private static void Slider(ConfigEntry entry, string label, float min, float max) { GUILayout.Label(label + ": " + entry.Value.ToString("F2"), GuiStyles.Label, Array.Empty()); entry.Value = GUILayout.HorizontalSlider(entry.Value, min, max, GuiStyles.Slider, GuiStyles.SliderThumb, Array.Empty()); } private static void IntSlider(ConfigEntry entry, string label, int min, int max) { GUILayout.Label(label + ": " + entry.Value, GuiStyles.Label, Array.Empty()); entry.Value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)entry.Value, (float)min, (float)max, GuiStyles.Slider, GuiStyles.SliderThumb, Array.Empty())); } private static void IntFieldLikeSlider(ref int value, string label, int min, int max) { GUILayout.Label(label + ": " + value, GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) }); value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)value, (float)min, (float)max, GuiStyles.Slider, GuiStyles.SliderThumb, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })); } private static void DrawConfigTextField(ConfigEntry entry, string label) { GUILayout.BeginHorizontal(Array.Empty()); GUILayout.Label(label, GuiStyles.Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }); string text = GUILayout.TextField(entry.Value ?? "", GuiStyles.TextField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); if (text != entry.Value) { entry.Value = text; } GUILayout.EndHorizontal(); } private static float ParsePositiveFloat(string value, float fallback) { if (float.TryParse((value ?? "").Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return Mathf.Max(0f, result); } return fallback; } private static string L(string text) { if (!IsRussian) { return text; } return text switch { "Main" => "Главная", "Player" => "Игрок", "ESP" => "ESP", "Items" => "Предметы", "Spawn" => "Спавн", "World" => "Мир", "Resources" => "Ресурсы", "Chaos" => "Хаос", "Performance" => "FPS", "FPS" => "FPS", "Debug" => "Дебаг", "Language" => "Язык", "Enable BGMod" => "Включить BGMod", "Enable HUD" => "Включить HUD", "Enable ESP" => "Включить ESP", "Enable player features" => "Функции игрока", "Enable chaos features" => "Функции хаоса", "Enable FPS optimizations" => "Оптимизация FPS", "Show debug info" => "Показывать дебаг", "Pause game time while menu is open" => "Пауза времени при открытом меню", "Menu key" => "Клавиша меню", "Save config" => "Сохранить", "Reset config" => "Сбросить", "Confirm reset" => "Подтвердить", "Click Confirm reset to restore BGMod defaults." => "Нажми Подтвердить, чтобы вернуть настройки BGMod.", "Speed" => "Скорость", "Toggles" => "Переключатели", "Hands and scale" => "Руки и размер", "Full heal" => "Полное лечение", "Kill player" => "Убить игрока", "Force ragdoll" => "Ragdoll", "Unragdoll" => "Встать", "God mode" => "Бессмертие", "Infinite stamina" => "Бесконечная выносливость", "Movement hotkeys" => "Горячие клавиши движения", "Fly (Experimental)" => "Fly (Экспериментально)", "Noclip (Experimental)" => "Noclip (Экспериментально)", "Walk noclip (Experimental)" => "Ходячий noclip (экспериментально)", "No fall damage" => "Без урона от падения", "Anti kidnap" => "Анти-похищение", "Long hands" => "Длинные руки", "Speed multiplier" => "Скорость", "Fly speed" => "Скорость fly", "Interaction distance" => "Дистанция взаимодействия", "Player scale" => "Размер игрока", "Hotkeys" => "Клавиши", "Experimental movement note" => "Fly/Noclip оставлены как Experimental: TP на G стабильнее.", _ => text, }; } private static KeyCode ParseKey(string value, KeyCode fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_001e: Unknown result type (might be due to invalid IL or missing references) try { return (KeyCode)Enum.Parse(typeof(KeyCode), value, ignoreCase: true); } catch { return fallback; } } } } namespace BGMod.Performance { public class PerformanceModule : ModuleBase { public override string Id => "performance"; public override string DisplayName => "Performance"; public override bool Enabled { get { return ModConfig.EnablePerformanceMode.Value; } set { ModConfig.EnablePerformanceMode.Value = value; } } public float EspRefreshRate { get { if (!ModConfig.LowFPSMode.Value) { return Math.Max(ModConfig.ESPRefreshRate.Value, 0.1f); } return Math.Max(ModConfig.ESPRefreshRate.Value, 1.5f); } } public float HudRefreshRate { get { if (!ModConfig.LowFPSMode.Value) { return Math.Max(ModConfig.HUDRefreshRate.Value, 0.05f); } return Math.Max(ModConfig.HUDRefreshRate.Value, 0.5f); } } public int MaxEspObjects { get { if (!ModConfig.LowFPSMode.Value) { return Math.Max(ModConfig.MaxESPObjects.Value, 1); } return Math.Min(ModConfig.MaxESPObjects.Value, 25); } } public float MaxEspDistance { get { if (!ModConfig.LowFPSMode.Value) { return Math.Max(ModConfig.MaxESPDistance.Value, 5f); } return Math.Min(ModConfig.MaxESPDistance.Value, 45f); } } public bool ExpensiveScansAllowed { get { if (!ModConfig.DisableExpensiveScans.Value) { return !ModConfig.LowFPSMode.Value; } return false; } } } } namespace BGMod.Patches { public static class PatchManager { public static void Apply(Harmony harmony) { TryPatch(harmony, "PlayerController", "Update", "PlayerControllerUpdatePrefix", null); } public static bool PlayerControllerUpdatePrefix() { if (!((Object)(object)BGModPlugin.Instance == (Object)null) && BGModPlugin.Instance.Menu != null) { return !BGModPlugin.Instance.Menu.Visible; } return true; } private static void TryPatch(Harmony harmony, string typeName, string methodName, string prefix, string postfix) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) try { Type type = AccessTools.TypeByName(typeName); if (type == null) { ModLog.Warning("Patch skipped, type unavailable: " + typeName); return; } MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); if (methodInfo == null) { ModLog.Warning("Patch skipped, method unavailable: " + typeName + "." + methodName); return; } HarmonyMethod val = ((prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(PatchManager).GetMethod(prefix))); HarmonyMethod val2 = ((postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(PatchManager).GetMethod(postfix))); harmony.Patch((MethodBase)methodInfo, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ModLog.Msg("Patch applied: " + typeName + "." + methodName); } catch (Exception ex) { ModLog.Warning("Patch failed for " + typeName + "." + methodName + ": " + ex.Message); } } } } namespace BGMod.HUD { public class HUDModule : ModuleBase { private float deltaTime; private float nextRefresh; private string activeModulesText = ""; private string warningsText = ""; private GUIStyle hudStyle; private GUIStyle fpsStyle; public override string Id => "hud"; public override string DisplayName => "HUD"; public override bool Enabled { get { return ModConfig.EnableHUD.Value; } set { ModConfig.EnableHUD.Value = value; } } public override void OnUpdate() { deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f; float num = base.Modules.Get()?.HudRefreshRate ?? ModConfig.HUDRefreshRate.Value; if (Time.unscaledTime >= nextRefresh) { nextRefresh = Time.unscaledTime + num; activeModulesText = string.Join(", ", base.Modules.EnabledModuleNames.Where((string n) => n != "Menu").Take(8).ToArray()); BuildWarnings(); } } public override void OnGUI() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) if (Enabled) { InitStyles(); float num = Mathf.Clamp(ModConfig.HUDScale.Value, 0.6f, 2f); float num2 = Mathf.Clamp(ModConfig.HUDPositionX.Value, 0f, (float)Screen.width - 80f); float num3 = Mathf.Clamp(ModConfig.HUDPositionY.Value, 0f, (float)Screen.height - 40f); int fontSize = Mathf.RoundToInt(12f * num); hudStyle.fontSize = fontSize; fpsStyle.fontSize = Mathf.RoundToInt(13f * num); GUILayout.BeginArea(new Rect(num2, num3, 380f * num, 160f * num), GUIContent.none, GUIStyle.none); if (ModConfig.ShowFPS.Value) { GUILayout.Label("FPS " + ((deltaTime > 0.0001f) ? (1f / deltaTime) : 0f).ToString("F0"), fpsStyle, Array.Empty()); } if (ModConfig.ShowActiveModules.Value && !string.IsNullOrEmpty(activeModulesText)) { GUILayout.Label("Active: " + activeModulesText, hudStyle, Array.Empty()); } if (ModConfig.ShowWarnings.Value && !string.IsNullOrEmpty(warningsText)) { GUILayout.Label(warningsText, hudStyle, Array.Empty()); } if (ModConfig.DebugMode.Value) { PlayerNetworking val = GameAccess.LocalPlayer(); string text = ((Object)(object)val != (Object)null).ToString(); Scene activeScene = SceneManager.GetActiveScene(); GUILayout.Label("Debug: local=" + text + " scene=" + ((Scene)(ref activeScene)).name, hudStyle, Array.Empty()); } GUILayout.EndArea(); } } private void InitStyles() { //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if (hudStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label); val.normal.textColor = new Color(0.92f, 0.94f, 0.9f, 0.92f); val.richText = true; val.wordWrap = true; hudStyle = val; GUIStyle val2 = new GUIStyle(hudStyle) { fontStyle = (FontStyle)1 }; val2.normal.textColor = new Color(0.45f, 1f, 0.72f, 0.96f); fpsStyle = val2; } } private void BuildWarnings() { List list = new List(); if ((Object)(object)Camera.main == (Object)null) { list.Add("camera unavailable"); } if ((Object)(object)GameAccess.LocalPlayer() == (Object)null) { list.Add("local player not found"); } warningsText = ((list.Count == 0) ? "" : ("Warn: " + string.Join(", ", list.ToArray()))); } } } namespace BGMod.Features { public class ChaosModule : ModuleBase { private object lastPossessTarget; public string LastMessage = ""; public override string Id => "chaos"; public override string DisplayName => "Chaos"; public override bool Enabled { get { return ModConfig.EnableChaos.Value; } set { ModConfig.EnableChaos.Value = value; } } public override void OnUpdate() { if (!Enabled) { return; } PlayerNetworking local = GameAccess.LocalPlayer(); if ((Object)(object)local == (Object)null) { return; } Guard("update", delegate { if (ModConfig.PoltergeistMode.Value) { RunPoltergeist(local); } if (Input.GetMouseButtonDown(2)) { SnatchLookedAtItem(local); } }); } private void RunPoltergeist(PlayerNetworking local) { Component val = ((Component)local).GetComponent("PlayerGhosty") ?? ((Component)local).GetComponentInChildren(TypeByName("PlayerGhosty"), true); if (!((Object)(object)val == (Object)null)) { ReflectionUtils.TrySetMemberValue(val, "possessCooldown", 0f); object memberValue = ReflectionUtils.GetMemberValue(val, "CurrentPossessTarget"); if (memberValue != null && memberValue != lastPossessTarget) { lastPossessTarget = memberValue; BGModPlugin.Instance?.StartPluginCoroutine(ExtendPossession(memberValue)); } } } private IEnumerator ExtendPossession(object target) { for (int i = 0; i < 15; i++) { if (target == null) { break; } ReflectionUtils.TrySetMemberValue(target, "maxPossessTime", 99999f); yield return (object)new WaitForSeconds(0.1f); } } private void SnatchLookedAtItem(PlayerNetworking local) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if ((Object)(object)Camera.main == (Object)null || !Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f)), ref val, 120f)) { return; } StealableObject componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); if (!((Object)(object)componentInParent == (Object)null)) { ((Component)componentInParent).transform.position = ((Component)local).transform.position + ((Component)local).transform.forward * 1.2f + Vector3.up * 0.4f; Rigidbody component = ((Component)componentInParent).GetComponent(); if ((Object)(object)component != (Object)null) { component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; } } } public void ThrowNearbyProps(float radius, float force) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } int num = 0; Vector3 position = ((Component)val).transform.position; Rigidbody[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Rigidbody val2 in array) { if (!((Object)(object)val2 == (Object)null) && !val2.isKinematic && !((Component)val2).transform.IsChildOf(((Component)val).transform) && !(Vector3.Distance(position, val2.position) > radius)) { val2.AddExplosionForce(force, position - Vector3.up, radius, 0.5f, (ForceMode)1); num++; } } LastMessage = "Thrown props: " + num; } public unsafe void ApplyNearbyStatus(Type type, float radius, float minutes) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } float num = ((minutes <= 0f) ? float.PositiveInfinity : (minutes * 60f)); int num2 = 0; Vector3 position = ((Component)val).transform.position; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)val).gameObject) && !(Vector3.Distance(position, ((Component)val2).transform.position) > radius)) { StatusEffectHandler val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInChildren(true); if (!((Object)(object)val3 == (Object)null)) { val3.AddStatus(type, num); num2++; } } } LastMessage = ((object)(*(Type*)(&type))/*cast due to .constrained prefix*/).ToString() + " applied to nearby units: " + num2; } public void BringNearbyUnits(float radius) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } int num = 0; Vector3 position = ((Component)val).transform.position; Vector3 val2 = position + ((Component)val).transform.forward * 2f; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)(object)((Component)val).gameObject) && !(Vector3.Distance(position, ((Component)val3).transform.position) > radius)) { ((Component)val3).transform.position = val2 + Random.insideUnitSphere * 1.2f; Rigidbody val4 = ((Component)val3).GetComponent() ?? ((Component)val3).GetComponentInChildren(true); if ((Object)(object)val4 != (Object)null) { val4.linearVelocity = Vector3.zero; val4.angularVelocity = Vector3.zero; } num++; } } LastMessage = "Moved units to you: " + num; } public void KillNearbyUnits(float radius) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } int num = 0; Vector3 position = ((Component)val).transform.position; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)val).gameObject) && !(Vector3.Distance(position, ((Component)val2).transform.position) > radius)) { HealthBase val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInChildren(true); if (!((Object)(object)val3 == (Object)null)) { val3.TakeDamage(9999f); num++; } } } LastMessage = "Killed nearby units: " + num; } public void LaunchNearbyUnits(float radius) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } int num = 0; Vector3 position = ((Component)val).transform.position; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)(object)((Component)val).gameObject || Vector3.Distance(position, ((Component)val2).transform.position) > radius) { continue; } PlayerNetworking val3 = (PlayerNetworking)(object)((val2 is PlayerNetworking) ? val2 : null); if ((Object)(object)val3 != (Object)null) { val3.ForceRagdoll(); val3.AddRagdollVelocity(Vector3.up * 35f + Random.insideUnitSphere * 10f); num++; continue; } Rigidbody val4 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInChildren(true); if (!((Object)(object)val4 == (Object)null)) { val4.AddForce(Vector3.up * 18f + Random.insideUnitSphere * 8f, (ForceMode)1); num++; } } LastMessage = "Launched nearby units: " + num; } public void ClearNearbyEffects(float radius) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Local player not found"; return; } int num = 0; Vector3 position = ((Component)val).transform.position; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)(object)((Component)val).gameObject) && !(Vector3.Distance(position, ((Component)val2).transform.position) > radius)) { StatusEffectHandler val3 = ((Component)val2).GetComponent() ?? ((Component)val2).GetComponentInChildren(true); if (!((Object)(object)val3 == (Object)null)) { val3.SetOnFire(false); val3.SetTied(false); val3.ClearStun(); num++; } } } LastMessage = "Cleared nearby effects: " + num; } public void DespawnEnemies() { AiDirector val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { LastMessage = "AI director not found"; return; } try { val.DespawnEnemies(); LastMessage = "Despawned enemies"; } catch (Exception ex) { LastMessage = "Despawn failed: " + ex.Message; } } private static Type TypeByName(string name) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType(name); if (type != null) { return type; } } return null; } } public class GameModule : ModuleBase { public string LastMessage = ""; public override string Id => "game"; public override string DisplayName => "Game"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public string RoundStatusText { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 GameProgressionManager val = FindProgression(); if ((Object)(object)val == (Object)null) { return ""; } try { if ((int)val.CurrentGameState != 1) { return ""; } float num = Mathf.Max(0f, val.MaxMinutes - val.GameTimeInMinutes); return "Round: " + Mathf.CeilToInt(num) + "m left"; } catch { return ""; } } } public void CompleteTask(int taskNumber) { if (!IsHostOrServer()) { LastMessage = "Complete task needs host/server"; return; } PlayerTaskManager val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { LastMessage = "Task manager not found. Start a round first."; return; } int num = Mathf.Clamp(taskNumber - 1, 0, 4); try { val.DebugCompleteTask(num); LastMessage = "Completed task " + (num + 1); } catch (Exception ex) { LastMessage = "Complete task failed: " + ex.Message; } } public void CompleteTasksUpTo(int count) { for (int i = 1; i <= Mathf.Clamp(count, 1, 5); i++) { CompleteTask(i); if (LastMessage.StartsWith("Complete task failed", StringComparison.OrdinalIgnoreCase) || LastMessage.Contains("needs host/server") || LastMessage.Contains("not found")) { return; } } LastMessage = "Completed tasks 1-" + Mathf.Clamp(count, 1, 5); } public void SetRemainingMinutes(float minutes) { if (!IsHostOrServer()) { LastMessage = "Round time needs host/server"; return; } GameProgressionManager val = FindProgression(); if ((Object)(object)val == (Object)null) { LastMessage = "Progression manager not found"; return; } float num = Mathf.Clamp(minutes, 0f, 999f) * 60f; float num2 = Mathf.Max(val.MaxSeconds, 1f); float gameTimeNormalized = Mathf.Clamp01((num2 - num) / num2); val.SetGameTimeNormalized(gameTimeNormalized); SetTimeActive(val, value: true); LastMessage = "Round time left: " + minutes.ToString("F1") + " min"; } public void FreezeRoundTime(bool frozen) { if (!IsHostOrServer()) { LastMessage = "Round time needs host/server"; return; } GameProgressionManager val = FindProgression(); if ((Object)(object)val == (Object)null) { LastMessage = "Progression manager not found"; return; } SetTimeActive(val, !frozen); LastMessage = (frozen ? "Round timer frozen" : "Round timer running"); } public void StartGame() { GameProgressionManager val = FindProgression(); if ((Object)(object)val == (Object)null || (Object)(object)val.Bootstrap == (Object)null) { LastMessage = "Progression/bootstrap not found"; return; } try { val.Bootstrap.StartGame("GamePlay"); LastMessage = "Started GamePlay"; } catch (Exception ex) { LastMessage = "Start game failed: " + ex.Message; } } public void EndGame() { GameProgressionManager val = FindProgression(); if ((Object)(object)val == (Object)null || (Object)(object)val.Bootstrap == (Object)null) { LastMessage = "Progression/bootstrap not found"; return; } try { val.Bootstrap.GoToLobby((GameEndedReason)0); LastMessage = "Ended game"; } catch (Exception ex) { LastMessage = "End game failed: " + ex.Message; } } private static GameProgressionManager FindProgression() { try { if ((Object)(object)GameProgressionManager.Instance != (Object)null) { return GameProgressionManager.Instance; } } catch { } return Object.FindFirstObjectByType(); } private static void SetTimeActive(GameProgressionManager manager, bool value) { FieldInfo field = typeof(GameProgressionManager).GetField("n_timeActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); object obj = ((field != null) ? field.GetValue(manager) : null); (obj?.GetType().GetProperty("Value"))?.SetValue(obj, value, null); } private static bool IsHostOrServer() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { if (!singleton.IsServer) { return singleton.IsHost; } return true; } return false; } } public class GnomeModule : ModuleBase { private struct RigidbodyState { public Rigidbody Rigidbody; public bool UseGravity; public bool IsKinematic; public CollisionDetectionMode CollisionDetectionMode; public RigidbodyInterpolation Interpolation; } private struct ColliderState { public Collider Collider; public bool Enabled; } private struct BehaviourState { public Behaviour Behaviour; public bool Enabled; } private struct ActorState { public bool HasActor; public bool AlwaysNotGrounded; public bool SupportDynamicGround; } private float originalBaseSpeed = -1f; private float originalBoostSpeed = -1f; private bool flyNoclipActive; private bool lastFly; private bool lastNoclip; private bool lastWalkNoclip; private bool longHandsActive; private PlayerHandController longHandsController; private float originalMaxHandStretchDistance; private float originalHandBreakDistance; private float originalHandReachDistance; private float originalHandStretchSpeed; private bool repairedVisionLayers; private float lastMovementLogTime; private ActorState savedActorState; private readonly List savedRigidbodies = new List(); private readonly List savedColliders = new List(); private readonly List savedCharacterControllers = new List(); private readonly List savedBehaviours = new List(); public override string Id => "gnome"; public override string DisplayName => "Player"; public string LastMovementMessage { get; private set; } = ""; public override bool Enabled { get { return ModConfig.EnableGnomeFeatures.Value; } set { ModConfig.EnableGnomeFeatures.Value = value; } } public override void OnUpdate() { PlayerNetworking local = GameAccess.LocalPlayer(); if ((Object)(object)local == (Object)null) { return; } if (!Enabled) { RestoreSpeed(local); SetFlyNoclipState(local, active: false); RestoreHands(); ReflectionUtils.TrySetMemberValue(local, "godMode", false); lastFly = false; lastNoclip = false; lastWalkNoclip = false; } else { Guard("update", delegate { UpdateLocalFeatures(local); }); } } public override void OnApplicationQuit() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val != (Object)null) { RestoreSpeed(val); SetFlyNoclipState(val, active: false); RestoreHands(); } } private void UpdateLocalFeatures(PlayerNetworking local) { UpdateGod(local); UpdateSpeed(local); UpdateMovementHotkeys(); UpdateFlyNoclipToggles(local); if (ModConfig.FlyMode.Value || ModConfig.Noclip.Value) { UpdateFly(local); } if (ModConfig.AntiKidnap.Value) { TryReleaseFromKidnappers(local); } if (ModConfig.InfiniteStamina.Value) { TryRestoreStamina(local); } if (ModConfig.LongHands.Value) { TryExtendHands(local); } else { RestoreHands(); } ApplyScale(local); } private void UpdateGod(PlayerNetworking local) { if (ModConfig.GodMode.Value && (Object)(object)local.Health != (Object)null) { ((HealthBase)local.Health).Respawn(); ReflectionUtils.TrySetMemberValue(local, "godMode", true); } else { ReflectionUtils.TrySetMemberValue(local, "godMode", false); } } private void UpdateSpeed(PlayerNetworking local) { NormalMovement componentInChildren = ((Component)local).GetComponentInChildren(true); if (!((Object)(object)componentInChildren == (Object)null)) { if (originalBaseSpeed < 0f) { originalBaseSpeed = componentInChildren.planarMovementParameters.baseSpeedLimit; originalBoostSpeed = componentInChildren.planarMovementParameters.boostSpeedLimit; } if (ModConfig.FlyMode.Value || ModConfig.Noclip.Value) { componentInChildren.planarMovementParameters.baseSpeedLimit = 0f; componentInChildren.planarMovementParameters.boostSpeedLimit = 0f; } else { float num = Mathf.Clamp(ModConfig.SpeedMultiplier.Value, 0.25f, 6f); componentInChildren.planarMovementParameters.baseSpeedLimit = originalBaseSpeed * num; componentInChildren.planarMovementParameters.boostSpeedLimit = originalBoostSpeed * num; } } } private void RestoreSpeed(PlayerNetworking local) { if (!(originalBaseSpeed < 0f)) { NormalMovement componentInChildren = ((Component)local).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.planarMovementParameters.baseSpeedLimit = originalBaseSpeed; componentInChildren.planarMovementParameters.boostSpeedLimit = originalBoostSpeed; } } } private void UpdateFlyNoclipToggles(PlayerNetworking local) { bool flag = ModConfig.FlyMode.Value; bool flag2 = ModConfig.Noclip.Value; bool value = ModConfig.WalkNoclip.Value; if (value && (flag || flag2)) { ModConfig.FlyMode.Value = false; ModConfig.Noclip.Value = false; flag = false; flag2 = false; } if (flag2 && !flag) { ModConfig.FlyMode.Value = true; flag = true; } if (flag != lastFly || flag2 != lastNoclip || value != lastWalkNoclip) { lastFly = flag; lastNoclip = flag2; lastWalkNoclip = value; SetFlyNoclipState(local, flag || flag2); SetNoclipColliders(local, flag2 || value); if (!flag2 && !value) { RepairVisionLayers(local); } } } private void SetFlyNoclipState(PlayerNetworking local, bool active) { //IL_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (flyNoclipActive == active) { return; } flyNoclipActive = active; if (active) { local.ForceNotRagdoll(); SaveActorState(local); savedRigidbodies.Clear(); Rigidbody[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Rigidbody val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { savedRigidbodies.Add(new RigidbodyState { Rigidbody = val, UseGravity = val.useGravity, IsKinematic = val.isKinematic, CollisionDetectionMode = val.collisionDetectionMode, Interpolation = val.interpolation }); val.useGravity = false; val.collisionDetectionMode = (CollisionDetectionMode)3; val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } ModLog.Msg("Fly/Noclip movement enabled."); } else { RestoreNoclipColliders(); RestoreCharacterControllers(); RestoreActorState(local); RestoreRigidbodies(); RestoreBehaviours(); RepairVisionLayers(local); ModLog.Msg("Fly/Noclip movement disabled."); } } private void SetNoclipColliders(PlayerNetworking local, bool enabled) { if (enabled) { if (savedColliders.Count > 0) { return; } Collider[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { savedColliders.Add(new ColliderState { Collider = val, Enabled = val.enabled }); val.enabled = false; } } } else { RestoreNoclipColliders(); } } private void RestoreNoclipColliders() { foreach (ColliderState savedCollider in savedColliders) { if ((Object)(object)savedCollider.Collider != (Object)null) { savedCollider.Collider.enabled = savedCollider.Enabled; } } savedColliders.Clear(); } private void RestoreCharacterControllers() { foreach (ColliderState savedCharacterController in savedCharacterControllers) { if ((Object)(object)savedCharacterController.Collider != (Object)null) { savedCharacterController.Collider.enabled = savedCharacterController.Enabled; } } savedCharacterControllers.Clear(); } private void RestoreRigidbodies() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) foreach (RigidbodyState savedRigidbody in savedRigidbodies) { if (!((Object)(object)savedRigidbody.Rigidbody == (Object)null)) { savedRigidbody.Rigidbody.useGravity = savedRigidbody.UseGravity; savedRigidbody.Rigidbody.isKinematic = savedRigidbody.IsKinematic; savedRigidbody.Rigidbody.collisionDetectionMode = savedRigidbody.CollisionDetectionMode; savedRigidbody.Rigidbody.interpolation = savedRigidbody.Interpolation; savedRigidbody.Rigidbody.linearVelocity = Vector3.zero; savedRigidbody.Rigidbody.angularVelocity = Vector3.zero; } } savedRigidbodies.Clear(); } private void RestoreBehaviours() { foreach (BehaviourState savedBehaviour in savedBehaviours) { if ((Object)(object)savedBehaviour.Behaviour != (Object)null) { savedBehaviour.Behaviour.enabled = savedBehaviour.Enabled; } } savedBehaviours.Clear(); } private void SaveDisable(Behaviour behaviour) { if ((Object)(object)behaviour == (Object)null) { return; } foreach (BehaviourState savedBehaviour in savedBehaviours) { if ((Object)(object)savedBehaviour.Behaviour == (Object)(object)behaviour) { return; } } savedBehaviours.Add(new BehaviourState { Behaviour = behaviour, Enabled = behaviour.enabled }); behaviour.enabled = false; } private void SaveActorState(PlayerNetworking local) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null) && !savedActorState.HasActor) { savedActorState = new ActorState { HasActor = true, AlwaysNotGrounded = val.alwaysNotGrounded, SupportDynamicGround = val.supportDynamicGround }; val.alwaysNotGrounded = true; val.supportDynamicGround = false; ((PhysicsActor)val).Velocity = Vector3.zero; } } private void RestoreActorState(PlayerNetworking local) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { ((PhysicsActor)val).Velocity = Vector3.zero; if (savedActorState.HasActor) { val.alwaysNotGrounded = savedActorState.AlwaysNotGrounded; val.supportDynamicGround = savedActorState.SupportDynamicGround; } } savedActorState = default(ActorState); } private void SaveDisableCharacterController(CharacterController controller) { if ((Object)(object)controller == (Object)null) { return; } foreach (ColliderState savedCharacterController in savedCharacterControllers) { if ((Object)(object)savedCharacterController.Collider == (Object)(object)controller) { return; } } savedCharacterControllers.Add(new ColliderState { Collider = (Collider)(object)controller, Enabled = ((Collider)controller).enabled }); ((Collider)controller).enabled = false; } private void UpdateFly(PlayerNetworking local) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ab: 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_00ad: 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_00bc: 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_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_00cd: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)BGModPlugin.Instance != (Object)null && BGModPlugin.Instance.Menu != null && BGModPlugin.Instance.Menu.Visible) { return; } Camera val = ActiveCamera(); if (!((Object)(object)val == (Object)null)) { EnsureGameplayCamera(local); Vector3 val2 = Vector3.zero; Vector3 forward = ((Component)val).transform.forward; Vector3 right = ((Component)val).transform.right; if (!ModConfig.Noclip.Value) { forward.y = 0f; right.y = 0f; ((Vector3)(ref forward)).Normalize(); ((Vector3)(ref right)).Normalize(); } if (Input.GetKey((KeyCode)119)) { val2 += forward; } if (Input.GetKey((KeyCode)115)) { val2 -= forward; } if (Input.GetKey((KeyCode)97)) { val2 -= right; } if (Input.GetKey((KeyCode)100)) { val2 += right; } if (Input.GetKey((KeyCode)32)) { val2 += Vector3.up; } if (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) { val2 += Vector3.down; } local.ForceNotRagdoll(); Rigidbody[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Rigidbody obj in componentsInChildren) { obj.linearVelocity = Vector3.zero; obj.angularVelocity = Vector3.zero; } CharacterActor val3 = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val3 != (Object)null) { ((PhysicsActor)val3).Velocity = Vector3.zero; } if (!(val2 == Vector3.zero)) { bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); float num = Mathf.Clamp(ModConfig.FlySpeed.Value, 1f, 60f) * (flag ? 2f : 1f); Vector3 val4 = Vector3.ClampMagnitude(((Vector3)(ref val2)).normalized * num * Time.unscaledDeltaTime, 1.25f); MoveFlyPlayer(local, GetLocalPosition(local) + val4); } } } private void UpdateMovementHotkeys() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (!ModConfig.EnableFlyNoclipHotkeys.Value || ((Object)(object)BGModPlugin.Instance != (Object)null && BGModPlugin.Instance.Menu != null && BGModPlugin.Instance.Menu.Visible)) { return; } if (Input.GetKeyDown(ParseKey(ModConfig.FlyToggleKey.Value, (KeyCode)283))) { ModConfig.FlyMode.Value = !ModConfig.FlyMode.Value; if (!ModConfig.FlyMode.Value) { ModConfig.Noclip.Value = false; } } if (Input.GetKeyDown(ParseKey(ModConfig.NoclipToggleKey.Value, (KeyCode)284))) { ModConfig.Noclip.Value = !ModConfig.Noclip.Value; if (ModConfig.Noclip.Value) { ModConfig.FlyMode.Value = true; ModConfig.WalkNoclip.Value = false; } } if (Input.GetKeyDown(ParseKey(ModConfig.WalkNoclipToggleKey.Value, (KeyCode)285))) { ModConfig.WalkNoclip.Value = !ModConfig.WalkNoclip.Value; if (ModConfig.WalkNoclip.Value) { ModConfig.Noclip.Value = false; ModConfig.FlyMode.Value = false; } } if (Input.GetKeyDown((KeyCode)103)) { BlinkToCrosshair(); } } public bool BlinkToCrosshair() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); Camera val2 = ActiveCamera(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMovementMessage = "Blink failed: player or camera not found"; ModLog.Warning(LastMovementMessage); return false; } RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(val2.ScreenPointToRay(new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f)), ref val3, 250f, -1, (QueryTriggerInteraction)1)) { Vector3 localPosition = GetLocalPosition(val); Vector3 forward = ((Component)val2).transform.forward; Vector3 val4 = localPosition + ((Vector3)(ref forward)).normalized * 18f + Vector3.up * 0.35f; MoveLocalPlayer(val, val4); ZeroMotion(val); LastMovementMessage = "Blink: no ray hit, moved forward to " + FormatVector(val4) + " using " + ((Object)val2).name; LogMovement(LastMovementMessage); return true; } Vector3 val5 = ((RaycastHit)(ref val3)).point + Vector3.up * 1.15f; MoveLocalPlayer(val, val5); ZeroMotion(val); LastMovementMessage = "Blink: hit " + ((Object)((RaycastHit)(ref val3)).collider).name + ", moved to " + FormatVector(val5) + " using " + ((Object)val2).name; LogMovement(LastMovementMessage); return true; } public void HealLocal() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Health == (Object)null) { LastMovementMessage = "Heal failed: player not found"; return; } ((HealthBase)val.Health).Respawn(); LastMovementMessage = "Player healed"; LogMovement(LastMovementMessage); } public void KillLocal() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Health == (Object)null) { LastMovementMessage = "Kill failed: player not found"; return; } ((HealthBase)val.Health).TakeDamage(999f); LastMovementMessage = "Player killed"; LogMovement(LastMovementMessage); } public void ForceLocalRagdoll() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMovementMessage = "Ragdoll failed: player not found"; return; } val.ForceRagdoll(); LastMovementMessage = "Ragdoll forced"; LogMovement(LastMovementMessage); } public void UnragdollLocal() { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMovementMessage = "Unragdoll failed: player not found"; return; } val.ForceNotRagdoll(); LastMovementMessage = "Unragdolled"; LogMovement(LastMovementMessage); } private static Camera ActiveCamera() { if ((Object)(object)Camera.main != (Object)null && ((Behaviour)Camera.main).isActiveAndEnabled) { return Camera.main; } Camera[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Camera val in array) { if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled) { return val; } } return null; } private void LogMovement(string message) { if (!(Time.unscaledTime - lastMovementLogTime <= 0.5f)) { lastMovementLogTime = Time.unscaledTime; ModLog.Msg(message); } } private static string FormatVector(Vector3 value) { return value.x.ToString("F1") + ", " + value.y.ToString("F1") + ", " + value.z.ToString("F1"); } private static Vector3 GetLocalPosition(PlayerNetworking local) { //IL_0028: 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) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if (!((Object)(object)val != (Object)null)) { return ((Component)local).transform.position; } return ((PhysicsActor)val).Position; } private static void MoveLocalPlayer(PlayerNetworking local, Vector3 position) { //IL_0033: 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_0023: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { ((PhysicsActor)val).Teleport(position); ((PhysicsActor)val).Velocity = Vector3.zero; } ((Component)local).transform.position = position; Physics.SyncTransforms(); } private static void MoveLocalPlayerSoft(PlayerNetworking local, Vector3 position) { //IL_002b: 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_0080: 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_0070: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled) { val.ForceNotGrounded(2); ((PhysicsActor)val).Position = position; ((PhysicsActor)val).Velocity = Vector3.zero; ((PhysicsActor)val).ResetInterpolationPosition(); } Rigidbody val2 = ((Component)local).GetComponent() ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val2 != (Object)null) { val2.position = position; val2.linearVelocity = Vector3.zero; val2.angularVelocity = Vector3.zero; } ((Component)local).transform.position = position; Physics.SyncTransforms(); } private static void MoveFlyPlayer(PlayerNetworking local, Vector3 position) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0039: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val != (Object)null && ((Behaviour)val).enabled) { val.ForceNotGrounded(2); ((PhysicsActor)val).Teleport(position); ((PhysicsActor)val).Position = position; ((PhysicsActor)val).Velocity = Vector3.zero; ((PhysicsActor)val).ResetInterpolationPosition(); } else { ((Component)local).transform.position = position; } ((Component)local).transform.position = position; Rigidbody component = ((Component)local).GetComponent(); Rigidbody[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { if ((Object)(object)val2 == (Object)(object)component) { val2.position = position; } val2.linearVelocity = Vector3.zero; val2.angularVelocity = Vector3.zero; } } Physics.SyncTransforms(); } private static void EnsureGameplayCamera(PlayerNetworking local) { PlayerController val = local.Controller ?? ((Component)local).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null) && !val.UIOpen) { val.ShowCursor(false); if ((Object)(object)val.Camera != (Object)null) { val.Camera.active = true; } } } private static void ZeroMotion(PlayerNetworking local) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { ((PhysicsActor)val).Velocity = Vector3.zero; } Rigidbody[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Rigidbody val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { val2.linearVelocity = Vector3.zero; val2.angularVelocity = Vector3.zero; } } } private static KeyCode ParseKey(string value, KeyCode fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_001e: Unknown result type (might be due to invalid IL or missing references) try { return (KeyCode)Enum.Parse(typeof(KeyCode), value, ignoreCase: true); } catch { return fallback; } } private void RepairVisionLayers(PlayerNetworking local) { int num = LayerMask.NameToLayer("Ignore Raycast"); if (num < 0) { return; } bool flag = SetDefaultIfIgnored(((Component)local).gameObject, num); Collider[] componentsInChildren = ((Component)local).GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { if ((Object)(object)val != (Object)null) { flag |= SetDefaultIfIgnored(((Component)val).gameObject, num); } } if (flag && !repairedVisionLayers) { repairedVisionLayers = true; ModLog.Msg("Player layers restored from Ignore Raycast so AI can see the player again."); } } private static bool SetDefaultIfIgnored(GameObject go, int ignoreRaycast) { if ((Object)(object)go == (Object)null || go.layer != ignoreRaycast) { return false; } go.layer = 0; return true; } private void TryReleaseFromKidnappers(PlayerNetworking local) { TryApplyAntiKidnapEffect(local); HumanAILink[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (HumanAILink val in array) { if ((Object)(object)val != (Object)null && ReflectionUtils.GetMemberValue(val, "PlayerInHand") == local) { val.ReleasePlayer(); } } PlayerKidnapper[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (PlayerKidnapper val2 in array2) { if ((Object)(object)val2 != (Object)null && (object)val2.CurrentlyHeld == local) { val2.CurrentlyHeld = null; } } } private void TryRestoreStamina(PlayerNetworking local) { CharacterActor val = local.Actor ?? ((Component)local).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null)) { FieldInfo field = typeof(CharacterActor).GetField("currentStamina", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(val, val.maxStamina); } } } private void TryApplyAntiKidnapEffect(PlayerNetworking local) { MethodInfo method = typeof(GameEntityBase).GetMethod("ApplyEffect", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(method == null)) { ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length >= 2 && parameters[0].ParameterType.IsEnum) { object obj = Enum.ToObject(parameters[0].ParameterType, 3); method.Invoke(local, new object[2] { obj, 0f }); } } } private void TryExtendHands(PlayerNetworking local) { PlayerHandController val = local.HandController ?? ((Component)local).GetComponentInChildren(true); if (!((Object)(object)val == (Object)null)) { BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; if (!longHandsActive || (Object)(object)longHandsController != (Object)(object)val) { RestoreHands(); longHandsActive = true; longHandsController = val; originalMaxHandStretchDistance = GetFloatField(val, "maxHandStretchDistance", flags, 0f); originalHandBreakDistance = GetFloatField(val, "handBreakDistance", flags, 0f); originalHandReachDistance = GetFloatField(val, "handReachDistance", flags, 0f); originalHandStretchSpeed = GetFloatField(val, "handStretchSpeed", flags, 0f); } float num = Mathf.Clamp(ModConfig.InteractionDistance.Value, 1f, 999f); SetField(val, "maxHandStretchDistance", num * 400f, flags); SetField(val, "handBreakDistance", num * 4000f, flags); SetField(val, "handReachDistance", num, flags); SetField(val, "handStretchSpeed", 1f, flags); } } private void RestoreHands() { if (!longHandsActive || (Object)(object)longHandsController == (Object)null) { longHandsActive = false; longHandsController = null; return; } BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; SetField(longHandsController, "maxHandStretchDistance", originalMaxHandStretchDistance, flags); SetField(longHandsController, "handBreakDistance", originalHandBreakDistance, flags); SetField(longHandsController, "handReachDistance", originalHandReachDistance, flags); SetField(longHandsController, "handStretchSpeed", originalHandStretchSpeed, flags); longHandsActive = false; longHandsController = null; } private void ApplyScale(PlayerNetworking local) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(ModConfig.PlayerScale.Value, 0.2f, 3f); if (Math.Abs(((Component)local).transform.localScale.x - num) > 0.01f) { ((Component)local).transform.localScale = Vector3.one * num; } } private static void SetField(object target, string name, object value, BindingFlags flags) { FieldInfo field = target.GetType().GetField(name, flags); if (field != null) { field.SetValue(target, value); } } private static float GetFloatField(object target, string name, BindingFlags flags, float fallback) { FieldInfo field = target.GetType().GetField(name, flags); if (field == null) { return fallback; } object value = field.GetValue(target); if (!(value is float)) { return fallback; } return (float)value; } } public class ItemGiverModule : ModuleBase { public class LevelItemTarget { public string Name; public string ComponentName; public GameObject GameObject; public ItemInstance ItemInstance; public StealableObject StealableObject; public Vector3 Position; public float Distance; } private AllItems cachedAllItems; private readonly List allItems = new List(); private readonly List matches = new List(); private readonly List levelItems = new List(); private readonly string[] questKeywords = new string[4] { "key", "shed", "garage", "remote" }; private string lastSearch = ""; public string SearchTerm = ""; public int SelectedIndex; public int LevelSelectedIndex; public string LastMessage = ""; public override string Id => "items"; public override string DisplayName => "Items"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public IReadOnlyList Matches => matches; public IReadOnlyList LevelItems => levelItems; public void RefreshItems() { cachedAllItems = FindAllItems(); allItems.Clear(); matches.Clear(); if ((Object)(object)cachedAllItems != (Object)null && cachedAllItems.items != null) { AddKnownItemData(allItems, cachedAllItems.items); } AddKnownItemData(allItems, Resources.FindObjectsOfTypeAll()); if (allItems.Count == 0) { LastMessage = "No ItemData found"; ModLog.Warning("Item Giver: no ItemData found."); return; } allItems.Sort((ItemData a, ItemData b) => string.Compare(((CraftableItemBase)a).Name, ((CraftableItemBase)b).Name, StringComparison.OrdinalIgnoreCase)); lastSearch = null; UpdateSearch(); LastMessage = "Loaded items: " + allItems.Count; } public void UpdateSearch() { string search = SearchTerm ?? ""; if (search == lastSearch && matches.Count > 0) { return; } if (allItems.Count == 0) { RefreshItems(); return; } lastSearch = search; matches.Clear(); IEnumerable source = allItems; if (!string.IsNullOrWhiteSpace(search)) { source = source.Where((ItemData i) => ((CraftableItemBase)i).Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0); } matches.AddRange(source.Take(500)); SelectedIndex = Mathf.Clamp(SelectedIndex, 0, Math.Max(matches.Count - 1, 0)); } public bool GiveSelected(int amount) { UpdateSearch(); if (matches.Count == 0) { LastMessage = "No item selected"; return false; } return Give(((CraftableItemBase)matches[SelectedIndex]).Name, amount); } public bool SpawnSelectedNearPlayer(int amount) { UpdateSearch(); if (matches.Count == 0) { LastMessage = "No item selected"; return false; } return SpawnNearPlayer(((CraftableItemBase)matches[SelectedIndex]).Name, amount); } public unsafe bool Give(string itemName, int amount) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Inventory == (Object)null) { LastMessage = "Player inventory not found"; ModLog.Warning("Item Giver: player inventory not found."); return false; } int num = Mathf.Clamp(amount, 1, 999); try { int num2 = default(int); ItemData itemData = ((InventoryBase)val.Inventory).GetItemData(itemName, ref num2); ItemContainmentResult val2 = ((InventoryBase)val.Inventory).CanContainItem(itemData, -1); if ((int)val2 != 0) { LastMessage = itemName + " cannot go into inventory: " + ((object)(*(ItemContainmentResult*)(&val2))/*cast due to .constrained prefix*/).ToString() + ". Use Spawn."; return false; } int num3 = SafeItemCount((InventoryBase)(object)val.Inventory, itemName); int num4 = 0; int num5 = num; int num6 = Mathf.Clamp(((InventoryBase)val.Inventory).GetMaxStackSize(itemData), 1, 999); while (num5 > 0) { int num7 = Mathf.Min(num6, num5); if (!((InventoryBase)val.Inventory).TryAddItem(itemName, num7)) { if (num7 == 1) { break; } num7 = 1; if (!((InventoryBase)val.Inventory).TryAddItem(itemName, num7)) { break; } } num4 += num7; num5 -= num7; } RefreshInventory((InventoryBase)(object)val.Inventory); int num8 = SafeItemCount((InventoryBase)(object)val.Inventory, itemName); bool flag = num4 > 0 || num8 > num3; LastMessage = (flag ? ("Gave " + itemName + " x" + num4 + ". Inventory now: " + num8) : ("Could not give " + itemName + ". Inventory full or item blocked. Use Spawn.")); ModLog.Msg("Item giver: " + itemName + " requested=" + num + " added=" + num4 + " current=" + num8); if (!flag) { ModLog.Warning("Item Giver failed for item: " + itemName); } return flag; } catch (Exception ex) { LastMessage = "Give failed: " + ex.Message; ModLog.Warning("Item Giver exception: " + ex.Message); return false; } } public bool SpawnNearPlayer(string itemName, int amount) { //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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); AllItems val2 = cachedAllItems ?? FindAllItems(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Player or AllItems not found"; return false; } int num = Mathf.Clamp(amount, 1, 50); int num2 = 0; for (int i = 0; i < num; i++) { try { Vector3 val3 = ((Component)val).transform.position + ((Component)val).transform.forward * (1.2f + (float)i * 0.12f) + Vector3.up * 0.4f; if ((Object)(object)val2.SpawnItemInstance(itemName, val3) != (Object)null) { num2++; } } catch (Exception ex) { LastMessage = "Spawn failed: " + ex.Message; ModLog.Warning("Item spawn from giver failed: " + ex.Message); break; } } LastMessage = ((num2 > 0) ? ("Spawned " + itemName + " x" + num2 + " near player") : ("Spawn unavailable for " + itemName)); return num2 > 0; } public void RefreshLevelItems() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); Vector3 origin = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); levelItems.Clear(); HashSet hashSet = new HashSet(); ItemInstance[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (ItemInstance val2 in array) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)null) && hashSet.Add(((Component)val2).gameObject)) { levelItems.Add(MakeTarget(((Component)val2).gameObject, val2, null, origin)); } } StealableObject[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (StealableObject val3 in array2) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null) && hashSet.Add(((Component)val3).gameObject)) { levelItems.Add(MakeTarget(((Component)val3).gameObject, null, val3, origin)); } } levelItems.Sort((LevelItemTarget a, LevelItemTarget b) => a.Distance.CompareTo(b.Distance)); if (levelItems.Count > 120) { levelItems.RemoveRange(120, levelItems.Count - 120); } LevelSelectedIndex = Mathf.Clamp(LevelSelectedIndex, 0, Math.Max(levelItems.Count - 1, 0)); LastMessage = "Level items: " + levelItems.Count; ModLog.Msg("Level/ESP item scan found " + levelItems.Count + " objects from ItemInstance/StealableObject."); } public void RefreshQuestObjects() { //IL_0022: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) RefreshLevelItems(); PlayerNetworking val = GameAccess.LocalPlayer(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); HashSet hashSet = new HashSet(from i in levelItems where (Object)(object)i.GameObject != (Object)null select i.GameObject); int num = 0; Transform[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (Transform val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null) && !hashSet.Contains(((Component)val3).gameObject)) { string name = ((Object)((Component)val3).gameObject).name ?? ""; if (questKeywords.Any((string k) => name.IndexOf(k, StringComparison.OrdinalIgnoreCase) >= 0) && (!((Object)(object)((Component)val3).GetComponentInChildren(true) == (Object)null) || !((Object)(object)((Component)val3).GetComponentInChildren(true) == (Object)null))) { levelItems.Add(new LevelItemTarget { Name = name, ComponentName = "SceneObject", GameObject = ((Component)val3).gameObject, Position = val3.position, Distance = Vector3.Distance(val2, val3.position) }); hashSet.Add(((Component)val3).gameObject); num++; } } } levelItems.Sort((LevelItemTarget a, LevelItemTarget b) => a.Distance.CompareTo(b.Distance)); LevelSelectedIndex = Mathf.Clamp(LevelSelectedIndex, 0, Math.Max(levelItems.Count - 1, 0)); LastMessage = "Quest scan: " + num + " extra objects. Total: " + levelItems.Count; ModLog.Msg("Quest object scan added " + num + " key/garage/remote/shed scene objects."); } public bool TeleportSelectedItemToPlayer() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //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_0073: Unknown result type (might be due to invalid IL or missing references) LevelItemTarget levelItemTarget = SelectedLevelTarget(); if (levelItemTarget == null) { LastMessage = "No level item selected"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return false; } Vector3 position = ((Component)val).transform.position + ((Component)val).transform.forward * 1.2f + Vector3.up * 0.4f; MoveObject(levelItemTarget.GameObject, position); LastMessage = "Teleported " + levelItemTarget.Name + " to player (" + levelItemTarget.ComponentName + ")"; ModLog.Msg("Level/ESP item teleport to player: " + levelItemTarget.Name + " via " + levelItemTarget.ComponentName); return true; } public bool TeleportPlayerToSelectedItem() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) LevelItemTarget levelItemTarget = SelectedLevelTarget(); if (levelItemTarget == null) { LastMessage = "No level item selected"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return false; } Vector3 val2 = levelItemTarget.Position + Vector3.up * 1.15f; GameEntityBase val3 = (GameEntityBase)(object)val; if ((Object)(object)val3 != (Object)null) { val3.Teleport(val2); } else { ((Component)val).transform.position = val2; } LastMessage = "Teleported player to " + levelItemTarget.Name; return true; } public bool CollectSelectedLevelItem() { LevelItemTarget levelItemTarget = SelectedLevelTarget(); if (levelItemTarget == null) { LastMessage = "No level item selected"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Inventory == (Object)null) { LastMessage = "Player inventory not found"; return false; } ItemInstance val2 = levelItemTarget.ItemInstance ?? levelItemTarget.GameObject.GetComponentInChildren(true) ?? levelItemTarget.GameObject.GetComponentInParent(); if ((Object)(object)val2 != (Object)null) { try { bool flag = ((InventoryBase)val.Inventory).TryAddItem(val2); LastMessage = (flag ? ("Collected " + levelItemTarget.Name) : ("Could not collect " + levelItemTarget.Name)); ModLog.Msg("Level/ESP item collect via ItemInstance: " + levelItemTarget.Name); return flag; } catch (Exception ex) { LastMessage = "Collect failed: " + ex.Message; ModLog.Warning("Level/ESP item collect failed: " + ex.Message); return false; } } Component[] components = levelItemTarget.GameObject.GetComponents(); foreach (Component val3 in components) { if (!((Object)(object)val3 == (Object)null)) { MethodInfo method = ((object)val3).GetType().GetMethod("Interact", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(PlayerNetworking) }, null); if (!(method == null)) { method.Invoke(val3, new object[1] { val }); LastMessage = "Used pickup method on " + levelItemTarget.Name; ModLog.Msg("Level/ESP item collect via " + ((object)val3).GetType().Name + ".Interact"); return true; } } } TeleportSelectedItemToPlayer(); LastMessage = "No safe pickup method; item moved to player"; return false; } public bool SpawnCopyOfSelectedLevelItem() { //IL_0096: 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_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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e4: Unknown result type (might be due to invalid IL or missing references) LevelItemTarget levelItemTarget = SelectedLevelTarget(); if (levelItemTarget == null) { LastMessage = "No level item selected"; return false; } ItemInstance itemInstance = levelItemTarget.ItemInstance; string text = (((Object)(object)itemInstance != (Object)null) ? ResolveItemName(itemInstance) : null); if ((Object)(object)itemInstance == (Object)null || string.IsNullOrEmpty(text)) { TeleportSelectedItemToPlayer(); LastMessage = "Spawn copy is unsafe here; original item moved to player"; return false; } AllItems val = cachedAllItems ?? FindAllItems(); PlayerNetworking val2 = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Spawn source not found; try Refresh"; return false; } try { Vector3 val3 = ((Component)val2).transform.position + ((Component)val2).transform.forward * 1.4f + Vector3.up * 0.4f; ItemInstance val4 = val.SpawnItemInstance(text, val3); if ((Object)(object)val4 != (Object)null) { val4.SetInstanceData(itemInstance.InstanceData); } LastMessage = "Spawned copy of " + text + " from ItemInstance"; ModLog.Msg("Level/ESP item copy spawned from ItemInstance prefab: " + text); return true; } catch (Exception ex) { LastMessage = "Spawn failed, moved original: " + ex.Message; ModLog.Warning("Level/ESP item copy failed: " + ex.Message); TeleportSelectedItemToPlayer(); return false; } } private LevelItemTarget SelectedLevelTarget() { if (levelItems.Count == 0) { RefreshLevelItems(); } if (levelItems.Count == 0) { return null; } LevelSelectedIndex = Mathf.Clamp(LevelSelectedIndex, 0, levelItems.Count - 1); return levelItems[LevelSelectedIndex]; } private LevelItemTarget MakeTarget(GameObject go, ItemInstance item, StealableObject stealable, Vector3 origin) { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Vector3 position = go.transform.position; string text = (((Object)(object)item != (Object)null) ? ResolveItemName(item) : ResolveStealableName(stealable)); if (string.IsNullOrEmpty(text)) { text = ((Object)go).name; } return new LevelItemTarget { Name = text, ComponentName = (((Object)(object)item != (Object)null) ? "ItemInstance" : "StealableObject"), GameObject = go, ItemInstance = item, StealableObject = stealable, Position = position, Distance = Vector3.Distance(origin, position) }; } private string ResolveItemName(ItemInstance item) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) AllItems val = cachedAllItems ?? FindAllItems(); if ((Object)(object)val == (Object)null || val.items == null) { return ((Object)((Component)item).gameObject).name; } int itemIndex = item.InstanceData.itemIndex; if (itemIndex >= 0 && itemIndex < val.items.Length && (Object)(object)val.items[itemIndex] != (Object)null) { return ((CraftableItemBase)val.items[itemIndex]).Name; } return ((Object)((Component)item).gameObject).name; } private static string ResolveStealableName(StealableObject stealable) { //IL_0010: 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) if ((Object)(object)stealable == (Object)null) { return ""; } string text = ((object)stealable.ItemType/*cast due to .constrained prefix*/).ToString(); if (string.IsNullOrEmpty(text) || !(text != "None")) { return ((Object)((Component)stealable).gameObject).name; } return text; } private static void MoveObject(GameObject go, Vector3 position) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)go == (Object)null)) { go.transform.position = position; Rigidbody component = go.GetComponent(); if ((Object)(object)component != (Object)null) { component.position = position; component.linearVelocity = Vector3.zero; component.angularVelocity = Vector3.zero; } } } private static AllItems FindAllItems() { return Resources.FindObjectsOfTypeAll().FirstOrDefault(); } private static void RefreshInventory(InventoryBase inventory) { if ((Object)(object)inventory == (Object)null) { return; } try { inventory.OnInventoryContentsChanged(); } catch (Exception ex) { ModLog.Warning("Inventory refresh failed: " + ex.Message); } } private static int SafeItemCount(InventoryBase inventory, string itemName) { try { return ((Object)(object)inventory != (Object)null) ? inventory.GetItemCount(itemName) : 0; } catch { return 0; } } private static void AddKnownItemData(List target, IEnumerable source) { if (source == null) { return; } HashSet hashSet = new HashSet(from i in target where (Object)(object)i != (Object)null && !string.IsNullOrEmpty(((CraftableItemBase)i).Name) select ((CraftableItemBase)i).Name, StringComparer.OrdinalIgnoreCase); foreach (ItemData item in source) { if (!((Object)(object)item == (Object)null) && !string.IsNullOrEmpty(((CraftableItemBase)item).Name) && hashSet.Add(((CraftableItemBase)item).Name)) { target.Add(item); } } } } public class OnlineModule : ModuleBase { private readonly List players = new List(); public int SelectedPlayerIndex; public string LastMessage = ""; public override string Id => "online"; public override string DisplayName => "Online"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public IReadOnlyList Players => players; public void RefreshPlayers() { players.Clear(); players.AddRange(GameAccess.AllPlayers()); SelectedPlayerIndex = Mathf.Clamp(SelectedPlayerIndex, 0, Math.Max(players.Count - 1, 0)); LastMessage = "Players: " + players.Count; } public PlayerNetworking SelectedPlayer() { if (players.Count == 0) { RefreshPlayers(); } if (players.Count == 0) { return null; } SelectedPlayerIndex = Mathf.Clamp(SelectedPlayerIndex, 0, players.Count - 1); return players[SelectedPlayerIndex]; } public string PlayerLabel(int index) { if (index < 0 || index >= players.Count || (Object)(object)players[index] == (Object)null) { return "Player"; } PlayerNetworking obj = players[index]; string text = GameAccess.PlayerName(obj); bool isLocalPlayer = ((NetworkBehaviour)obj).IsLocalPlayer; float num = GameAccess.DistanceFromLocal((Component)(object)obj); string text2 = (isLocalPlayer ? " [YOU]" : (" [" + num.ToString("F0") + "m]")); return text + text2; } public void HealSelected() { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Health == (Object)null) { LastMessage = "Player not found"; return; } ((HealthBase)val.Health).Respawn(); LastMessage = "Healed " + GameAccess.PlayerName(val); } public void KillSelected() { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Health == (Object)null) { LastMessage = "Player not found"; return; } ((HealthBase)val.Health).TakeDamage(999f); LastMessage = "Killed " + GameAccess.PlayerName(val); } public void RagdollSelected(bool ragdoll) { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; } else if (ragdoll) { val.ForceRagdoll(); LastMessage = "Ragdolled " + GameAccess.PlayerName(val); } else { val.ForceNotRagdoll(); LastMessage = "Unragdolled " + GameAccess.PlayerName(val); } } public void TeleportSelectedToMe() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0060: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); PlayerNetworking val2 = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Player not found"; return; } ((GameEntityBase)val).Teleport(((Component)val2).transform.position + ((Component)val2).transform.forward * 1.5f + Vector3.up * 0.2f); LastMessage = "Teleported " + GameAccess.PlayerName(val) + " to me"; } public void TeleportMeToSelected() { //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); PlayerNetworking val2 = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Player not found"; return; } ((GameEntityBase)val2).Teleport(((Component)val).transform.position + Vector3.up * 1.2f); LastMessage = "Teleported me to " + GameAccess.PlayerName(val); } public void SetFireSelected(float minutes) { ApplyStatus((Type)1, minutes); } public void StunSelected(float minutes) { ApplyStatus((Type)0, minutes); } public void TieSelected(float minutes) { ApplyStatus((Type)2, minutes); } public void ClearEffectsSelected() { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)((GameEntityBase)val).StatusEffectHandler == (Object)null) { LastMessage = "Player or status handler not found"; return; } ((GameEntityBase)val).StatusEffectHandler.SetOnFire(false); ((GameEntityBase)val).StatusEffectHandler.SetTied(false); ((GameEntityBase)val).StatusEffectHandler.ClearStun(); LastMessage = "Cleared effects on " + GameAccess.PlayerName(val); } public void SetGodSelected(bool enabled) { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } ReflectionUtils.TrySetMemberValue(val, "godMode", enabled); if (enabled && (Object)(object)val.Health != (Object)null) { ((HealthBase)val.Health).Respawn(); } LastMessage = "God mode " + (enabled ? "on" : "off") + " for " + GameAccess.PlayerName(val); } public void GiveResourcesSelected(int amount) { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Resources == (Object)null) { LastMessage = "Player resources not found"; return; } int num = Mathf.Clamp(amount, 1, 10000); try { PlayerResources resources = val.Resources; ((ResourceStorage)resources).CeramicsCount = ((ResourceStorage)resources).CeramicsCount + num; PlayerResources resources2 = val.Resources; ((ResourceStorage)resources2).MetalCount = ((ResourceStorage)resources2).MetalCount + num; PlayerResources resources3 = val.Resources; ((ResourceStorage)resources3).FabricCount = ((ResourceStorage)resources3).FabricCount + num; PlayerResources resources4 = val.Resources; ((ResourceStorage)resources4).PlasticCount = ((ResourceStorage)resources4).PlasticCount + num; PlayerResources resources5 = val.Resources; ((ResourceStorage)resources5).ChemicalsCount = ((ResourceStorage)resources5).ChemicalsCount + num; PlayerResources resources6 = val.Resources; ((ResourceStorage)resources6).GnomiumCount = ((ResourceStorage)resources6).GnomiumCount + num; LastMessage = "Gave all resources x" + num + " to " + GameAccess.PlayerName(val); } catch (Exception ex) { LastMessage = "Give resources failed: " + ex.Message; } } public void GiveBuffsSelected(float minutes) { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)((GameEntityBase)val).StatusEffectHandler == (Object)null) { LastMessage = "Player or status handler not found"; return; } float num = ((minutes <= 0f) ? float.PositiveInfinity : (Mathf.Clamp(minutes, 0.05f, 120f) * 60f)); ((GameEntityBase)val).StatusEffectHandler.AddStatus((Type)7, num); ((GameEntityBase)val).StatusEffectHandler.AddStatus((Type)6, num); ((GameEntityBase)val).StatusEffectHandler.AddStatus((Type)12, num); ((GameEntityBase)val).StatusEffectHandler.AddStatus((Type)11, 1f); if ((Object)(object)val.Health != (Object)null) { ((HealthBase)val.Health).Respawn(); } LastMessage = "Gave buffs to " + GameAccess.PlayerName(val); } public void GiveSupportPackSelected(float minutes, int resourceAmount) { PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } SetGodSelected(enabled: true); GiveBuffsSelected(minutes); GiveResourcesSelected(resourceAmount); LastMessage = "Gave support pack to " + GameAccess.PlayerName(val); } public void ExplodeSelected() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } val.AddExplosionForceToRagdollRpc(((GameEntityBase)val).Position, 10f, 900f); LastMessage = "Exploded " + GameAccess.PlayerName(val); } public void LaunchSelected() { //IL_0023: 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) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } val.ForceRagdoll(); val.AddRagdollVelocity(Vector3.up * 45f); LastMessage = "Launched " + GameAccess.PlayerName(val); } public void SpinSelected() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } val.ForceRagdoll(); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Random.Range(-20f, 20f), Random.Range(8f, 22f), Random.Range(-20f, 20f)); val.AddRagdollVelocity(val2); LastMessage = "Spun " + GameAccess.PlayerName(val); } public void FreezeSelected() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return; } val.ForceRagdoll(); val.SetRagdollVelocity(Vector3.zero); LastMessage = "Froze " + GameAccess.PlayerName(val); } public void DismemberSelected(bool head) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)val.Dismemberment == (Object)null) { LastMessage = "Player dismemberment not found"; return; } try { MethodInfo method = ((object)val.Dismemberment).GetType().GetMethod("DismemberRpc", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { LastMessage = "Dismember method not found"; return; } ParameterInfo[] parameters = method.GetParameters(); object obj = ((parameters.Length != 0 && parameters[0].ParameterType.IsEnum) ? Enum.ToObject(parameters[0].ParameterType, head ? 32 : 24) : ((object)(head ? 32 : 24))); method.Invoke(val.Dismemberment, new object[5] { obj, 100f, ((GameEntityBase)val).Position, 30f, 5f }); LastMessage = (head ? "Dismembered head of " : "Dismembered legs of ") + GameAccess.PlayerName(val); } catch (Exception ex) { LastMessage = "Dismember failed: " + ex.Message; } } private unsafe void ApplyStatus(Type type, float minutes) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = SelectedPlayer(); if ((Object)(object)val == (Object)null || (Object)(object)((GameEntityBase)val).StatusEffectHandler == (Object)null) { LastMessage = "Player or status handler not found"; return; } float num = ((minutes <= 0f) ? float.PositiveInfinity : (Mathf.Clamp(minutes, 0.05f, 120f) * 60f)); ((GameEntityBase)val).StatusEffectHandler.AddStatus(type, num); LastMessage = ((object)(*(Type*)(&type))/*cast due to .constrained prefix*/).ToString() + " on " + GameAccess.PlayerName(val) + " for " + (float.IsPositiveInfinity(num) ? "infinity" : (minutes.ToString("F1") + " min")); } } public class ResourcesModule : ModuleBase { public string LastMessage = ""; public string CurrentValuesText = ""; public override string Id => "resources"; public override string DisplayName => "Resources"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public int GetCount(int index) { PlayerNetworking val = GameAccess.LocalPlayer(); ResourceStorage val2 = (ResourceStorage)(object)(((Object)(object)val != (Object)null) ? val.Resources : null); if ((Object)(object)val2 == (Object)null) { return 0; } return index switch { 0 => val2.CeramicsCount, 1 => val2.MetalCount, 2 => val2.FabricCount, 3 => val2.PlasticCount, 4 => val2.ChemicalsCount, 5 => val2.GnomiumCount, _ => 0, }; } public int GetStockpileCount(int index) { InventoryBase val = FindStockpileInventory(); if ((Object)(object)val == (Object)null) { return 0; } try { return val.GetItemCount(ResourceStorage.GetResourceName(index)); } catch { return 0; } } public void Refresh() { CurrentValuesText = BuildCurrentValuesText(); LastMessage = (string.IsNullOrEmpty(CurrentValuesText) ? "Resources not found" : ("Resources refreshed: " + CurrentValuesText)); } public bool AddResource(int index, int amount) { return AddCarriedResource(index, amount); } public bool AddCarriedResource(int index, int amount) { PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null) { LastMessage = "Player not found"; return false; } int num = Mathf.Clamp(amount, 1, 9999); string resourceName = ResourceStorage.GetResourceName(index); try { ResourceStorage resources = (ResourceStorage)(object)val.Resources; if ((Object)(object)resources != (Object)null) { SetCount(resources, index, GetCarriedCount(resources, index) + num); RefreshResourceUi(resources); int carriedCount = GetCarriedCount(resources, index); CurrentValuesText = BuildCurrentValuesText(); LastMessage = "Added " + resourceName + " x" + num + " to carried resources. Now: " + carriedCount; return true; } if ((Object)(object)val.Inventory != (Object)null && ((InventoryBase)val.Inventory).TryAddItem(resourceName, num)) { LastMessage = "Added " + resourceName + " x" + num + " to inventory"; return true; } LastMessage = "Could not add " + resourceName; ModLog.Warning("Resources: could not add " + resourceName); return false; } catch (Exception ex) { LastMessage = "Resource add failed: " + ex.Message; ModLog.Warning("Resources exception: " + ex.Message); return false; } } public bool AddStockpileResource(int index, int amount) { InventoryBase val = FindStockpileInventory(); if ((Object)(object)val == (Object)null) { LastMessage = "Stockpile not found"; return false; } int num = Mathf.Clamp(amount, 1, 9999); string resourceName = ResourceStorage.GetResourceName(index); try { bool flag = val.TryAddItem(resourceName, num); CurrentValuesText = BuildCurrentValuesText(); LastMessage = (flag ? ("Added " + resourceName + " x" + num + " to stockpile. Now: " + GetStockpileCount(index)) : ("Could not add " + resourceName + " to stockpile. It may be full or stack-limited.")); return flag; } catch (Exception ex) { LastMessage = "Stockpile add failed: " + ex.Message; ModLog.Warning("Stockpile resource add failed: " + ex.Message); return false; } } public bool AddBoth(int index, int amount) { bool num = AddCarriedResource(index, amount); bool flag = AddStockpileResource(index, amount); return num || flag; } public bool AddAll(int amount) { bool flag = true; for (int i = 0; i < 6; i++) { flag &= AddCarriedResource(i, amount); } CurrentValuesText = BuildCurrentValuesText(); LastMessage = (flag ? ("Added all x" + Mathf.Clamp(amount, 1, 9999) + ". Current: " + CurrentValuesText) : LastMessage); return flag; } public bool AddAllStockpile(int amount) { bool flag = true; for (int i = 0; i < 6; i++) { flag &= AddStockpileResource(i, amount); } CurrentValuesText = BuildCurrentValuesText(); LastMessage = (flag ? ("Added all stockpile x" + Mathf.Clamp(amount, 1, 9999) + ". Current: " + CurrentValuesText) : LastMessage); return flag; } public bool AddAllBoth(int amount) { bool flag = true; for (int i = 0; i < 6; i++) { flag &= AddBoth(i, amount); } CurrentValuesText = BuildCurrentValuesText(); LastMessage = (flag ? ("Added all carried + stockpile x" + Mathf.Clamp(amount, 1, 9999)) : LastMessage); return flag; } private string BuildCurrentValuesText() { PlayerNetworking val = GameAccess.LocalPlayer(); ResourceStorage val2 = (ResourceStorage)(object)(((Object)(object)val != (Object)null) ? val.Resources : null); if ((Object)(object)val2 == (Object)null) { return ""; } string text = "carried: ceramics " + val2.CeramicsCount + ", metal " + val2.MetalCount + ", fabric " + val2.FabricCount + ", plastic " + val2.PlasticCount + ", chemicals " + val2.ChemicalsCount + ", gnomium " + val2.GnomiumCount; InventoryBase val3 = FindStockpileInventory(); if ((Object)(object)val3 == (Object)null) { return text; } return text + " | stockpile: ceramics " + val3.GetItemCount("ceramics") + ", metal " + val3.GetItemCount("metal") + ", fabric " + val3.GetItemCount("fabric") + ", plastic " + val3.GetItemCount("plastic") + ", chemicals " + val3.GetItemCount("chemicals") + ", gnomium " + val3.GetItemCount("gnomium"); } private static void RefreshResourceUi(ResourceStorage storage) { try { MethodInfo methodInfo = typeof(ResourceStorage).GetMethod("UpdateResourceAmounts", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(ResourceStorage).GetMethod("OnResourcesChanged", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (methodInfo != null) { methodInfo.Invoke(storage, null); } } catch (Exception ex) { ModLog.Warning("Resources UI refresh failed: " + ex.Message); } } private static InventoryBase FindStockpileInventory() { try { GameProgressionManager instance = GameProgressionManager.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.Deposit != (Object)null && (Object)(object)instance.Deposit.ResourceInventory != (Object)null) { return instance.Deposit.ResourceInventory; } } catch { } GnomiumDeposit val = Object.FindFirstObjectByType(); if (!((Object)(object)val != (Object)null)) { return null; } return val.ResourceInventory; } private static int GetCarriedCount(ResourceStorage storage, int index) { return index switch { 0 => storage.CeramicsCount, 1 => storage.MetalCount, 2 => storage.FabricCount, 3 => storage.PlasticCount, 4 => storage.ChemicalsCount, 5 => storage.GnomiumCount, _ => 0, }; } private static void SetCount(ResourceStorage storage, int index, int value) { switch (index) { case 0: storage.CeramicsCount = value; break; case 1: storage.MetalCount = value; break; case 2: storage.FabricCount = value; break; case 3: storage.PlasticCount = value; break; case 4: storage.ChemicalsCount = value; break; case 5: storage.GnomiumCount = value; break; } } } public class SpawnerModule : ModuleBase { public class SpawnPrefabTarget { public string Name; public string Kind; public GameObject Prefab; } public class NpcSpawnTarget { public string Name; public string Source; public EntityData EntityData; public GameObject Prefab; public bool DirectorBacked; } public class ExistingUnitTarget { public string Name; public string TypeName; public GameObject GameObject; public GameEntityBase Entity; public Vector3 Position; public float Distance; } private AllItems cachedAllItems; private readonly List allItems = new List(); private readonly List itemMatches = new List(); private readonly List allPrefabs = new List(); private readonly List prefabMatches = new List(); private readonly List allNpcs = new List(); private readonly List npcMatches = new List(); private readonly List existingUnits = new List(); private string lastItemSearch = ""; private string lastPrefabSearch = ""; private string lastNpcSearch = ""; public string ItemSearchTerm = ""; public string PrefabSearchTerm = ""; public string NpcSearchTerm = ""; public int SelectedItemIndex; public int SelectedPrefabIndex; public int SelectedNpcIndex; public int SelectedExistingUnitIndex; public int SpawnAmount = 1; public string LastMessage = ""; public override string Id => "spawner"; public override string DisplayName => "Spawner"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public IReadOnlyList ItemMatches => itemMatches; public IReadOnlyList PrefabMatches => prefabMatches; public IReadOnlyList NpcMatches => npcMatches; public IReadOnlyList ExistingUnits => existingUnits; public void Refresh() { RefreshItems(); RefreshPrefabs(); RefreshNpcs(); RefreshExistingUnits(); LastMessage = "Spawn lists refreshed. Items: " + allItems.Count + ", prefabs: " + allPrefabs.Count + ", NPCs: " + allNpcs.Count + ", existing units: " + existingUnits.Count; } public void RefreshItems() { cachedAllItems = Resources.FindObjectsOfTypeAll().FirstOrDefault(); allItems.Clear(); itemMatches.Clear(); if ((Object)(object)cachedAllItems != (Object)null && cachedAllItems.items != null) { AddKnownItemData(allItems, cachedAllItems.items); } AddKnownItemData(allItems, Resources.FindObjectsOfTypeAll()); if (allItems.Count == 0) { LastMessage = "No ItemData found"; return; } allItems.Sort((ItemData a, ItemData b) => string.Compare(((CraftableItemBase)a).Name, ((CraftableItemBase)b).Name, StringComparison.OrdinalIgnoreCase)); lastItemSearch = null; UpdateItemSearch(); } public void RefreshPrefabs() { allPrefabs.Clear(); prefabMatches.Clear(); HashSet hashSet = new HashSet(); GameObject[] array = Resources.FindObjectsOfTypeAll(); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null) && hashSet.Add(val) && !((Object)(object)(val.GetComponent() ?? val.GetComponentInChildren(true)) == (Object)null)) { allPrefabs.Add(new SpawnPrefabTarget { Name = CleanName(((Object)val).name), Kind = ClassifyPrefab(val), Prefab = val }); } } allPrefabs.Sort(delegate(SpawnPrefabTarget a, SpawnPrefabTarget b) { int num = string.Compare(a.Kind, b.Kind, StringComparison.OrdinalIgnoreCase); return (num == 0) ? string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) : num; }); lastPrefabSearch = null; UpdatePrefabSearch(); } public void RefreshNpcs() { allNpcs.Clear(); npcMatches.Clear(); HashSet names = new HashSet(StringComparer.OrdinalIgnoreCase); AiDirector val = Object.FindFirstObjectByType(); EnemySpawnConfig[] array = null; try { array = (((Object)(object)val != (Object)null) ? val.SpawnConfig : null); } catch { array = null; } if (array != null) { EnemySpawnConfig[] array2 = array; for (int i = 0; i < array2.Length; i++) { AddNpcTarget(array2[i]?.entityData, "AiDirector", directorBacked: true, names); } } EntityData[] array3 = Resources.FindObjectsOfTypeAll(); foreach (EntityData data in array3) { AddNpcTarget(data, "EntityData", directorBacked: false, names); } allNpcs.Sort(delegate(NpcSpawnTarget a, NpcSpawnTarget b) { int num = string.Compare(a.Source, b.Source, StringComparison.OrdinalIgnoreCase); return (num == 0) ? string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase) : num; }); lastNpcSearch = null; UpdateNpcSearch(); } public void RefreshExistingUnits() { //IL_0027: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) existingUnits.Clear(); PlayerNetworking val = GameAccess.LocalPlayer(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); HashSet hashSet = new HashSet(); GameEntityAI[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityAI val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Component)val3).gameObject == (Object)null) && hashSet.Add(((Component)val3).gameObject)) { GameEntityBase val4 = (GameEntityBase)(object)val3; if (!((Object)(object)val4 != (Object)null) || !val4.IsDead) { existingUnits.Add(new ExistingUnitTarget { Name = ResolveUnitName((Component)(object)val3), TypeName = ((object)val3).GetType().Name, GameObject = ((Component)val3).gameObject, Entity = val4, Position = ((Component)val3).transform.position, Distance = Vector3.Distance(val2, ((Component)val3).transform.position) }); } } } HumanAILink[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (HumanAILink val5 in array2) { if (!((Object)(object)val5 == (Object)null) && !((Object)(object)((Component)val5).gameObject == (Object)null) && hashSet.Add(((Component)val5).gameObject)) { existingUnits.Add(new ExistingUnitTarget { Name = ResolveUnitName((Component)(object)val5), TypeName = ((object)val5).GetType().Name, GameObject = ((Component)val5).gameObject, Entity = (GameEntityBase)(object)val5, Position = ((Component)val5).transform.position, Distance = Vector3.Distance(val2, ((Component)val5).transform.position) }); } } existingUnits.Sort((ExistingUnitTarget a, ExistingUnitTarget b) => a.Distance.CompareTo(b.Distance)); if (existingUnits.Count > 120) { existingUnits.RemoveRange(120, existingUnits.Count - 120); } SelectedExistingUnitIndex = Mathf.Clamp(SelectedExistingUnitIndex, 0, Math.Max(existingUnits.Count - 1, 0)); } public void UpdateItemSearch() { string search = ItemSearchTerm ?? ""; if (search == lastItemSearch && itemMatches.Count > 0) { return; } if (allItems.Count == 0) { RefreshItems(); return; } lastItemSearch = search; itemMatches.Clear(); IEnumerable source = allItems; if (!string.IsNullOrWhiteSpace(search)) { source = source.Where((ItemData i) => ((CraftableItemBase)i).Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0); } itemMatches.AddRange(source.Take(500)); SelectedItemIndex = Mathf.Clamp(SelectedItemIndex, 0, Math.Max(itemMatches.Count - 1, 0)); } public void UpdatePrefabSearch() { string search = PrefabSearchTerm ?? ""; if (search == lastPrefabSearch && prefabMatches.Count > 0) { return; } if (allPrefabs.Count == 0) { RefreshPrefabs(); return; } lastPrefabSearch = search; prefabMatches.Clear(); IEnumerable source = allPrefabs; if (!string.IsNullOrWhiteSpace(search)) { source = source.Where((SpawnPrefabTarget p) => p.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || p.Kind.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0); } prefabMatches.AddRange(source.Take(500)); SelectedPrefabIndex = Mathf.Clamp(SelectedPrefabIndex, 0, Math.Max(prefabMatches.Count - 1, 0)); } public void UpdateNpcSearch() { string search = NpcSearchTerm ?? ""; if (search == lastNpcSearch && npcMatches.Count > 0) { return; } if (allNpcs.Count == 0) { RefreshNpcs(); return; } lastNpcSearch = search; npcMatches.Clear(); IEnumerable source = allNpcs; if (!string.IsNullOrWhiteSpace(search)) { source = source.Where((NpcSpawnTarget n) => n.Name.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || n.Source.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0); } npcMatches.AddRange(source.Take(500)); SelectedNpcIndex = Mathf.Clamp(SelectedNpcIndex, 0, Math.Max(npcMatches.Count - 1, 0)); } public bool SpawnSelectedItem() { UpdateItemSearch(); if (itemMatches.Count == 0) { LastMessage = "No item selected"; return false; } return SpawnItem(((CraftableItemBase)itemMatches[SelectedItemIndex]).Name, SpawnAmount); } public bool SpawnSelectedItemInHumanHands() { UpdateItemSearch(); if (itemMatches.Count == 0) { LastMessage = "No item selected"; return false; } return SpawnItemInHumanHands(((CraftableItemBase)itemMatches[SelectedItemIndex]).Name); } public bool SpawnSelectedPrefab() { UpdatePrefabSearch(); if (prefabMatches.Count == 0) { LastMessage = "No prefab selected"; return false; } return SpawnPrefab(prefabMatches[SelectedPrefabIndex], SpawnAmount); } public bool SpawnSelectedPrefabInHumanHands() { UpdatePrefabSearch(); if (prefabMatches.Count == 0) { LastMessage = "No object selected"; return false; } return SpawnPrefabInHumanHands(prefabMatches[SelectedPrefabIndex]); } public bool SpawnRCCar() { //IL_005b: 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_0063: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "RC Car spawn needs host/server"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); GameObject val2 = FindRCCarPrefab(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "RC Car prefab not found. Load Mountain/garage once, then refresh."; return false; } int num = Mathf.Clamp(SpawnAmount, 1, 10); int num2 = 0; for (int i = 0; i < num; i++) { Vector3 val3 = SpawnPosition(val, i); try { GameObject val4 = Object.Instantiate(val2, val3, Quaternion.identity); val4.SetActive(true); Rigidbody val5 = val4.GetComponent() ?? val4.GetComponentInChildren(true); if ((Object)(object)val5 != (Object)null) { val5.position = val3; val5.linearVelocity = Vector3.zero; val5.angularVelocity = Vector3.zero; } NetworkObject val6 = val4.GetComponent() ?? val4.GetComponentInChildren(true); if ((Object)(object)val6 == (Object)null) { Object.Destroy((Object)(object)val4); continue; } val6.Spawn(false); num2++; } catch (Exception ex) { LastMessage = "RC Car spawn failed: " + ex.Message; ModLog.Warning("RC Car spawn failed: " + ex.Message); break; } } LastMessage = ((num2 > 0) ? ("Spawned RC Car x" + num2) : "RC Car spawn unavailable"); return num2 > 0; } public bool SpawnSelectedNpc() { UpdateNpcSearch(); if (npcMatches.Count == 0) { LastMessage = "No NPC selected"; return false; } return SpawnNpc(npcMatches[SelectedNpcIndex], SpawnAmount); } public bool SpawnItem(string itemName, int amount) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "Spawn needs host/server"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); AllItems val2 = cachedAllItems ?? Resources.FindObjectsOfTypeAll().FirstOrDefault(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Player or AllItems not found"; return false; } int num = Mathf.Clamp(amount, 1, 50); int num2 = 0; for (int i = 0; i < num; i++) { Vector3 val3 = SpawnPosition(val, i); try { if ((Object)(object)val2.SpawnItemInstance(itemName, val3) != (Object)null) { num2++; } } catch (Exception ex) { LastMessage = "Item spawn failed: " + ex.Message; ModLog.Warning("Item spawn failed: " + ex.Message); break; } } LastMessage = ((num2 > 0) ? ("Spawned item " + itemName + " x" + num2) : ("Spawn unavailable for item " + itemName)); ModLog.Msg("Spawn item: " + itemName + " requested=" + num + " spawned=" + num2); return num2 > 0; } public bool SpawnItemInHumanHands(string itemName) { //IL_0055: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "Human hand spawn needs host/server"; return false; } HumanAILink val = FindBestHuman(); AllItems val2 = cachedAllItems ?? Resources.FindObjectsOfTypeAll().FirstOrDefault(); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { LastMessage = "Human or AllItems not found"; return false; } try { Vector3 val3 = ((Component)val).transform.position + ((Component)val).transform.forward * 0.8f + Vector3.up * 1.2f; ItemInstance val4 = val2.SpawnItemInstance(itemName, val3); if ((Object)(object)val4 == (Object)null) { LastMessage = "Spawn unavailable for item " + itemName; return false; } StealableObject val5 = ((Component)val4).GetComponent() ?? ((Component)val4).GetComponentInChildren(true); if ((Object)(object)val5 == (Object)null) { Object.Destroy((Object)(object)((Component)val4).gameObject); LastMessage = itemName + " spawned, but it is not a hand item"; return false; } ForceHumanHoldItem(val, val5); LastMessage = "Put " + itemName + " in Human hands"; ModLog.Msg("Human hand item: " + itemName + " -> " + ResolveUnitName((Component)(object)val)); return true; } catch (Exception ex) { LastMessage = "Human hand spawn failed: " + ex.Message; ModLog.Warning("Human hand spawn failed: " + ex.Message); return false; } } public bool SpawnPrefab(SpawnPrefabTarget target, int amount) { //IL_0056: 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_0063: 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_0087: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "Spawn needs host/server"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || target == null || (Object)(object)target.Prefab == (Object)null) { LastMessage = "Player or prefab not found"; return false; } int num = Mathf.Clamp(amount, 1, 25); int num2 = 0; for (int i = 0; i < num; i++) { Vector3 val2 = SpawnPosition(val, i); try { GameObject val3 = Object.Instantiate(target.Prefab, val2, Quaternion.identity); GameEntityAI componentInChildren = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((GameEntityBase)componentInChildren).Teleport(val2); } NetworkObject val4 = val3.GetComponent() ?? val3.GetComponentInChildren(true); if ((Object)(object)val4 == (Object)null) { Object.Destroy((Object)(object)val3); continue; } val4.Spawn(true); num2++; } catch (Exception ex) { LastMessage = "Prefab spawn failed: " + ex.Message; ModLog.Warning("Prefab spawn failed: " + ex.Message); break; } } LastMessage = ((num2 > 0) ? ("Spawned " + target.Name + " x" + num2 + " (" + target.Kind + ")") : ("Spawn unavailable for " + target.Name + " (" + target.Kind + ")")); ModLog.Msg("Spawn prefab: " + target.Name + " requested=" + num + " spawned=" + num2); return num2 > 0; } public bool SpawnPrefabInHumanHands(SpawnPrefabTarget target) { //IL_0048: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "Human hand object spawn needs host/server"; return false; } HumanAILink val = FindBestHuman(); if ((Object)(object)val == (Object)null || target == null || (Object)(object)target.Prefab == (Object)null) { LastMessage = "Human or object prefab not found"; return false; } try { Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 0.8f + Vector3.up * 1.2f; GameObject val3 = Object.Instantiate(target.Prefab, val2, Quaternion.identity); val3.SetActive(true); StealableObject val4 = val3.GetComponent() ?? val3.GetComponentInChildren(true); ItemInstance val5 = val3.GetComponent() ?? val3.GetComponentInChildren(true); if ((Object)(object)val4 == (Object)null && (Object)(object)val5 != (Object)null) { val4 = ((Component)val5).GetComponent() ?? ((Component)val5).GetComponentInChildren(true); } if ((Object)(object)val4 == (Object)null) { Object.Destroy((Object)(object)val3); LastMessage = target.Name + " is not a Human hand item"; return false; } NetworkObject val6 = val3.GetComponent() ?? val3.GetComponentInChildren(true); if ((Object)(object)val6 != (Object)null && !val6.IsSpawned) { val6.Spawn(true); } Rigidbody val7 = (((Object)(object)val4.Rb != (Object)null) ? val4.Rb : ((Component)val4).GetComponent()); if ((Object)(object)val7 != (Object)null) { val7.position = val2; val7.linearVelocity = Vector3.zero; val7.angularVelocity = Vector3.zero; } ForceHumanHoldItem(val, val4); LastMessage = "Put " + target.Name + " in Human hands"; ModLog.Msg("Human hand object: " + target.Name + " -> " + ResolveUnitName((Component)(object)val)); return true; } catch (Exception ex) { LastMessage = "Human hand object failed: " + ex.Message; ModLog.Warning("Human hand object failed: " + ex.Message); return false; } } public bool SpawnNpc(NpcSpawnTarget target, int amount) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (!CanServerSpawn()) { LastMessage = "NPC spawn needs host/server"; return false; } PlayerNetworking val = GameAccess.LocalPlayer(); if ((Object)(object)val == (Object)null || target == null) { LastMessage = "Player or NPC data not found"; return false; } int num = Mathf.Clamp(amount, 1, 25); int num2 = 0; AiDirector val2 = Object.FindFirstObjectByType(); for (int i = 0; i < num; i++) { Vector3 val3 = SpawnPosition(val, i); try { GameEntityBase val4 = null; if (target.DirectorBacked && (Object)(object)val2 != (Object)null) { val2.SpawnEnemy(target.Name, val3); val4 = FindNearestEntity(target.Name, val3, 4f); goto IL_011f; } if (!((Object)(object)target.Prefab != (Object)null) || !((Object)(object)target.Prefab.GetComponentInChildren(true) != (Object)null)) { goto IL_011f; } GameObject val5 = Object.Instantiate(target.Prefab, val3, Quaternion.identity); val4 = val5.GetComponentInChildren(true); GameEntityAI componentInChildren = val5.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ((GameEntityBase)componentInChildren).Teleport(val3); } NetworkObject val6 = val5.GetComponent() ?? val5.GetComponentInChildren(true); if ((Object)(object)val6 == (Object)null) { Object.Destroy((Object)(object)val5); continue; } val6.Spawn(true); goto IL_011f; IL_011f: if ((Object)(object)val4 != (Object)null || (Object)(object)FindNearestEntity(target.Name, val3, 4f) != (Object)null) { num2++; } } catch (Exception ex) { LastMessage = "NPC spawn failed: " + ex.Message; ModLog.Warning("NPC spawn failed: " + ex.Message); break; } } LastMessage = ((num2 > 0) ? ("Spawned NPC " + target.Name + " x" + num2 + " via " + target.Source) : ("NPC spawn unavailable for " + target.Name)); ModLog.Msg("Spawn NPC: " + target.Name + " requested=" + num + " spawned=" + num2 + " source=" + target.Source); RefreshExistingUnits(); return num2 > 0; } public bool TeleportSelectedUnitToPlayer() { //IL_002c: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) ExistingUnitTarget existingUnitTarget = SelectedExistingUnit(); PlayerNetworking val = GameAccess.LocalPlayer(); if (existingUnitTarget == null || (Object)(object)val == (Object)null) { LastMessage = "Unit or player not found"; return false; } Vector3 position = ((Component)val).transform.position + ((Component)val).transform.forward * 1.4f + Vector3.up * 0.2f; MoveUnit(existingUnitTarget, position); LastMessage = "Teleported " + existingUnitTarget.Name + " to player"; RefreshExistingUnits(); return true; } public bool TeleportPlayerToSelectedUnit() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) ExistingUnitTarget existingUnitTarget = SelectedExistingUnit(); PlayerNetworking val = GameAccess.LocalPlayer(); if (existingUnitTarget == null || (Object)(object)val == (Object)null) { LastMessage = "Unit or player not found"; return false; } Vector3 val2 = existingUnitTarget.Position + Vector3.up * 1.15f; GameEntityBase val3 = (GameEntityBase)(object)val; if ((Object)(object)val3 != (Object)null) { val3.Teleport(val2); } else { ((Component)val).transform.position = val2; } LastMessage = "Teleported player to " + existingUnitTarget.Name; return true; } public bool KillSelectedUnit() { ExistingUnitTarget existingUnitTarget = SelectedExistingUnit(); if (existingUnitTarget == null) { LastMessage = "Unit not found"; return false; } GameEntityBase val = existingUnitTarget.Entity ?? existingUnitTarget.GameObject.GetComponent() ?? existingUnitTarget.GameObject.GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { val.OnReceiveDamage(9999f); LastMessage = "Killed " + existingUnitTarget.Name; RefreshExistingUnits(); return true; } HealthBase val2 = existingUnitTarget.GameObject.GetComponent() ?? existingUnitTarget.GameObject.GetComponentInChildren(true); if ((Object)(object)val2 != (Object)null) { val2.TakeDamage(9999f); LastMessage = "Killed " + existingUnitTarget.Name; RefreshExistingUnits(); return true; } LastMessage = "Selected unit has no health"; return false; } public unsafe bool ApplyStatusToSelectedUnit(Type type, float minutes) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) ExistingUnitTarget existingUnitTarget = SelectedExistingUnit(); if (existingUnitTarget == null) { LastMessage = "Unit not found"; return false; } StatusEffectHandler val = existingUnitTarget.GameObject.GetComponent() ?? existingUnitTarget.GameObject.GetComponentInChildren(true); if ((Object)(object)val == (Object)null) { LastMessage = "Selected unit has no status handler"; return false; } float num = ((minutes <= 0f) ? float.PositiveInfinity : (Mathf.Clamp(minutes, 0.05f, 120f) * 60f)); val.AddStatus(type, num); LastMessage = ((object)(*(Type*)(&type))/*cast due to .constrained prefix*/).ToString() + " on " + existingUnitTarget.Name + " for " + (float.IsPositiveInfinity(num) ? "infinity" : (minutes.ToString("F1") + " min")); return true; } private static bool CanServerSpawn() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening) { if (!singleton.IsServer) { return singleton.IsHost; } return true; } return false; } private static HumanAILink FindBestHuman() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) PlayerNetworking val = GameAccess.LocalPlayer(); Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); HumanAILink result = null; float num = float.MaxValue; HumanAILink[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (HumanAILink val3 in array) { if (!((Object)(object)val3 == (Object)null) && !((GameEntityBase)val3).IsDead) { float num2 = Vector3.Distance(val2, ((Component)val3).transform.position); if (num2 < num) { num = num2; result = val3; } } } return result; } private static void ForceHumanHoldItem(HumanAILink human, StealableObject stealable) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)human.ObjectInHand != (Object)null) { human.ReleaseObject(); } EnsureHumanEquipmentCache(human); typeof(HumanAILink).GetMethod("SetObjectInHand", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(human, new object[1] { stealable }); if ((Object)(object)stealable.Rb != (Object)null) { stealable.Rb.interpolation = (RigidbodyInterpolation)0; stealable.Rb.linearVelocity = Vector3.zero; stealable.Rb.angularVelocity = Vector3.zero; } HumanEquipment val = default(HumanEquipment); if (human.TryResolveEquippedItemHandler(ref val) && (Object)(object)val != (Object)null) { typeof(HumanAILink).GetField("activeEquipment", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(human, val); MethodInfo method = typeof(HumanAILink).GetMethod("UpdateEquipmentStateRpc", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { NetworkBehaviourReference val2 = default(NetworkBehaviourReference); ((NetworkBehaviourReference)(ref val2))..ctor((NetworkBehaviour)(object)val); method.Invoke(human, new object[1] { val2 }); } ApplyHumanAimEquipment(human, val); SetHumanAnimatorBool(human, val.AnimationBoolName, value: true); if ((Object)(object)((GameEntityBase)human).NAnimator != (Object)null && !string.IsNullOrEmpty(val.AnimationTriggerName)) { ((GameEntityBase)human).NAnimator.SetTrigger(val.AnimationTriggerName); } } } private static void SetHumanAnimatorBool(HumanAILink human, string boolName, bool value) { if (!((Object)(object)human == (Object)null) && !((Object)(object)((GameEntityBase)human).NAnimator == (Object)null) && !string.IsNullOrEmpty(boolName)) { object obj = ((object)((GameEntityBase)human).NAnimator).GetType().GetProperty("Animator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(((GameEntityBase)human).NAnimator, null); obj?.GetType().GetMethod("SetBool", new Type[2] { typeof(string), typeof(bool) })?.Invoke(obj, new object[2] { boolName, value }); } } private static void ApplyHumanAimEquipment(HumanAILink human, HumanEquipment equipment) { if ((Object)(object)human == (Object)null || (Object)(object)equipment == (Object)null || !equipment.AimAtPlayer) { return; } try { object obj = typeof(HumanAILink).GetField("aim", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(human); if (obj != null) { ((object)equipment).GetType().GetMethod("ApplyAimTransforms", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(equipment, new object[1] { obj }); } } catch { } } private static void EnsureHumanEquipmentCache(HumanAILink human) { FieldInfo field = typeof(HumanAILink).GetField("equipments", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null) && (!(field.GetValue(human) is HumanEquipment[] array) || array.Length == 0)) { field.SetValue(human, ((Component)human).GetComponentsInChildren(true)); } } private static void SendHumanFsmEvent(HumanAILink human, string eventName) { try { object obj = typeof(GameEntityAI).GetField("fsm", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(human); obj?.GetType().GetMethod("SendEvent", new Type[1] { typeof(string) })?.Invoke(obj, new object[1] { eventName }); } catch { } } private void AddNpcTarget(EntityData data, string source, bool directorBacked, HashSet names) { if (!((Object)(object)data == (Object)null)) { string text = (string.IsNullOrEmpty(((Object)data).name) ? CleanName(((Object)(object)data.prefab != (Object)null) ? ((Object)data.prefab).name : "") : ((Object)data).name.Trim()); if (!string.IsNullOrEmpty(text) && names.Add(source + ":" + text)) { allNpcs.Add(new NpcSpawnTarget { Name = text, Source = source, EntityData = data, Prefab = data.prefab, DirectorBacked = directorBacked }); } } } private ExistingUnitTarget SelectedExistingUnit() { if (existingUnits.Count == 0) { RefreshExistingUnits(); } if (existingUnits.Count == 0) { return null; } SelectedExistingUnitIndex = Mathf.Clamp(SelectedExistingUnitIndex, 0, existingUnits.Count - 1); return existingUnits[SelectedExistingUnitIndex]; } private static void MoveUnit(ExistingUnitTarget target, Vector3 position) { //IL_0039: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (target != null && !((Object)(object)target.GameObject == (Object)null)) { if ((Object)(object)target.Entity != (Object)null) { target.Entity.Teleport(position); } else { target.GameObject.transform.position = position; } Rigidbody val = target.GameObject.GetComponent() ?? target.GameObject.GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { val.position = position; val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } Physics.SyncTransforms(); } } private static GameEntityBase FindNearestEntity(string name, Vector3 position, float maxDistance) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) GameEntityBase result = null; float num = maxDistance; GameEntityBase[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityBase val in array) { if ((Object)(object)val == (Object)null) { continue; } string text = ResolveUnitName((Component)(object)val); if (text.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { float num2 = Vector3.Distance(((Component)val).transform.position, position); if (num2 <= num) { num = num2; result = val; } } } return result; } private static Vector3 SpawnPosition(PlayerNetworking local, int index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)local).transform.right * (float)(index % 5 - 2) * 0.7f; Vector3 val2 = ((Component)local).transform.forward * (2f + (float)(index / 5) * 0.8f); return ((Component)local).transform.position + val2 + val + Vector3.up * 0.8f; } private static string ClassifyPrefab(GameObject go) { string text = CleanName(((Object)go).name); if ((Object)(object)go.GetComponentInChildren(true) != (Object)null || text.IndexOf("car", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("vehicle", StringComparison.OrdinalIgnoreCase) >= 0) { return "Vehicle"; } if ((Object)(object)go.GetComponentInChildren(true) != (Object)null || (Object)(object)go.GetComponentInChildren(true) != (Object)null || (Object)(object)go.GetComponentInChildren(true) != (Object)null || (Object)(object)go.GetComponentInChildren(true) != (Object)null || (Object)(object)go.GetComponentInChildren(true) != (Object)null) { return "Unit"; } if ((Object)(object)go.GetComponentInChildren(true) != (Object)null || (Object)(object)go.GetComponentInChildren(true) != (Object)null) { return "Item"; } return "Object"; } private static GameObject FindRCCarPrefab() { RCCar[] array = Resources.FindObjectsOfTypeAll(); foreach (RCCar val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null) && ((Object)(object)((Component)val).GetComponent() != (Object)null || (Object)(object)((Component)val).GetComponentInChildren(true) != (Object)null)) { return ((Component)val).gameObject; } } return null; } private static string ResolveUnitName(Component component) { if ((Object)(object)component == (Object)null) { return "Unknown"; } GameEntityBase val = (GameEntityBase)(object)((component is GameEntityBase) ? component : null); if ((Object)(object)val != (Object)null && (Object)(object)val.EntityData != (Object)null && !string.IsNullOrEmpty(((Object)val.EntityData).name)) { return CleanName(((Object)val.EntityData).name); } string text = ((object)component).GetType().Name; if (text.EndsWith("AILink", StringComparison.OrdinalIgnoreCase)) { text = text.Substring(0, text.Length - "AILink".Length); } return CleanName(text); } private static string CleanName(string name) { if (string.IsNullOrEmpty(name)) { return "Unknown"; } return name.Replace("(Clone)", "").Trim(); } private static void AddKnownItemData(List target, IEnumerable source) { if (source == null) { return; } HashSet hashSet = new HashSet(from i in target where (Object)(object)i != (Object)null && !string.IsNullOrEmpty(((CraftableItemBase)i).Name) select ((CraftableItemBase)i).Name, StringComparer.OrdinalIgnoreCase); foreach (ItemData item in source) { if (!((Object)(object)item == (Object)null) && !string.IsNullOrEmpty(((CraftableItemBase)item).Name) && hashSet.Add(((CraftableItemBase)item).Name)) { target.Add(item); } } } } public class WorldModule : ModuleBase { public class WorldTarget { public string SceneName; public string DisplayName; public string Source; public int LevelIndex; public LevelInstance Level; } private readonly List allLevels = new List(); private readonly List levels = new List(); private string lastSearch = ""; public string SearchTerm = ""; public int SelectedIndex; public string LastMessage = ""; public string MethodInfo = ""; public override string Id => "world"; public override string DisplayName => "World"; public override bool Enabled { get { return ModConfig.EnableMod.Value; } set { } } public IReadOnlyList Levels => levels; public string CurrentScene { get { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).name; } } public void Refresh() { allLevels.Clear(); levels.Clear(); HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); AddGameLevels(hashSet); if (allLevels.Count == 0) { for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { string text = SceneNameFromPath(SceneUtility.GetScenePathByBuildIndex(i)); if (!string.IsNullOrEmpty(text) && hashSet.Add(text)) { allLevels.Add(new WorldTarget { SceneName = text, DisplayName = i + ": " + text, Source = "Scene fallback", LevelIndex = -1 }); } } } ApplySearch(); SelectedIndex = Mathf.Clamp(SelectedIndex, 0, Math.Max(levels.Count - 1, 0)); LastMessage = "World levels refreshed: " + allLevels.Count; MethodInfo = ((allLevels.Count > 0 && allLevels[0].Source != "Scene fallback") ? "Sources: GameProgressionManager levelData + LevelData assets" : "Source: SceneManager fallback"); } public void ApplySearch() { string search = SearchTerm ?? ""; if (search == lastSearch && levels.Count > 0) { return; } lastSearch = search; levels.Clear(); if (string.IsNullOrWhiteSpace(search)) { levels.AddRange(allLevels); return; } List collection = allLevels.Where((WorldTarget l) => l.SceneName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0 || l.Source.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); levels.AddRange(collection); SelectedIndex = Mathf.Clamp(SelectedIndex, 0, Math.Max(levels.Count - 1, 0)); } public bool LoadSelected() { if (levels.Count == 0) { Refresh(); } if (levels.Count == 0) { LastMessage = "No levels found"; return false; } SelectedIndex = Mathf.Clamp(SelectedIndex, 0, levels.Count - 1); return LoadLevel(levels[SelectedIndex]); } public bool LoadLevel(WorldTarget target) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) string text = ((target != null) ? target.SceneName : ""); if (string.IsNullOrWhiteSpace(text)) { LastMessage = "Scene name is empty"; return false; } try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && (singleton.IsServer || singleton.IsHost)) { Bootstrap val = FindBootstrap(); if ((Object)(object)val != (Object)null) { val.StartGame(text); LastMessage = "Starting " + target.DisplayName + " through Bootstrap"; MethodInfo = "Bootstrap.StartGame(" + text + ")"; ModLog.Msg("World start via Bootstrap.StartGame: " + target.DisplayName + " scene=" + text); return true; } singleton.SceneManager.LoadScene(text, (LoadSceneMode)1); LastMessage = "Loading " + target.DisplayName + " through NetworkManager.SceneManager"; MethodInfo = "NetworkManager.SceneManager.LoadScene additive"; ModLog.Msg("World load via NetworkManager.SceneManager: " + target.DisplayName + " scene=" + text); return true; } LastMessage = "Starting game levels needs host/server"; MethodInfo = "Bootstrap.StartGame requires NetworkManager.IsServer"; return false; } catch (Exception ex) { LastMessage = "Load failed: " + ex.Message; ModLog.Warning("World load failed: " + ex.Message); return false; } } public bool SetHouseStage(int stage) { LastMessage = "House stage is disabled: the game can delete/rebuild the home when forced."; MethodInfo = "House upgrade buttons are disabled until the real safe home-upgrade API is found."; return false; } public bool RepairMissingHome() { try { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.IsListening && !singleton.IsServer && !singleton.IsHost) { LastMessage = "Home repair needs host/server"; MethodInfo = "HomeManager changes are server-side."; return false; } HomeManager val = Object.FindAnyObjectByType(); if ((Object)(object)val == (Object)null) { LastMessage = "HomeManager not found. Go to lobby/plateau and try again."; MethodInfo = "No HomeManager in current scene."; return false; } int num = Mathf.Clamp(val.CurrentHomeTier, 0, Math.Max(0, val.Homes.Count - 1)); if ((Object)(object)val.CurrentHome == (Object)null) { val.SpawnHome(num); LastMessage = "Spawned missing home tier " + num; MethodInfo = "HomeManager.SpawnHome(" + num + ")"; return true; } val.MoveHomeToPlateau(); LastMessage = "Moved current home back to plateau"; MethodInfo = "HomeManager.MoveHomeToPlateau()"; return true; } catch (Exception ex) { LastMessage = "Home repair failed: " + ex.Message; MethodInfo = "Home repair exception"; ModLog.Warning("Home repair failed: " + ex.Message); return false; } } private void AddGameLevels(HashSet names) { int num = 0; GameProgressionManager val = FindProgression(); LevelData data = null; if ((Object)(object)val != (Object)null) { FieldInfo field = typeof(GameProgressionManager).GetField("levelData", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); data = (LevelData)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); } num += AddLevelData(data, "GameProgressionManager.levelData", names); LevelData[] array = Resources.FindObjectsOfTypeAll(); foreach (LevelData data2 in array) { num += AddLevelData(data2, "LevelData asset", names); } if (num == 0) { ModLog.Warning("World: no LevelData entries found yet. Open lobby/gameplay and refresh."); } } private int AddLevelData(LevelData data, string source, HashSet names) { if ((Object)(object)data == (Object)null || data.levels == null) { return 0; } int num = 0; for (int i = 0; i < data.levels.Count; i++) { LevelInstance val = data.levels[i]; if (val != null && !string.IsNullOrWhiteSpace(val.SceneName)) { string text = ResolveLevelName(val); string item = i + ":" + text + ":" + val.SceneName; if (names.Add(item)) { allLevels.Add(new WorldTarget { SceneName = val.SceneName, DisplayName = i + ": " + text + " -> " + val.SceneName, Source = source, LevelIndex = i, Level = val }); num++; } } } return num; } private static GameProgressionManager FindProgression() { try { GameProgressionManager instance = GameProgressionManager.Instance; if ((Object)(object)instance != (Object)null) { return instance; } } catch { } return Object.FindFirstObjectByType(); } private static Bootstrap FindBootstrap() { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null) { Bootstrap component = ((Component)singleton).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } } return Object.FindFirstObjectByType(); } private static bool TrySetNetworkInt(object owner, string fieldName, int value) { if (owner == null) { return false; } FieldInfo field = owner.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); object obj = ((field != null) ? field.GetValue(owner) : null); if (obj == null) { return false; } PropertyInfo property = obj.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property == null || !property.CanWrite) { return false; } property.SetValue(obj, value, null); return true; } private static bool TrySetMemberInt(object owner, string memberName, int value) { if (owner == null) { return false; } Type type = owner.GetType(); FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(int)) { field.SetValue(owner, value); return true; } PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.PropertyType == typeof(int) && property.CanWrite) { property.SetValue(owner, value, null); return true; } return false; } private static string ResolveLevelName(LevelInstance level) { if (level == null) { return "Unknown level"; } if (ModConfig.MenuLanguage == null || !ModConfig.MenuLanguage.Value.StartsWith("Russian", StringComparison.OrdinalIgnoreCase)) { string text = EnglishLevelName(level.SceneName); if (!string.IsNullOrEmpty(text)) { return text; } } try { object levelName = level.LevelName; if (levelName != null) { MethodInfo method = levelName.GetType().GetMethod("GetLocalizedString", Type.EmptyTypes); string text2 = ((method != null) ? (method.Invoke(levelName, null) as string) : null); if (!string.IsNullOrWhiteSpace(text2)) { return text2; } object memberValue = ReflectionUtils.GetMemberValue(levelName, "TableEntryReference"); string text3 = ((memberValue != null) ? memberValue.ToString() : ""); if (!string.IsNullOrWhiteSpace(text3)) { return text3; } } } catch { } return level.SceneName; } private static string EnglishLevelName(string sceneName) { return sceneName switch { "GamePlay" => "Suburbs", "GamePlay 1" => "Dense Forest", "GamePlay 2" => "Island", "GamePlay 3" => "Swamp", "GamePlay 4" => "Mountain Peak", _ => sceneName, }; } private static string SceneNameFromPath(string path) { if (string.IsNullOrEmpty(path)) { return ""; } string text = path.Replace("\\", "/"); int num = text.LastIndexOf('/'); if (num >= 0) { text = text.Substring(num + 1); } if (!text.EndsWith(".unity", StringComparison.OrdinalIgnoreCase)) { return text; } return text.Substring(0, text.Length - ".unity".Length); } } } namespace BGMod.ESP { public class ESPModule : ModuleBase { private readonly List targets = new List(); private Texture2D lineTex; private GUIStyle labelStyle; private float nextScanTime; private FieldInfo cabinetSpawnField; private bool reflectionInitialized; private AllItems cachedAllItems; public override string Id => "esp"; public override string DisplayName => "ESP"; public override bool Enabled { get { return ModConfig.EnableESP.Value; } set { ModConfig.EnableESP.Value = value; } } public IReadOnlyList Targets => targets; public void RefreshNow() { nextScanTime = Time.time + 0.25f; Guard("scan", ScanTargets); } public override void OnUpdate() { if (Enabled) { float num = base.Modules.Get()?.EspRefreshRate ?? ModConfig.ESPRefreshRate.Value; if (!(Time.time < nextScanTime)) { nextScanTime = Time.time + num; Guard("scan", ScanTargets); } } } public override void OnGUI() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0082: 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_00bc: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || (Object)(object)Camera.main == (Object)null) { return; } InitStyles(); Camera main = Camera.main; foreach (ESPTarget target in targets) { Vector3 val = main.WorldToScreenPoint(target.Position + Vector3.up * target.Height); if (!(val.z <= 0f)) { val.y = (float)Screen.height - val.y; DrawLabel(val, target.Label + "\n" + target.Distance.ToString("F0") + "m", target.Color); if (target.DrawBox) { DrawBox(new Rect(val.x - 22f, val.y - 36f, 44f, 58f), target.Color); } if (target.DrawTracer) { DrawLine(new Vector2((float)Screen.width / 2f, (float)Screen.height), new Vector2(val.x, val.y), target.Color, 1f); } } } } private void ScanTargets() { targets.Clear(); PlayerNetworking val = GameAccess.LocalPlayer(); if (!((Object)(object)val == (Object)null)) { PerformanceModule performanceModule = base.Modules.Get(); float maxDistance = performanceModule?.MaxEspDistance ?? ModConfig.MaxESPDistance.Value; int num = performanceModule?.MaxEspObjects ?? ModConfig.MaxESPObjects.Value; if (ModConfig.EnableItemESP.Value) { AddItems(val, maxDistance, targets.Count + num); } if (ModConfig.EnableLevelItemESP.Value) { AddCabinets(val, maxDistance, targets.Count + num); } if (ModConfig.EnableHumanESP.Value) { AddHumans(val, maxDistance, targets.Count + num); AddOtherUnits(val, maxDistance, targets.Count + num); } if (ModConfig.EnableRobotESP.Value) { AddMachines(val, maxDistance, targets.Count + num); } if (ModConfig.EnableInteractableESP.Value) { AddInteractables(val, maxDistance, targets.Count + num); } if (ModConfig.EnableGnomeESP.Value) { AddPlayers(val, maxDistance, targets.Count + num); } } } private void AddItems(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_0043: 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_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_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_014a: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); StealableObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (StealableObject val in array) { if ((Object)(object)val == (Object)null || targets.Count >= maxObjects) { return; } hashSet.Add(((Component)val).gameObject); float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance)) { string label = StealableLabel(val); if (MatchesFilter(label, ModConfig.ESPItemFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(1f, 0.78f, 0.25f), Position = ((Component)val).transform.position, Height = 0.35f, Distance = num, DrawBox = false, DrawTracer = false }); } } } ItemInstance[] array2 = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (ItemInstance val2 in array2) { if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null) { continue; } if (targets.Count >= maxObjects) { break; } if (hashSet.Contains(((Component)val2).gameObject)) { continue; } float num2 = Vector3.Distance(((Component)local).transform.position, ((Component)val2).transform.position); if (!(num2 > maxDistance)) { string label2 = ItemInstanceLabel(val2); if (MatchesFilter(label2, ModConfig.ESPItemFilter.Value)) { targets.Add(new ESPTarget { Label = label2, Color = new Color(0.95f, 0.88f, 0.35f), Position = ((Component)val2).transform.position, Height = 0.25f, Distance = num2, DrawBox = false, DrawTracer = false }); } } } } private void AddCabinets(PlayerNetworking local, float maxDistance, int maxObjects) { //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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) EnsureReflection(); if (cabinetSpawnField == null) { return; } CabinetDrawer[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (CabinetDrawer val in array) { if ((Object)(object)val == (Object)null || targets.Count >= maxObjects) { break; } if (val.HasSpawnedContents) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (num > maxDistance) { continue; } string text = CabinetLabel(val); if (!string.IsNullOrEmpty(text)) { string label = "Cabinet: " + text; if (MatchesFilter(label, ModConfig.ESPItemFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(0.45f, 0.9f, 1f), Position = ((Component)val).transform.position, Height = 0.55f, Distance = num, DrawBox = false, DrawTracer = false }); } } } } private void AddHumans(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_0046: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) HumanAILink[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (HumanAILink val in array) { if ((Object)(object)val == (Object)null || targets.Count >= maxObjects) { break; } GameEntityBase val2 = (GameEntityBase)(object)val; if ((Object)(object)val2 != (Object)null && val2.IsDead) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance)) { string label = HumanLabel(val); if (MatchesFilter(label, ModConfig.ESPHumanFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(1f, 0.36f, 0.32f), Position = ((Component)val).transform.position, Height = 2.2f, Distance = num, DrawBox = true, DrawTracer = false, TargetObject = ((Component)val).gameObject, StatusHandler = FindStatusHandler(((Component)val).gameObject) }); } } } } private void AddOtherUnits(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_0049: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) GameEntityAI[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (GameEntityAI val in array) { if ((Object)(object)val == (Object)null) { continue; } if (targets.Count >= maxObjects) { return; } if (val is HumanAILink || ((GameEntityBase)val).IsDead) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance)) { string label = UnitLabel(val); if (MatchesFilter(label, ModConfig.ESPHumanFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(1f, 0.48f, 0.9f), Position = ((Component)val).transform.position, Height = 1.6f, Distance = num, DrawBox = true, DrawTracer = false, TargetObject = ((Component)val).gameObject, StatusHandler = FindStatusHandler(((Component)val).gameObject) }); } } } AddSimpleUnits(local, maxDistance, maxObjects, "Dog", 1f); AddSimpleUnits(local, maxDistance, maxObjects, "Boar", 1.2f); AddSimpleUnits(local, maxDistance, maxObjects, "Bee", 0.35f); AddSimpleUnits(local, maxDistance, maxObjects, "Kidnapper", 0.8f); } private void AddMachines(PlayerNetworking local, float maxDistance, int maxObjects) { AddRCCars(local, maxDistance, maxObjects); AddSimpleUnits(local, maxDistance, maxObjects, "Vacuum", 0.8f); AddSimpleUnits(local, maxDistance, maxObjects, "Robot toy", 0.45f); } private void AddRCCars(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00bd: 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) RCCar[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (RCCar val in array) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || targets.Count >= maxObjects) { break; } if (AlreadyTargeted(((Component)val).gameObject)) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance)) { string label = "RC Car"; if (MatchesFilter(label, ModConfig.ESPHumanFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(0.2f, 0.95f, 1f), Position = ((Component)val).transform.position, Height = 1f, Distance = num, DrawBox = true, DrawTracer = false, TargetObject = ((Component)val).gameObject, StatusHandler = (((Component)val).GetComponent() ?? ((Component)val).GetComponentInChildren(true)) }); } } } } private void AddInteractables(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) InteractableObject[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (InteractableObject val in array) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null || targets.Count >= maxObjects) { break; } if (AlreadyTargeted(((Component)val).gameObject)) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance)) { string label = "Interactable: " + CleanName(((object)val).GetType().Name); if (MatchesFilter(label, ModConfig.ESPItemFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(0.7f, 0.75f, 1f), Position = ((Component)val).transform.position, Height = 0.6f, Distance = num, DrawBox = false, DrawTracer = false }); } } } } private void AddSimpleUnits(PlayerNetworking local, float maxDistance, int maxObjects, string label, float height) where T : Component { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) T[] array = Object.FindObjectsByType((FindObjectsSortMode)0); foreach (T val in array) { if ((Object)(object)val == (Object)null || targets.Count >= maxObjects) { break; } if (!AlreadyTargeted(((Component)val).gameObject)) { float num = Vector3.Distance(((Component)local).transform.position, ((Component)val).transform.position); if (!(num > maxDistance) && MatchesFilter(label, ModConfig.ESPHumanFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(1f, 0.48f, 0.9f), Position = ((Component)val).transform.position, Height = height, Distance = num, DrawBox = true, DrawTracer = false, TargetObject = ((Component)val).gameObject, StatusHandler = FindStatusHandler(((Component)val).gameObject) }); } } } } private void AddPlayers(PlayerNetworking local, float maxDistance, int maxObjects) { //IL_0046: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) foreach (PlayerNetworking item in GameAccess.AllPlayers()) { if ((Object)(object)item == (Object)null || targets.Count >= maxObjects || ((NetworkBehaviour)item).IsLocalPlayer) { continue; } float num = Vector3.Distance(((Component)local).transform.position, ((Component)item).transform.position); if (!(num > maxDistance)) { string label = PlayerLabel(item); if (MatchesFilter(label, ModConfig.ESPPlayerFilter.Value)) { targets.Add(new ESPTarget { Label = label, Color = new Color(0.45f, 1f, 0.55f), Position = ((Component)item).transform.position, Height = 1.8f, Distance = num, DrawBox = true, DrawTracer = false, TargetObject = ((Component)item).gameObject, StatusHandler = FindStatusHandler(((Component)item).gameObject) }); } } } } private void EnsureReflection() { if (!reflectionInitialized) { reflectionInitialized = true; cabinetSpawnField = typeof(CabinetDrawer).GetField("toSpawnOnCabinetOpen", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (cabinetSpawnField == null) { ModLog.Warning("Cabinet spawn list unavailable in this game version."); } } } private string CabinetLabel(CabinetDrawer cabinet) { if (!(cabinetSpawnField.GetValue(cabinet) is IEnumerable enumerable)) { return ""; } Dictionary dictionary = new Dictionary(); foreach (object item in enumerable) { object memberValue = ReflectionUtils.GetMemberValue(item, "prefab"); GameObject val = (GameObject)((memberValue is GameObject) ? memberValue : null); if (!((Object)(object)val == (Object)null)) { string key = CleanName(((Object)val).name); dictionary[key] = ((!dictionary.ContainsKey(key)) ? 1 : (dictionary[key] + 1)); } } List list = new List(); foreach (KeyValuePair item2 in dictionary) { list.Add(item2.Key + ((item2.Value > 1) ? (" x" + item2.Value) : "")); } return string.Join(", ", list.ToArray()); } private string HumanLabel(HumanAILink human) { List list = new List(); string text = (((Object)(object)human != (Object)null) ? EntityLabel((GameEntityBase)(object)human) : CleanName(((Object)((Component)human).gameObject).name)); list.Add(string.IsNullOrEmpty(text) ? "Human" : text); if (human.IsKnockedOut) { list.Add("knocked out"); } object memberValue = ReflectionUtils.GetMemberValue(human, "PlayerInHand"); if (ReflectionUtils.GetBool(human, "HasHumanInHand") || memberValue != null) { list.Add("holding player"); } if (ModConfig.ShowNpcHeldItemOnESP.Value) { string text2 = HeldObjectLabel(human); if (!string.IsNullOrEmpty(text2)) { list.Add("holding " + text2); } } if (ReflectionUtils.GetBool(human, "HasGun") || ReflectionUtils.GetBool(human, "IsHoldingWeapon")) { list.Add("armed"); } if ((Object)(object)human != (Object)null && !((GameEntityBase)human).CanSee) { list.Add("sleeping"); } return string.Join(": ", list.ToArray()); } private static string UnitLabel(GameEntityAI entity) { string text = EntityLabel((GameEntityBase)(object)entity); if (!string.IsNullOrEmpty(text) && !IsGenericEntityName(text)) { return text; } string text2 = ((object)entity).GetType().Name; if (text2.EndsWith("AILink", StringComparison.OrdinalIgnoreCase)) { text2 = text2.Substring(0, text2.Length - "AILink".Length); } return CleanName(text2); } private static string EntityLabel(GameEntityBase entity) { if ((Object)(object)entity == (Object)null) { return ""; } if ((Object)(object)entity.EntityData != (Object)null) { if ((Object)(object)entity.EntityData.prefab != (Object)null) { string text = CleanName(((Object)entity.EntityData.prefab).name); if (!IsGenericEntityName(text)) { return text; } } string text2 = CleanName(((Object)entity.EntityData).name); if (!IsGenericEntityName(text2)) { return text2; } } MonoBehaviour[] componentsInChildren = ((Component)entity).GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { string text3 = CleanName(((object)val).GetType().Name); if (!IsGenericEntityName(text3)) { return text3; } } } string text4 = CleanName(((Object)((Component)entity).gameObject).name); if (!IsGenericEntityName(text4)) { return text4; } return ""; } private static bool IsGenericEntityName(string name) { if (string.IsNullOrEmpty(name)) { return true; } string text = Regex.Replace(name, "\\s+", "", RegexOptions.CultureInvariant); if (!text.Equals("GameEntityAI", StringComparison.OrdinalIgnoreCase) && !text.Equals("GameEntityBase", StringComparison.OrdinalIgnoreCase) && !text.Equals("NetworkObject", StringComparison.OrdinalIgnoreCase) && !text.Equals("NetworkTransform", StringComparison.OrdinalIgnoreCase) && !text.Equals("StatusEffectHandler", StringComparison.OrdinalIgnoreCase) && !text.Equals("CharacterActor", StringComparison.OrdinalIgnoreCase) && !text.Equals("CharacterBrain", StringComparison.OrdinalIgnoreCase) && !text.Equals("AIController", StringComparison.OrdinalIgnoreCase)) { return text.Equals("NavmeshAgent", StringComparison.OrdinalIgnoreCase); } return true; } private string ItemInstanceLabel(ItemInstance item) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)cachedAllItems == (Object)null) { cachedAllItems = Resources.FindObjectsOfTypeAll().FirstOrDefault(); } if ((Object)(object)cachedAllItems != (Object)null && cachedAllItems.items != null) { int itemIndex = item.InstanceData.itemIndex; if (itemIndex >= 0 && itemIndex < cachedAllItems.items.Length && (Object)(object)cachedAllItems.items[itemIndex] != (Object)null) { return ((CraftableItemBase)cachedAllItems.items[itemIndex]).Name; } } } catch { } return CleanName(((Object)((Component)item).gameObject).name); } private string StealableLabel(StealableObject item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) string text = ((object)item.ItemType/*cast due to .constrained prefix*/).ToString(); if (!string.IsNullOrEmpty(text) && text != "None") { return CleanName(text); } return CleanName(((Object)((Component)item).gameObject).name); } private string HeldObjectLabel(HumanAILink human) { try { StealableObject objectInHand = human.ObjectInHand; if ((Object)(object)objectInHand != (Object)null) { return StealableLabel(objectInHand); } object memberValue = ReflectionUtils.GetMemberValue(human, "activeEquipment"); if (memberValue != null) { return CleanName(memberValue.GetType().Name); } } catch { } return ""; } private string PlayerLabel(PlayerNetworking player) { string text = GameAccess.PlayerName(player); if (!ModConfig.ShowPlayerInventoryOnESP.Value) { return text; } string text2 = InventoryLabel((InventoryBase)(object)player.Inventory); if (!string.IsNullOrEmpty(text2)) { text = text + "\nInv: " + text2; } return text; } private string InventoryLabel(InventoryBase inventory) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inventory == (Object)null || inventory.Contents == null) { return ""; } Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); try { foreach (InventoryItem content in inventory.Contents) { InventoryItem current = content; if (((InventoryItem)(ref current)).IsValidItem) { ItemData itemData = inventory.GetItemData((int)((InventoryItem)(ref current)).ItemIndex); string key = (((Object)(object)itemData != (Object)null) ? ((CraftableItemBase)itemData).Name : ("item " + ((InventoryItem)(ref current)).ItemIndex)); dictionary[key] = (dictionary.ContainsKey(key) ? (dictionary[key] + ((InventoryItem)(ref current)).ItemCount) : ((InventoryItem)(ref current)).ItemCount); } } } catch { return ""; } if (dictionary.Count == 0) { return ""; } List list = new List(); foreach (KeyValuePair item in dictionary.Take(6)) { list.Add(item.Key + ((item.Value > 1) ? (" x" + item.Value) : "")); } if (dictionary.Count > 6) { list.Add("+" + (dictionary.Count - 6)); } return string.Join(", ", list.ToArray()); } private static bool MatchesFilter(string label, string filter) { if (string.IsNullOrWhiteSpace(filter)) { return true; } if (string.IsNullOrEmpty(label)) { return false; } string[] array = filter.Split(new char[3] { ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { if (label.IndexOf(text.Trim(), StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private bool AlreadyTargeted(GameObject go) { //IL_002e: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)go == (Object)null) { return false; } Transform root = go.transform.root; foreach (ESPTarget target in targets) { if (target.Position == go.transform.position) { return true; } if (Vector3.Distance(target.Position, go.transform.position) < 0.25f) { return true; } if ((Object)(object)root != (Object)null && Vector3.Distance(target.Position, root.position) < 0.25f) { return true; } } return false; } private static StatusEffectHandler FindStatusHandler(GameObject go) { if (!((Object)(object)go != (Object)null)) { return null; } return go.GetComponent() ?? go.GetComponentInChildren(true); } private static string CleanName(string name) { if (string.IsNullOrEmpty(name)) { return "Unknown"; } return Regex.Replace(name, "\\([^)]*\\)", "").Replace("_", " ").Trim(); } private void InitStyles() { //IL_0010: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0051: Expected O, but got Unknown if (!((Object)(object)lineTex != (Object)null)) { lineTex = GuiStyles.MakeTexture(Color.white); labelStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1, fontSize = 12, richText = true }; } } private void DrawLabel(Vector3 screenPos, string text, Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Vector2 val = labelStyle.CalcSize(new GUIContent(text)); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(screenPos.x - val.x / 2f, screenPos.y - val.y - 4f, val.x + 8f, val.y + 4f); labelStyle.normal.textColor = Color.black; GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), text, labelStyle); labelStyle.normal.textColor = color; GUI.Label(val2, text, labelStyle); } private void DrawBox(Rect rect, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1.5f), (Texture)(object)lineTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax, ((Rect)(ref rect)).width, 1.5f), (Texture)(object)lineTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1.5f, ((Rect)(ref rect)).height), (Texture)(object)lineTex); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).y, 1.5f, ((Rect)(ref rect)).height), (Texture)(object)lineTex); GUI.color = color2; } private void DrawLine(Vector2 start, Vector2 end, Color color, float width) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) Color color2 = GUI.color; Matrix4x4 matrix = GUI.matrix; GUI.color = color; Vector2 val = end - start; GUIUtility.RotateAroundPivot(Mathf.Atan2(val.y, val.x) * 57.29578f, start); GUI.DrawTexture(new Rect(start.x, start.y - width / 2f, ((Vector2)(ref val)).magnitude, width), (Texture)(object)lineTex); GUI.matrix = matrix; GUI.color = color2; } } public class ItemESPModule : ModuleBase { public override string Id => "item_esp"; public override string DisplayName => "Item ESP"; public override bool Enabled { get { if (ModConfig.EnableItemESP.Value) { return ModConfig.EnableESP.Value; } return false; } set { ModConfig.EnableItemESP.Value = value; } } } public class HumanESPModule : ModuleBase { public override string Id => "human_esp"; public override string DisplayName => "Human ESP"; public override bool Enabled { get { if (ModConfig.EnableHumanESP.Value) { return ModConfig.EnableESP.Value; } return false; } set { ModConfig.EnableHumanESP.Value = value; } } } public class ESPTarget { public string Label; public Color Color; public Vector3 Position; public float Height; public float Distance; public bool DrawBox; public bool DrawTracer; public GameObject TargetObject; public StatusEffectHandler StatusHandler; } } namespace BGMod.Core { public interface IModModule { string Id { get; } string DisplayName { get; } bool Enabled { get; set; } void Initialize(ModuleManager modules); void OnSceneWasInitialized(int buildIndex, string sceneName); void OnUpdate(); void OnGUI(); void OnApplicationQuit(); } public abstract class ModuleBase : IModModule { protected ModuleManager Modules { get; private set; } public abstract string Id { get; } public abstract string DisplayName { get; } public abstract bool Enabled { get; set; } public virtual void Initialize(ModuleManager modules) { Modules = modules; } public virtual void OnSceneWasInitialized(int buildIndex, string sceneName) { } public virtual void OnUpdate() { } public virtual void OnGUI() { } public virtual void OnApplicationQuit() { } protected void Guard(string operation, Action action) { try { action(); } catch (Exception ex) { ModLog.Error(DisplayName + " " + operation + " failed: " + ex.Message); } } } public class ModuleManager { private readonly List modules = new List(); public IEnumerable AllModules => modules; public IEnumerable EnabledModuleNames => from m in modules where m.Enabled select m.DisplayName; public void Register(IModModule module) { modules.Add(module); } public void Initialize() { foreach (IModModule module in modules) { try { module.Initialize(this); ModLog.Msg("Module registered: " + module.DisplayName + " enabled=" + module.Enabled); } catch (Exception ex) { ModLog.Error(module.DisplayName + " initialize failed: " + ex.Message); } } } public T Get() where T : class, IModModule { return modules.OfType().FirstOrDefault(); } public void OnSceneWasInitialized(int buildIndex, string sceneName) { foreach (IModModule module in modules) { try { module.OnSceneWasInitialized(buildIndex, sceneName); } catch (Exception ex) { ModLog.Error(module.DisplayName + " scene update failed: " + ex.Message); } } } public void OnUpdate() { foreach (IModModule module in modules) { try { module.OnUpdate(); } catch (Exception ex) { ModLog.Error(module.DisplayName + " update failed: " + ex.Message); } } } public void OnGUI() { foreach (IModModule module in modules) { try { module.OnGUI(); } catch (Exception ex) { ModLog.Error(module.DisplayName + " GUI failed: " + ex.Message); } } } public void OnApplicationQuit() { foreach (IModModule module in modules) { try { module.OnApplicationQuit(); } catch (Exception ex) { ModLog.Error(module.DisplayName + " quit failed: " + ex.Message); } } } } } namespace BGMod.Config { public static class ModConfig { private static ConfigFile config; public static ConfigEntry EnableMod; public static ConfigEntry MenuKey; public static ConfigEntry OpenMenuOnStart; public static ConfigEntry MenuLanguage; public static ConfigEntry EnableHUD; public static ConfigEntry ShowFPS; public static ConfigEntry ShowActiveModules; public static ConfigEntry ShowWarnings; public static ConfigEntry HUDScale; public static ConfigEntry HUDPositionX; public static ConfigEntry HUDPositionY; public static ConfigEntry EnableESP; public static ConfigEntry EnableItemESP; public static ConfigEntry EnableLevelItemESP; public static ConfigEntry EnableHumanESP; public static ConfigEntry EnableRobotESP; public static ConfigEntry EnableInteractableESP; public static ConfigEntry EnableGnomeESP; public static ConfigEntry ESPRefreshRate; public static ConfigEntry MaxESPDistance; public static ConfigEntry MaxESPObjects; public static ConfigEntry ESPItemFilter; public static ConfigEntry ESPHumanFilter; public static ConfigEntry ESPPlayerFilter; public static ConfigEntry ShowPlayerInventoryOnESP; public static ConfigEntry ShowNpcHeldItemOnESP; public static ConfigEntry EnableGnomeFeatures; public static ConfigEntry EnableChaos; public static ConfigEntry EnablePerformanceMode; public static ConfigEntry LowFPSMode; public static ConfigEntry DisableExpensiveScans; public static ConfigEntry CacheLifetime; public static ConfigEntry HUDRefreshRate; public static ConfigEntry DebugMode; public static ConfigEntry UsePauseTimeScale; public static ConfigEntry GodMode; public static ConfigEntry InfiniteStamina; public static ConfigEntry FlyMode; public static ConfigEntry Noclip; public static ConfigEntry WalkNoclip; public static ConfigEntry EnableFlyNoclipHotkeys; public static ConfigEntry FlyToggleKey; public static ConfigEntry NoclipToggleKey; public static ConfigEntry WalkNoclipToggleKey; public static ConfigEntry BlinkKey; public static ConfigEntry BlinkToCrosshair; public static ConfigEntry NoFallDamage; public static ConfigEntry AntiKidnap; public static ConfigEntry LongHands; public static ConfigEntry SpeedMultiplier; public static ConfigEntry FlySpeed; public static ConfigEntry InteractionDistance; public static ConfigEntry PlayerScale; public static ConfigEntry PoltergeistMode; public static ConfigEntry ItemGiveAmount; public static ConfigEntry ResourceGiveAmount; public static void Initialize(ConfigFile configFile) { config = configFile; EnableMod = Bind("General", "EnableMod", value: true, "Enable BGMod"); MenuKey = Bind("General", "MenuKey", "Insert", "Menu key"); OpenMenuOnStart = Bind("General", "OpenMenuOnStart", value: false, "Open BGMod menu once after the plugin loads"); MenuLanguage = Bind("General", "MenuLanguage", "English", "Menu language: English or Russian"); EnableHUD = Bind("HUD", "EnableHUD", value: false, "Enable HUD"); ShowFPS = Bind("HUD", "ShowFPS", value: false, "Show FPS"); ShowActiveModules = Bind("HUD", "ShowActiveModules", value: false, "Show active modules"); ShowWarnings = Bind("HUD", "ShowWarnings", value: false, "Show warnings"); HUDScale = Bind("HUD", "HUDScale", 1f, "HUD scale"); HUDPositionX = Bind("HUD", "HUDPositionX", 16f, "HUD X"); HUDPositionY = Bind("HUD", "HUDPositionY", 16f, "HUD Y"); EnableESP = Bind("ESP", "EnableESP", value: false, "Enable ESP"); EnableItemESP = Bind("ESP", "EnableItemESP", value: false, "Enable item ESP"); EnableLevelItemESP = Bind("ESP", "EnableLevelItemESP", value: false, "Enable level item ESP"); EnableHumanESP = Bind("ESP", "EnableHumanESP", value: false, "Enable human ESP"); EnableRobotESP = Bind("ESP", "EnableRobotESP", value: false, "Enable robot and machine ESP"); EnableInteractableESP = Bind("ESP", "EnableInteractableESP", value: false, "Enable interactable ESP"); EnableGnomeESP = Bind("ESP", "EnableGnomeESP", value: false, "Enable player ESP"); ESPRefreshRate = Bind("ESP", "ESPRefreshRate", 0.75f, "ESP refresh rate"); MaxESPDistance = Bind("ESP", "MaxESPDistance", 80f, "Max ESP distance"); MaxESPObjects = Bind("ESP", "MaxESPObjects", 80, "Max ESP objects per category"); ESPItemFilter = Bind("ESP", "ESPItemFilter", "", "Only show items matching this text. Empty shows all."); ESPHumanFilter = Bind("ESP", "ESPHumanFilter", "", "Only show humans/units matching this text. Empty shows all."); ESPPlayerFilter = Bind("ESP", "ESPPlayerFilter", "", "Only show players matching this text. Empty shows all."); ShowPlayerInventoryOnESP = Bind("ESP", "ShowPlayerInventoryOnESP", value: false, "Show player inventory in ESP labels"); ShowNpcHeldItemOnESP = Bind("ESP", "ShowNpcHeldItemOnESP", value: false, "Show NPC held item in ESP labels"); EnableGnomeFeatures = Bind("Player", "EnablePlayerFeatures", value: true, "Enable player features"); EnableChaos = Bind("Chaos", "EnableChaos", value: false, "Enable chaos features"); EnablePerformanceMode = Bind("Performance", "EnablePerformanceMode", value: false, "Enable performance module"); LowFPSMode = Bind("Performance", "LowFPSMode", value: false, "Low FPS mode"); DisableExpensiveScans = Bind("Performance", "DisableExpensiveScans", value: false, "Disable expensive scans"); CacheLifetime = Bind("Performance", "CacheLifetime", 2f, "Cache lifetime"); HUDRefreshRate = Bind("Performance", "HUDRefreshRate", 0.25f, "HUD refresh rate"); DebugMode = Bind("Debug", "DebugMode", value: false, "Show debug info"); UsePauseTimeScale = Bind("Menu", "UsePauseTimeScale", value: false, "Pause game time while menu is open"); GodMode = Bind("Player", "GodMode", value: false, "Local god mode"); InfiniteStamina = Bind("Player", "InfiniteStamina", value: false, "Infinite stamina"); FlyMode = Bind("Player", "FlyMode", value: false, "Fly mode, experimental"); Noclip = Bind("Player", "Noclip", value: false, "Noclip, experimental"); WalkNoclip = Bind("Player", "WalkNoclip", value: false, "Walk through walls without flying"); EnableFlyNoclipHotkeys = Bind("Player", "EnableFlyNoclipHotkeys", value: false, "Enable player movement hotkeys"); FlyToggleKey = Bind("Player", "FlyToggleKey", "F2", "Fly toggle key"); NoclipToggleKey = Bind("Player", "NoclipToggleKey", "F3", "Noclip toggle key"); WalkNoclipToggleKey = Bind("Player", "WalkNoclipToggleKey", "F4", "Walk noclip toggle key"); BlinkKey = Bind("Player", "BlinkKey", "G", "Blink to crosshair key"); BlinkToCrosshair = Bind("Player", "BlinkToCrosshair", value: false, "Blink to crosshair"); NoFallDamage = Bind("Player", "NoFallDamage", value: false, "No fall damage"); AntiKidnap = Bind("Player", "AntiKidnap", value: false, "Anti kidnap"); LongHands = Bind("Player", "LongHands", value: false, "Long hands"); SpeedMultiplier = Bind("Player", "SpeedMultiplier", 1f, "Speed multiplier"); FlySpeed = Bind("Player", "FlySpeed", 10f, "Fly speed"); InteractionDistance = Bind("Player", "InteractionDistance", 2.5f, "Interaction distance"); PlayerScale = Bind("Player", "PlayerScale", 1f, "Player scale"); PoltergeistMode = Bind("Chaos", "PoltergeistMode", value: false, "Poltergeist mode"); ItemGiveAmount = Bind("Items", "ItemGiveAmount", 1, "Item give amount"); ResourceGiveAmount = Bind("Resources", "ResourceGiveAmount", 25, "Resource give amount"); } public static void Save() { ConfigFile obj = config; if (obj != null) { obj.Save(); } } public static void ResetToDefaults() { EnableMod.Value = true; MenuKey.Value = "Insert"; OpenMenuOnStart.Value = false; MenuLanguage.Value = "English"; EnableHUD.Value = false; ShowFPS.Value = false; ShowActiveModules.Value = false; ShowWarnings.Value = false; HUDScale.Value = 1f; HUDPositionX.Value = 16f; HUDPositionY.Value = 16f; EnableESP.Value = false; EnableItemESP.Value = false; EnableLevelItemESP.Value = false; EnableHumanESP.Value = false; EnableRobotESP.Value = false; EnableInteractableESP.Value = false; EnableGnomeESP.Value = false; ESPRefreshRate.Value = 0.75f; MaxESPDistance.Value = 80f; MaxESPObjects.Value = 80; ESPItemFilter.Value = ""; ESPHumanFilter.Value = ""; ESPPlayerFilter.Value = ""; ShowPlayerInventoryOnESP.Value = false; ShowNpcHeldItemOnESP.Value = false; EnableGnomeFeatures.Value = true; EnableChaos.Value = false; EnablePerformanceMode.Value = false; LowFPSMode.Value = false; DisableExpensiveScans.Value = false; CacheLifetime.Value = 2f; HUDRefreshRate.Value = 0.25f; DebugMode.Value = false; UsePauseTimeScale.Value = false; GodMode.Value = false; InfiniteStamina.Value = false; FlyMode.Value = false; Noclip.Value = false; WalkNoclip.Value = false; EnableFlyNoclipHotkeys.Value = false; FlyToggleKey.Value = "F2"; NoclipToggleKey.Value = "F3"; WalkNoclipToggleKey.Value = "F4"; BlinkKey.Value = "G"; BlinkToCrosshair.Value = false; NoFallDamage.Value = false; AntiKidnap.Value = false; LongHands.Value = false; SpeedMultiplier.Value = 1f; FlySpeed.Value = 10f; InteractionDistance.Value = 2.5f; PlayerScale.Value = 1f; PoltergeistMode.Value = false; ItemGiveAmount.Value = 1; ResourceGiveAmount.Value = 25; Save(); } private static ConfigEntry Bind(string section, string key, T value, string description) { return config.Bind(section, key, value, description); } } }