diff --git a/QSB/QSB.cs b/QSB/QSB.cs index 09d02ecc..ba41172e 100644 --- a/QSB/QSB.cs +++ b/QSB/QSB.cs @@ -1,7 +1,6 @@ using OWML.Common; using OWML.ModHelper; using QSB.ElevatorSync; -using QSB.Events; using QSB.GeyserSync; using QSB.Utility; using UnityEngine; diff --git a/QSB/QSB.csproj b/QSB/QSB.csproj index 66c9f979..84230304 100644 --- a/QSB/QSB.csproj +++ b/QSB/QSB.csproj @@ -180,7 +180,7 @@ - + diff --git a/QSB/TimeSync/WakeUpPatches.cs b/QSB/TimeSync/WakeUpPatches.cs index 88f5b012..0bca8f7c 100644 --- a/QSB/TimeSync/WakeUpPatches.cs +++ b/QSB/TimeSync/WakeUpPatches.cs @@ -1,8 +1,4 @@ -using QSB.Utility; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using OWML.ModHelper.Events; namespace QSB.TimeSync { @@ -10,14 +6,14 @@ namespace QSB.TimeSync { public static void AddPatches() { - QSB.Helper.HarmonyHelper.AddPrefix("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(WakeUpPatches.OnStartOfTimeLoopPrefix)); + QSB.Helper.HarmonyHelper.AddPrefix("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(OnStartOfTimeLoopPrefix)); } public static bool OnStartOfTimeLoopPrefix(ref PlayerCameraEffectController __instance) { if (__instance.gameObject.CompareTag("MainCamera") && LoadManager.GetCurrentScene() != OWScene.EyeOfTheUniverse) { - __instance.Call("WakeUp"); + __instance.Invoke("WakeUp"); } return false; } diff --git a/QSB/TimeSync/WakeUpSync.cs b/QSB/TimeSync/WakeUpSync.cs index c66fda44..fb0c2ff0 100644 --- a/QSB/TimeSync/WakeUpSync.cs +++ b/QSB/TimeSync/WakeUpSync.cs @@ -1,5 +1,5 @@ -using QSB.Events; -using QSB.Messaging; +using OWML.ModHelper.Events; +using QSB.Events; using UnityEngine; using UnityEngine.Networking; @@ -133,7 +133,7 @@ namespace QSB.TimeSync } _timeScale = MaxFastForwardSpeed; _state = State.FastForwarding; - SpinnerUI.Show(); + FindObjectOfType().Invoke("OnStartFastForward"); } private void StartPausing() @@ -159,6 +159,7 @@ namespace QSB.TimeSync _isFirstFastForward = false; Physics.SyncTransforms(); SpinnerUI.Hide(); + FindObjectOfType().Invoke("OnEndFastForward"); GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest); } @@ -217,8 +218,9 @@ namespace QSB.TimeSync if (LoadManager.GetCurrentScene() == OWScene.SolarSystem && _isFirstFastForward) { - Locator.GetPlayerTransform().position = Locator.GetPlayerBody().GetComponent().GetInitialSpawnPoint().transform.position; - Locator.GetPlayerTransform().rotation = Locator.GetPlayerBody().GetComponent().GetInitialSpawnPoint().transform.rotation; + var spawnPoint = Locator.GetPlayerBody().GetComponent().GetInitialSpawnPoint().transform; + Locator.GetPlayerTransform().position = spawnPoint.position; + Locator.GetPlayerTransform().rotation = spawnPoint.rotation; Physics.SyncTransforms(); } } diff --git a/QSB/Tools/ToolExtensions.cs b/QSB/Tools/ToolExtensions.cs new file mode 100644 index 00000000..67a871ad --- /dev/null +++ b/QSB/Tools/ToolExtensions.cs @@ -0,0 +1,17 @@ +namespace QSB.Tools +{ + public static class ToolExtensions + { + public static void ChangeEquipState(this PlayerTool tool, bool equipState) + { + if (equipState) + { + tool.EquipTool(); + } + else + { + tool.UnequipTool(); + } + } + } +} diff --git a/QSB/Utility/QSBExtensions.cs b/QSB/Utility/QSBExtensions.cs deleted file mode 100644 index d50d38e4..00000000 --- a/QSB/Utility/QSBExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using UnityEngine; - -namespace QSB.Utility -{ - public static class QSBExtensions - { - public static void ChangeEquipState(this PlayerTool tool, bool equipState) - { - if (equipState) - { - tool.EquipTool(); - } - else - { - tool.UnequipTool(); - } - } - - public static string GetHierarchy(this GameObject go) - { - var name = go.name; - while (go.transform.parent != null) - { - go = go.transform.parent.gameObject; - name = go.name + "/" + name; - } - return name; - } - - public static object Call(this object obj, string methodName, params object[] args) - { - var method = obj.GetType().GetMethod(methodName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); - if (method != null) - { - return method.Invoke(obj, args); - } - return null; - } - } -}