diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5e51eda --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CS0618: Type or member is obsolete +dotnet_diagnostic.CS0618.severity = silent diff --git a/CHackLoader.cs b/CHackLoader.cs index 3504178..4a22aaf 100644 --- a/CHackLoader.cs +++ b/CHackLoader.cs @@ -1,18 +1,31 @@ -using UnityEngine; +using System.Linq; +using System.Reflection; +using UnityEngine; namespace UmbraRoR { public class Loader { - static GameObject gameObject; + public static GameObject gameObject; public static void Load() { - gameObject = new GameObject(); - gameObject.AddComponent
(); + //RoR2.RoR2Application.isModded = true; + while (gameObject = GameObject.Find("Umbra Menu")) + GameObject.Destroy(gameObject); + gameObject = new GameObject("Umbra Menu"); Object.DontDestroyOnLoad(gameObject); + gameObject.SetActive(false); + var types = Assembly.GetExecutingAssembly().GetTypes().ToList().Where(t => t.BaseType == typeof(MonoBehaviour) && !t.IsNested); + foreach (var type in types) + { + var component = (MonoBehaviour)gameObject.AddComponent(type); + component.enabled = false; + } Utility.LoadAssembly(); Updates.CheckForUpdate(); + gameObject.GetComponent
().enabled = true; + gameObject.SetActive(true); } public static void Unload() diff --git a/Chests.cs b/Chests.cs new file mode 100644 index 0000000..a63a708 --- /dev/null +++ b/Chests.cs @@ -0,0 +1,136 @@ +using RoR2; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; + +namespace UmbraRoR +{ + class Chests : MonoBehaviour + { + public static List purchaseInteractions = new List(); + public static List chests = new List(); + + public static void EnableChests() + { + if (Main.onChestsEnable) + { + DumpInteractables(null); + SceneDirector.onPostPopulateSceneServer += DumpInteractables; + Main.onChestsEnable = false; + } + else + { + return; + } + } + public static void DisableChests() + { + if (!Main.onChestsEnable) + { + SceneDirector.onPostPopulateSceneServer -= DumpInteractables; + Main.onChestsEnable = true; + } + else + { + return; + } + } + + private static void DumpInteractables(SceneDirector obj) + { + purchaseInteractions = FindObjectsOfType().ToList(); + chests = ConvertPurchaseInteractsToChests(); + } + + public static List ConvertPurchaseInteractsToChests() + { + List chests = new List(); + foreach (PurchaseInteraction purchaseInteraction in purchaseInteractions) + { + var chest = purchaseInteraction?.gameObject.GetComponent(); + if (chest) + { + chests.Add(chest); + } + } + return chests; + } + + public static ChestBehavior FindClosestChest() + { + Dictionary chestsWithDistance = new Dictionary(); + foreach (var chest in chests) + { + if (chest) + { + string dropName = Language.GetString(chest.GetField("dropPickup").GetPickupNameToken()); + if (dropName != null && dropName != "???") + { + float distanceToChest = Vector3.Distance(Camera.main.transform.position, chest.transform.position); + chestsWithDistance.Add(distanceToChest, chest); + } + } + } + var keys = chestsWithDistance.Keys.ToList(); + keys.Sort(); + float leastDistance = keys[0]; + chestsWithDistance.TryGetValue(leastDistance, out ChestBehavior closestChest); + return closestChest; + } + + public static void RenderClosestChest() + { + var chest = FindClosestChest(); + Vector3 chestPosition = Camera.main.WorldToScreenPoint(chest.transform.position); + var chestBoundingVector = new Vector3(chestPosition.x, chestPosition.y, chestPosition.z); + if (chestBoundingVector.z > 0.01) + { + string dropNameColored = Util.GenerateColoredString(Language.GetString(chest.GetField("dropPickup").GetPickupNameToken()), chest.GetField("dropPickup").GetPickupColor()); + float distanceToChest = Vector3.Distance(Camera.main.transform.position, FindClosestChest().transform.position); + float width = 100f * (distanceToChest / 100); + if (width > 125) + { + width = 125; + } + float height = 100f * (distanceToChest / 100); + if (height > 125) + { + height = 125; + } + + if (Main.renderInteractables) + { + GUI.Label(new Rect(chestBoundingVector.x - 50f, (float)Screen.height - chestBoundingVector.y + 35f, 100f, 50f), $"Selected Chest", Main.selectedChestStyle); + } + else + { + GUI.Label(new Rect(chestBoundingVector.x - 50f, (float)Screen.height - chestBoundingVector.y + 35f, 100f, 50f), $"Selected Chest\n{dropNameColored}", Main.selectedChestStyle); + } + ESPHelper.DrawBox(chestBoundingVector.x - width / 2, (float)Screen.height - chestBoundingVector.y - height / 2, width, height, new Color32(0, 0, 255, 255)); + } + } + + public static void SetChestItem(ItemIndex itemIndex) + { + var chest = FindClosestChest(); + chest.SetField("dropPickup", PickupCatalog.FindPickupIndex(itemIndex)); + } + + public static void SetChestEquipment(EquipmentIndex euipmentIndex) + { + var chest = FindClosestChest(); + chest.SetField("dropPickup", PickupCatalog.FindPickupIndex(euipmentIndex)); + } + + public static bool IsClosestChestEquip() + { + var chest = FindClosestChest(); + var equipmentDrop = chest.GetField("dropPickup").equipmentIndex; + if (Main.equipment.Contains(equipmentDrop) && equipmentDrop != EquipmentIndex.None) + { + return true; + } + return false; + } + } +} diff --git a/DrawMenu.cs b/DrawMenu.cs index 8708b53..68e43e6 100644 --- a/DrawMenu.cs +++ b/DrawMenu.cs @@ -4,8 +4,9 @@ namespace UmbraRoR { - internal class DrawMenu + internal class DrawMenu : MonoBehaviour { + public static Vector2 chestItemChangerScrollPosition = Vector2.zero; public static Vector2 itemSpawnerScrollPosition = Vector2.zero; public static Vector2 equipmentSpawnerScrollPosition = Vector2.zero; public static Vector2 buffMenuScrollPosition = Vector2.zero; @@ -250,6 +251,15 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int DrawButton(8, "itemmanager", "S T A C K I N V E N T O R Y", buttonStyle); DrawButton(9, "itemmanager", "C L E A R I N V E N T O R Y", buttonStyle); + + if (Main._isChangeCharacterMenuOpen) + { + DrawButton(10, "itemmanager", "C H A N G E C H E S T I T E M : O N", buttonStyle); + } + else + { + DrawButton(10, "itemmanager", "C H A N G E C H E S T I T E M : O F F", buttonStyle); + } } public static void DrawSpawnMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle OnStyle, GUIStyle OffStyle, GUIStyle LabelStyle) @@ -350,20 +360,30 @@ public static void DrawLobbyMenu(float x, float y, float widthSize, int mulY, GU public static void CharacterWindowMethod(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) { - GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), "", BGstyle); + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 10; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 5, 85f), "C H A R A C T E R M E N U", LabelStyle); - characterScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), characterScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + characterScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), characterScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); PlayerMod.ChangeCharacter(buttonStyle, "character"); GUI.EndScrollView(); } public static void DrawBuffMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle, GUIStyle offStyle) { - GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * 15), "", BGstyle); + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 10; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * heightMul), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "B U F F S L I S T", LabelStyle); - buffMenuScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), buffMenuScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + buffMenuScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), buffMenuScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); PlayerMod.GiveBuff(buttonStyle, "giveBuff"); GUI.EndScrollView(); } @@ -413,54 +433,168 @@ public static void DrawStatsModMenu(float x, float y, float widthSize, int mulY, { DrawButton(5, "statsmod", $"M O V E S P E E D ( O F F ) : {PlayerMod.movespeed}", OffStyle, true); } + + DrawButton(6, "statsmod", $"M U L T I P L I E R : {PlayerMod.multiplyer}", buttonStyle, true); + if (Main._isStatMenuOpen) { - DrawButton(6, "statsmod", "S H O W S T A T S : O N", OnStyle); + DrawButton(7, "statsmod", "S H O W S T A T S : O N", OnStyle); } else { - DrawButton(6, "statsmod", "S H O W S T A T S : O F F", OffStyle); + DrawButton(7, "statsmod", "S H O W S T A T S : O F F", OffStyle); } } public static void DrawItemMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) { - GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * 15), "", BGstyle); + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 10; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * heightMul), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "I T E M S L I S T", LabelStyle); - itemSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), itemSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + itemSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), itemSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); int buttonPlacement = 1; foreach (var itemIndex in Main.items) { - string itemName = itemIndex.ToString(); - DrawButton(buttonPlacement, "itemSpawner", itemName, buttonStyle); - buttonPlacement++; + Color32 itemColor = ColorCatalog.GetColor(ItemCatalog.GetItemDef(itemIndex).colorIndex); + if (itemColor.r <= 105 && itemColor.g <= 105 && itemColor.b <= 105) + { + string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), new Color32(255, 255, 255, 255)); + DrawButton(buttonPlacement, "itemSpawner", itemName, buttonStyle); + buttonPlacement++; + } + else + { + string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), itemColor); + DrawButton(buttonPlacement, "itemSpawner", itemName, buttonStyle); + buttonPlacement++; + } } GUI.EndScrollView(); } - public static void DrawEquipmentMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle, GUIStyle offStyle) + public static void DrawChestItemMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) + { + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 10; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * heightMul), "", BGstyle); + GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "C H A N G E C H E S T L I S T", LabelStyle); + + chestItemChangerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), chestItemChangerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + int buttonPlacement = 1; + if (Chests.IsClosestChestEquip()) + { + foreach (var equipmentIndex in Main.equipment) + { + if (equipmentIndex != EquipmentIndex.None) + { + Color32 equipColor = ColorCatalog.GetColor(EquipmentCatalog.GetEquipmentDef(equipmentIndex).colorIndex); + if (equipColor.r <= 105 && equipColor.g <= 105 && equipColor.b <= 105) + { + string equipmentName = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(equipmentIndex).nameToken), new Color32(255, 255, 255, 255)); + DrawButton(buttonPlacement, "chestItemChanger", equipmentName, buttonStyle); + buttonPlacement++; + } + else + { + string equipmentName = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(equipmentIndex).nameToken), ColorCatalog.GetColor(EquipmentCatalog.GetEquipmentDef(equipmentIndex).colorIndex)); + DrawButton(buttonPlacement, "chestItemChanger", equipmentName, buttonStyle); + buttonPlacement++; + } + } + } + } + else + { + foreach (var itemIndex in Main.items) + { + Color32 itemColor = ColorCatalog.GetColor(ItemCatalog.GetItemDef(itemIndex).colorIndex); + if (itemColor.r <= 105 && itemColor.g <= 105 && itemColor.b <= 105) + { + string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), new Color32(255, 255, 255, 255)); + DrawButton(buttonPlacement, "chestItemChanger", itemName, buttonStyle); + buttonPlacement++; + } + else + { + string itemName = Util.GenerateColoredString(Language.GetString(ItemCatalog.GetItemDef(itemIndex).nameToken), itemColor); + DrawButton(buttonPlacement, "chestItemChanger", itemName, buttonStyle); + buttonPlacement++; + } + } + } + GUI.EndScrollView(); + } + + public static void DrawChestMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) { GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * 15), "", BGstyle); + GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "C H E S T M E N U", LabelStyle); + + //DrawButton(1, "chestManagement", $"T I E R 1 : {Chests.FindClosestChest().tier1Chance / 100}%", buttonStyle, isMultButton: true); + //DrawButton(2, "chestManagement", $"T I E R 2 : {Chests.FindClosestChest().tier2Chance / 100}%", buttonStyle, isMultButton: true); + //DrawButton(3, "chestManagement", $"T I E R 3 : {Chests.FindClosestChest().tier3Chance / 100}%", buttonStyle, isMultButton: true); + //DrawButton(4, "chestManagement", "C L O S E S T C H E S T I T E M", buttonStyle); + } + + public static void DrawEquipmentMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle, GUIStyle offStyle) + { + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 10; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * heightMul), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "E Q U I P M E N T L I S T", LabelStyle); - equipmentSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), equipmentSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + equipmentSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), equipmentSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); int buttonPlacement = 1; foreach (var equipmentIndex in Main.equipment) { - string equipmentName = equipmentIndex.ToString(); - DrawButton(buttonPlacement, "equipmentSpawner", equipmentName, buttonStyle); - buttonPlacement++; + if (equipmentIndex != EquipmentIndex.None) + { + Color32 equipColor = ColorCatalog.GetColor(EquipmentCatalog.GetEquipmentDef(equipmentIndex).colorIndex); + if (equipColor.r <= 105 && equipColor.g <= 105 && equipColor.b <= 105) + { + string equipmentName = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(equipmentIndex).nameToken), new Color32(255, 255, 255, 255)); + DrawButton(buttonPlacement, "equipmentSpawner", equipmentName, buttonStyle); + buttonPlacement++; + } + else + { + string equipmentName = Util.GenerateColoredString(Language.GetString(EquipmentCatalog.GetEquipmentDef(equipmentIndex).nameToken), equipColor); + DrawButton(buttonPlacement, "equipmentSpawner", equipmentName, buttonStyle); + buttonPlacement++; + } + } + else + { + string equipmentName = "Remove Equipment"; + DrawButton(buttonPlacement, "equipmentSpawner", equipmentName, buttonStyle); + buttonPlacement++; + } } GUI.EndScrollView(); } public static void DrawSpawnMobMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) { - GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * 15), "", BGstyle); + int heightMul = 15; + if (Main.lowResolutionMonitor) + { + heightMul = 7; + } + GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * heightMul), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 85f), "S P A W N L I S T", LabelStyle); - spawnScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), spawnScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); + spawnScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * heightMul), spawnScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); Spawn.SpawnMob(buttonStyle, "spawnMob"); GUI.EndScrollView(); } @@ -642,6 +776,22 @@ public static void DrawButton(int position, string id, string text, GUIStyle def break; } + case "chestItemChanger": + { + menuIndex = 3.3f; + menuBg = Main.chestItemChangerRect; + Main.chestItemChangerRectMulY = position; + if (isMultButton) + { + rect = new Rect(Main.chestItemChangerRect.x + 5, Main.chestItemChangerRect.y + 5 + 45 * position, Main.widthSize - 90, 40); + } + else + { + rect = new Rect(Main.chestItemChangerRect.x + 5, Main.chestItemChangerRect.y + 5 + 45 * position, Main.widthSize, 40); + } + break; + } + case "spawn": { menuIndex = 4f; diff --git a/ItemManager.cs b/ItemManager.cs index 841b657..556c38b 100644 --- a/ItemManager.cs +++ b/ItemManager.cs @@ -7,7 +7,7 @@ namespace UmbraRoR { - public class ItemManager + public class ItemManager : MonoBehaviour { public static int itemsToRoll = 5; public static bool isDropItemForAll = false; diff --git a/Lobby.cs b/Lobby.cs index cbfb6e0..e222af8 100644 --- a/Lobby.cs +++ b/Lobby.cs @@ -1,10 +1,11 @@ using System; using RoR2; +using UnityEngine; using Console = RoR2.Console; namespace UmbraRoR { - class Lobby + class Lobby : MonoBehaviour { // More posibilities here using console. // Not added to ui yet. diff --git a/Main.cs b/Main.cs index 8263136..0837708 100644 --- a/Main.cs +++ b/Main.cs @@ -20,7 +20,7 @@ public class Main : MonoBehaviour { public const string NAME = "U M B R A", - VERSION = "1.3.0"; + VERSION = "1.3.1"; public static string log = "[" + NAME + "] "; @@ -34,8 +34,6 @@ public const string public static List spawnCards = Utility.GetSpawnCards(); // These Are updated in FixedUpdate for performance reasons - public static List purchaseInteractables; - public static List teleporterInteractables; public static List hurtBoxes; public static Scene currentScene; @@ -58,6 +56,13 @@ public const string public static CharacterMotor LocalMotor; #endregion + #region Enable Checks + public static bool onChestsEnable = true; + public static bool onChestsDisable = false; + public static bool onRenderIntEnable = true; + public static bool onRenderIntDisable = false; + #endregion + #region Menu Checks public static bool _isMenuOpen = false; public static bool _ifDragged = false; @@ -76,13 +81,15 @@ public const string public static bool _isMovementOpen = false; public static bool _isSpawnListMenuOpen = false; public static bool _isSpawnMenuOpen = false; + public static bool _isChestItemListOpen = false; + public static bool lowResolutionMonitor = false; public static bool enableRespawnButton = false; #endregion #region Button Styles / Toggles - public static GUIStyle MainBgStyle, StatBgSytle, TeleBgStyle, OnStyle, OffStyle, LabelStyle, TitleStyle, BtnStyle, ItemBtnStyle, CornerStyle, DisplayStyle, BgStyle, HighlightBtnStyle, ActiveModsStyle, renderTeleporterStyle, renderMobsStyle, renderInteractablesStyle, WatermarkStyle, StatsStyle; + public static GUIStyle MainBgStyle, StatBgSytle, TeleBgStyle, OnStyle, OffStyle, LabelStyle, TitleStyle, BtnStyle, ItemBtnStyle, CornerStyle, DisplayStyle, BgStyle, HighlightBtnStyle, ActiveModsStyle, renderTeleporterStyle, renderMobsStyle, renderInteractablesStyle, WatermarkStyle, StatsStyle, selectedChestStyle; public static GUIStyle BtnStyle1, BtnStyle2, BtnStyle3; - public static bool skillToggle, renderInteractables, renderMobs, damageToggle, critToggle, attackSpeedToggle, armorToggle, regenToggle, moveSpeedToggle, MouseToggle, FlightToggle, listItems, noEquipmentCooldown, listBuffs, aimBot, alwaysSprint, godToggle, unloadConfirm, jumpPackToggle; + public static bool skillToggle, renderInteractables, renderMobs, damageToggle, critToggle, attackSpeedToggle, armorToggle, regenToggle, moveSpeedToggle, MouseToggle, FlightToggle, listItems, noEquipmentCooldown, listBuffs, aimBot, alwaysSprint, godToggle, unloadConfirm, jumpPackToggle, tier1Toggle, tier2Toggle, tier3Toggle, scrolled, devDoOnce = true; public static bool renderActiveMods = true; public static float delay = 0, widthSize = 350; public static bool navigationToggle = false; @@ -96,6 +103,7 @@ public const string public static Rect lobbyRect; public static Rect itemSpawnerRect; public static Rect equipmentSpawnerRect; + public static Rect chestItemChangerRect; public static Rect buffMenuRect; public static Rect characterRect; public static Rect playerModRect; @@ -118,7 +126,7 @@ public const string public static Texture2D NewTexture2D { get { return new Texture2D(1, 1); } } public static Texture2D Image = null, ontexture, onpresstexture, offtexture, offpresstexture, highlightTexture, highlightPressTexture, cornertexture, backtexture, btntexture, btnpresstexture, btntexturelabel; - public static int PlayerModBtnY, MainMulY, StatMulY, TeleMulY, ESPMulY, LobbyMulY, itemSpawnerMulY, equipmentSpawnerMulY, buffMenuMulY, CharacterMulY, PlayerModMulY, ItemManagerMulY, ItemManagerBtnY, editStatsMulY, editStatsBtnY, movementMulY, spawnListMulY, spawnMulY, spawnBtnY; + public static int PlayerModBtnY, MainMulY, StatMulY, TeleMulY, ESPMulY, LobbyMulY, itemSpawnerMulY, equipmentSpawnerMulY, buffMenuMulY, CharacterMulY, PlayerModMulY, ItemManagerMulY, ItemManagerBtnY, editStatsMulY, editStatsBtnY, movementMulY, spawnListMulY, spawnMulY, spawnBtnY, chestItemChangerRectMulY; public static int btnY, mulY; public static Rect rect = new Rect(10, 10, 20, 20); @@ -228,6 +236,11 @@ private void OnGUI() spawnListRect = GUI.Window(14, spawnListRect, new GUI.WindowFunction(SetSpawnListBG), "", new GUIStyle()); DrawMenu.DrawSpawnMobMenu(spawnListRect.x, spawnListRect.y, widthSize, spawnListMulY, MainBgStyle, BtnStyle, LabelStyle); } + if (_isChestItemListOpen) + { + chestItemChangerRect = GUI.Window(15, chestItemChangerRect, new GUI.WindowFunction(SetChestListBG), "", new GUIStyle()); + DrawMenu.DrawChestItemMenu(chestItemChangerRect.x, chestItemChangerRect.y, widthSize, chestItemChangerRectMulY, MainBgStyle, BtnStyle, LabelStyle); + } if (_CharacterCollected) { ESPRoutine(); @@ -251,18 +264,19 @@ public void Start() teleRect = new Rect(10, 425, 20, 20); // start position ESPRect = new Rect(10, 795, 20, 20); // start position lobbyRect = new Rect(10, 985, 20, 20); // start position - spawnRect = new Rect(738, 470, 20, 20); // start position + spawnRect = new Rect(738, 515, 20, 20); // start position statRect = new Rect(1626, 457, 20, 20); // start position spawnListRect = new Rect(1503, 10, 20, 20); // start position itemSpawnerRect = new Rect(1503, 10, 20, 20); // start position + chestItemChangerRect = new Rect(1503, 10, 20, 20); // start position equipmentSpawnerRect = new Rect(1503, 10, 20, 20); // start positions buffMenuRect = new Rect(1503, 10, 20, 20); // start position characterRect = new Rect(1503, 10, 20, 20); // start position editStatsRect = new Rect(1503, 10, 20, 20); // start position } - else + else if (Screen.height == 1080) { mainRect = new Rect(10, 10, 20, 20); // start position playerModRect = new Rect(374, 10, 20, 20); // start position @@ -271,17 +285,41 @@ public void Start() teleRect = new Rect(10, 425, 20, 20); // start position ESPRect = new Rect(10, 795, 20, 20); // start position lobbyRect = new Rect(374, 750, 20, 20); // start position - spawnRect = new Rect(738, 470, 20, 20); // start position + spawnRect = new Rect(738, 515, 20, 20); // start position statRect = new Rect(1626, 457, 20, 20); // start position spawnListRect = new Rect(1503, 10, 20, 20);// start position itemSpawnerRect = new Rect(1503, 10, 20, 20); // start position + chestItemChangerRect = new Rect(1503, 10, 20, 20); // start position equipmentSpawnerRect = new Rect(1503, 10, 20, 20); // start positions buffMenuRect = new Rect(1503, 10, 20, 20); // start position characterRect = new Rect(1503, 10, 20, 20); // start position editStatsRect = new Rect(1503, 10, 20, 20); // start position } + else + { + lowResolutionMonitor = true; + renderActiveMods = false; + mainRect = new Rect(10, 10, 20, 20); // start position + playerModRect = new Rect(374, 10, 20, 20); // start position + movementRect = new Rect(374, 10, 20, 20); // start position + itemManagerRect = new Rect(374, 10, 20, 20); // start positions + teleRect = new Rect(374, 10, 20, 20); // start position + ESPRect = new Rect(374, 10, 20, 20); // start position + lobbyRect = new Rect(374, 10, 20, 20); // start position + spawnRect = new Rect(374, 10, 20, 20); // start position + + statRect = new Rect(374, 10, 20, 20); // start position + + spawnListRect = new Rect(374, 10, 20, 20); // start position + itemSpawnerRect = new Rect(374, 10, 20, 20); // start position + chestItemChangerRect = new Rect(374, 10, 20, 20); // start position + equipmentSpawnerRect = new Rect(374, 10, 20, 20); // start positions + buffMenuRect = new Rect(374, 10, 20, 20); // start position + characterRect = new Rect(374, 10, 20, 20); // start position + editStatsRect = new Rect(374, 10, 20, 20); // start position + } #endregion @@ -399,6 +437,17 @@ public void Start() renderMobsStyle.alignment = TextAnchor.MiddleLeft; } + if (selectedChestStyle == null) + { + selectedChestStyle = new GUIStyle(); + selectedChestStyle.normal.textColor = Color.blue; + selectedChestStyle.onNormal.textColor = Color.blue; + selectedChestStyle.active.textColor = Color.blue; + selectedChestStyle.onActive.textColor = Color.blue; + selectedChestStyle.fontStyle = FontStyle.Normal; + selectedChestStyle.alignment = TextAnchor.MiddleLeft; + } + if (WatermarkStyle == null) { WatermarkStyle = new GUIStyle(); @@ -508,6 +557,7 @@ public void Update() AimBotRoutine(); GodRoutine(); UpdateNavIndexRoutine(); + DevBuildRoutine(); // UpdateMenuPositions(); } catch (NullReferenceException) @@ -520,16 +570,18 @@ public void Update() #region FixedUpdate public void FixedUpdate() { - currentScene = SceneManager.GetActiveScene(); - - if (renderInteractables) + try { - purchaseInteractables = Utility.GetPurchaseInteractions(); - teleporterInteractables = Utility.GetTeleporterInteractions(); + LowResolutionRoutine(); + currentScene = SceneManager.GetActiveScene(); + if (renderMobs) + { + hurtBoxes = Utility.GetHurtBoxes(); + } } - if (renderMobs) + catch { - hurtBoxes = Utility.GetHurtBoxes(); + throw; } } #endregion @@ -579,7 +631,7 @@ private void CheckInputs() if (Input.GetKeyDown(KeyCode.RightArrow)) { bool playerPlusMinusBtn = Navigation.menuIndex == 1 && Enumerable.Range(0, 3).Contains(Navigation.intraMenuIndex); - bool statsPlusMinusBtn = Navigation.menuIndex == 1.3f && Enumerable.Range(0, 5).Contains(Navigation.intraMenuIndex); + bool statsPlusMinusBtn = Navigation.menuIndex == 1.3f && Enumerable.Range(0, 6).Contains(Navigation.intraMenuIndex); bool itemPlusMinusBtn = Navigation.menuIndex == 3 && Enumerable.Range(0, 2).Contains(Navigation.intraMenuIndex); bool spawnPlusMinusBtn = Navigation.menuIndex == 4 && Enumerable.Range(0, 3).Contains(Navigation.intraMenuIndex); if (playerPlusMinusBtn || itemPlusMinusBtn || statsPlusMinusBtn || spawnPlusMinusBtn) @@ -601,7 +653,7 @@ private void CheckInputs() if (Input.GetKeyDown(KeyCode.LeftArrow)) { bool playerPlusMinusBtn = Navigation.menuIndex == 1 && Enumerable.Range(0, 3).Contains(Navigation.intraMenuIndex); - bool statsPlusMinusBtn = Navigation.menuIndex == 1.3f && Enumerable.Range(0, 5).Contains(Navigation.intraMenuIndex); + bool statsPlusMinusBtn = Navigation.menuIndex == 1.3f && Enumerable.Range(0, 6).Contains(Navigation.intraMenuIndex); bool itemPlusMinusBtn = Navigation.menuIndex == 3 && Enumerable.Range(0, 2).Contains(Navigation.intraMenuIndex); bool spawnPlusMinusBtn = Navigation.menuIndex == 4 && Enumerable.Range(0, 3).Contains(Navigation.intraMenuIndex); if (playerPlusMinusBtn || itemPlusMinusBtn || statsPlusMinusBtn || spawnPlusMinusBtn) @@ -617,6 +669,25 @@ private void CheckInputs() { Navigation.GoBackAMenu(); } + + if (_isBuffMenuOpen || _isChangeCharacterMenuOpen || _isChestItemListOpen || _isEquipmentSpawnMenuOpen || _isItemSpawnMenuOpen || _isSpawnListMenuOpen) + { + if (!scrolled) + { + if (Input.GetAxis("Mouse ScrollWheel") != 0f) // Scrolled + { + scrolled = true; + } + } + else + { + if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.UpArrow)) + { + scrolled = false; + } + } + + } } } else if (!_isMenuOpen) @@ -626,6 +697,7 @@ private void CheckInputs() Navigation.menuIndex = 0; Cursor.visible = false; } + if (Input.GetKeyDown(KeyCode.Insert)) { unloadConfirm = false; @@ -639,6 +711,38 @@ private void CheckInputs() GetCharacter(); SceneManager.sceneLoaded += OnSceneLoaded; } + + if (Input.GetKeyDown(KeyCode.Z)) + { + _isPlayerMod = !_isPlayerMod; + if (navigationToggle) + { + Navigation.menuIndex = 1; + } + } + + if (Input.GetKeyDown(KeyCode.I)) + { + _isItemSpawnMenuOpen = !_isItemSpawnMenuOpen; + if (navigationToggle) + { + Navigation.menuIndex = 3.1f; + } + } + + if (Input.GetKeyDown(KeyCode.C)) + { + FlightToggle = !FlightToggle; + } + + if (Input.GetKeyDown(KeyCode.B)) + { + _isTeleMenuOpen = !_isTeleMenuOpen; + if (navigationToggle) + { + Navigation.menuIndex = 5; + } + } } #endregion Inputs @@ -651,6 +755,33 @@ private void CharacterRoutine() } } + private void LowResolutionRoutine() + { + if (lowResolutionMonitor) + { + Utility.MenusOpenKeys(); + LowResolutionMonitor(); + } + } + + private void DevBuildRoutine() + { + if (Updates.devBuild) + { + if (_CharacterCollected) + { + if (devDoOnce) + { + godToggle = true; + FlightToggle = true; + alwaysSprint = true; + LocalPlayer.GiveMoney(10000); + devDoOnce = false; + } + } + } + } + private void ESPRoutine() { if (renderInteractables) @@ -665,6 +796,10 @@ private void ESPRoutine() { Render.ActiveMods(); } + if (_isChestItemListOpen) + { + Chests.RenderClosestChest(); + } } private void EquipCooldownRoutine() @@ -766,8 +901,6 @@ private void JumpPackRoutine() #region On Scene Loaded public void OnSceneLoaded(Scene scene, LoadSceneMode mode) { - purchaseInteractables = Utility.GetPurchaseInteractions(); - teleporterInteractables = Utility.GetTeleporterInteractions(); if (!InGameCheck()) { Utility.ResetMenu(); @@ -953,6 +1086,29 @@ public static void SetTeleBG(int windowID) GUI.DragWindow(); } + public static void SetChestListBG(int windowID) + { + GUI.Box(new Rect(0f, 0f, widthSize + 10, 50f + 45 * chestItemChangerRectMulY), "", CornerStyle); + if (Event.current.type == EventType.MouseDrag) + { + delay += Time.deltaTime; + if (delay > 0.3f) + { + _ifDragged = true; + } + } + else if (Event.current.type == EventType.MouseUp) + { + delay = 0; + if (!_ifDragged) + { + _isChestItemListOpen = !_isChestItemListOpen; + } + _ifDragged = false; + } + GUI.DragWindow(); + } + public static void SetESPBG(int windowID) { GUI.Box(new Rect(0f, 0f, widthSize + 10, 50f + 45 * ESPMulY), "", CornerStyle); @@ -1024,7 +1180,7 @@ public static void SetEditStatBG(int windowID) public static void SetItemSpawnerBG(int windowID) { - GUI.Box(new Rect(0f, 0f, widthSize + 10, 50f + 45 * MainMulY), "", CornerStyle); + GUI.Box(new Rect(0f, 0f, widthSize + 10, 50f + 45 * itemSpawnerMulY), "", CornerStyle); if (Event.current.type == EventType.MouseDrag) { delay += Time.deltaTime; @@ -1199,7 +1355,7 @@ public static Texture2D BtnTexture if (btntexture == null) { btntexture = NewTexture2D; - btntexture.SetPixel(0, 0, new Color32(120, 120, 120, 240)); + btntexture.SetPixel(0, 0, new Color32(105, 105, 105, 240)); btntexture.Apply(); } return btntexture; @@ -1283,7 +1439,7 @@ public static Texture2D OffTexture if (offtexture == null) { offtexture = NewTexture2D; - offtexture.SetPixel(0, 0, new Color32(120, 120, 120, 240)); + offtexture.SetPixel(0, 0, new Color32(105, 105, 105, 240)); // byte[] FileData = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/BepInEx/plugins/UmbraRoR/Resources/Images/OffStyle.png"); // offtexture.LoadImage(FileData); offtexture.Apply(); @@ -1386,5 +1542,115 @@ public static void GetCharacter() } } #endregion + + private void LowResolutionMonitor() + { + int i = 1; + var menusOpen = Utility.MenusOpenKeys(); + if (menusOpen.Count > 2) + { + if (Navigation.lowResMenuIndex < Navigation.prevLowResMenuIndex) + { + i = 2; + } + + switch (menusOpen[i]) + { + case 0: // Main Menu + { + break; + } + + case 1: // Player Management Menu + { + _isPlayerMod = false; + break; + } + + case 1.1f: // Character Menu + { + _isChangeCharacterMenuOpen = false; + break; + } + + case 1.2f: // Buff Menu + { + _isBuffMenuOpen = false; + break; + } + + case 1.3f: // Stats Modification Menu + { + _isEditStatsOpen = false; + break; + } + + case 2: // Movement Menu + { + _isMovementOpen = false; + break; + } + + case 3: // Item Management Menu + { + _isItemManagerOpen = false; + break; + } + + case 3.1f: // Give Item Menu + { + _isItemSpawnMenuOpen = false; + break; + } + + case 3.2f: // Give Equipment Menu + { + _isEquipmentSpawnMenuOpen = false; + break; + } + + case 3.3f: // Change Chest Item List Menu + { + _isChestItemListOpen = false; + break; + } + + case 4: // Spawn Menu + { + _isSpawnMenuOpen = false; + break; + } + + case 4.1f: // Spawn List Menu + { + _isSpawnListMenuOpen = false; + break; + } + + case 5: // Teleporter Menu + { + _isTeleMenuOpen = false; + break; + } + + case 6: // Render Menu + { + _isESPMenuOpen = false; + break; + } + + case 7: // Lobby Management Menu + { + _isLobbyMenuOpen = false; + break; + } + + default: + { + break; + } + } + } + } } } diff --git a/Movement.cs b/Movement.cs index 23f4c56..a5031af 100644 --- a/Movement.cs +++ b/Movement.cs @@ -4,7 +4,7 @@ namespace UmbraRoR { - class Movement + class Movement : MonoBehaviour { public static int jumpPackMul = 1; diff --git a/Navigation.cs b/Navigation.cs index 78cd14d..cd3c073 100644 --- a/Navigation.cs +++ b/Navigation.cs @@ -10,6 +10,8 @@ class Navigation public static float menuIndex = 0; public static int intraMenuIndex = -1; public static int prevIntraMenuIndex; + public static float lowResMenuIndex = 0; + public static float prevLowResMenuIndex = 0; public static Tuple highlightedBtn = new Tuple(menuIndex, intraMenuIndex); #region Menu Layout Variables @@ -49,131 +51,286 @@ class Navigation // Goes to previous menu when backspace or left arrow is pressed public static void GoBackAMenu() { - switch (Navigation.menuIndex) + if (Main.lowResolutionMonitor) { - case 0: // Main Menu - { - if (intraMenuIndex == 5) + switch (Navigation.menuIndex) + { + case 0: // Main Menu { - Main.unloadConfirm = false; + if (intraMenuIndex == 5) + { + Main.unloadConfirm = false; + } + else + { + Main.navigationToggle = false; + menuIndex = 0; + intraMenuIndex = -1; + } + break; } - else + + case 1: // Player Management Menu { - Main.navigationToggle = false; + Main._isPlayerMod = false; menuIndex = 0; - intraMenuIndex = -1; + intraMenuIndex = 0; + break; } - break; - } - case 1: // Player Management Menu - { - Main._isPlayerMod = false; - menuIndex = 0; - intraMenuIndex = 0; - break; - } + case 1.1f: // Character Menu + { + Main._isChangeCharacterMenuOpen = false; + Main._isPlayerMod = true; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 1.1f: // Character Menu - { - Main._isChangeCharacterMenuOpen = false; - menuIndex = 1; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 1.2f: // Buff Menu + { + Main._isBuffMenuOpen = false; + Main._isPlayerMod = true; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 1.2f: // Buff Menu - { - Main._isBuffMenuOpen = false; - menuIndex = 1; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 1.3f: // Stats Modification Menu + { + Main._isEditStatsOpen = false; + Main._isPlayerMod = true; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 1.3f: // Stats Modification Menu - { - Main._isEditStatsOpen = false; - menuIndex = 1; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 2: // Movement Menu + { + Main._isMovementOpen = false; + menuIndex = 0; + intraMenuIndex = 1; + break; + } - case 2: // Movement Menu - { - Main._isMovementOpen = false; - menuIndex = 0; - intraMenuIndex = 1; - break; - } + case 3: // Item Management Menu + { + Main._isItemManagerOpen = false; + menuIndex = 0; + intraMenuIndex = 2; + break; + } - case 3: // Item Management Menu - { - Main._isItemManagerOpen = false; - menuIndex = 0; - intraMenuIndex = 2; - break; - } + case 3.1f: // Give Item Menu + { + Main._isItemSpawnMenuOpen = false; + Main._isItemManagerOpen = true; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 3.1f: // Give Item Menu - { - Main._isItemSpawnMenuOpen = false; - menuIndex = 3; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 3.2f: // Give Equipment Menu + { + Main._isEquipmentSpawnMenuOpen = false; + Main._isItemManagerOpen = true; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 3.2f: // Give Equipment Menu - { - Main._isEquipmentSpawnMenuOpen = false; - menuIndex = 3; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 3.3f: // Change Chest Item List Menu + { + Main._isChestItemListOpen = false; + Main._isItemManagerOpen = true; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 4: // Spawn Menu - { - Main._isSpawnMenuOpen = false; - menuIndex = 0; - intraMenuIndex = 3; - break; - } + case 4: // Spawn Menu + { + Main._isSpawnMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 3; + break; + } - case 4.1f: // Spawn List Menu - { - Main._isSpawnListMenuOpen = false; - menuIndex = 4; - intraMenuIndex = prevIntraMenuIndex; - break; - } + case 4.1f: // Spawn List Menu + { + Main._isSpawnListMenuOpen = false; + Main._isSpawnMenuOpen = true; + menuIndex = 4; + intraMenuIndex = prevIntraMenuIndex; + break; + } - case 5: // Teleporter Menu - { - Main._isTeleMenuOpen = false; - menuIndex = 0; - intraMenuIndex = 4; - break; - } + case 5: // Teleporter Menu + { + Main._isTeleMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 4; + break; + } - case 6: // Render Menu - { - Main._isESPMenuOpen = false; - menuIndex = 0; - intraMenuIndex = 5; - break; - } + case 6: // Render Menu + { + Main._isESPMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 5; + break; + } - case 7: // Lobby Management Menu - { - Main._isLobbyMenuOpen = false; - menuIndex = 0; - intraMenuIndex = 6; - break; - } + case 7: // Lobby Management Menu + { + Main._isLobbyMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 6; + break; + } - default: - { - break; - } + default: + { + break; + } + } + } + else + { + switch (Navigation.menuIndex) + { + case 0: // Main Menu + { + if (intraMenuIndex == 5) + { + Main.unloadConfirm = false; + } + else + { + Main.navigationToggle = false; + menuIndex = 0; + intraMenuIndex = -1; + } + break; + } + + case 1: // Player Management Menu + { + Main._isPlayerMod = false; + menuIndex = 0; + intraMenuIndex = 0; + break; + } + + case 1.1f: // Character Menu + { + Main._isChangeCharacterMenuOpen = false; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 1.2f: // Buff Menu + { + Main._isBuffMenuOpen = false; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 1.3f: // Stats Modification Menu + { + Main._isEditStatsOpen = false; + menuIndex = 1; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 2: // Movement Menu + { + Main._isMovementOpen = false; + menuIndex = 0; + intraMenuIndex = 1; + break; + } + + case 3: // Item Management Menu + { + Main._isItemManagerOpen = false; + menuIndex = 0; + intraMenuIndex = 2; + break; + } + + case 3.1f: // Give Item Menu + { + Main._isItemSpawnMenuOpen = false; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 3.2f: // Give Equipment Menu + { + Main._isEquipmentSpawnMenuOpen = false; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 3.3f: // Change Chest Item List Menu + { + Main._isChestItemListOpen = false; + menuIndex = 3; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 4: // Spawn Menu + { + Main._isSpawnMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 3; + break; + } + + case 4.1f: // Spawn List Menu + { + Main._isSpawnListMenuOpen = false; + menuIndex = 4; + intraMenuIndex = prevIntraMenuIndex; + break; + } + + case 5: // Teleporter Menu + { + Main._isTeleMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 4; + break; + } + + case 6: // Render Menu + { + Main._isESPMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 5; + break; + } + + case 7: // Lobby Management Menu + { + Main._isLobbyMenuOpen = false; + menuIndex = 0; + intraMenuIndex = 6; + break; + } + + default: + { + break; + } + } } } @@ -222,35 +379,44 @@ public static void IncreaseValue(float pressMenuIndex, int pressIntraMenuIndex) case 0: { if (PlayerMod.damagePerLvl >= 0) - PlayerMod.damagePerLvl += 10; + PlayerMod.damagePerLvl += PlayerMod.multiplyer; break; } case 1: { if (PlayerMod.CritPerLvl >= 0) - PlayerMod.CritPerLvl += 1; + PlayerMod.CritPerLvl += PlayerMod.multiplyer; break; } case 2: { if (PlayerMod.attackSpeed >= 0) - PlayerMod.attackSpeed += 1; + PlayerMod.attackSpeed += PlayerMod.multiplyer; break; } case 3: { if (PlayerMod.armor >= 0) - PlayerMod.armor += 10; + PlayerMod.armor += PlayerMod.multiplyer; break; } case 4: { if (PlayerMod.movespeed >= 7) - PlayerMod.movespeed += 10; + PlayerMod.movespeed += PlayerMod.multiplyer; + break; + } + + case 5: + { + if (PlayerMod.multiplyer == 1) + PlayerMod.multiplyer = 10; + else if (PlayerMod.multiplyer >= 10) + PlayerMod.multiplyer += 10; break; } @@ -382,28 +548,28 @@ public static void DecreaseValue(float pressMenuIndex, int pressIntraMenuIndex) { case 0: { - if (PlayerMod.damagePerLvl > 0) - PlayerMod.damagePerLvl -= 10; + if (PlayerMod.damagePerLvl > PlayerMod.multiplyer) + PlayerMod.damagePerLvl -= PlayerMod.multiplyer; break; } case 1: { - if (PlayerMod.CritPerLvl > 0) - PlayerMod.CritPerLvl -= 1; + if (PlayerMod.CritPerLvl > PlayerMod.multiplyer) + PlayerMod.CritPerLvl -= PlayerMod.multiplyer; break; } case 2: { - if (PlayerMod.attackSpeed > 0) - PlayerMod.attackSpeed -= 1; + if (PlayerMod.attackSpeed > PlayerMod.multiplyer) + PlayerMod.attackSpeed -= PlayerMod.multiplyer; break; } case 3: { - if (PlayerMod.armor > 0) + if (PlayerMod.armor > PlayerMod.multiplyer) PlayerMod.armor -= 10; break; } @@ -411,7 +577,16 @@ public static void DecreaseValue(float pressMenuIndex, int pressIntraMenuIndex) case 4: { if (PlayerMod.movespeed > 7) - PlayerMod.movespeed -= 10; + PlayerMod.movespeed -= PlayerMod.multiplyer; + break; + } + + case 5: + { + if (PlayerMod.multiplyer == 10) + PlayerMod.multiplyer = 1; + else if (PlayerMod.multiplyer > 10) + PlayerMod.multiplyer -= 10; break; } @@ -511,49 +686,91 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) case 0: // Toggle PlayerMod Menu { Main._isPlayerMod = !Main._isPlayerMod; - Navigation.menuIndex = 1; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 1; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 1; + } break; } case 1: // Toggle Movement Menu { Main._isMovementOpen = !Main._isMovementOpen; - Navigation.menuIndex = 2; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 2; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 2; + } break; } case 2: // Toggle Item Menu { Main._isItemManagerOpen = !Main._isItemManagerOpen; - Navigation.menuIndex = 3; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 3; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 3; + } break; } case 3: // Toggle Spawn Menu { Main._isSpawnMenuOpen = !Main._isSpawnMenuOpen; - Navigation.menuIndex = 4; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 4; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 4; + } break; } case 4: // Toggle Teleporter Menu { Main._isTeleMenuOpen = !Main._isTeleMenuOpen; - Navigation.menuIndex = 5; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 5; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 5; + } break; } case 5: // Toggle Render Menu { Main._isESPMenuOpen = !Main._isESPMenuOpen; - Navigation.menuIndex = 6; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 6; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 6; + } break; } case 6: // Toggle Lobby Menu { Main._isLobbyMenuOpen = !Main._isLobbyMenuOpen; - Navigation.menuIndex = 7; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 7; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 7; + } break; } @@ -606,8 +823,14 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) { prevIntraMenuIndex = intraMenuIndex; intraMenuIndex = 0; - menuIndex = 1.3f; Main._isEditStatsOpen = !Main._isEditStatsOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 1.3f; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 1.3f; + } break; } @@ -615,8 +838,14 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) { prevIntraMenuIndex = intraMenuIndex; intraMenuIndex = 0; - menuIndex = 1.1f; Main._isChangeCharacterMenuOpen = !Main._isChangeCharacterMenuOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 1.1f; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 1.1f; + } break; } @@ -624,8 +853,14 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) { prevIntraMenuIndex = intraMenuIndex; intraMenuIndex = 0; - menuIndex = 1.2f; Main._isBuffMenuOpen = !Main._isBuffMenuOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 1.2f; + + if (Main.navigationToggle) + { + Navigation.menuIndex = 1.2f; + } break; } @@ -642,6 +877,11 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) EntityStates.FireNailgun.spreadPitchScale = 0.5f; EntityStates.FireNailgun.spreadYawScale = 1f; EntityStates.FireNailgun.spreadBloomValue = 0.2f; + if (PlayerMod.GetCurrentCharacter().ToString() == "Huntress") + { + var huntTracker = Main.LocalPlayerBody.GetComponent(); + huntTracker.SetField("maxTrackingDistance", 20f); + } Main.aimBot = false; break; } @@ -650,6 +890,11 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) EntityStates.FireNailgun.spreadPitchScale = 0; EntityStates.FireNailgun.spreadYawScale = 0; EntityStates.FireNailgun.spreadBloomValue = 0; + if (PlayerMod.GetCurrentCharacter().ToString() == "Huntress") + { + var huntTracker = Main.LocalPlayerBody.GetComponent(); + huntTracker.SetField("maxTrackingDistance", 1000f); + } Main.aimBot = true; break; } @@ -741,7 +986,13 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) break; } - case 5: // Toggle View Stats Menu + case 5: // Multiplier change + { + + break; + } + + case 6: // Toggle View Stats Menu { Main._isStatMenuOpen = !Main._isStatMenuOpen; break; @@ -819,6 +1070,8 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) intraMenuIndex = 0; menuIndex = 3.1f; Main._isItemSpawnMenuOpen = !Main._isItemSpawnMenuOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 3.1f; break; } @@ -828,6 +1081,8 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) intraMenuIndex = 0; menuIndex = 3.2f; Main._isEquipmentSpawnMenuOpen = !Main._isEquipmentSpawnMenuOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 3.2f; break; } @@ -863,6 +1118,25 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) break; } + case 9: // Toggle Chest List Menu + { + if (Main._isChangeCharacterMenuOpen) + { + Chests.DisableChests(); + } + else + { + Chests.EnableChests(); + } + prevIntraMenuIndex = intraMenuIndex; + intraMenuIndex = 0; + menuIndex = 3.3f; + Main._isChestItemListOpen = !Main._isChestItemListOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 3.3f; + break; + } + default: { break; @@ -931,6 +1205,19 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) break; } + case 3.3f: // Chest Item List Menu + { + if (Chests.IsClosestChestEquip()) + { + Chests.SetChestEquipment(Main.equipment[pressIntraMenuIndex]); + } + else + { + Chests.SetChestItem(Main.items[pressIntraMenuIndex]); + } + break; + } + case 4: // Spawn Menu { switch (pressIntraMenuIndex) @@ -956,6 +1243,8 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) intraMenuIndex = 0; menuIndex = 4.1f; Main._isSpawnListMenuOpen = !Main._isSpawnListMenuOpen; + Navigation.prevLowResMenuIndex = Navigation.lowResMenuIndex; + Navigation.lowResMenuIndex = 4.1f; break; } @@ -1110,6 +1399,14 @@ public static void PressBtn(float pressMenuIndex, int pressIntraMenuIndex) case 1: // Toggle Render Interactables { + if (Main.renderInteractables) + { + Render.DisableInteractables(); + } + else + { + Render.EnableInteractables(); + } Main.renderInteractables = !Main.renderInteractables; break; } @@ -1225,7 +1522,12 @@ public static void UpdateIndexValues() case 1.1f: // Change Character Menu { - DrawMenu.characterScrollPosition.y = 40 * intraMenuIndex; + int scrollMul = 40; + + if (!Main.scrolled) + { + DrawMenu.characterScrollPosition.y = scrollMul * intraMenuIndex; + } if (intraMenuIndex > Main.bodyPrefabs.Count - 1) { @@ -1236,20 +1538,28 @@ public static void UpdateIndexValues() intraMenuIndex = Main.bodyPrefabs.Count - 1; } - if (DrawMenu.characterScrollPosition.y > (Main.bodyPrefabs.Count - 1) * 40) - { - DrawMenu.characterScrollPosition = Vector2.zero; - } - if (DrawMenu.characterScrollPosition.y < 0) + if (!Main.scrolled) { - DrawMenu.characterScrollPosition.y = (Main.bodyPrefabs.Count - 1) * 40; + if (DrawMenu.characterScrollPosition.y > (Main.bodyPrefabs.Count - 1) * scrollMul) + { + DrawMenu.characterScrollPosition = Vector2.zero; + } + if (DrawMenu.characterScrollPosition.y < 0) + { + DrawMenu.characterScrollPosition.y = (Main.bodyPrefabs.Count - 1) * scrollMul; + } } break; } case 1.2f: // Give Buff Menu { - DrawMenu.buffMenuScrollPosition.y = 40 * intraMenuIndex; + int scrollMul = 40; + + if (!Main.scrolled) + { + DrawMenu.buffMenuScrollPosition.y = scrollMul * intraMenuIndex; + } if (intraMenuIndex > Enum.GetNames(typeof(BuffIndex)).Length - 1) { @@ -1260,27 +1570,29 @@ public static void UpdateIndexValues() intraMenuIndex = Enum.GetNames(typeof(BuffIndex)).Length - 1; } - if (DrawMenu.buffMenuScrollPosition.y > (Enum.GetNames(typeof(BuffIndex)).Length - 1) * 40) - { - DrawMenu.buffMenuScrollPosition = Vector2.zero; - } - if (DrawMenu.buffMenuScrollPosition.y < 0) + if (!Main.scrolled) { - DrawMenu.buffMenuScrollPosition.y = (Enum.GetNames(typeof(BuffIndex)).Length - 1) * 40; + if (DrawMenu.buffMenuScrollPosition.y > (Enum.GetNames(typeof(BuffIndex)).Length - 1) * scrollMul) + { + DrawMenu.buffMenuScrollPosition = Vector2.zero; + } + if (DrawMenu.buffMenuScrollPosition.y < 0) + { + DrawMenu.buffMenuScrollPosition.y = (Enum.GetNames(typeof(BuffIndex)).Length - 1) * scrollMul; + } } break; } - case 1.3f: // Stats Modification Menu 0-5 + case 1.3f: // Stats Modification Menu 0 - 6 { - - if (intraMenuIndex > 5) + if (intraMenuIndex > 6) { intraMenuIndex = 0; } if (intraMenuIndex < 0) { - intraMenuIndex = 5; + intraMenuIndex = 6; } break; } @@ -1298,22 +1610,27 @@ public static void UpdateIndexValues() break; } - case 3: // Item Management Menu 0 - 8 + case 3: // Item Management Menu 0 - 9 { - if (intraMenuIndex > 8) + if (intraMenuIndex > 9) { intraMenuIndex = 0; } if (intraMenuIndex < 0) { - intraMenuIndex = 8; + intraMenuIndex = 9; } break; } case 3.1f: // Give Item Menu { - DrawMenu.itemSpawnerScrollPosition.y = 40 * intraMenuIndex; + int scrollMul = 40; + + if (!Main.scrolled) + { + DrawMenu.itemSpawnerScrollPosition.y = scrollMul * intraMenuIndex; + } if (intraMenuIndex > Main.items.Count - 1) { @@ -1324,20 +1641,28 @@ public static void UpdateIndexValues() intraMenuIndex = Main.items.Count - 1; } - if (DrawMenu.itemSpawnerScrollPosition.y > (Main.items.Count - 1) * 40) + if (!Main.scrolled) { - DrawMenu.itemSpawnerScrollPosition = Vector2.zero; - } - if (DrawMenu.itemSpawnerScrollPosition.y < 0) - { - DrawMenu.itemSpawnerScrollPosition.y = (Main.items.Count - 1) * 40; + if (DrawMenu.itemSpawnerScrollPosition.y > (Main.items.Count - 1) * scrollMul) + { + DrawMenu.itemSpawnerScrollPosition = Vector2.zero; + } + if (DrawMenu.itemSpawnerScrollPosition.y < 0) + { + DrawMenu.itemSpawnerScrollPosition.y = (Main.items.Count - 1) * scrollMul; + } } break; } case 3.2f: // Give Equip Menu { - DrawMenu.equipmentSpawnerScrollPosition.y = 40 * intraMenuIndex; + int scrollMul = 40; + + if (!Main.scrolled) + { + DrawMenu.equipmentSpawnerScrollPosition.y = scrollMul * intraMenuIndex; + } if (intraMenuIndex > Main.equipment.Count - 1) { @@ -1348,13 +1673,82 @@ public static void UpdateIndexValues() intraMenuIndex = Main.equipment.Count - 1; } - if (DrawMenu.equipmentSpawnerScrollPosition.y > (Main.equipment.Count - 1) * 40) + if (!Main.scrolled) { - DrawMenu.equipmentSpawnerScrollPosition = Vector2.zero; + if (DrawMenu.equipmentSpawnerScrollPosition.y > (Main.equipment.Count - 1) * scrollMul) + { + DrawMenu.equipmentSpawnerScrollPosition = Vector2.zero; + } + if (DrawMenu.equipmentSpawnerScrollPosition.y < 0) + { + DrawMenu.equipmentSpawnerScrollPosition.y = (Main.equipment.Count - 1) * scrollMul; + } } - if (DrawMenu.equipmentSpawnerScrollPosition.y < 0) + break; + } + + case 3.3f: // Change Chest Item/Equipment List + { + int scrollMul = 40; + + if (Main._isChestItemListOpen) { - DrawMenu.equipmentSpawnerScrollPosition.y = (Main.equipment.Count - 1) * 40; + if (Chests.IsClosestChestEquip()) + { + if (!Main.scrolled) + { + DrawMenu.chestItemChangerScrollPosition.y = scrollMul * intraMenuIndex; + } + + if (intraMenuIndex > Main.equipment.Count - 2) + { + intraMenuIndex = 0; + } + if (intraMenuIndex < 0) + { + intraMenuIndex = Main.equipment.Count - 2; + } + + if (!Main.scrolled) + { + if (DrawMenu.chestItemChangerScrollPosition.y > (Main.equipment.Count - 2) * scrollMul) + { + DrawMenu.chestItemChangerScrollPosition = Vector2.zero; + } + if (DrawMenu.chestItemChangerScrollPosition.y < 0) + { + DrawMenu.chestItemChangerScrollPosition.y = (Main.equipment.Count - 2) * scrollMul; + } + } + } + else + { + if (!Main.scrolled) + { + DrawMenu.chestItemChangerScrollPosition.y = 40 * intraMenuIndex; + } + + if (intraMenuIndex > Main.items.Count - 1) + { + intraMenuIndex = 0; + } + if (intraMenuIndex < 0) + { + intraMenuIndex = Main.items.Count - 1; + } + + if (!Main.scrolled) + { + if (DrawMenu.chestItemChangerScrollPosition.y > (Main.items.Count - 1) * scrollMul) + { + DrawMenu.chestItemChangerScrollPosition = Vector2.zero; + } + if (DrawMenu.chestItemChangerScrollPosition.y < 0) + { + DrawMenu.chestItemChangerScrollPosition.y = (Main.items.Count - 1) * scrollMul; + } + } + } } break; } @@ -1374,7 +1768,12 @@ public static void UpdateIndexValues() case 4.1f: // Spawn List Menu { - DrawMenu.spawnScrollPosition.y = 40 * intraMenuIndex; + int scrollMul = 40; + + if (!Main.scrolled) + { + DrawMenu.spawnScrollPosition.y = scrollMul * intraMenuIndex; + } if (intraMenuIndex > Main.spawnCards.Count - 1) { @@ -1385,13 +1784,16 @@ public static void UpdateIndexValues() intraMenuIndex = Main.spawnCards.Count - 1; } - if (DrawMenu.spawnScrollPosition.y > (Main.spawnCards.Count - 1) * 40) - { - DrawMenu.spawnScrollPosition = Vector2.zero; - } - if (DrawMenu.spawnScrollPosition.y < 0) + if (!Main.scrolled) { - DrawMenu.spawnScrollPosition.y = (Main.spawnCards.Count - 1) * 40; + if (DrawMenu.spawnScrollPosition.y > (Main.spawnCards.Count - 1) * scrollMul) + { + DrawMenu.spawnScrollPosition = Vector2.zero; + } + if (DrawMenu.spawnScrollPosition.y < 0) + { + DrawMenu.spawnScrollPosition.y = (Main.spawnCards.Count - 1) * scrollMul; + } } break; } diff --git a/Player.cs b/Player.cs index 700a92e..49c2650 100644 --- a/Player.cs +++ b/Player.cs @@ -5,7 +5,7 @@ namespace UmbraRoR { - public class PlayerMod + public class PlayerMod : MonoBehaviour { public static int damagePerLvl = 10; public static int CritPerLvl = 1; @@ -16,6 +16,7 @@ public class PlayerMod public static ulong xpToGive = 50; public static uint moneyToGive = 50; public static uint coinsToGive = 50; + public static int multiplyer = 10; public static void GiveBuff(GUIStyle buttonStyle,string buttonId) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index addfa96..8df1f01 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.0")] -[assembly: AssemblyFileVersion("1.3.0")] +[assembly: AssemblyVersion("1.3.1")] +[assembly: AssemblyFileVersion("1.3.1")] diff --git a/README.md b/README.md index 8fc29ef..4c0cd6f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Doesn't require BepInEx or R2API! This is an unofficial fork of the Spektre Menu by [BennettStaley](https://github.com/BennettStaley/) and was merged with [Lodington's](https://github.com/Lodington/) unofficial fork. +This menu is for testing/personal fun. I do not condone the use of this menu in competitive modes such as the Prismatic Trials nor do I condone the use of this menu if it harms the experience of other players in any way. Thank you. + # Just released Umbra-Injector to auto inject/update Umbra Menu. Check it out [here](https://github.com/Acher0ns/Umbra-Menu-Injector) # Features @@ -56,6 +58,11 @@ Use mouse to select cheats. This can be done while holding tab ingame or while i Note: Some features may not work if you are not the host of the lobby +- Z -> Toggle Player Menu +- I -> Toggle Item Spawn Menu +- C -> Toggle Flight +- B -> Toggle Teleporter Menu + # List of Improvements I Might Add: - [ ] Add filters to ESPs? @@ -155,6 +162,26 @@ pause # Changelog: +### X/XX/XXXX v1.3.1: +- [ ] Added Menu to change whats inside chests/equipment barrels. +- [ ] Added Scrappers and Barrels to Interactables ESP. +- [ ] Added what item is in chests to Interactable ESP. +- [ ] Added Keybinds: + - Z -> Toggle Player Menu + - I -> Toggle Item Spawn Menu + - C -> Toggle Flight + - B -> Toggle Teleporter Menu +- [ ] Added better support for low resolution monitors (less than 1080p). +- [ ] Added a customizable multiplier for Stats Mod Menu. +- [ ] Item/Equipment list now shows friendly item names and their color based on rarity. +- [ ] Slightly improved Navigation logic. +- [ ] Greatly Improved Interactable ESP performance. +- [ ] Slightly Improved the Menus Load() method. +- [ ] Improved how teleporters are spawned. +- [ ] Fixed a bug allowing menu index to be set while Navigation was off. +- [ ] Fixed a bug not allowing you to scroll on list menus while Navigation was on. + + ### 8/11/2020 v1.3.0: - [ ] Updated for Risk of Rain 2 1.0 Update. - [ ] Slightly improved ESP performances. diff --git a/Reflections.cs b/Reflections.cs new file mode 100644 index 0000000..868f339 --- /dev/null +++ b/Reflections.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace UmbraRoR +{ + // shalzuth//RiskOfShame/Reflection.cs + public static class Reflections + { + public static BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | + BindingFlags.Static | BindingFlags.FlattenHierarchy; + public static ConcurrentDictionary fields = new ConcurrentDictionary(); + public static FieldInfo GetFieldFast(this Type type, String fieldName, String fieldType, String baseType) + { + var key = type.FullName + "." + fieldName + "(" + fieldType + ")" + " " + baseType; + if (fields.ContainsKey(key)) return fields[key]; + var field = type.GetField(fieldName, flags); + if (!field.FieldType.Name.Contains(fieldType) || !field.DeclaringType.Name.Contains(baseType)) + field = type.GetFields(flags).FirstOrDefault(f => f.Name == fieldName + && f.FieldType.ToString().Contains(fieldType) + && f.DeclaringType.ToString().Contains(baseType)); + if (field != null) fields[key] = field; + return field; + } + public static ConcurrentDictionary properties = new ConcurrentDictionary(); + public static PropertyInfo GetPropertyFast(this Type type, String propertyName, String propretyType, String baseType) + { + var key = type.FullName + "." + propertyName + "(" + propretyType + ")" + " " + baseType; + if (properties.ContainsKey(key)) return properties[key]; + var property = type.GetProperty(propertyName, flags); + if (!property.PropertyType.Name.Contains(propretyType) || !property.DeclaringType.Name.Contains(baseType)) + property = type.GetProperties(flags).FirstOrDefault(p => p.Name == propertyName + && p.PropertyType.ToString().Contains(propretyType) + && p.DeclaringType.ToString().Contains(baseType)); + if (property != null) properties[key] = property; + return property; + } + public static Object GetField(this Object obj, String fieldName, String fieldType, String baseType) + { + if (obj == null) return null; + var objType = obj is Type ? (Type)obj : obj.GetType(); + var field = objType.GetFieldFast(fieldName, fieldType, baseType); + if (field != null) return obj is Type ? field.GetValue(null) : field.GetValue(obj); + var property = objType.GetPropertyFast(fieldName, fieldType, baseType); + if (property != null) return obj is Type ? property.GetValue(null) : property.GetValue(obj); + return null; + } + public static T GetField(this Object obj, String fieldName, String fieldType = "", String baseType = "") + { + if (String.IsNullOrEmpty(fieldType)) fieldType = typeof(T).Name; + if (String.IsNullOrEmpty(baseType)) baseType = obj is Type ? ((Type)obj).Name : obj.GetType().Name; + return (T)GetField(obj, fieldName, fieldType, baseType); + } + public static void SetField(this Object obj, String fieldName, String fieldType, String baseType, T val) + { + if (obj == null) return; + var objType = obj.GetType(); + var field = objType.GetFieldFast(fieldName, fieldType, baseType); + if (field != null) + { + field.SetValue(obj, val); + return; + } + var property = objType.GetPropertyFast(fieldName, fieldType, baseType); + if (property != null) property.SetValue(obj, val); + } + public static void SetField(this Object obj, String fieldName, T val, String fieldType = "", String baseType = "") + { + if (String.IsNullOrEmpty(fieldType)) + fieldType = typeof(T).Name; + if (String.IsNullOrEmpty(baseType)) + baseType = obj is Type ? ((Type)obj).Name : obj.GetType().Name; + SetField(obj, fieldName, fieldType, baseType, val); + } + public static List GetList(this Object obj) + { + var methods = obj.GetType().GetMethods(flags); + var obj_get_Item = methods.First(m => m.Name == "get_Item"); + var obj_Count = obj.GetType().GetProperty("Count"); + var count = (Int32)obj_Count.GetValue(obj, new Object[0]); + var elements = new List(); + for (Int32 i = 0; i < count; i++) + elements.Add(obj_get_Item.Invoke(obj, new Object[] { i })); + return elements; + } + public static Object Invoke(this Object obj, String methodName, params Object[] paramArray) + { + var type = obj is Type ? (Type)obj : obj.GetType(); + var method = type.GetMethod(methodName, flags); + return obj is Type ? method.Invoke(null, paramArray) : method.Invoke(obj, paramArray); + } + public static T CreateInstance(params Object[] paramArray) + { + return (T)Activator.CreateInstance(typeof(T), args: paramArray); + } + } +} \ No newline at end of file diff --git a/Render.cs b/Render.cs index aeeb9e7..f31d001 100644 --- a/Render.cs +++ b/Render.cs @@ -2,33 +2,58 @@ using UnityEngine; using RoR2; using System.Collections.Generic; +using System.Linq; +using EntityStates.Scrapper; namespace UmbraRoR { + // Needs improvement. Causes a lot of lag public class Render : MonoBehaviour { - public static void Interactables() + public static List purchaseInteractions = new List(); + public static List barrelInteractions = new List(); + public static List secretButtons = new List(); + public static List scrappers = new List(); + public static void EnableInteractables() { - foreach (PurchaseInteraction purchaseInteraction in Main.purchaseInteractables) + if (Main.onRenderIntEnable) { - if (purchaseInteraction.available) - { - float distanceToObject = Vector3.Distance(Camera.main.transform.position, purchaseInteraction.transform.position); - Vector3 Position = Camera.main.WorldToScreenPoint(purchaseInteraction.transform.position); - var BoundingVector = new Vector3(Position.x, Position.y, Position.z); - if (BoundingVector.z > 0.01) - { - int distance = (int)distanceToObject; - String friendlyName = purchaseInteraction.GetDisplayName(); - int cost = purchaseInteraction.cost; - string boxText = $"{friendlyName}\n${cost}\n{distance}m"; - GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderInteractablesStyle); - } - } + DumpInteractables(null); + SceneDirector.onPostPopulateSceneServer += DumpInteractables; + Main.onRenderIntEnable = false; + } + else + { + return; + } + } + public static void DisableInteractables() + { + if (!Main.onRenderIntEnable) + { + SceneDirector.onPostPopulateSceneServer -= DumpInteractables; + Main.onRenderIntEnable = true; + } + else + { + return; } + } + + private static void DumpInteractables(SceneDirector obj) + { + Debug.Log("Dumping Interactables"); + barrelInteractions = FindObjectsOfType().ToList(); + purchaseInteractions = FindObjectsOfType().ToList(); + secretButtons = FindObjectsOfType().ToList(); + scrappers = FindObjectsOfType().ToList(); + } - foreach (TeleporterInteraction teleporterInteraction in Main.teleporterInteractables) + public static void Interactables() + { + if (TeleporterInteraction.instance) { + var teleporterInteraction = TeleporterInteraction.instance; float distanceToObject = Vector3.Distance(Camera.main.transform.position, teleporterInteraction.transform.position); Vector3 Position = Camera.main.WorldToScreenPoint(teleporterInteraction.transform.position); var BoundingVector = new Vector3(Position.x, Position.y, Position.z); @@ -52,9 +77,80 @@ public static void Interactables() GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderTeleporterStyle); } } + + foreach (BarrelInteraction barrel in barrelInteractions) + { + if (!barrel.Networkopened) + { + string friendlyName = "Barrel"; + Vector3 Position = Camera.main.WorldToScreenPoint(barrel.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + float distance = (int)Vector3.Distance(Camera.main.transform.position, barrel.transform.position); + string boxText = $"{friendlyName}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderInteractablesStyle); + } + } + } + + foreach (PressurePlateController secretButton in secretButtons) + { + if (secretButton) + { + string friendlyName = "Secret Button"; + Vector3 Position = Camera.main.WorldToScreenPoint(secretButton.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + float distance = (int)Vector3.Distance(Camera.main.transform.position, secretButton.transform.position); + string boxText = $"{friendlyName}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderInteractablesStyle); + } + } + } + + foreach (ScrapperController scrapper in scrappers) + { + if (scrapper) + { + string friendlyName = "Scrapper"; + Vector3 Position = Camera.main.WorldToScreenPoint(scrapper.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + float distance = (int)Vector3.Distance(Camera.main.transform.position, scrapper.transform.position); + string boxText = $"{friendlyName}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderInteractablesStyle); + } + } + } + + foreach (PurchaseInteraction purchaseInteraction in purchaseInteractions) + { + if (purchaseInteraction.available) + { + string dropName = null; + var chest = purchaseInteraction?.gameObject.GetComponent(); + if (chest) + { + dropName = Util.GenerateColoredString(Language.GetString(chest.GetField("dropPickup").GetPickupNameToken()), chest.GetField("dropPickup").GetPickupColor()); + } + float distanceToObject = Vector3.Distance(Camera.main.transform.position, purchaseInteraction.transform.position); + Vector3 Position = Camera.main.WorldToScreenPoint(purchaseInteraction.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + int distance = (int)distanceToObject; + String friendlyName = purchaseInteraction.GetDisplayName(); + int cost = purchaseInteraction.cost; + string boxText = dropName != null ? $"{friendlyName}\n${cost}\n{distance}m\n{dropName}" : $"{friendlyName}\n${cost}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText, Main.renderInteractablesStyle); + } + } + } } - // Needs improvement. Causes a lot of lag public static void Mobs() { foreach (var hurtbox in Main.hurtBoxes) diff --git a/Spawn.cs b/Spawn.cs index 85715b7..9a40100 100644 --- a/Spawn.cs +++ b/Spawn.cs @@ -6,7 +6,7 @@ namespace UmbraRoR { - class Spawn + class Spawn : MonoBehaviour { public static TeamIndex[] team = { TeamIndex.Monster, TeamIndex.Neutral, TeamIndex.Player, TeamIndex.None }; public static int teamIndex = 0; diff --git a/Teleporter.cs b/Teleporter.cs index be84086..057773b 100644 --- a/Teleporter.cs +++ b/Teleporter.cs @@ -3,7 +3,7 @@ namespace UmbraRoR { - public class Teleporter + public class Teleporter : MonoBehaviour { public static void InstaTeleporter() { @@ -30,21 +30,28 @@ public static void SpawnPortals(string portal) if (portal.Equals("gold")) { Debug.Log("UmbraRoR : Spawned Gold Portal"); + TeleporterInteraction.instance.Network_shouldAttemptToSpawnGoldshoresPortal = true; TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; } else if (portal.Equals("newt")) { Debug.Log("UmbraRoR : Spawned Shop Portal"); + TeleporterInteraction.instance.Network_shouldAttemptToSpawnShopPortal = true; TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; } else if (portal.Equals("blue")) { Debug.Log("UmbraRoR : Spawned Celestal Portal"); + TeleporterInteraction.instance.Network_shouldAttemptToSpawnMSPortal = true; TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; } else if (portal.Equals("all")) { Debug.Log("UmbraRoR : Spawned All Portals"); + TeleporterInteraction.instance.Network_shouldAttemptToSpawnGoldshoresPortal = true; + TeleporterInteraction.instance.Network_shouldAttemptToSpawnShopPortal = true; + TeleporterInteraction.instance.Network_shouldAttemptToSpawnMSPortal = true; + TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; diff --git a/UmbraRoR.csproj b/UmbraRoR.csproj index b30603c..e03fade 100644 --- a/UmbraRoR.csproj +++ b/UmbraRoR.csproj @@ -57,8 +57,10 @@ MinimumRecommendedRules.ruleset + + @@ -130,6 +132,9 @@ ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Risk of Rain 2\Risk of Rain 2_Data\Managed\UnityEngine.TextRenderingModule.dll + + +