Runtime Spawner 1.5.0
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.SpawnExecutor Class Referencesealed

Default implementation of ISpawnExecutor. Pulls instances from a pool, resolves placement via ISpawnLocator, applies the NavMeshPlacementPolicy from SpawnEntry, activates the instance, and updates population tracking. More...

Inheritance diagram for MegaCrush.Spawner.SpawnExecutor:
MegaCrush.Spawner.ISpawnExecutor

Public Member Functions

 SpawnExecutor (RuntimeSpawner owner, IObjectFactory factory, ISpawnLocator locator, PopulationTracker pop)
 Creates a new executor bound to a spawner, factory, locator, and population tracker.
 
GameObject Spawn (SpawnEntry entry, SpawnContext ctx)
 Spawns an instance for entry at a position derived from ctx .
Parameters
entrySpawn configuration (prefab, group settings, etc.).
ctxContext describing source, placement hints, and player position.
Returns
The spawned instance (active), or null on failure.

 

Private Member Functions

GameObject SpawnOne (SpawnEntry entry, ref SpawnContext ctx, GameObject explicitParent)
 Spawns a single instance of entry , placed according to ctx and an optional explicitParent . Applies NavMesh placement policy and updates population tracking.
 
Vector3 ResolvePositionDet (SpawnEntry entry, ref SpawnContext ctx, GameObject explicitParent)
 Chooses a world position based on the context (group, global, region, wave) and delegates to ISpawnLocator. When a wave point is present, passes SpawnContext.HintTags so the locator can prefer matching hints. Uses the deterministic locator overloads with SpawnContext.Rng.
 

Static Private Member Functions

static void EnsureEnabler (GameObject go)
 Ensures a NavMeshReadyEnabler exists and is configured to enable a NavMeshAgent later (used when the policy is NavMeshPlacementPolicy.Prefer).
 

Private Attributes

readonly RuntimeSpawner _owner
 
readonly IObjectFactory _factory
 
readonly ISpawnLocator _locator
 
readonly PopulationTracker _pop
 

Detailed Description

Default implementation of ISpawnExecutor. Pulls instances from a pool, resolves placement via ISpawnLocator, applies the NavMeshPlacementPolicy from SpawnEntry, activates the instance, and updates population tracking.

Constructor & Destructor Documentation

◆ SpawnExecutor()

MegaCrush.Spawner.SpawnExecutor.SpawnExecutor ( RuntimeSpawner owner,
IObjectFactory factory,
ISpawnLocator locator,
PopulationTracker pop )

Creates a new executor bound to a spawner, factory, locator, and population tracker.

Parameters
ownerOwning RuntimeSpawner for deferred placement and events.
factoryFactory used to spawn/despawn (offline, PUN, Fusion, etc.).
locatorPlacement service that finds valid world positions.
popPopulation tracker that records alive/culled instances.

Member Function Documentation

◆ EnsureEnabler()

static void MegaCrush.Spawner.SpawnExecutor.EnsureEnabler ( GameObject go)
staticprivate

Ensures a NavMeshReadyEnabler exists and is configured to enable a NavMeshAgent later (used when the policy is NavMeshPlacementPolicy.Prefer).

Parameters
goSpawned GameObject.

◆ ResolvePositionDet()

Vector3 MegaCrush.Spawner.SpawnExecutor.ResolvePositionDet ( SpawnEntry entry,
ref SpawnContext ctx,
GameObject explicitParent )
private

Chooses a world position based on the context (group, global, region, wave) and delegates to ISpawnLocator. When a wave point is present, passes SpawnContext.HintTags so the locator can prefer matching hints. Uses the deterministic locator overloads with SpawnContext.Rng.

Parameters
entrySpawn settings (may influence grouping behavior).
ctxContext describing the source and player position.
explicitParentOptional explicit parent for clustered/group spawns. If provided, placement is computed near this parent.
Returns
Resolved world position. May be NaN if hint-only refusal is in effect.

◆ Spawn()

GameObject MegaCrush.Spawner.SpawnExecutor.Spawn ( SpawnEntry entry,
SpawnContext ctx )

Spawns an instance for entry at a position derived from ctx .

Parameters
entrySpawn configuration (prefab, group settings, etc.).
ctxContext describing source, placement hints, and player position.
Returns
The spawned instance (active), or null on failure.

Implements MegaCrush.Spawner.ISpawnExecutor.

◆ SpawnOne()

GameObject MegaCrush.Spawner.SpawnExecutor.SpawnOne ( SpawnEntry entry,
ref SpawnContext ctx,
GameObject explicitParent )
private

Spawns a single instance of entry , placed according to ctx and an optional explicitParent . Applies NavMesh placement policy and updates population tracking.

Parameters
entrySpawn configuration (prefab, navmesh policy, etc.).
ctxContext for placement, including deterministic RNG.
explicitParentOptional explicit parent for clustered/group spawns. When provided, placement is computed near this parent. If null, placement uses the standard global/region/wave logic.
Returns
The spawned instance, or null if placement was refused or deferred.

Member Data Documentation

◆ _factory

readonly IObjectFactory MegaCrush.Spawner.SpawnExecutor._factory
private

◆ _locator

readonly ISpawnLocator MegaCrush.Spawner.SpawnExecutor._locator
private

◆ _owner

readonly RuntimeSpawner MegaCrush.Spawner.SpawnExecutor._owner
private

◆ _pop

readonly PopulationTracker MegaCrush.Spawner.SpawnExecutor._pop
private

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