Revert "QSBSceneManager: OnStartSceneLoad"

This reverts commit 382fb58003.
This commit is contained in:
JohnCorby 2022-04-22 20:00:52 -07:00
parent 382fb58003
commit ca043076a4
4 changed files with 16 additions and 24 deletions

View File

@ -104,6 +104,7 @@ public class QSBCore : ModBehaviour
TextAssetsBundle = Helper.Assets.LoadBundle("AssetBundles/textassets");
QSBPatchManager.Init();
DeterministicManager.Init();
var components = typeof(IAddComponentOnStart).GetDerivedTypes()
.Select(x => gameObject.AddComponent(x))

View File

@ -16,21 +16,14 @@ public static class QSBSceneManager
static QSBSceneManager()
{
LoadManager.OnStartSceneLoad += OnStartSceneLoad;
LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad;
DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success);
}
private static void OnStartSceneLoad(OWScene oldScene, OWScene newScene)
{
DebugLog.DebugWrite($"START SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info);
QSBWorldSync.RemoveWorldObjects();
DeterministicManager.OnStartSceneLoad();
}
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
{
DebugLog.DebugWrite($"COMPLETE SCENE LOAD ({oldScene} -> {newScene})", MessageType.Info);
QSBWorldSync.RemoveWorldObjects();
var universe = InUniverse(newScene);
if (QSBCore.IsInMultiplayer && universe)
{
@ -52,4 +45,4 @@ public static class QSBSceneManager
private static bool InUniverse(OWScene scene) =>
scene is OWScene.SolarSystem or OWScene.EyeOfTheUniverse;
}
}

View File

@ -16,21 +16,19 @@ public static class DeterministicManager
private static readonly Dictionary<Transform, (int SiblingIndex, Transform Parent)> _cache = new();
public static void Init() =>
LoadManager.OnStartSceneLoad += (_, _) => { };
public static void OnStartSceneLoad()
{
DebugLog.DebugWrite("cleared cache");
_cache.Clear();
if (!_patched)
LoadManager.OnStartSceneLoad += (_, _) =>
{
_harmony.PatchAll(typeof(OWRigidbodyPatches));
_patched = true;
}
}
DebugLog.DebugWrite("cleared cache");
_cache.Clear();
public static void OnWorldObjectsReady()
if (!_patched)
{
_harmony.PatchAll(typeof(OWRigidbodyPatches));
_patched = true;
}
};
public static void WorldObjectsReady()
{
if (QSBCore.DebugSettings.DumpWorldObjects)
{
@ -301,4 +299,4 @@ public static class DeterministicManager
/// </summary>
public static IEnumerable<T> SortDeterministic<T>(this IEnumerable<T> components) where T : Component
=> components.OrderBy(DeterministicPath);
}
}

View File

@ -96,7 +96,7 @@ public static class QSBWorldSync
AllObjectsReady = true;
DebugLog.DebugWrite("World Objects ready.", MessageType.Success);
DeterministicManager.OnWorldObjectsReady();
DeterministicManager.WorldObjectsReady();
if (!QSBCore.IsHost)
{