Loading...
Searching...
No Matches
PixelCrushers.QuestMachine.Spawner Class Reference

Spawner. More...

Inheritance diagram for PixelCrushers.QuestMachine.Spawner:
Collaboration diagram for PixelCrushers.QuestMachine.Spawner:

Classes

class  PositionInfo
 
class  PrefabInfo
 

Public Member Functions

virtual void OnMessage (MessageArgs messageArgs)
 Handles a message that the message handler is listening for.
 
virtual void StartSpawning ()
 Starts spawning.
 
virtual void StopSpawning ()
 Stops spawning.
 
virtual void DespawnAll ()
 Stops spawning and despawns all spawned entities.
 
virtual void AddRestoredEntity (SpawnedEntity spawnedEntity)
 

Static Public Member Functions

static Spawner FindSpawner (string spawnerName)
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual IEnumerator StartSpawningAfterSaveDataApplied ()
 
virtual void OnDestroy ()
 
virtual void RegisterWithMessageSystem ()
 
virtual void UnregisterWithMessageSystem ()
 
virtual IEnumerator SpawnCoroutine ()
 This coroutine runs until killed, spawning entities so the count remains between min and max.
 
virtual void SetupSpawnpoints ()
 Prepares for spawning.
 
virtual void SpawnAndPlaceEntity ()
 Spawns an entity and places it in the scene.
 
virtual bool IsThereSpaceForEntity ()
 Checks if there is space (e.g., an available spawnpoint) for the entity.
 
virtual void PlaceSpawnedEntity (SpawnedEntity spawnedEntity)
 Places a spawned entity in the scene.
 
void PlaceSpawnedEntityInRadius (SpawnedEntity spawnedEntity)
 Places an entity within the specified radius of the spawner.
 
virtual void PlaceSpawnedEntityInSpawnpoint (SpawnedEntity spawnedEntity)
 Places an entity at an available spawnpoint.
 
virtual void RemoveSpawnedEntity (SpawnedEntity spawnedEntity)
 Removes an entity from the spawnedEntities list.
 
virtual SpawnedEntity SpawnEntity ()
 Spawns an entity and returns the SpawnedEntity component on it, adding the component if necessary.
 
virtual PrefabInfo ChooseWeightedRandomPrefab ()
 
virtual void DespawnEntity (SpawnedEntity spawnedEntity)
 Despawns an entity.
 
virtual GameObject InstantiateEntity (GameObject prefab)
 Returns an instance of a prefab.
 
virtual void DestroyEntity (GameObject go)
 Destroys an instance of a prefab.
 
virtual void OnSpawnedEntityDisabled (SpawnedEntity spawnedEntity)
 Invoked by a SpawnedEntity when it's disabled.
 

Protected Attributes

List< int > m_availablePositions = new List<int>()
 

Static Protected Attributes

static List< Spawnerm_spawners = new List<Spawner>()
 

Properties

StringField spawnerName [get, set]
 Name by which Quest Machine can reference this spawner.
 
PrefabInfo[] prefabs [get, set]
 Prefabs to spawn.
 
PositionInfo positionInfo [get, set]
 Where to spawn.
 
List< SpawnedEntityspawnedEntities [get, set]
 Entities that have been spawned.
 
bool spawnAsRootObjects [get, set]
 Make spawned entities root objects instead of children of spawner.
 
int min [get, set]
 Minimum number of entities to spawn.
 
int max [get, set]
 Maximum number of entities to spawn.
 
float spawnRate [get, set]
 Once above the minimum, spawn one entity at this frequency in seconds.
 
bool autoStart [get, set]
 Start spawning as soon as this component starts.
 
bool autoStartAfterSaveDataApplied [get, set]
 If Auto Start is ticked, wait for save data to be applied if loading a saved game or changing scenes.
 
bool stopWhenMinReached [get, set]
 Stop spawning as soon as the minimum number of entities has been reached.
 
bool despawnOnDestroy [get, set]
 Despawn all spawned entities when this component is destroyed.
 
int spawnCount [get, set]
 

Detailed Description

Spawner.

Methods are virtual so you can override them if you need custom behavior.

Member Function Documentation

◆ AddRestoredEntity()

