/// <summary> /// Attempts to spawn an item at a spawn point. /// If successful the return value will be true otherwise false. /// </summary> /// <param name="toSpawn">The transform of the object to spawn</param> /// <returns>True if the spawn was successful otherwise false</returns> public virtual bool spawn(Transform toSpawn) { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Check if we can spawn if (canSpawn() == false) { // Trigger failed invokeSpawnFailedEvent(); return(false); } // Get the spawn point ISpawn spawn = this.selectSpawn(spawnMode); // Get the spawn info SpawnInfo info = spawn.getSpawnInfo(); // Spawn the item info.spawnObjectAt(toSpawn); // Success invokeSpawnedEvent(toSpawn); return(true); }
// Methods /// <summary> /// Attempt to spawn an item using the current settings. /// </summary> /// <returns>The transform of the spawned item</returns> public override Transform spawn() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Make sure we can spawn if (IsSpawnFree == false) { // Spawn failed invokeSpawnFailedEvent(); return(null); } // Create the spawner object Transform instance = this.createSpawnableInstance(); // Check for error if (instance == null) { // Spawn failed invokeSpawnFailedEvent(); return(null); } // Get the spawn info SpawnInfo info = getSpawnInfo(); // Spawn the item info.spawnObjectAt(instance); // Success invokeSpawnedEvent(instance); return(instance); }