A generic object spawning system, supports local regions for density controls.
More...
|
bool | UseInternalCulling [get, set] |
| Should we do culling ourselves?
|
|
bool | UseGlobalSpawners [get, set] |
| Do we have global spawners? otherwise only region spawners will be active.
|
|
bool | UseRegionSpawners [get, set] |
| Does this spawner have custom region spawners?
|
|
bool | UseWaveSpawners [get, set] |
| Does this spawner have wave spawners?
|
|
string | PlayerTag [get, set] |
|
List< GameObject > | SpawnedObjects [get] |
| The list of currently spawned objects.
|
|
List< SpawnEntry > | GlobalSpawners [get, set] |
| List of global spawners.
|
|
List< string > | NavmeshAreas [get, set] |
|
List< LocalAreaSpawner > | SpawnRegions [get, set] |
| Our list of spawn regions.
|
|
List< WaveTrigger > | WaveTriggers [get, set] |
| Wave triggers.
|
|
float | CullDistance [get] |
| Range that objects will be culled if we are doing internal culling.
|
|
Vector2 | WorldSizeVector2 [get] |
| Get the specified world size as a Vector2.
|
|
float | MinSpawnRange [get] |
| Min spawn range.
|
|
int | MinGlobalObjectCount [get, set] |
| min global object count
|
|
int | MaxGlobalObjectCount [get, set] |
| max global object count
|
|
Vector3 | WorldSizeVector3 [get] |
| Returns the world size as a Vector3 (y is set to 5 arbitrarily)
|
|
bool | LogSpawnEntries [get] |
| Used by the inspector, editor only.
|
|
bool | DrawExtents [get] |
| Editor only, draws the world size.
|
|
|
void | Awake () |
|
void | OnDisable () |
|
void | Start () |
|
void | CreateObjectPools () |
| Create Object Pools for all of the spawners used by this spawner.
|
|
IEnumerator | DoCulling () |
| Our internal culling routine.
|
|
IEnumerator | StartGlobalSpawners () |
| Runs the global spawner loop.
|
|
IEnumerator | StartRegionSpawners () |
| Run our spawn loop.
|
|
void | OnPlayerEnteredRegion (LocalAreaSpawner region, bool isInRegion) |
| Event handler for when the player enters or leaves a spawn region.
|
|
IEnumerator | StartWaveSpawners (WaveTrigger thisTrigger) |
| Wave spawners are handled slightly differently. Instead of just starting, they might be activated by a trigger or the API. Once activated we will iterate through the waves as defined in the WaveSpawner scriptable object.
|
|
void | UpdatePopulation () |
| Internally whenever we spawn new objects we add them into the newWaveSpawners list. This method iterates through the list and called the onObjectSpawned event to let other scripts know that they objects were spawned.
|
|
void | OnWaveTriggerActivated (WaveTrigger thisTrigger) |
| Event handler from the WaveTrigger to start spawning.
|
|
void | OnUnitDied (GameObject thisObject) |
| Event callback - an object died.
|
|
void | OnObjectCulled (GameObject thisObject) |
| callback if the object in question gets too far from the player
|
|
GameObject | SpawnObject (SpawnEntry thisEntry, LocalAreaSpawner thisRegion=null, WaveTrigger trigger=null, Transform spawnPoint=null, float spawnRange=0f, bool isGlobal=false, GameObject groupParent=null) |
| Spawn an object based on the given configuration.
|
|
Vector3 | GetSpawnPosition (GameObject instance, SpawnEntry entry, LocalAreaSpawner region=null, WaveTrigger trigger=null, Transform spawnPoint=null, float spawnRange=1f, bool isGlobal=false, GameObject parentObject=null) |
| Get a random spawn position. This is the meat of the whole system.
|
|
RuntimeSpawnerSettings | GetSettings () |
|
void | OnDrawGizmosSelected () |
|
A generic object spawning system, supports local regions for density controls.
◆ AddRegion()
void MegaCrush.Spawner.RuntimeSpawner.AddRegion |
( |
| ) |
|
Editor only - add a new region.
◆ AddWaveTrigger()
WaveTrigger MegaCrush.Spawner.RuntimeSpawner.AddWaveTrigger |
( |
| ) |
|
◆ Awake()
void MegaCrush.Spawner.RuntimeSpawner.Awake |
( |
| ) |
|
|
private |
◆ CreateNewSpawner()
static void MegaCrush.Spawner.RuntimeSpawner.CreateNewSpawner |
( |
| ) |
|
|
staticprivate |
Add a menu option to create a new spawner.
◆ CreateObjectPools()
void MegaCrush.Spawner.RuntimeSpawner.CreateObjectPools |
( |
| ) |
|
|
private |
Create Object Pools for all of the spawners used by this spawner.
◆ CreateSpawnEntry()
static SpawnEntry MegaCrush.Spawner.RuntimeSpawner.CreateSpawnEntry |
( |
string | path | ) |
|
|
static |
◆ CreateWaveSpawner()
static WaveSpawner MegaCrush.Spawner.RuntimeSpawner.CreateWaveSpawner |
( |
string | path | ) |
|
|
static |
◆ DoCulling()
IEnumerator MegaCrush.Spawner.RuntimeSpawner.DoCulling |
( |
| ) |
|
|
private |
Our internal culling routine.
- Returns
◆ DrawWorldExtents()
void MegaCrush.Spawner.RuntimeSpawner.DrawWorldExtents |
( |
| ) |
|
Editor only, shows scene view gizmo.
◆ GetSettings()
◆ GetSpawnPosition()
Vector3 MegaCrush.Spawner.RuntimeSpawner.GetSpawnPosition |
( |
GameObject | instance, |
|
|
SpawnEntry | entry, |
|
|
LocalAreaSpawner | region = null, |
|
|
WaveTrigger | trigger = null, |
|
|
Transform | spawnPoint = null, |
|
|
float | spawnRange = 1f, |
|
|
bool | isGlobal = false, |
|
|
GameObject | parentObject = null ) |
|
private |
Get a random spawn position. This is the meat of the whole system.
- Parameters
-
instance | the object we are positioning |
entry | spawn config for the object |
spawner | the local area spawner (if one) |
spawnPoint | wave spawner spawnpoint position (if one) |
range | offset range for the wave spawner spawnpoint (if one) |
isGlobal | is this a global spawner? |
parentObject | if this is a group spawner, then this is the first in the group |
- Returns
◆ Init()
void MegaCrush.Spawner.RuntimeSpawner.Init |
( |
| ) |
|
Initialize all of the spawners, find child regions and clear all cache's.
Note: called automatically by StartSpawners()
◆ OnDisable()
void MegaCrush.Spawner.RuntimeSpawner.OnDisable |
( |
| ) |
|
|
private |
◆ OnDrawGizmosSelected()
void MegaCrush.Spawner.RuntimeSpawner.OnDrawGizmosSelected |
( |
| ) |
|
|
private |
◆ OnObjectCulled()
void MegaCrush.Spawner.RuntimeSpawner.OnObjectCulled |
( |
GameObject | thisObject | ) |
|
|
private |
callback if the object in question gets too far from the player
- Parameters
-
◆ OnPlayerEnteredRegion()
void MegaCrush.Spawner.RuntimeSpawner.OnPlayerEnteredRegion |
( |
LocalAreaSpawner | region, |
|
|
bool | isInRegion ) |
|
private |
Event handler for when the player enters or leaves a spawn region.
- Parameters
-
region | The region the player is entering / leaving |
isInRegion | true if entered, false if leaving |
◆ OnUnitDied()
void MegaCrush.Spawner.RuntimeSpawner.OnUnitDied |
( |
GameObject | thisObject | ) |
|
|
private |
Event callback - an object died.
- Parameters
-
◆ OnWaveTriggerActivated()
void MegaCrush.Spawner.RuntimeSpawner.OnWaveTriggerActivated |
( |
WaveTrigger | thisTrigger | ) |
|
|
private |
Event handler from the WaveTrigger to start spawning.
- Parameters
-
◆ SetPlayer()
void MegaCrush.Spawner.RuntimeSpawner.SetPlayer |
( |
GameObject | player | ) |
|
Set the active player for the spawner. Useful if you spawn your player object dynamically at runtime.
- Parameters
-
player | The GameObject for the current player |
◆ SetStartAutomatically()
void MegaCrush.Spawner.RuntimeSpawner.SetStartAutomatically |
( |
bool | value | ) |
|
should this spawner start automatically when the scene starts?
- Parameters
-
◆ ShowHideSpawnVolumes()
void MegaCrush.Spawner.RuntimeSpawner.ShowHideSpawnVolumes |
( |
| ) |
|
Editor only - toggle show / hide spawn regions in scene view.
◆ ShowHideWaveTriggers()
void MegaCrush.Spawner.RuntimeSpawner.ShowHideWaveTriggers |
( |
| ) |
|
◆ ShowOccluderRange()
void MegaCrush.Spawner.RuntimeSpawner.ShowOccluderRange |
( |
| ) |
|
Editor only, shows scene view gizmo.
◆ SpawnObject()
GameObject MegaCrush.Spawner.RuntimeSpawner.SpawnObject |
( |
SpawnEntry | thisEntry, |
|
|
LocalAreaSpawner | thisRegion = null, |
|
|
WaveTrigger | trigger = null, |
|
|
Transform | spawnPoint = null, |
|
|
float | spawnRange = 0f, |
|
|
bool | isGlobal = false, |
|
|
GameObject | groupParent = null ) |
|
private |
Spawn an object based on the given configuration.
- Parameters
-
thisEntry | the object config |
thisRegion | a local region we are spawning in |
isGlobal | is this a global spawn? |
groupParent | is it a group spawn - this is the first / parent object |
- Returns
◆ Start()
void MegaCrush.Spawner.RuntimeSpawner.Start |
( |
| ) |
|
|
private |
◆ StartGlobalSpawners()
IEnumerator MegaCrush.Spawner.RuntimeSpawner.StartGlobalSpawners |
( |
| ) |
|
|
private |
Runs the global spawner loop.
◆ StartRegionSpawners()
IEnumerator MegaCrush.Spawner.RuntimeSpawner.StartRegionSpawners |
( |
| ) |
|
|
private |
Run our spawn loop.
- Returns
◆ StartSpawners()
void MegaCrush.Spawner.RuntimeSpawner.StartSpawners |
( |
| ) |
|
The primary Entry point - start this spawner!
◆ StartWaveSpawner()
void MegaCrush.Spawner.RuntimeSpawner.StartWaveSpawner |
( |
string | spawnerName | ) |
|
◆ StartWaveSpawners()
IEnumerator MegaCrush.Spawner.RuntimeSpawner.StartWaveSpawners |
( |
WaveTrigger | thisTrigger | ) |
|
|
private |
Wave spawners are handled slightly differently. Instead of just starting, they might be activated by a trigger or the API. Once activated we will iterate through the waves as defined in the WaveSpawner scriptable object.
- Returns
◆ UpdatePopulation()
void MegaCrush.Spawner.RuntimeSpawner.UpdatePopulation |
( |
| ) |
|
|
private |
Internally whenever we spawn new objects we add them into the newWaveSpawners list. This method iterates through the list and called the onObjectSpawned event to let other scripts know that they objects were spawned.
◆ activeSpawnRegions
List<LocalAreaSpawner> MegaCrush.Spawner.RuntimeSpawner.activeSpawnRegions = new() |
|
private |
keep track of any regions that the player is in
◆ autoLaunchOnStart
bool MegaCrush.Spawner.RuntimeSpawner.autoLaunchOnStart = false |
|
private |
Should the spawner start automatically?
◆ cullDistance
float MegaCrush.Spawner.RuntimeSpawner.cullDistance |
|
private |
How far away do they need to be before culling them?
◆ cullingCheckFrequency
int MegaCrush.Spawner.RuntimeSpawner.cullingCheckFrequency = 2 |
|
private |
How often we should check for objects to be culled.
◆ currentPopulation
int MegaCrush.Spawner.RuntimeSpawner.currentPopulation = 0 |
|
private |
The current global population of this spawner.
◆ drawExtents
bool MegaCrush.Spawner.RuntimeSpawner.drawExtents = false |
|
private |
Editor only: draw extents of worldSize in scene view.
◆ globalSpawners
List<SpawnEntry> MegaCrush.Spawner.RuntimeSpawner.globalSpawners = new() |
|
private |
Our list of global spawners.
◆ initialized
bool MegaCrush.Spawner.RuntimeSpawner.initialized = false |
|
private |
◆ layerMask
LayerMask MegaCrush.Spawner.RuntimeSpawner.layerMask |
|
private |
Only spawn agents on the specified layers, otherwise spawned anywhere.
◆ logSpawnEntries
bool MegaCrush.Spawner.RuntimeSpawner.logSpawnEntries |
|
private |
log spawn entries to the console
◆ maxGlobalObjectCount
int MegaCrush.Spawner.RuntimeSpawner.maxGlobalObjectCount = 25 |
|
private |
Maximum number of global objects we should spawn.
◆ maxObjectCount
int MegaCrush.Spawner.RuntimeSpawner.maxObjectCount = 100 |
|
private |
Max overall population we should have active at one time.
◆ minGlobalObjectCount
int MegaCrush.Spawner.RuntimeSpawner.minGlobalObjectCount = 25 |
|
private |
Minimum number of global objects we should spawn.
◆ minSpawnRange
float MegaCrush.Spawner.RuntimeSpawner.minSpawnRange |
|
private |
don't spawn objects within this range of the player
◆ navmeshAreaMask
int MegaCrush.Spawner.RuntimeSpawner.navmeshAreaMask = 0 |
|
private |
◆ navmeshHit
NavMeshHit MegaCrush.Spawner.RuntimeSpawner.navmeshHit |
|
private |
◆ newGlobalSpawners
List<GameObject> MegaCrush.Spawner.RuntimeSpawner.newGlobalSpawners = new() |
|
private |
global objects that were spawned the current spawn turn
◆ newRegionSpawners
List<GameObject> MegaCrush.Spawner.RuntimeSpawner.newRegionSpawners = new() |
|
private |
global objects that were spawned the current spawn turn
◆ newWaveSpawners
List<GameObject> MegaCrush.Spawner.RuntimeSpawner.newWaveSpawners = new() |
|
private |
global objects that were spawned the current spawn turn
◆ playerObject
GameObject MegaCrush.Spawner.RuntimeSpawner.playerObject |
|
private |
◆ playerTag
string MegaCrush.Spawner.RuntimeSpawner.playerTag = "Player" |
|
private |
◆ raycastHit
RaycastHit MegaCrush.Spawner.RuntimeSpawner.raycastHit |
|
private |
◆ restrictToNavmeshAreas
List<string> MegaCrush.Spawner.RuntimeSpawner.restrictToNavmeshAreas = new() |
|
private |
Only spawn global objects on these navmesh areas.
◆ settings
◆ showOccluderRange
bool MegaCrush.Spawner.RuntimeSpawner.showOccluderRange = false |
|
private |
◆ showSpawnTriggers
bool MegaCrush.Spawner.RuntimeSpawner.showSpawnTriggers = false |
|
private |
◆ showSpawnVolumes
bool MegaCrush.Spawner.RuntimeSpawner.showSpawnVolumes = true |
|
private |
◆ spawnedObjects
List<GameObject> MegaCrush.Spawner.RuntimeSpawner.spawnedObjects = new() |
|
private |
all of the spawned objects
◆ spawnerCache
Dictionary<string, int> MegaCrush.Spawner.RuntimeSpawner.spawnerCache = new() |
|
private |
Cache the names of spawner objects so we can track their population.
◆ spawnerTag
string MegaCrush.Spawner.RuntimeSpawner.spawnerTag = string.Empty |
|
private |
Tag to apply to objects that have been spawned.
◆ spawnRegions
◆ useGlobalSpawners
bool MegaCrush.Spawner.RuntimeSpawner.useGlobalSpawners = true |
|
private |
◆ useInternalCulling
bool MegaCrush.Spawner.RuntimeSpawner.useInternalCulling = true |
|
private |
Use our internal culling system to remove distant spawned objects.
◆ useRegionSpawners
bool MegaCrush.Spawner.RuntimeSpawner.useRegionSpawners = true |
|
private |
Are we using region spawners?
◆ useWaveSpawners
bool MegaCrush.Spawner.RuntimeSpawner.useWaveSpawners = true |
|
private |
◆ waveTriggers
List<WaveTrigger> MegaCrush.Spawner.RuntimeSpawner.waveTriggers = new() |
|
private |
◆ worldSize
Vector2 MegaCrush.Spawner.RuntimeSpawner.worldSize = new Vector2(50, 50) |
|
private |
Size of the global spawn region.
◆ CullDistance
float MegaCrush.Spawner.RuntimeSpawner.CullDistance |
|
get |
Range that objects will be culled if we are doing internal culling.
◆ DrawExtents
bool MegaCrush.Spawner.RuntimeSpawner.DrawExtents |
|
get |
Editor only, draws the world size.
◆ GlobalSpawners
List<SpawnEntry> MegaCrush.Spawner.RuntimeSpawner.GlobalSpawners |
|
getset |
◆ LogSpawnEntries
bool MegaCrush.Spawner.RuntimeSpawner.LogSpawnEntries |
|
get |
Used by the inspector, editor only.
◆ MaxGlobalObjectCount
int MegaCrush.Spawner.RuntimeSpawner.MaxGlobalObjectCount |
|
getset |
◆ MinGlobalObjectCount
int MegaCrush.Spawner.RuntimeSpawner.MinGlobalObjectCount |
|
getset |
◆ MinSpawnRange
float MegaCrush.Spawner.RuntimeSpawner.MinSpawnRange |
|
get |
◆ NavmeshAreas
List<string> MegaCrush.Spawner.RuntimeSpawner.NavmeshAreas |
|
getset |
◆ PlayerTag
string MegaCrush.Spawner.RuntimeSpawner.PlayerTag |
|
getset |
◆ SpawnedObjects
List<GameObject> MegaCrush.Spawner.RuntimeSpawner.SpawnedObjects |
|
get |
The list of currently spawned objects.
◆ SpawnRegions
Our list of spawn regions.
◆ UseGlobalSpawners
bool MegaCrush.Spawner.RuntimeSpawner.UseGlobalSpawners |
|
getset |
Do we have global spawners? otherwise only region spawners will be active.
◆ UseInternalCulling
bool MegaCrush.Spawner.RuntimeSpawner.UseInternalCulling |
|
getset |
Should we do culling ourselves?
◆ UseRegionSpawners
bool MegaCrush.Spawner.RuntimeSpawner.UseRegionSpawners |
|
getset |
Does this spawner have custom region spawners?
◆ UseWaveSpawners
bool MegaCrush.Spawner.RuntimeSpawner.UseWaveSpawners |
|
getset |
Does this spawner have wave spawners?
◆ WaveTriggers
List<WaveTrigger> MegaCrush.Spawner.RuntimeSpawner.WaveTriggers |
|
getset |
◆ WorldSizeVector2
Vector2 MegaCrush.Spawner.RuntimeSpawner.WorldSizeVector2 |
|
get |
Get the specified world size as a Vector2.
◆ WorldSizeVector3
Vector3 MegaCrush.Spawner.RuntimeSpawner.WorldSizeVector3 |
|
get |
Returns the world size as a Vector3 (y is set to 5 arbitrarily)
◆ onNewWaveTriggered
Action<WaveEntry> MegaCrush.Spawner.RuntimeSpawner.onNewWaveTriggered |
|
static |
◆ onObjectCulled
Action<GameObject> MegaCrush.Spawner.RuntimeSpawner.onObjectCulled |
|
static |
◆ onObjectSpawned
Action<GameObject> MegaCrush.Spawner.RuntimeSpawner.onObjectSpawned |
|
static |
Listen to this in your AI objects so they know that they were spawned.
◆ onSpawnerInit
Action<float> MegaCrush.Spawner.RuntimeSpawner.onSpawnerInit |
|
static |
When this spawner was initialized.
◆ onUpdateCurrentPopulation
Action<int> MegaCrush.Spawner.RuntimeSpawner.onUpdateCurrentPopulation |
|
static |
◆ onWaveSpawnerComplete
Action<WaveTrigger> MegaCrush.Spawner.RuntimeSpawner.onWaveSpawnerComplete |
|
static |
◆ onWaveTriggerActivated
Action<WaveTrigger> MegaCrush.Spawner.RuntimeSpawner.onWaveTriggerActivated |
|
static |
The documentation for this class was generated from the following file:
- D:/projects/Asset Store Packages/com.pixelwizards.runtimespawner/Code/Runtime/Components/RuntimeSpawner.cs