virtual void PixelCrushers.QuestMachine.Spawner.AddRestoredEntity ( SpawnedEntity  spawnedEntity)
inlinevirtual

◆ Awake()

virtual void PixelCrushers.QuestMachine.Spawner.Awake ( )
inlineprotectedvirtual

◆ ChooseWeightedRandomPrefab()

virtual PrefabInfo PixelCrushers.QuestMachine.Spawner.ChooseWeightedRandomPrefab ( )
inlineprotectedvirtual

◆ DespawnAll()

virtual void PixelCrushers.QuestMachine.Spawner.DespawnAll ( )
inlinevirtual

Stops spawning and despawns all spawned entities.

Reimplemented in PixelCrushers.QuestMachine.ServerSpawner.

◆ DespawnEntity()

virtual void PixelCrushers.QuestMachine.Spawner.DespawnEntity ( SpawnedEntity  spawnedEntity)
inlineprotectedvirtual

Despawns an entity.

Parameters
spawnedEntity

◆ DestroyEntity()

virtual void PixelCrushers.QuestMachine.Spawner.DestroyEntity ( GameObject  go)
inlineprotectedvirtual

Destroys an instance of a prefab.

Override this method if you want to use a pooling system to return the instance to the pool.

◆ FindSpawner()

static Spawner PixelCrushers.QuestMachine.Spawner.FindSpawner ( string  spawnerName)
inlinestatic

◆ InstantiateEntity()

virtual GameObject PixelCrushers.QuestMachine.Spawner.InstantiateEntity ( GameObject  prefab)
inlineprotectedvirtual

Returns an instance of a prefab.

Override this method if you want to use a pooling system instead of Instantiate.

Reimplemented in PixelCrushers.QuestMachine.ServerSpawner.

◆ IsThereSpaceForEntity()

virtual bool PixelCrushers.QuestMachine.Spawner.IsThereSpaceForEntity ( )
inlineprotectedvirtual

Checks if there is space (e.g., an available spawnpoint) for the entity.

◆ OnDestroy()

virtual void PixelCrushers.QuestMachine.Spawner.OnDestroy ( )
inlineprotectedvirtual

◆ OnMessage()

virtual void PixelCrushers.QuestMachine.Spawner.OnMessage ( MessageArgs  messageArgs)
inlinevirtual

Handles a message that the message handler is listening for.

Parameters
messageArgsThe message that was sent to the MessageSystem.

Implements PixelCrushers.IMessageHandler.

◆ OnSpawnedEntityDisabled()

virtual void PixelCrushers.QuestMachine.Spawner.OnSpawnedEntityDisabled ( SpawnedEntity  spawnedEntity)
inlineprotectedvirtual

Invoked by a SpawnedEntity when it's disabled.

Removes it from the spawnedEntities list.

Parameters
spawnedEntity

◆ PlaceSpawnedEntity()

virtual void PixelCrushers.QuestMachine.Spawner.PlaceSpawnedEntity ( SpawnedEntity  spawnedEntity)
inlineprotectedvirtual

Places a spawned entity in the scene.

◆ PlaceSpawnedEntityInRadius()

void PixelCrushers.QuestMachine.Spawner.PlaceSpawnedEntityInRadius ( SpawnedEntity  spawnedEntity)
inlineprotected

Places an entity within the specified radius of the spawner.

◆ PlaceSpawnedEntityInSpawnpoint()

virtual void PixelCrushers.QuestMachine.Spawner.PlaceSpawnedEntityInSpawnpoint ( SpawnedEntity  spawnedEntity)
inlineprotectedvirtual

Places an entity at an available spawnpoint.

◆ RegisterWithMessageSystem()

virtual void PixelCrushers.QuestMachine.Spawner.RegisterWithMessageSystem ( )
inlineprotectedvirtual

◆ RemoveSpawnedEntity()

virtual void PixelCrushers.QuestMachine.Spawner.RemoveSpawnedEntity ( SpawnedEntity  spawnedEntity)
inlineprotectedvirtual

Removes an entity from the spawnedEntities list.

Parameters
spawnedEntity

◆ SetupSpawnpoints()

virtual void PixelCrushers.QuestMachine.Spawner.SetupSpawnpoints ( )
inlineprotectedvirtual

Prepares for spawning.

