public SpawnableResult ClientSpawnAt(SpawnDestination destination) { bool isPooled; // not used for Client-only instantiation var go = Spawn._PoolInstantiate(prefab, destination, out isPooled); return(SpawnableResult.Single(go, destination)); }
public SpawnableResult SpawnAt(SpawnDestination destination) { if (!SpawnableUtils.IsValidDestination(destination)) { return(SpawnableResult.Fail(destination)); } if (prefab == null) { Logger.LogWarning("Cannot spawn, prefab to use is null", Category.ItemSpawn); return(SpawnableResult.Fail(destination)); } Logger.LogTraceFormat("Spawning using prefab {0}", Category.ItemSpawn, prefab); bool isPooled; GameObject tempObject = Spawn._PoolInstantiate(prefab, destination, out isPooled); if (!isPooled) { Logger.LogTrace("Prefab to spawn was not pooled, spawning new instance.", Category.ItemSpawn); NetworkServer.Spawn(tempObject); tempObject.GetComponent <CustomNetTransform>() ?.NotifyPlayers(); //Sending clientState for newly spawned items } else { Logger.LogTrace("Prefab to spawn was pooled, reusing it...", Category.ItemSpawn); } return(SpawnableResult.Single(tempObject, destination)); }
public SpawnableResult SpawnAt(SpawnDestination destination) { var prefab = Spawn.DeterminePrefab(toClone); if (prefab == null) { Logger.LogErrorFormat( "Object {0} cannot be cloned because it has no PoolPrefabTracker and its name" + " does not match a prefab name, so we cannot" + " determine the prefab to instantiate. Please fix this object so that it" + " has an attached PoolPrefabTracker or so its name matches the prefab it was created from.", Category.ItemSpawn, toClone); return(SpawnableResult.Fail(destination)); } GameObject tempObject = Spawn._PoolInstantiate(prefab, destination, out var isPooled); if (!isPooled) { NetworkServer.Spawn(tempObject); tempObject.GetComponent <CustomNetTransform>() ?.NotifyPlayers(); //Sending clientState for newly spawned items } return(SpawnableResult.Single(tempObject, destination)); }
public SpawnableResult ClientSpawnAt(SpawnDestination destination) { if (Spawn._ObjectPool.TryPoolInstantiate(prefab, destination, true, out var spawnedObject)) { return(SpawnableResult.Single(spawnedObject, destination)); } else { return(SpawnableResult.Fail(destination)); } }
public SpawnableResult SpawnAt(SpawnDestination destination) { if (!SpawnableUtils.IsValidDestination(destination)) { return(SpawnableResult.Fail(destination)); } if (prefab == null) { Logger.LogWarning("Cannot spawn, prefab to use is null", Category.ItemSpawn); return(SpawnableResult.Fail(destination)); } Logger.LogTraceFormat("Spawning using prefab {0}", Category.ItemSpawn, prefab); if (Spawn._ObjectPool.TryPoolInstantiate(prefab, destination, false, out var spawnedObject)) { return(SpawnableResult.Single(spawnedObject, destination)); } else { return(SpawnableResult.Fail(destination)); } }
public SpawnableResult SpawnAt(SpawnDestination destination) { var prefab = Spawn.DeterminePrefab(toClone); if (prefab == null) { Logger.LogErrorFormat( "Object {0} cannot be cloned because it has no PoolPrefabTracker and its name" + " does not match a prefab name, so we cannot" + " determine the prefab to instantiate. Please fix this object so that it" + " has an attached PoolPrefabTracker or so its name matches the prefab it was created from.", Category.ItemSpawn, toClone); return(SpawnableResult.Fail(destination)); } if (Spawn._ObjectPool.TryPoolInstantiate(prefab, destination, false, out var spawnedObject)) { return(SpawnableResult.Single(spawnedObject, destination)); } else { return(SpawnableResult.Fail(destination)); } }