InterestManagement: NetworkIdentity.forceHidden added again to replace NetworkProximityChecker.forceHidden

This commit is contained in:
vis2k 2020-10-05 17:31:29 +02:00
parent a9b0254fcc
commit b9c0ee144b
2 changed files with 22 additions and 11 deletions

View File

@ -31,6 +31,9 @@ void RebuildObservers()
// clear previous rebuild first // clear previous rebuild first
identity.rebuild.Clear(); identity.rebuild.Clear();
// only add observers if not currently hidden from observers
if (!identity.forceHidden)
{
// check distance with each player connection // check distance with each player connection
// TODO check with each player connection's owned entities // TODO check with each player connection's owned entities
// (a monster is visible to a player, if either the player or // (a monster is visible to a player, if either the player or
@ -48,6 +51,7 @@ void RebuildObservers()
} }
} }
} }
}
//if (identity.rebuild.Count > 0) //if (identity.rebuild.Count > 0)
// Debug.Log($"{identity.name} is observed by {identity.rebuild.Count} connections"); // Debug.Log($"{identity.name} is observed by {identity.rebuild.Count} connections");

View File

@ -165,6 +165,13 @@ public sealed class NetworkIdentity : MonoBehaviour
internal HashSet<NetworkConnectionToClient> rebuild = new HashSet<NetworkConnectionToClient>(); internal HashSet<NetworkConnectionToClient> rebuild = new HashSet<NetworkConnectionToClient>();
public HashSet<NetworkConnectionToClient> observers = new HashSet<NetworkConnectionToClient>(); public HashSet<NetworkConnectionToClient> observers = new HashSet<NetworkConnectionToClient>();
// Enable to temporarily hide from players. For example, to hide a
// monster while it's respawning. This way the monster still exists,
// still gets updated, but is hidden from players. This is more
// convenient than removing the monster completely and respawning it
// with a Spawner.
[HideInInspector] public bool forceHidden;
/// <summary> /// <summary>
/// Unique identifier for this particular object instance, used for tracking objects between networked clients and the server. /// Unique identifier for this particular object instance, used for tracking objects between networked clients and the server.
/// <para>This is a unique identifier for this particular GameObject instance. Use it to track GameObjects between networked clients and the server.</para> /// <para>This is a unique identifier for this particular GameObject instance. Use it to track GameObjects between networked clients and the server.</para>