Skip to content

Commit

Permalink
feat!: SpawnVisibleObjects now calls RemoveAllVisibleObjects
Browse files Browse the repository at this point in the history
calling RemoveAllVisibleObjects means that Mirage will send spawn message for objects destroyed in scene change.

BREAKING CHANGE: SpawnVisibleObjects now calls RemoveAllVisibleObjects before spawning objects
  • Loading branch information
James-Frowen committed Dec 27, 2024
1 parent d160e77 commit fe14235
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ public void SpawnVisibleObjects(INetworkPlayer player, bool ignoreHasCharacter,
/// <param name="skip">NetworkIdentity to skip when spawning. Can be null</param>
public void SpawnVisibleObjects(INetworkPlayer player, bool ignoreHasCharacter, HashSet<NetworkIdentity> skip)
{
// todo Call player.RemoveAllVisibleObjects() first so that it will send spawn message for objects destroyed in scene change
// remove all, so that it will send spawn message for objects destroyed in scene change
player.RemoveAllVisibleObjects();

if (!ignoreHasCharacter && !player.HasCharacter)
{
Expand Down Expand Up @@ -768,12 +769,12 @@ public void SpawnVisibleObjects(INetworkPlayer player, bool ignoreHasCharacter,
if (skip != null && skip.Contains(identity))
continue;

if (logger.LogEnabled()) logger.Log($"Checking Observers on server objects name='{identity.name}' netId={identity.NetId} sceneId={identity.SceneId:X}");
if (logger.LogEnabled()) logger.Log($"Checking Observers on server objects name='{identity.name}' netId={identity.NetId} sceneId={identity.SceneId:X}");

var visible = identity.OnCheckObserver(player);
if (visible)
{
identity.AddObserver(player);
var visible = identity.OnCheckObserver(player);
if (visible)
{
identity.AddObserver(player);
}
}

Expand Down

0 comments on commit fe14235

Please sign in to comment.