Runtime Spawner 1.2.5
Generic Runtime spawn and instance pooling system for spawning random AI agents around a map. Works with ANY AI system easily.
Loading...
Searching...
No Matches
MegaCrush.Spawner.PopulationTracker Class Referencesealed

Tracks the current and historical population of spawned objects, including metadata and source breakdowns. More...

Public Member Functions

int GetCount (SpawnSource s)
 Gets the count for a specific SpawnSource.
 
void Add (GameObject go)
 Adds a new object with unknown source.
 
void Add (GameObject go, in SpawnMeta meta)
 Adds a new object with associated metadata.
 
void Remove (GameObject go)
 Removes an object from tracking (not necessarily culled).
 
void Remove (GameObject go, bool cull)
 Removes an object from tracking.
 
bool Contains (GameObject go)
 Checks whether the tracker contains this object.
 
bool TryGetMeta (GameObject go, out SpawnMeta meta)
 Tries to retrieve the metadata for a tracked object.
 

Properties

IReadOnlyList< GameObject > Spawned [get]
 All currently spawned objects.
 
int Current [get]
 Current active population count.
 
int Total [get]
 Total spawned ever (monotonic).
 
IReadOnlyDictionary< SpawnSource, int > BySource [get]
 Breakdown of population count per SpawnSource.
 
IReadOnlyDictionary< string, int > SpecialsByTag [get]
 Breakdown of special spawns by tag.
 

Events

Action< GameObject > OnSpawned
 Raised when an object is spawned (legacy simple event).
 
Action< GameObject > OnCulled
 Raised when an object is culled (only fired when cull==true).
 
Action< int > OnPopulationChanged
 Raised whenever the active population count changes.
 
Action< GameObject, SpawnMetaOnSpawnedWithMeta
 Raised when an object is spawned with its metadata.
 
Action< GameObject, SpawnMetaOnDespawned
 Raised when an object is despawned (removed from tracking).
 

Private Attributes

readonly List< GameObject > _spawned = new()
 
readonly Dictionary< GameObject, SpawnMeta_meta = new()
 
readonly Dictionary< SpawnSource, int > _bySource = new()
 
readonly Dictionary< string, int > _specialsByTag = new()
 
int _current
 
int _total
 

Detailed Description

Tracks the current and historical population of spawned objects, including metadata and source breakdowns.

Member Function Documentation

◆ Add() [1/2]

void MegaCrush.Spawner.PopulationTracker.Add ( GameObject go)

Adds a new object with unknown source.

◆ Add() [2/2]

void MegaCrush.Spawner.PopulationTracker.Add ( GameObject go,
in SpawnMeta meta )

Adds a new object with associated metadata.

◆ Contains()

bool MegaCrush.Spawner.PopulationTracker.Contains ( GameObject go)

Checks whether the tracker contains this object.

◆ GetCount()

int MegaCrush.Spawner.PopulationTracker.GetCount ( SpawnSource s)

Gets the count for a specific SpawnSource.

◆ Remove() [1/2]

void MegaCrush.Spawner.PopulationTracker.Remove ( GameObject go)

Removes an object from tracking (not necessarily culled).

◆ Remove() [2/2]

void MegaCrush.Spawner.PopulationTracker.Remove ( GameObject go,
bool cull )

Removes an object from tracking.

Parameters
goThe object to remove.
cullIf true, also fires the legacy OnCulled event.

◆ TryGetMeta()

bool MegaCrush.Spawner.PopulationTracker.TryGetMeta ( GameObject go,
out SpawnMeta meta )

Tries to retrieve the metadata for a tracked object.

Member Data Documentation

◆ _bySource

readonly Dictionary<SpawnSource, int> MegaCrush.Spawner.PopulationTracker._bySource = new()
private

◆ _current

int MegaCrush.Spawner.PopulationTracker._current
private

◆ _meta

readonly Dictionary<GameObject, SpawnMeta> MegaCrush.Spawner.PopulationTracker._meta = new()
private

◆ _spawned

readonly List<GameObject> MegaCrush.Spawner.PopulationTracker._spawned = new()
private

◆ _specialsByTag

readonly Dictionary<string, int> MegaCrush.Spawner.PopulationTracker._specialsByTag = new()
private

◆ _total

int MegaCrush.Spawner.PopulationTracker._total
private

Property Documentation

◆ BySource

IReadOnlyDictionary<SpawnSource, int> MegaCrush.Spawner.PopulationTracker.BySource
get

Breakdown of population count per SpawnSource.

◆ Current

int MegaCrush.Spawner.PopulationTracker.Current
get

Current active population count.

◆ Spawned

IReadOnlyList<GameObject> MegaCrush.Spawner.PopulationTracker.Spawned
get

All currently spawned objects.

◆ SpecialsByTag

IReadOnlyDictionary<string, int> MegaCrush.Spawner.PopulationTracker.SpecialsByTag
get

Breakdown of special spawns by tag.

◆ Total

int MegaCrush.Spawner.PopulationTracker.Total
get

Total spawned ever (monotonic).

Event Documentation

◆ OnCulled

Action<GameObject> MegaCrush.Spawner.PopulationTracker.OnCulled

Raised when an object is culled (only fired when cull==true).

◆ OnDespawned

Action<GameObject, SpawnMeta> MegaCrush.Spawner.PopulationTracker.OnDespawned

Raised when an object is despawned (removed from tracking).

◆ OnPopulationChanged

Action<int> MegaCrush.Spawner.PopulationTracker.OnPopulationChanged

Raised whenever the active population count changes.

◆ OnSpawned

Action<GameObject> MegaCrush.Spawner.PopulationTracker.OnSpawned

Raised when an object is spawned (legacy simple event).

◆ OnSpawnedWithMeta

Action<GameObject, SpawnMeta> MegaCrush.Spawner.PopulationTracker.OnSpawnedWithMeta

Raised when an object is spawned with its metadata.


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