public GameObject Spawn() { if (!this.enabled) { return(null); } if (_spawnedAttachment != null) { this.Despawn(); } int index = SpawnPointHelper.SelectFromMultiple(this, this.PrefabCount); if (index < 0 || index >= this.PrefabCount) { return(null); } var prefab = _prefabs[index]; _spawnedAttachment = _spawnMechanism.Spawn(prefab, this.transform.position, this.transform.rotation, this.transform); if (_onSpawnedObject != null && _onSpawnedObject.Count > 0) { _onSpawnedObject.ActivateTrigger(this, _spawnedAttachment); } return(_spawnedAttachment); }
public GameObject Spawn() { if (!this.enabled) { return(null); } int index = SpawnPointHelper.SelectFromMultiple(this, this.PrefabCount); if (index < 0 || index >= this.PrefabCount) { return(null); } return(this.Spawn(_prefabs[index])); }
protected GameObject SelectPrefab(GameObject[] prefabs) { if (!this.enabled) { return(null); } int index = SpawnPointHelper.SelectFromMultiple(this, prefabs.Length); if (index < 0 || index >= prefabs.Length) { return(null); } return(prefabs[index]); }
public SpawnedObjectController SpawnAsController(GameObject prefab, Vector3 pos, Quaternion rot, Transform par = null, System.Action <GameObject> initializeProperties = null) { if (_spawnPoint == null) { throw new System.InvalidOperationException("SpawnerMechanism must be initialized before calling Spawn."); } if (!_active) { return(null); } if (prefab == null) { return(null); } using (var modifiers = TempCollection.GetList <ISpawnerModifier>()) { SpawnPointHelper.GetSpawnModifiers(_spawnPoint, modifiers); if (SpawnPointHelper.SignalOnBeforeSpawnNotification(_spawnPoint, prefab, modifiers)) { return(null); } //perform actual spawn var controller = this.SpawnPool.SpawnAsController(prefab, pos, rot, par, initializeProperties, _spawnPoint); if (controller == null) { return(null); } _spawnedObjects.Add(controller); _totalCount++; //end actual spawn SpawnPointHelper.SignalOnSpawnedNotification(_spawnPoint, this.SpawnPool, controller.gameObject, modifiers); return(controller); } }
protected override void OnDisable() { base.OnDisable(); SpawnPointHelper.UnRegisterModifierWithSpawners(this.gameObject, this); }