From 22b66093f3211da023c4f53d555f4383a293666e Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 18 Sep 2020 16:49:38 +0100 Subject: [PATCH 1/2] slight cleanup --- QSB/OrbSync/OrbPatches.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QSB/OrbSync/OrbPatches.cs b/QSB/OrbSync/OrbPatches.cs index 89c7868e..692933d6 100644 --- a/QSB/OrbSync/OrbPatches.cs +++ b/QSB/OrbSync/OrbPatches.cs @@ -23,7 +23,7 @@ namespace QSB.OrbSync return false; } var orbDistance = Vector3.Distance(orb.transform.position, __instance.transform.position); - var triggerRadius = !orb.IsBeingDragged() ? ____radius : ____exitRadius; + var triggerRadius = orb.IsBeingDragged() ? ____exitRadius : ____radius; if (____occupyingOrb == null && orbDistance < ____radius) { ____occupyingOrb = orb; @@ -35,7 +35,7 @@ namespace QSB.OrbSync __result = true; return false; } - if (!(____occupyingOrb != null) || !(____occupyingOrb == orb)) + if (____occupyingOrb == null || ____occupyingOrb != orb) { __result = false; return false; From 71d6a4581ce5691f70bd33a25266146f30745269 Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Tue, 22 Sep 2020 21:00:56 +0100 Subject: [PATCH 2/2] cleanup (aleks's suggestions) --- QSB/OrbSync/OrbSlotManager.cs | 6 ------ QSB/OrbSync/QSBOrbSlot.cs | 1 + QSB/Utility/DebugLog.cs | 20 +++----------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/QSB/OrbSync/OrbSlotManager.cs b/QSB/OrbSync/OrbSlotManager.cs index b381a6ce..526e6e84 100644 --- a/QSB/OrbSync/OrbSlotManager.cs +++ b/QSB/OrbSync/OrbSlotManager.cs @@ -6,11 +6,6 @@ namespace QSB.OrbSync public class OrbSlotManager : MonoBehaviour { private void Awake() - { - QSBSceneManager.OnSceneLoaded += OnSceneLoaded; - } - - private void OnSceneLoaded(OWScene scene, bool isInUniverse) { QSB.Helper.Events.Unity.RunWhen(() => QSB.HasWokenUp, InitSlots); } @@ -22,7 +17,6 @@ namespace QSB.OrbSync { var qsbOrbSlot = WorldRegistry.GetObject(id) ?? new QSBOrbSlot(); qsbOrbSlot.Init(orbSlots[id], id); - WorldRegistry.AddObject(qsbOrbSlot); } } } diff --git a/QSB/OrbSync/QSBOrbSlot.cs b/QSB/OrbSync/QSBOrbSlot.cs index 9af2005d..32123c4e 100644 --- a/QSB/OrbSync/QSBOrbSlot.cs +++ b/QSB/OrbSync/QSBOrbSlot.cs @@ -14,6 +14,7 @@ namespace QSB.OrbSync ObjectId = id; InterfaceSlot = slot; _initialized = true; + WorldRegistry.AddObject(this); } public void HandleEvent(bool state) diff --git a/QSB/Utility/DebugLog.cs b/QSB/Utility/DebugLog.cs index 71efb97d..f39828c4 100644 --- a/QSB/Utility/DebugLog.cs +++ b/QSB/Utility/DebugLog.cs @@ -14,14 +14,6 @@ namespace QSB.Utility .GetMethods(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) .Last(x => x.Name == "WriteLine"); var callingType = GetCallingType(new StackTrace()); - if (callingType == "DebugLog") - { - callingType = GetCallingType(new StackTrace(), 2); - } - if (callingType == "DebugLog") - { - callingType = GetCallingType(new StackTrace(), 3); - } method.Invoke(console, new object[] { type, message, callingType }); } @@ -56,16 +48,10 @@ namespace QSB.Utility DebugWrite($"* {name} {status}", messageType); } - private static string GetCallingType(StackTrace frame, int index = 1) + private static string GetCallingType(StackTrace frame) { - try - { - return frame.GetFrame(index).GetMethod().DeclaringType.Name; - } - catch - { - return ""; - } + var stackFrame = frame.GetFrames().First(x => x.GetMethod().DeclaringType.Name != "DebugLog"); + return stackFrame.GetMethod().DeclaringType.Name; } } }