Made Update internal in Int Mgmt Components

- also standardized on using [ServerCallback]
This commit is contained in:
MrGadget1024 2021-10-30 02:47:26 -04:00
parent 895279ee79
commit 52d1445091
5 changed files with 11 additions and 22 deletions

View File

@ -53,11 +53,10 @@ public override void OnRebuildObservers(NetworkIdentity identity, HashSet<Networ
}
}
void Update()
// internal so we can update from tests
[ServerCallback]
internal void Update()
{
// only on server
if (!NetworkServer.active) return;
// rebuild all spawned NetworkIdentity's observers every interval
if (NetworkTime.localTime >= lastRebuildTime + rebuildInterval)
{

View File

@ -43,8 +43,9 @@ public override void OnDestroyed(NetworkIdentity identity)
RebuildMatchObservers(currentMatch);
}
// internal so we can update from tests
[ServerCallback]
void Update()
internal void Update()
{
// for each spawned:
// if match changed:

View File

@ -37,11 +37,10 @@ public override void OnDestroyed(NetworkIdentity identity)
RebuildSceneObservers(currentScene);
}
void Update()
// internal so we can update from tests
[ServerCallback]
internal void Update()
{
// only on server
if (!NetworkServer.active) return;
// for each spawned:
// if scene changed:
// add previous to dirty

View File

@ -62,11 +62,9 @@ public override void OnRebuildObservers(NetworkIdentity identity, HashSet<Networ
// update everyone's position in the grid
// (internal so we can update from tests)
[ServerCallback]
internal void Update()
{
// only on server
if (!NetworkServer.active) return;
// NOTE: unlike Scene/MatchInterestManagement, this rebuilds ALL
// entities every INTERVAL. consider the other approach later.

View File

@ -35,17 +35,15 @@ public override void OnSpawned(NetworkIdentity identity)
public override void OnDestroyed(NetworkIdentity identity)
{
// Do nothing if server has shut down (or not started)
if (!NetworkServer.active) return;
lastObjectTeam.TryGetValue(identity, out string currentTeam);
lastObjectTeam.Remove(identity);
if (currentTeam != string.Empty && teamObjects.TryGetValue(currentTeam, out HashSet<NetworkIdentity> objects) && objects.Remove(identity))
RebuildTeamObservers(currentTeam);
}
// internal so we can update from tests
[ServerCallback]
void Update()
internal void Update()
{
// for each spawned:
// if team changed:
@ -116,9 +114,6 @@ void RebuildTeamObservers(string teamId)
public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection newObserver)
{
// Do nothing if server has shut down (or not started)
if (!NetworkServer.active) return false;
// Always observed if no NetworkTeam component
if (!identity.TryGetComponent<NetworkTeam>(out NetworkTeam identityNetworkTeam))
return true;
@ -133,9 +128,6 @@ public override bool OnCheckObserver(NetworkIdentity identity, NetworkConnection
public override void OnRebuildObservers(NetworkIdentity identity, HashSet<NetworkConnection> newObservers, bool initialize)
{
// Do nothing if server has shut down (or not started)
if (!NetworkServer.active) return;
// If this object doesn't have a NetworkTeam then it's visible to all clients
if (!identity.TryGetComponent<NetworkTeam>(out NetworkTeam networkTeam))
{