Skip to content

Commit

Permalink
feat: add quick access ref to NetIdentity.ServerObjectManager (#444)
Browse files Browse the repository at this point in the history
* feat: add quick access ref to NetIdentity.ServerObjectManager

* update samples
  • Loading branch information
uweeby committed Oct 30, 2020
1 parent cc28239 commit d691ca4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Assets/Mirror/Runtime/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public abstract class NetworkBehaviour : MonoBehaviour
/// </summary>
public NetworkServer Server => NetIdentity.Server;

public ServerObjectManager ServerObjectManager => NetIdentity.ServerObjectManager;

/// <summary>
/// The <see cref="NetworkClient">NetworkClient</see> associated to this object.
/// </summary>
Expand Down Expand Up @@ -200,7 +202,7 @@ private void SyncObject_OnChange()
{
if (IsServer)
{
NetIdentity.ServerObjectManager.DirtyObjects.Add(NetIdentity);
ServerObjectManager.DirtyObjects.Add(NetIdentity);
}
}

Expand Down Expand Up @@ -429,7 +431,7 @@ public void SetDirtyBit(ulong dirtyBit)
{
SyncVarDirtyBits |= dirtyBit;
if (IsServer)
NetIdentity.ServerObjectManager.DirtyObjects.Add(NetIdentity);
ServerObjectManager.DirtyObjects.Add(NetIdentity);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void ClaimPrize(GameObject player)
spawner.SpawnPrize();

// destroy this one
NetIdentity.ServerObjectManager.Destroy(gameObject);
ServerObjectManager.Destroy(gameObject);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void SpawnPrize()
Reward reward = newPrize.gameObject.GetComponent<Reward>();
reward.spawner = this;

NetIdentity.ServerObjectManager.Spawn(newPrize);
ServerObjectManager.Spawn(newPrize);
SceneManager.MoveGameObjectToScene(newPrize, gameObject.scene);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Mirror/Samples~/Tanks/Scripts/Projectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void Start()
[Server]
void DestroySelf()
{
NetIdentity.ServerObjectManager.Destroy(gameObject);
ServerObjectManager.Destroy(gameObject);
}

// [Server] because we don't want a warning if OnTriggerEnter is
Expand All @@ -51,7 +51,7 @@ void OnTriggerEnter(Collider co)
source.GetComponent<Tank>().score += damage;
}

NetIdentity.ServerObjectManager.Destroy(gameObject);
ServerObjectManager.Destroy(gameObject);
}
}
}
2 changes: 1 addition & 1 deletion Assets/Mirror/Samples~/Tanks/Scripts/Tank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void CmdFire()
{
GameObject projectile = Instantiate(projectilePrefab, projectileMount.position, transform.rotation);
projectile.GetComponent<Projectile>().source = gameObject;
NetIdentity.ServerObjectManager.Spawn(projectile);
ServerObjectManager.Spawn(projectile);
RpcOnFire();
}

Expand Down

0 comments on commit d691ca4

Please sign in to comment.