breaking(NetworkIdentity): Rename visible to visibility

This commit is contained in:
MrGadget 2024-01-21 17:10:24 -05:00
parent ac344fd9d1
commit 952aa093e5
6 changed files with 23 additions and 13 deletions

View File

@ -54,7 +54,7 @@ public override void Rebuild(NetworkIdentity identity, bool initialize)
newObservers.Clear();
// not force hidden?
if (identity.visible != Visibility.ForceHidden)
if (identity.visibility != Visibility.ForceHidden)
{
OnRebuildObservers(identity, newObservers);
}

View File

@ -200,7 +200,17 @@ internal set
//
// TODO rename to 'visibility' after removing .visibility some day!
[Tooltip("Visibility can overwrite interest management. ForceHidden can be useful to hide monsters while they respawn. ForceShown can be useful for score NetworkIdentities that should always broadcast to everyone in the world.")]
public Visibility visible = Visibility.Default;
[FormerlySerializedAs("visible")]
public Visibility visibility = Visibility.Default;
// Deprecated 2024-01-21
[HideInInspector]
[Obsolete("Deprecated - Use .visibility instead. This will be removed soon.")]
public Visibility visible
{
get => visibility;
set => visibility = value;
}
// broadcasting serializes all entities around a player for each player.
// we don't want to serialize one entity twice in the same tick.

View File

@ -1198,17 +1198,17 @@ static void SpawnObserversForConnection(NetworkConnectionToClient conn)
// first!
// ForceShown: add no matter what
if (identity.visible == Visibility.ForceShown)
if (identity.visibility == Visibility.ForceShown)
{
identity.AddObserver(conn);
}
// ForceHidden: don't show no matter what
else if (identity.visible == Visibility.ForceHidden)
else if (identity.visibility == Visibility.ForceHidden)
{
// do nothing
}
// default: legacy system / new system / no system support
else if (identity.visible == Visibility.Default)
else if (identity.visibility == Visibility.Default)
{
// aoi system
if (aoi != null)
@ -1674,7 +1674,7 @@ static void RebuildObserversDefault(NetworkIdentity identity, bool initialize)
if (initialize)
{
// not force hidden?
if (identity.visible != Visibility.ForceHidden)
if (identity.visibility != Visibility.ForceHidden)
{
AddAllReadyServerConnectionsToObservers(identity);
}
@ -1717,7 +1717,7 @@ public static void RebuildObservers(NetworkIdentity identity, bool initialize)
{
// if there is no interest management system,
// or if 'force shown' then add all connections
if (aoi == null || identity.visible == Visibility.ForceShown)
if (aoi == null || identity.visibility == Visibility.ForceShown)
{
RebuildObserversDefault(identity, initialize);
}

View File

@ -11,7 +11,7 @@ public class InterestManagementTests_Default : InterestManagementTests_Common
public override void ForceHidden_Initial()
{
// force hide A
identityA.visible = Visibility.ForceHidden;
identityA.visibility = Visibility.ForceHidden;
// rebuild for both
// initial rebuild adds all connections if no interest management available
@ -30,7 +30,7 @@ public override void ForceHidden_Initial()
public override void ForceShown_Initial()
{
// force show A
identityA.visible = Visibility.ForceShown;
identityA.visibility = Visibility.ForceShown;
// rebuild for both
// initial rebuild adds all connections if no interest management available

View File

@ -36,7 +36,7 @@ public override void ForceHidden_Initial()
// A and B are at (0,0,0) so within range!
// force hide A
identityA.visible = Visibility.ForceHidden;
identityA.visibility = Visibility.ForceHidden;
// rebuild for both
// initial rebuild while both are within range
@ -58,7 +58,7 @@ public override void ForceShown_Initial()
identityB.transform.position = Vector3.right * (aoi.visRange + 1);
// force show A
identityA.visible = Visibility.ForceShown;
identityA.visibility = Visibility.ForceShown;
// rebuild for both
// initial rebuild while both are within range

View File

@ -39,7 +39,7 @@ public override void ForceHidden_Initial()
// A and B are at (0,0,0) so within range!
// force hide A
identityA.visible = Visibility.ForceHidden;
identityA.visibility = Visibility.ForceHidden;
// rebuild for both
// initial rebuild while both are within range
@ -61,7 +61,7 @@ public override void ForceShown_Initial()
identityB.transform.position = Vector3.right * (aoi.visRange + 1);
// force show A
identityA.visible = Visibility.ForceShown;
identityA.visibility = Visibility.ForceShown;
// update grid now that positions were changed
aoi.Update();