Skip to content

Commit

Permalink
Update v1.3.1
Browse files Browse the repository at this point in the history
Merge pull request #17 from Acher0ns/dev-branch

- 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.
  • Loading branch information
NeonixRIT authored Aug 29, 2020
2 parents af6eb12 + f893de7 commit 270fd1e
Show file tree
Hide file tree
Showing 19 changed files with 1,504 additions and 245 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CS0618: Type or member is obsolete
dotnet_diagnostic.CS0618.severity = silent
21 changes: 17 additions & 4 deletions CHackLoader.cs
Original file line number Diff line number Diff line change
@@ -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<Main>();
//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<Main>().enabled = true;
gameObject.SetActive(true);
}

public static void Unload()
Expand Down
136 changes: 136 additions & 0 deletions Chests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
using RoR2;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace UmbraRoR
{
class Chests : MonoBehaviour
{
public static List<PurchaseInteraction> purchaseInteractions = new List<PurchaseInteraction>();
public static List<ChestBehavior> chests = new List<ChestBehavior>();

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<PurchaseInteraction>().ToList();
chests = ConvertPurchaseInteractsToChests();
}

public static List<ChestBehavior> ConvertPurchaseInteractsToChests()
{
List<ChestBehavior> chests = new List<ChestBehavior>();
foreach (PurchaseInteraction purchaseInteraction in purchaseInteractions)
{
var chest = purchaseInteraction?.gameObject.GetComponent<ChestBehavior>();
if (chest)
{
chests.Add(chest);
}
}
return chests;
}

public static ChestBehavior FindClosestChest()
{
Dictionary<float, ChestBehavior> chestsWithDistance = new Dictionary<float, ChestBehavior>();
foreach (var chest in chests)
{
if (chest)
{
string dropName = Language.GetString(chest.GetField<PickupIndex>("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<PickupIndex>("dropPickup").GetPickupNameToken()), chest.GetField<PickupIndex>("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<PickupIndex>("dropPickup", PickupCatalog.FindPickupIndex(itemIndex));
}

public static void SetChestEquipment(EquipmentIndex euipmentIndex)
{
var chest = FindClosestChest();
chest.SetField<PickupIndex>("dropPickup", PickupCatalog.FindPickupIndex(euipmentIndex));
}

public static bool IsClosestChestEquip()
{
var chest = FindClosestChest();
var equipmentDrop = chest.GetField<PickupIndex>("dropPickup").equipmentIndex;
if (Main.equipment.Contains(equipmentDrop) && equipmentDrop != EquipmentIndex.None)
{
return true;
}
return false;
}
}
}
Loading

0 comments on commit 270fd1e

Please sign in to comment.