11using System . Collections . Generic ;
22using UnityEngine ;
33using Object = UnityEngine . Object ;
4- using System ;
5- #if ! MIRROR
4+ #if MIRAGE
65using Mirage ;
76#else
87using Mirror ;
@@ -14,7 +13,7 @@ public class ObjectPoolingManager : MonoBehaviour
1413 {
1514 #region Fields
1615
17- #if ! MIRROR
16+ #if MIRAGE
1817 private ServerObjectManager _serverObjectManager ;
1918 private readonly Dictionary < int ? , NetworkIdentity > _objectsAssetIds = new Dictionary < int ? , NetworkIdentity > ( ) ;
2019#else
@@ -32,7 +31,7 @@ private void Start()
3231 {
3332 _parent = new GameObject { name = "Pooled Objects" } ;
3433 DontDestroyOnLoad ( _parent ) ;
35- #if ! MIRROR
34+ #if MIRAGE
3635 _serverObjectManager = FindObjectOfType < ServerObjectManager > ( ) ;
3736
3837 ClientObjectManager clientObject = FindObjectOfType < ClientObjectManager > ( ) ;
@@ -59,7 +58,7 @@ private void Start()
5958
6059 #region Custom Spawn Handlers
6160
62- #if ! MIRROR
61+ #if MIRAGE
6362 /// <summary>
6463 /// Spawn handler for all network spawning of things.
6564 /// </summary>
@@ -76,8 +75,8 @@ internal NetworkIdentity SpawnObject(SpawnMessage msg)
7675 internal GameObject SpawnObject ( Vector3 position , Guid assetId )
7776#endif
7877 {
79- #if ! MIRROR
80- NetworkIdentity spawnedObject = NetworkSpawnPool ( msg . position , Quaternion . identity , msg . prefabHash , 1 ) ;
78+ #if MIRAGE
79+ NetworkIdentity spawnedObject = NetworkSpawnPool ( msg . position ?? new Vector3 ( ) , Quaternion . identity , msg . prefabHash , 1 ) ;
8180#else
8281 NetworkIdentity spawnedObject = NetworkSpawnPool ( position , Quaternion . identity , assetId , 1 ) ;
8382#endif
@@ -86,7 +85,7 @@ internal GameObject SpawnObject(Vector3 position, Guid assetId)
8685 spawnedObject . gameObject . SetActive ( true ) ;
8786
8887 // return the game object back to mirage to have it finish spawning.
89- #if ! MIRROR
88+ #if MIRAGE
9089 return spawnedObject ;
9190#else
9291 return spawnedObject . gameObject ;
@@ -97,7 +96,7 @@ internal GameObject SpawnObject(Vector3 position, Guid assetId)
9796 /// Spawn handler for all network unspawning of things.
9897 /// </summary>
9998 /// <param name="spawned">What network identity we are going to unspawn and return back to network pool.</param>
100- #if ! MIRROR
99+ #if MIRAGE
101100 internal void UnSpawnObject ( NetworkIdentity spawned )
102101#else
103102 internal void UnSpawnObject ( GameObject spawned )
@@ -113,7 +112,7 @@ internal void UnSpawnObject(GameObject spawned)
113112
114113 break ;
115114 }
116- #if ! MIRROR
115+ #if MIRAGE
117116
118117 p . Despawn ( spawned ) ;
119118#else
@@ -154,7 +153,7 @@ private void UnSpawnObject<T>(T spawned) where T : Object
154153 /// <param name="AssetId">The asset id of the object from <see cref="NetworkIdentity" /> to use to spawn object of.</param>
155154 /// <param name="quantity">How many pooled objects we want to create of this object. If we don't have a pool started.</param>
156155 /// <returns></returns>
157- #if ! MIRROR
156+ #if MIRAGE
158157 public NetworkIdentity NetworkSpawnPool ( Vector3 position , Quaternion rotation , int ? AssetId , int quantity = 3 )
159158#else
160159 public NetworkIdentity NetworkSpawnPool ( Vector3 position , Quaternion rotation , Guid AssetId , int quantity = 3 )
@@ -186,7 +185,7 @@ public void NetworkUnSpawnObject(NetworkIdentity objectSpawned, bool isServer)
186185 {
187186 UnSpawnObject ( objectSpawned ) ;
188187
189- #if ! MIRROR
188+ #if MIRAGE
190189 // If this is network server then tell rest of clients to unspawn object.
191190 if ( _serverObjectManager == null || ! isServer ) return ;
192191
0 commit comments