mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
InterestManagement: NetworkIdentity.forceHidden added again to replace NetworkProximityChecker.forceHidden
This commit is contained in:
parent
a9b0254fcc
commit
b9c0ee144b
@ -31,20 +31,24 @@ void RebuildObservers()
|
||||
// clear previous rebuild first
|
||||
identity.rebuild.Clear();
|
||||
|
||||
// check distance with each player connection
|
||||
// TODO check with each player connection's owned entities
|
||||
// (a monster is visible to a player, if either the player or
|
||||
// the player's pet sees it)
|
||||
foreach (NetworkConnectionToClient conn in NetworkServer.connections.Values)
|
||||
// only add observers if not currently hidden from observers
|
||||
if (!identity.forceHidden)
|
||||
{
|
||||
// only if joined the world (=ready) and selected a player yet
|
||||
if (conn.isReady && conn.identity != null)
|
||||
// check distance with each player connection
|
||||
// TODO check with each player connection's owned entities
|
||||
// (a monster is visible to a player, if either the player or
|
||||
// the player's pet sees it)
|
||||
foreach (NetworkConnectionToClient conn in NetworkServer.connections.Values)
|
||||
{
|
||||
float distance = Vector3.Distance(identity.transform.position, conn.identity.transform.position);
|
||||
if (distance <= visibilityRadius)
|
||||
// only if joined the world (=ready) and selected a player yet
|
||||
if (conn.isReady && conn.identity != null)
|
||||
{
|
||||
// add to rebuild
|
||||
identity.rebuild.Add(conn);
|
||||
float distance = Vector3.Distance(identity.transform.position, conn.identity.transform.position);
|
||||
if (distance <= visibilityRadius)
|
||||
{
|
||||
// add to rebuild
|
||||
identity.rebuild.Add(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +165,13 @@ public sealed class NetworkIdentity : MonoBehaviour
|
||||
internal HashSet<NetworkConnectionToClient> rebuild = 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>
|
||||
/// 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>
|
||||
|
Loading…
Reference in New Issue
Block a user