breaking(NetworkIdentity): Rename visible to visibility (#3748)

* breaking(NetworkIdentity): Rename visible to visibility

* Remove TODO comment
This commit is contained in:
MrGadget 2024-01-22 06:25:40 -05:00 committed by GitHub
parent 50d0008d03
commit 3e254f9ef9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 15 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

@ -197,10 +197,18 @@ internal set
// ForceHidden = useful to hide monsters while they respawn etc.
// ForceShown = useful to have score NetworkIdentities that always broadcast
// to everyone etc.
//
// 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

@ -1206,17 +1206,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)
@ -1682,7 +1682,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);
}
@ -1725,7 +1725,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();