◆ SpawnAndPlaceEntity()

virtual void PixelCrushers.QuestMachine.Spawner.SpawnAndPlaceEntity ( )
inlineprotectedvirtual

Spawns an entity and places it in the scene.

Reimplemented in PixelCrushers.QuestMachine.EmeraldAISupport.EmeraldSpawner.

◆ SpawnCoroutine()

virtual IEnumerator PixelCrushers.QuestMachine.Spawner.SpawnCoroutine ( )
inlineprotectedvirtual

This coroutine runs until killed, spawning entities so the count remains between min and max.

◆ SpawnEntity()

virtual SpawnedEntity PixelCrushers.QuestMachine.Spawner.SpawnEntity ( )
inlineprotectedvirtual

Spawns an entity and returns the SpawnedEntity component on it, adding the component if necessary.

Returns
A random spawned entity, or null on error.

◆ Start()

virtual void PixelCrushers.QuestMachine.Spawner.Start ( )
inlineprotectedvirtual

◆ StartSpawning()

virtual void PixelCrushers.QuestMachine.Spawner.StartSpawning ( )
inlinevirtual

Starts spawning.

May stop automatically if stopWhenMinReached is true.

Reimplemented in PixelCrushers.QuestMachine.ServerSpawner.

◆ StartSpawningAfterSaveDataApplied()

virtual IEnumerator PixelCrushers.QuestMachine.Spawner.StartSpawningAfterSaveDataApplied ( )
inlineprotectedvirtual

◆ StopSpawning()

virtual void PixelCrushers.QuestMachine.Spawner.StopSpawning ( )
inlinevirtual

Stops spawning.

Reimplemented in PixelCrushers.QuestMachine.ServerSpawner.

◆ UnregisterWithMessageSystem()

virtual void PixelCrushers.QuestMachine.Spawner.UnregisterWithMessageSystem ( )
inlineprotectedvirtual

Member Data Documentation

◆ m_availablePositions

List<int> PixelCrushers.QuestMachine.Spawner.m_availablePositions = new List<int>()
protected

◆ m_spawners

List<Spawner> PixelCrushers.QuestMachine.Spawner.m_spawners = new List<Spawner>()
staticprotected

Property Documentation

◆ autoStart

bool PixelCrushers.QuestMachine.Spawner.autoStart
getset

Start spawning as soon as this component starts.

◆ autoStartAfterSaveDataApplied

bool PixelCrushers.QuestMachine.Spawner.autoStartAfterSaveDataApplied
getset

If Auto Start is ticked, wait for save data to be applied if loading a saved game or changing scenes.

◆ despawnOnDestroy

bool PixelCrushers.QuestMachine.Spawner.despawnOnDestroy
getset

Despawn all spawned entities when this component is destroyed.

◆ max

int PixelCrushers.QuestMachine.Spawner.max
getset

Maximum number of entities to spawn.

◆ min

int PixelCrushers.QuestMachine.Spawner.min
getset

Minimum number of entities to spawn.

◆ positionInfo

PositionInfo PixelCrushers.QuestMachine.Spawner.positionInfo
getset

Where to spawn.

◆ prefabs

PrefabInfo [] PixelCrushers.QuestMachine.Spawner.prefabs
getset

Prefabs to spawn.

◆ spawnAsRootObjects

bool PixelCrushers.QuestMachine.Spawner.spawnAsRootObjects
getset

Make spawned entities root objects instead of children of spawner.

◆ spawnCount

int PixelCrushers.QuestMachine.Spawner.spawnCount
getsetprotected

◆ spawnedEntities

List<SpawnedEntity> PixelCrushers.QuestMachine.Spawner.spawnedEntities
getset

Entities that have been spawned.

◆ spawnerName

StringField PixelCrushers.QuestMachine.Spawner.spawnerName
getset

Name by which Quest Machine can reference this spawner.

◆ spawnRate

float PixelCrushers.QuestMachine.Spawner.spawnRate
getset

Once above the minimum, spawn one entity at this frequency in seconds.

◆ stopWhenMinReached

bool PixelCrushers.QuestMachine.Spawner.stopWhenMinReached
getset

Stop spawning as soon as the minimum number of entities has been reached.


The documentation for this class was generated from the following file: