This commit is contained in:
Mister_Nebula 2021-01-28 08:34:55 +00:00
parent a42cc762c5
commit b15f6a9f17
2 changed files with 4 additions and 3 deletions

View File

@ -42,6 +42,7 @@ namespace QSB.QuantumSync
foreach (var item in Resources.FindObjectsOfTypeAll<QuantumObject>())
{
DebugLog.DebugWrite($"adding tracker to {item.gameObject.name}");
item.gameObject.AddComponent<OnEnableDisableTracker>();
}
}

View File

@ -16,7 +16,7 @@ namespace QSB.QuantumSync.WorldObjects
var tracker = (AttachedObject as Component).gameObject.AddComponent<OnEnableDisableTracker>();
tracker.OnEnableEvent += OnEnable;
tracker.OnDisableEvent += OnDisable;
ControllingPlayer = 0;
ControllingPlayer = QSBCore.IsServer ? 1u : 0u;
}
private void OnEnable()
@ -27,7 +27,7 @@ namespace QSB.QuantumSync.WorldObjects
return;
}
var id = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().ToList().IndexOf(this);
//DebugLog.DebugWrite($"ON ENABLE {(this as WorldObject<T>).AttachedObject.name} ({id})");
DebugLog.DebugWrite($"ON ENABLE {(this as WorldObject<T>).AttachedObject.name} ({id})");
// no one is controlling this object right now, request authority
GlobalMessenger<int, uint>.FireEvent(EventNames.QSBQuantumAuthority, id, QSBPlayerManager.LocalPlayerId);
ControllingPlayer = QSBPlayerManager.LocalPlayerId;
@ -41,7 +41,7 @@ namespace QSB.QuantumSync.WorldObjects
return;
}
var id = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().ToList().IndexOf(this);
//DebugLog.DebugWrite($"ON DISABLE {(this as WorldObject<T>).AttachedObject.name} ({id})");
DebugLog.DebugWrite($"ON DISABLE {(this as WorldObject<T>).AttachedObject.name} ({id})");
// send event to other players that we're releasing authority
GlobalMessenger<int, uint>.FireEvent(EventNames.QSBQuantumAuthority, id, 0);
ControllingPlayer = 0;