Skip to content

Commit

Permalink
cleanup (aleks's suggestions)
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Sep 22, 2020
1 parent 22b6609 commit 71d6a45
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
6 changes: 0 additions & 6 deletions QSB/OrbSync/OrbSlotManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -22,7 +17,6 @@ private void InitSlots()
{
var qsbOrbSlot = WorldRegistry.GetObject<QSBOrbSlot>(id) ?? new QSBOrbSlot();
qsbOrbSlot.Init(orbSlots[id], id);
WorldRegistry.AddObject(qsbOrbSlot);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions QSB/OrbSync/QSBOrbSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void Init(NomaiInterfaceSlot slot, int id)
ObjectId = id;
InterfaceSlot = slot;
_initialized = true;
WorldRegistry.AddObject(this);
}

public void HandleEvent(bool state)
Expand Down
20 changes: 3 additions & 17 deletions QSB/Utility/DebugLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ public static void ToConsole(string message, MessageType type = MessageType.Mess
.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 });
}

Expand Down Expand Up @@ -56,16 +48,10 @@ public static void LogState(string name, bool state)
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;
}
}
}

0 comments on commit 71d6a45

Please sign in to comment.