This commit is contained in:
Mister_Nebula 2021-02-14 09:43:36 +00:00
parent 61866c6367
commit dd16a2f09e
5 changed files with 22 additions and 4 deletions

View File

@ -141,6 +141,11 @@ namespace QSB
{
QSBWorldSync.OldDialogueTrees = Resources.FindObjectsOfTypeAll<CharacterDialogueTree>().ToList();
}
if (QSBSceneManager.IsInUniverse)
{
QSBCore.HasWokenUp = true;
}
}
public override void OnServerAddPlayer(QNetworkConnection connection, short playerControllerId) // Called on the server when a client joins
@ -247,6 +252,7 @@ namespace QSB
base.OnStopServer();
}
private void RemoveWorldObjects()
{
QSBWorldSync.RemoveWorldObjects<QSBOrbSlot>();
@ -255,6 +261,5 @@ namespace QSB
QSBWorldSync.RemoveWorldObjects<QSBSector>();
QSBWorldSync.RemoveWorldObjects<IQSBQuantumObject>();
}
}
}

View File

@ -49,6 +49,7 @@ namespace QSB.QuantumSync.Events
{
var objects = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>();
var obj = objects.ToList()[message.ObjectId];
DebugLog.DebugWrite($"LOCAL {(obj as IWorldObject).Name} to owner {message.AuthorityOwner}");
obj.ControllingPlayer = message.AuthorityOwner;
}

View File

@ -24,16 +24,22 @@ namespace QSB.QuantumSync.WorldObjects
public override void Init(T attachedObject, int id)
{
DebugLog.DebugWrite($"Init of {attachedObject.name}");
_tracker = QSBCore.GameObjectInstance.AddComponent<OnEnableDisableTracker>();
_tracker.AttachedComponent = AttachedObject;
_tracker.OnEnableEvent += OnEnable;
_tracker.OnDisableEvent += OnDisable;
ControllingPlayer = 1u;
ControllingPlayer = 0u;
}
private void OnEnable()
{
DebugLog.DebugWrite($"Enable {AttachedObject.name}, current owner {ControllingPlayer}");
IsEnabled = true;
if (!QSBCore.HasWokenUp && !QSBCore.IsServer)
{
return;
}
if (ControllingPlayer != 0)
{
// controlled by another player, dont care that we activate it
@ -46,7 +52,12 @@ namespace QSB.QuantumSync.WorldObjects
private void OnDisable()
{
DebugLog.DebugWrite($"Disable {AttachedObject.name}, current owner {ControllingPlayer}");
IsEnabled = false;
if (!QSBCore.HasWokenUp && !QSBCore.IsServer)
{
return;
}
if (ControllingPlayer != QSBPlayerManager.LocalPlayerId)
{
// not being controlled by us, don't care if we leave area

View File

@ -50,7 +50,7 @@ namespace QSB.TimeSync
private void OnWakeUp()
{
DebugLog.DebugWrite($"OnWakeUp", OWML.Common.MessageType.Info);
DebugLog.DebugWrite($"OnWakeUp", MessageType.Info);
if (QNetworkServer.active)
{
QSBCore.HasWokenUp = true;

View File

@ -34,7 +34,7 @@ namespace QSB.WorldSync
{
item.OnRemoval();
}
DebugLog.DebugWrite($"Removing types {typeof(TWorldObject).Name}.");
DebugLog.DebugWrite($"Removing {typeof(TWorldObject).Name} : {WorldObjects.Count(x => x is TWorldObject)} instances.");
WorldObjects.RemoveAll(x => x is TWorldObject);
}
@ -42,6 +42,7 @@ namespace QSB.WorldSync
where TWorldObject : WorldObject<TUnityObject>
where TUnityObject : MonoBehaviour
{
RemoveWorldObjects<TWorldObject>();
var list = Resources.FindObjectsOfTypeAll<TUnityObject>().ToList();
DebugLog.DebugWrite($"{typeof(TWorldObject).Name} init : {list.Count} instances.", MessageType.Info);
for (var id = 0; id < list.Count; id++)