|
Runtime Spawner 1.5.1
Generic Runtime spawn and instance pooling system for spawning random AI agents around a map. Works with ANY AI system easily.
|
Simple factory implementation for single-player or offline projects. More...
Public Member Functions | |
| SinglePlayerPoolFactory (IPoolAdapter pool) | |
| Creates a new SinglePlayerPoolFactory bound to the specified object pool. | |
| ISpawnHandle | Spawn (SpawnRequest r) |
| Spawns a new object using the configured pool. | |
| Task< ISpawnHandle > | SpawnAsync (SpawnRequest r) |
| Asynchronously spawns an object using the same logic as Spawn(SpawnRequest). | |
| void | Prewarm (SpawnEntry entry, int count) |
| Prewarms the pool with instances of the specified prefab. | |
Private Attributes | |
| readonly IPoolAdapter | _pool |
Simple factory implementation for single-player or offline projects.
Uses a project-wide IPoolAdapter to spawn and recycle objects efficiently without network dependencies. This factory is ideal for local gameplay, simulation, or offline testing environments where networked synchronization is not required.
When a SpawnRequest is received, the factory retrieves an instance of the requested prefab from the pool (via IPoolAdapter.Get), and returns a BasicSpawnHandle that automatically returns the object to the pool when ISpawnHandle.Despawn is called.
This implementation also supports prewarming via IPrewarmableFactory, ensuring that frequently used prefabs can be instantiated ahead of time to minimize runtime allocation and instantiation costs.
| MegaCrush.Spawner.SinglePlayerPoolFactory.SinglePlayerPoolFactory | ( | IPoolAdapter | pool | ) |
Creates a new SinglePlayerPoolFactory bound to the specified object pool.
| pool | The project-wide IPoolAdapter responsible for retrieving and returning instances. |
| void MegaCrush.Spawner.SinglePlayerPoolFactory.Prewarm | ( | SpawnEntry | entry, |
| int | count ) |
Prewarms the pool with instances of the specified prefab.
| entry | The SpawnEntry to prewarm (must have a valid prefab). |
| count | Number of instances to allocate or prepare for reuse. |
This method forwards to IPoolAdapter.EnsurePool, creating or resizing the pool for the specified prefab. If count is less than or equal to zero, this call is ignored.
Implements MegaCrush.Spawner.IPrewarmableFactory.
| ISpawnHandle MegaCrush.Spawner.SinglePlayerPoolFactory.Spawn | ( | SpawnRequest | r | ) |
Spawns a new object using the configured pool.
| r | The SpawnRequest defining prefab, position, and context data. |
null if the prefab was not provided or the pool failed to return an instance. This factory does not perform network synchronization or ownership management. The returned object is purely local and managed via the provided IPoolAdapter.
Implements MegaCrush.Spawner.IObjectFactory.
| Task< ISpawnHandle > MegaCrush.Spawner.SinglePlayerPoolFactory.SpawnAsync | ( | SpawnRequest | r | ) |
Asynchronously spawns an object using the same logic as Spawn(SpawnRequest).
| r | The SpawnRequest to process. |
Implements MegaCrush.Spawner.IObjectFactory.
|
private |