mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-27 12:35:28 +00:00
move a bunch of WorldObjectManager stuff to QSBWorldSync
This commit is contained in:
parent
347cde2978
commit
2743c8ffa9
@ -10,7 +10,7 @@ namespace QSB.Anglerfish
|
||||
|
||||
public static readonly List<AnglerfishController> Anglers = new();
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
Anglers.Clear();
|
||||
Anglers.AddRange(QSBWorldSync.GetUnityObjects<AnglerfishController>());
|
||||
|
@ -49,7 +49,7 @@ namespace QSB.Anglerfish.Patches
|
||||
[HarmonyPatch(typeof(AnglerfishController), nameof(AnglerfishController.UpdateState))]
|
||||
public static bool UpdateState(AnglerfishController __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -155,7 +155,7 @@ namespace QSB.Anglerfish.Patches
|
||||
[HarmonyPatch(typeof(AnglerfishController), nameof(AnglerfishController.UpdateMovement))]
|
||||
public static bool UpdateMovement(AnglerfishController __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace QSB.Anglerfish.TransformSync
|
||||
{
|
||||
public class AnglerTransformSync : UnsectoredRigidbodySync
|
||||
{
|
||||
protected override bool IsReady => WorldObjectManager.AllObjectsAdded;
|
||||
protected override bool IsReady => QSBWorldSync.AllObjectsAdded;
|
||||
protected override bool UseInterpolation => false;
|
||||
protected override bool OnlyApplyOnDeserialize => true;
|
||||
|
||||
|
@ -8,7 +8,7 @@ namespace QSB.Animation.NPC
|
||||
// im assuming this is used in the eye as well
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
QSBWorldSync.Init<QSBCharacterAnimController, CharacterAnimController>();
|
||||
QSBWorldSync.Init<QSBTravelerController, TravelerController>();
|
||||
|
@ -24,7 +24,7 @@ namespace QSB.Animation.NPC.Patches
|
||||
public static bool AnimatorIKReplacement(
|
||||
CharacterAnimController __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady || ConversationManager.Instance == null)
|
||||
if (!QSBWorldSync.AllObjectsReady || ConversationManager.Instance == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -151,7 +151,7 @@ namespace QSB.Animation.NPC.Patches
|
||||
[HarmonyPatch(typeof(KidRockController), nameof(KidRockController.Update))]
|
||||
public static bool UpdateReplacement(KidRockController __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace QSB.Animation.Player.Messages
|
||||
Name = reader.ReadString();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ namespace QSB.Animation.Player.Messages
|
||||
PlayerId = reader.Read<uint>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ namespace QSB.Animation.Player.Thrusters
|
||||
|
||||
private void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.ShowLinesInDebug || !WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBCore.ShowLinesInDebug || !QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace QSB.AuthoritySync
|
||||
NetId = reader.ReadUInt();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||
public override void OnReceiveRemote() => NetworkServer.spawned[NetId].UpdateAuthQueue(From, Value);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.CampfireSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBCampfire, Campfire>();
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace QSB.ConversationSync
|
||||
_boxPrefab.GetComponent<Text>().color = Color.white;
|
||||
}
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBRemoteDialogueTrigger, RemoteDialogueTrigger>();
|
||||
|
||||
public uint GetPlayerTalkingToTree(CharacterDialogueTree tree)
|
||||
|
@ -33,7 +33,7 @@ namespace QSB.ConversationSync.Messages
|
||||
Message = reader.ReadString();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ namespace QSB.ConversationSync.Messages
|
||||
Value = reader.Read<bool>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -8,6 +8,6 @@ namespace QSB.EchoesOfTheEye.AirlockSync
|
||||
// is this used in the prisoner sequence in the eye?
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBGhostAirlock, GhostAirlock>();
|
||||
public override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBGhostAirlock, GhostAirlock>();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace QSB.EchoesOfTheEye.LightSensorSync
|
||||
// see AirlockManager question
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBSingleLightSensor, SingleLightSensor>();
|
||||
public override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBSingleLightSensor, SingleLightSensor>();
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.ElevatorSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBElevator, Elevator>();
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace QSB.EyeOfTheUniverse.EyeStateSync.Messages
|
||||
|
||||
private EyeStateMessage(EyeState state) => Value = state;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace QSB.EyeOfTheUniverse.EyeStateSync.Messages
|
||||
_onDuration = reader.Read<float>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace QSB.EyeOfTheUniverse.ForestOfGalaxies.Messages
|
||||
internal class EyeCloneSeenMessage : QSBMessage
|
||||
{
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace QSB.EyeOfTheUniverse.ForestOfGalaxies.Messages
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace QSB.EyeOfTheUniverse.GalaxyMap.Messages
|
||||
{
|
||||
internal class ZoomOutMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.EyeOfTheUniverse.InstrumentSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Eye;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBQuantumInstrument, QuantumInstrument>();
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.GeyserSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBGeyser, GeyserController>();
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace QSB.ItemSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Info);
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace QSB.ItemSync.Messages
|
||||
ItemId = reader.Read<int>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ namespace QSB.ItemSync.WorldObjects.Items
|
||||
}
|
||||
|
||||
StartDelayedReady();
|
||||
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllObjectsAdded, () =>
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBWorldSync.AllObjectsAdded, () =>
|
||||
{
|
||||
FinishDelayedReady();
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace QSB.JellyfishSync
|
||||
|
||||
public static readonly List<JellyfishController> Jellyfish = new();
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
Jellyfish.Clear();
|
||||
Jellyfish.AddRange(QSBWorldSync.GetUnityObjects<JellyfishController>());
|
||||
|
@ -15,7 +15,7 @@ namespace QSB.JellyfishSync.Patches
|
||||
[HarmonyPatch(typeof(JellyfishController), nameof(JellyfishController.FixedUpdate))]
|
||||
public static bool FixedUpdate(JellyfishController __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace QSB.JellyfishSync.TransformSync
|
||||
{
|
||||
public class JellyfishTransformSync : UnsectoredRigidbodySync
|
||||
{
|
||||
protected override bool IsReady => WorldObjectManager.AllObjectsAdded;
|
||||
protected override bool IsReady => QSBWorldSync.AllObjectsAdded;
|
||||
protected override bool UseInterpolation => false;
|
||||
protected override bool OnlyApplyOnDeserialize => true;
|
||||
|
||||
|
@ -33,7 +33,7 @@ namespace QSB.LogSync.Messages
|
||||
ShowNotification = reader.Read<bool>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
@ -50,7 +50,7 @@ namespace QSB.LogSync.Messages
|
||||
QSBWorldSync.AddFactReveal(FactId, SaveGame);
|
||||
}
|
||||
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace QSB.Messaging
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace QSB.MeteorSync
|
||||
|
||||
public static WhiteHoleVolume WhiteHoleVolume;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
// wait for all late initializers (which includes meteor launchers) to finish
|
||||
StartDelayedReady();
|
||||
|
@ -21,7 +21,7 @@ namespace QSB.MeteorSync.Patches
|
||||
[HarmonyPatch(typeof(MeteorLauncher), nameof(MeteorLauncher.FixedUpdate))]
|
||||
public static bool FixedUpdate(MeteorLauncher __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -319,7 +319,7 @@ namespace QSB.MeteorSync.Patches
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace QSB.OrbSync
|
||||
|
||||
public static readonly List<NomaiInterfaceOrb> Orbs = new();
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
Orbs.Clear();
|
||||
Orbs.AddRange(QSBWorldSync.GetUnityObjects<NomaiInterfaceOrb>());
|
||||
|
@ -17,7 +17,7 @@ namespace QSB.OrbSync.Patches
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.StartDragFromPosition))]
|
||||
public static void StartDragFromPosition(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -35,7 +35,7 @@ namespace QSB.OrbSync.Patches
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.CancelDrag))]
|
||||
public static bool CancelDrag(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -59,7 +59,7 @@ namespace QSB.OrbSync.Patches
|
||||
[HarmonyPatch(nameof(NomaiInterfaceOrb.CheckSlotCollision))]
|
||||
public static bool CheckSlotCollision(NomaiInterfaceOrb __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace QSB.OrbSync.TransformSync
|
||||
{
|
||||
public class NomaiOrbTransformSync : UnsectoredTransformSync
|
||||
{
|
||||
protected override bool IsReady => WorldObjectManager.AllObjectsAdded;
|
||||
protected override bool IsReady => QSBWorldSync.AllObjectsAdded;
|
||||
protected override bool UseInterpolation => true;
|
||||
protected override float DistanceLeeway => 1f;
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace QSB.Player.Messages
|
||||
ObjectId = reader.Read<int>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace QSB.Player.Messages
|
||||
{
|
||||
internal class LaunchCodesMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace QSB.Player.Messages
|
||||
|
||||
public PlayerEntangledMessage(int objectId) => ObjectId = objectId;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ namespace QSB.Player.Messages
|
||||
new ServerStateMessage(ServerStateManager.Instance.GetServerState()) { To = From }.Send();
|
||||
new PlayerInformationMessage { To = From }.Send();
|
||||
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
SendWorldObjectInfo();
|
||||
}
|
||||
@ -79,7 +79,7 @@ namespace QSB.Player.Messages
|
||||
new PlayerInformationMessage { To = From }.Send();
|
||||
}
|
||||
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
SendAuthorityObjectInfo();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace QSB.Player
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace QSB.PoolSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
foreach (var streaming in QSBWorldSync.GetUnityObjects<NomaiRemoteCameraStreaming>())
|
||||
{
|
||||
|
@ -112,10 +112,7 @@ namespace QSB
|
||||
gameObject.AddComponent<MaskManager>();
|
||||
|
||||
// WorldObject managers
|
||||
foreach (var type in typeof(WorldObjectManager).GetDerivedTypes())
|
||||
{
|
||||
gameObject.AddComponent(type);
|
||||
}
|
||||
QSBWorldSync.Init(this);
|
||||
|
||||
Helper.HarmonyHelper.EmptyMethod<ModCommandListener>("Update");
|
||||
|
||||
|
@ -196,8 +196,8 @@ namespace QSB
|
||||
|
||||
if (QSBSceneManager.IsInUniverse)
|
||||
{
|
||||
WorldObjectManager.Rebuild(QSBSceneManager.CurrentScene);
|
||||
QSBWorldSync.Init();
|
||||
QSBWorldSync.Rebuild(QSBSceneManager.CurrentScene);
|
||||
QSBWorldSync.GameInit();
|
||||
}
|
||||
|
||||
var specificType = QSBCore.IsHost ? QSBPatchTypes.OnServerClientConnect : QSBPatchTypes.OnNonServerClientConnect;
|
||||
@ -327,7 +327,7 @@ namespace QSB
|
||||
Destroy(streaming);
|
||||
}
|
||||
|
||||
WorldObjectManager.SetNotReady();
|
||||
QSBWorldSync.SetNotReady();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ namespace QSB
|
||||
// So objects have time to be deleted, made, whatever
|
||||
QSBCore.UnityEvents.FireOnNextUpdate(() =>
|
||||
{
|
||||
WorldObjectManager.Rebuild(newScene);
|
||||
QSBWorldSync.Init();
|
||||
QSBWorldSync.Rebuild(newScene);
|
||||
QSBWorldSync.GameInit();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace QSB.QuantumSync.Messages
|
||||
OrbitAngle = reader.Read<int>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(QuantumObject), nameof(QuantumObject.SetIsQuantum))]
|
||||
public static void QuantumObject_SetIsQuantum(QuantumObject __instance)
|
||||
{
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
__instance.GetWorldObject<IQSBQuantumObject>().SendMessage(new SetIsQuantumMessage(__instance.IsQuantum()));
|
||||
}
|
||||
@ -44,7 +44,7 @@ namespace QSB.QuantumSync.Patches
|
||||
ref bool __result,
|
||||
bool skipInstantVisibilityCheck)
|
||||
{
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
var socketedWorldObject = __instance.GetWorldObject<QSBSocketedQuantumObject>();
|
||||
if (socketedWorldObject.ControllingPlayer != QSBPlayerManager.LocalPlayerId)
|
||||
@ -149,7 +149,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(SocketedQuantumObject), nameof(SocketedQuantumObject.MoveToSocket))]
|
||||
public static void SocketedQuantumObject_MoveToSocket(SocketedQuantumObject __instance, QuantumSocket socket)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace QSB.QuantumSync.Patches
|
||||
ref bool __result)
|
||||
{
|
||||
QSBQuantumShuffleObject shuffleWorldObject = default;
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
shuffleWorldObject = __instance.GetWorldObject<QSBQuantumShuffleObject>();
|
||||
if (shuffleWorldObject.ControllingPlayer != QSBPlayerManager.LocalPlayerId)
|
||||
@ -210,7 +210,7 @@ namespace QSB.QuantumSync.Patches
|
||||
__instance._shuffledObjects[j].localPosition = __instance._localPositions[__instance._indexList[j]];
|
||||
}
|
||||
|
||||
if (WorldObjectManager.AllObjectsReady)
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
shuffleWorldObject.SendMessage(new QuantumShuffleMessage(__instance._indexList.ToArray()));
|
||||
__result = true;
|
||||
@ -223,7 +223,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(MultiStateQuantumObject), nameof(MultiStateQuantumObject.Start))]
|
||||
public static bool MultiStateQuantumObject_Start(MultiStateQuantumObject __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -259,7 +259,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(MultiStateQuantumObject), nameof(MultiStateQuantumObject.ChangeQuantumState))]
|
||||
public static bool MultiStateQuantumObject_ChangeQuantumState(MultiStateQuantumObject __instance)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -278,7 +278,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(QuantumState), nameof(QuantumState.SetVisible))]
|
||||
public static void QuantumState_SetVisible(QuantumState __instance, bool visible)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -434,7 +434,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(QuantumSkeletonTower), nameof(QuantumSkeletonTower.ChangeQuantumState))]
|
||||
public static bool QuantumSkeletonTower_ChangeQuantumState(QuantumSkeletonTower __instance, ref bool __result)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace QSB.QuantumSync.Patches
|
||||
[HarmonyPatch(typeof(EyeProxyQuantumMoon), nameof(EyeProxyQuantumMoon.ChangeQuantumState))]
|
||||
public static bool EyeProxyQuantumMoon_ChangeQuantumState(EyeProxyQuantumMoon __instance, ref bool __result, bool skipInstantVisibilityCheck)
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -18,19 +18,9 @@ namespace QSB.QuantumSync
|
||||
|
||||
public static QuantumShrine Shrine { get; private set; }
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
QSBPlayerManager.OnRemovePlayer += PlayerLeave;
|
||||
}
|
||||
public void Awake() => QSBPlayerManager.OnRemovePlayer += PlayerLeave;
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
QSBPlayerManager.OnRemovePlayer -= PlayerLeave;
|
||||
}
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
DebugLog.DebugWrite("Rebuilding quantum objects...", MessageType.Info);
|
||||
QSBWorldSync.Init<QSBQuantumState, QuantumState>();
|
||||
@ -78,7 +68,7 @@ namespace QSB.QuantumSync
|
||||
|
||||
public static Tuple<bool, List<PlayerInfo>> IsVisibleUsingCameraFrustum(ShapeVisibilityTracker tracker, bool ignoreLocalCamera)
|
||||
{
|
||||
if (!AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return new Tuple<bool, List<PlayerInfo>>(false, new List<PlayerInfo>());
|
||||
}
|
||||
@ -123,7 +113,7 @@ namespace QSB.QuantumSync
|
||||
|
||||
public static IEnumerable<PlayerInfo> GetEntangledPlayers(QuantumObject obj)
|
||||
{
|
||||
if (!AllObjectsReady)
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return Enumerable.Empty<PlayerInfo>();
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace QSB.QuantumSync.WorldObjects
|
||||
base.Init();
|
||||
|
||||
StartDelayedReady();
|
||||
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllObjectsAdded, () =>
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBWorldSync.AllObjectsAdded, () =>
|
||||
{
|
||||
FinishDelayedReady();
|
||||
|
||||
|
@ -175,7 +175,7 @@ namespace QSB.QuantumSync.WorldObjects
|
||||
}
|
||||
|
||||
IsEnabled = true;
|
||||
if (!WorldObjectManager.AllObjectsReady && !QSBCore.IsHost)
|
||||
if (!QSBWorldSync.AllObjectsReady && !QSBCore.IsHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -205,7 +205,7 @@ namespace QSB.QuantumSync.WorldObjects
|
||||
}
|
||||
|
||||
IsEnabled = false;
|
||||
if (!WorldObjectManager.AllObjectsReady && !QSBCore.IsHost)
|
||||
if (!QSBWorldSync.AllObjectsReady && !QSBCore.IsHost)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace QSB.RoastingSync.Messages
|
||||
ObjectId = reader.Read<int>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace QSB.RoastingSync.Messages
|
||||
{
|
||||
public MarshmallowEventMessage(MarshmallowMessageType type) => Value = type;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace QSB.SectorSync
|
||||
|
||||
public void UpdateReferenceSectors()
|
||||
{
|
||||
if (!Instance.IsReady || !AllObjectsReady)
|
||||
if (!Instance.IsReady || !QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -58,14 +58,13 @@ namespace QSB.SectorSync
|
||||
}
|
||||
}
|
||||
|
||||
public override void Awake()
|
||||
public void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
Instance = this;
|
||||
DebugLog.DebugWrite("Sector Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
DebugLog.DebugWrite("Rebuilding sectors...", MessageType.Info);
|
||||
if (QSBSceneManager.CurrentScene == OWScene.SolarSystem)
|
||||
|
@ -26,7 +26,7 @@ namespace QSB.ShipSync.Messages
|
||||
|
||||
public FlyShipMessage(bool flying) => Value = flying;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal() => SetCurrentFlyer(From, Value);
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace QSB.ShipSync.Messages
|
||||
{
|
||||
internal class FunnelEnableMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
=> ShipManager.Instance.ShipTractorBeam.ActivateTractorBeam();
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.ShipSync.Messages
|
||||
{
|
||||
public HatchMessage(bool open) => Value = open;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace QSB.ShipSync.Patches
|
||||
*
|
||||
*/
|
||||
|
||||
if (!WorldObjectManager.AllObjectsReady || __instance != ShipManager.Instance.HatchInteractZone)
|
||||
if (!QSBWorldSync.AllObjectsReady || __instance != ShipManager.Instance.HatchInteractZone)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace QSB.ShipSync
|
||||
public void Start()
|
||||
=> Instance = this;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
var shipTransform = GameObject.Find("Ship_Body");
|
||||
if (shipTransform == null)
|
||||
|
@ -35,7 +35,7 @@ namespace QSB.StatueSync.Messages
|
||||
CameraDegrees = reader.Read<float>();
|
||||
}
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace QSB.Syncs
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!WorldObjectManager.AllObjectsAdded)
|
||||
if (!QSBWorldSync.AllObjectsAdded)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace QSB.Tools.ProbeLauncherTool.Messages
|
||||
{
|
||||
internal class PlayerLaunchProbeMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace QSB.Tools.ProbeLauncherTool.Messages
|
||||
{
|
||||
public PlayerRetrieveProbeMessage(bool playEffects) => Value = playEffects;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.Tools.ProbeLauncherTool
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBProbeLauncher, ProbeLauncher>(typeof(PlayerProbeLauncher));
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ namespace QSB.Tools.ProbeTool.Messages
|
||||
{
|
||||
public PlayerProbeEventMessage(ProbeEvent probeEvent) => Value = probeEvent;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace QSB.Tools.ProbeTool.Messages
|
||||
{
|
||||
public ProbeStartRetrieveMessage(float duration) => Value = duration;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.Tools.SignalscopeTool.FrequencySync.Messages
|
||||
{
|
||||
public IdentifyFrequencyMessage(SignalFrequency frequency) => Value = frequency;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.Tools.SignalscopeTool.FrequencySync.Messages
|
||||
{
|
||||
public IdentifySignalMessage(SignalName name) => Value = name;
|
||||
|
||||
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ namespace QSB.Tools.TranslatorTool
|
||||
|
||||
private void OnRenderObject()
|
||||
{
|
||||
if (!QSBCore.ShowLinesInDebug || !WorldObjectManager.AllObjectsReady)
|
||||
if (!QSBCore.ShowLinesInDebug || !QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.Tools.TranslatorTool.TranslationSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
// wait for all late initializers (which includes nomai text) to finish
|
||||
StartDelayedReady();
|
||||
|
@ -10,7 +10,7 @@ namespace QSB.TornadoSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
QSBWorldSync.Init<QSBTornado, TornadoController>();
|
||||
|
||||
|
@ -13,7 +13,7 @@ namespace QSB.TornadoSync.TransformSync
|
||||
{
|
||||
public class OccasionalTransformSync : UnsectoredRigidbodySync
|
||||
{
|
||||
protected override bool IsReady => WorldObjectManager.AllObjectsReady
|
||||
protected override bool IsReady => QSBWorldSync.AllObjectsReady
|
||||
&& CenterOfTheUniverse.s_rigidbodies.IsInRange(_bodyIndex)
|
||||
&& CenterOfTheUniverse.s_rigidbodies.IsInRange(_refBodyIndex);
|
||||
protected override bool UseInterpolation => false;
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.TriggerSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
{
|
||||
QSBWorldSync.Init<QSBCharacterTrigger, CharacterAnimController>(x => x.playerTrackingZone);
|
||||
QSBWorldSync.Init<QSBSolanumTrigger, NomaiConversationManager>(x => x._watchPlayerVolume);
|
||||
|
@ -32,7 +32,7 @@ namespace QSB.TriggerSync.WorldObjects
|
||||
|
||||
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
|
||||
|
||||
QSBCore.UnityEvents.RunWhen(() => WorldObjectManager.AllObjectsReady, () =>
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBWorldSync.AllObjectsReady, () =>
|
||||
{
|
||||
if (AttachedObject._trackedObjects != null && AttachedObject._trackedObjects.Any(x => x.CompareTag(CompareTag)))
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ namespace QSB.Utility
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!WorldObjectManager.AllObjectsReady || !_isReady)
|
||||
if (!QSBWorldSync.AllObjectsReady || !_isReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace QSB.Utility
|
||||
#region Column1 - Server data
|
||||
|
||||
WriteLine(1, $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}");
|
||||
WriteLine(1, $"HasWokenUp : {WorldObjectManager.AllObjectsReady}");
|
||||
WriteLine(1, $"HasWokenUp : {QSBWorldSync.AllObjectsReady}");
|
||||
if (WakeUpSync.LocalInstance != null)
|
||||
{
|
||||
WriteLine(1, $"Server State : {ServerStateManager.Instance.GetServerState()}");
|
||||
@ -145,7 +145,7 @@ namespace QSB.Utility
|
||||
WriteLine(2, $"Ready : {player.IsReady}");
|
||||
WriteLine(2, $"Suited Up : {player.SuitedUp}");
|
||||
|
||||
if (player.IsReady && WorldObjectManager.AllObjectsReady)
|
||||
if (player.IsReady && QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
var networkTransform = player.TransformSync;
|
||||
var referenceSector = networkTransform.ReferenceSector;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using OWML.Common;
|
||||
using QSB.ConversationSync.Patches;
|
||||
using QSB.LogSync;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.TriggerSync.WorldObjects;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
@ -12,15 +13,111 @@ namespace QSB.WorldSync
|
||||
{
|
||||
public static class QSBWorldSync
|
||||
{
|
||||
public static List<CharacterDialogueTree> OldDialogueTrees { get; private set; } = new();
|
||||
private static WorldObjectManager[] _managers;
|
||||
|
||||
public static void Init(QSBCore qsbCore)
|
||||
{
|
||||
_managers = typeof(WorldObjectManager).GetDerivedTypes()
|
||||
.Select(x => (WorldObjectManager)qsbCore.gameObject.AddComponent(x))
|
||||
.ToArray();
|
||||
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
|
||||
private static void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool inUniverse)
|
||||
{
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set when all WorldObjectManagers have called Init() on all their objects (AKA all the objects are created)
|
||||
/// </summary>
|
||||
public static bool AllObjectsAdded { get; private set; }
|
||||
/// <summary>
|
||||
/// Set when all WorldObjects have finished running Init()
|
||||
/// </summary>
|
||||
public static bool AllObjectsReady { get; private set; }
|
||||
|
||||
public static void SetNotReady()
|
||||
{
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
}
|
||||
|
||||
public static void Rebuild(OWScene scene)
|
||||
{
|
||||
if (!QSBNetworkManager.singleton.IsReady)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to rebuild WorldObjects when Network Manager not ready! Building when ready...", MessageType.Warning);
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBNetworkManager.singleton.IsReady, () => Rebuild(scene));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerTransformSync.LocalInstance == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to rebuild WorldObjects when LocalPlayer is not ready! Building when ready...", MessageType.Warning);
|
||||
QSBCore.UnityEvents.RunWhen(() => PlayerTransformSync.LocalInstance, () => Rebuild(scene));
|
||||
return;
|
||||
}
|
||||
|
||||
DoRebuild(scene);
|
||||
}
|
||||
|
||||
private static void DoRebuild(OWScene scene)
|
||||
{
|
||||
RemoveWorldObjects();
|
||||
_numManagersReadying = 0;
|
||||
_numObjectsReadying = 0;
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
foreach (var manager in _managers)
|
||||
{
|
||||
switch (manager.WorldObjectType)
|
||||
{
|
||||
case WorldObjectType.SolarSystem when QSBSceneManager.CurrentScene != OWScene.SolarSystem:
|
||||
case WorldObjectType.Eye when QSBSceneManager.CurrentScene != OWScene.EyeOfTheUniverse:
|
||||
DebugLog.DebugWrite($"skipping {manager.GetType().Name} as it is type {manager.WorldObjectType} and scene is {QSBSceneManager.CurrentScene}");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DebugLog.DebugWrite($"Rebuilding {manager.GetType().Name}", MessageType.Info);
|
||||
manager.RebuildWorldObjects(scene);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugLog.ToConsole($"Exception - Exception when trying to rebuild WorldObjects of manager {manager.GetType().Name} : {ex.Message} Stacktrace :\r\n{ex.StackTrace}", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
QSBCore.UnityEvents.RunWhen(() => _numManagersReadying == 0, () =>
|
||||
{
|
||||
AllObjectsAdded = true;
|
||||
DebugLog.DebugWrite("World Objects added.", MessageType.Success);
|
||||
QSBCore.UnityEvents.RunWhen(() => _numObjectsReadying == 0, () =>
|
||||
{
|
||||
AllObjectsReady = true;
|
||||
DebugLog.DebugWrite("World Objects ready.", MessageType.Success);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
internal static uint _numManagersReadying;
|
||||
internal static uint _numObjectsReadying;
|
||||
|
||||
// =======================================================================================================
|
||||
|
||||
public static List<CharacterDialogueTree> OldDialogueTrees { get; } = new();
|
||||
public static Dictionary<string, bool> DialogueConditions { get; private set; } = new();
|
||||
public static Dictionary<string, bool> PersistentConditions { get; private set; } = new();
|
||||
public static List<FactReveal> ShipLogFacts { get; private set; } = new();
|
||||
public static List<FactReveal> ShipLogFacts { get; } = new();
|
||||
|
||||
private static readonly List<IWorldObject> WorldObjects = new();
|
||||
private static readonly Dictionary<MonoBehaviour, IWorldObject> WorldObjectsToUnityObjects = new();
|
||||
|
||||
public static void Init()
|
||||
public static void GameInit()
|
||||
{
|
||||
DebugLog.DebugWrite($"Init QSBWorldSync", MessageType.Info);
|
||||
|
||||
|
@ -19,9 +19,9 @@ namespace QSB.WorldSync
|
||||
public virtual void DisplayLines() { }
|
||||
|
||||
/// indicates that this won't become ready immediately
|
||||
protected void StartDelayedReady() => WorldObjectManager._numObjectsReadying++;
|
||||
protected void StartDelayedReady() => QSBWorldSync._numObjectsReadying++;
|
||||
|
||||
/// indicates that this is now ready
|
||||
protected void FinishDelayedReady() => WorldObjectManager._numObjectsReadying--;
|
||||
protected void FinishDelayedReady() => QSBWorldSync._numObjectsReadying--;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,4 @@
|
||||
using OWML.Common;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.WorldSync
|
||||
{
|
||||
@ -17,115 +11,17 @@ namespace QSB.WorldSync
|
||||
|
||||
public abstract class WorldObjectManager : MonoBehaviour
|
||||
{
|
||||
private static readonly List<WorldObjectManager> _managers = new();
|
||||
|
||||
/// <summary>
|
||||
/// Set when all WorldObjectManagers have called Init() on all their objects (AKA all the objects are created)
|
||||
/// </summary>
|
||||
public static bool AllObjectsAdded { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set when all WorldObjects have finished running Init()
|
||||
/// </summary>
|
||||
public static bool AllObjectsReady { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// when the scene does not match the type, this manager will not build its world objects
|
||||
/// </summary>
|
||||
public abstract WorldObjectType WorldObjectType { get; }
|
||||
|
||||
public virtual void Awake()
|
||||
{
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
_managers.Add(this);
|
||||
}
|
||||
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
_managers.Remove(this);
|
||||
}
|
||||
|
||||
public static void SetNotReady()
|
||||
{
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool inUniverse)
|
||||
{
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
}
|
||||
|
||||
public static void Rebuild(OWScene scene)
|
||||
{
|
||||
if (!QSBNetworkManager.singleton.IsReady)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to rebuild WorldObjects when Network Manager not ready! Building when ready...", MessageType.Warning);
|
||||
QSBCore.UnityEvents.RunWhen(() => QSBNetworkManager.singleton.IsReady, () => Rebuild(scene));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerTransformSync.LocalInstance == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to rebuild WorldObjects when LocalPlayer is not ready! Building when ready...", MessageType.Warning);
|
||||
QSBCore.UnityEvents.RunWhen(() => PlayerTransformSync.LocalInstance, () => Rebuild(scene));
|
||||
return;
|
||||
}
|
||||
|
||||
DoRebuild(scene);
|
||||
}
|
||||
|
||||
private static void DoRebuild(OWScene scene)
|
||||
{
|
||||
QSBWorldSync.RemoveWorldObjects();
|
||||
_numManagersReadying = 0;
|
||||
_numObjectsReadying = 0;
|
||||
AllObjectsAdded = false;
|
||||
AllObjectsReady = false;
|
||||
foreach (var manager in _managers)
|
||||
{
|
||||
switch (manager.WorldObjectType)
|
||||
{
|
||||
case WorldObjectType.SolarSystem when QSBSceneManager.CurrentScene != OWScene.SolarSystem:
|
||||
case WorldObjectType.Eye when QSBSceneManager.CurrentScene != OWScene.EyeOfTheUniverse:
|
||||
DebugLog.DebugWrite($"skipping {manager.GetType().Name} as it is type {manager.WorldObjectType} and scene is {QSBSceneManager.CurrentScene}");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DebugLog.DebugWrite($"Rebuilding {manager.GetType().Name}", MessageType.Info);
|
||||
manager.RebuildWorldObjects(scene);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DebugLog.ToConsole($"Exception - Exception when trying to rebuild WorldObjects of manager {manager.GetType().Name} : {ex.Message} Stacktrace :\r\n{ex.StackTrace}", MessageType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
QSBCore.UnityEvents.RunWhen(() => _numManagersReadying == 0, () =>
|
||||
{
|
||||
AllObjectsAdded = true;
|
||||
DebugLog.DebugWrite("World Objects added.", MessageType.Success);
|
||||
QSBCore.UnityEvents.RunWhen(() => _numObjectsReadying == 0, () =>
|
||||
{
|
||||
AllObjectsReady = true;
|
||||
DebugLog.DebugWrite("World Objects ready.", MessageType.Success);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void RebuildWorldObjects(OWScene scene);
|
||||
|
||||
private static uint _numManagersReadying;
|
||||
internal static uint _numObjectsReadying;
|
||||
public abstract void RebuildWorldObjects(OWScene scene);
|
||||
|
||||
/// indicates that this won't become ready immediately
|
||||
protected void StartDelayedReady() => _numManagersReadying++;
|
||||
protected void StartDelayedReady() => QSBWorldSync._numManagersReadying++;
|
||||
|
||||
/// indicates that this is now ready
|
||||
protected void FinishDelayedReady() => _numManagersReadying--;
|
||||
protected void FinishDelayedReady() => QSBWorldSync._numManagersReadying--;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace QSB.ZeroGCaveSync
|
||||
{
|
||||
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
|
||||
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
public override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBSatelliteNode, SatelliteNode>();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user