Class SpawnerWorker
The base class to spawn objects.
Implements
Inherited Members
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
[PublicAPI]
public abstract class SpawnerWorker : PipelineWorkerBase, IPipelineWorker
Constructors
SpawnerWorker(double, float, bool)
Instantiates a SpawnerWorker.
Declaration
public SpawnerWorker(double cellSize, float extents, bool isUnconstrained)
Parameters
| Type | Name | Description |
|---|---|---|
| double | cellSize | The edge length of each squared cell. |
| float | extents | The extents around the players position, defining the area where the objects are spawned. |
| bool | isUnconstrained | Whether this spawner uses unconstrained extents. Spawners using unconstrained extents may have extents larger than the extents of the generator (and thus the area covered by maps). As such, unclamped spawners should not rely on map data. |
Fields
CellSize
The edge length of each squared cell.
Declaration
public readonly double CellSize
Field Value
| Type | Description |
|---|---|
| double |
IsUnconstrained
Whether the extents of this spawner are always unclamped.
Declaration
public readonly bool IsUnconstrained
Field Value
| Type | Description |
|---|---|
| bool |
OnGameObjectsCreated
Declaration
public Action<List<GameObject>> OnGameObjectsCreated
Field Value
| Type | Description |
|---|---|
| Action<List<GameObject>> |
Properties
Bounds
Gets the current bounds of this spawner.
Declaration
public GlobalBounds Bounds { get; }
Property Value
| Type | Description |
|---|---|
| GlobalBounds |
DiscreteRadius
Gets the radius after discretization.
Declaration
public int DiscreteRadius { get; }
Property Value
| Type | Description |
|---|---|
| int |
Extents
Gets the extents around the players position, defining the area where the objects are spawned. Attempts to return clamped extents for the currently used GenerationSettings. Returns raw, unclamped extents if no settings are available (e.g. worker not in a pipeline).
Declaration
public float Extents { get; }
Property Value
| Type | Description |
|---|---|
| float |
MayUpdateMovingGrid
Declaration
protected virtual bool MayUpdateMovingGrid { get; }
Property Value
| Type | Description |
|---|---|
| bool |
QuantityInitEstimation
Gets or sets the precomputed quantity that should be initialized
by an
Declaration
public virtual int QuantityInitEstimation { get; protected set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
CallInit()
Initializes this node.
Declaration
public override sealed void CallInit()
Overrides
CellKeyToBounds(Vector2Int)
Helper function to compute the bounds of a cell.
Declaration
public GlobalBounds CellKeyToBounds(Vector2Int cellKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | cellKey | The cell key to convert. |
Returns
| Type | Description |
|---|---|
| GlobalBounds | The bounds of the cell. |
ComputeCellKeyFromPosition(GlobalPosition)
Hashes the position coordinates to receive a discrete cell key.
Declaration
public Vector2Int ComputeCellKeyFromPosition(GlobalPosition position)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The position to hash. |
Returns
| Type | Description |
|---|---|
| Vector2Int | The discrete cell key. |
DestroyAllCells()
Destroys all currently existing spawned game objects and clears the internal cache.
Declaration
protected void DestroyAllCells()
DestroyCell(IEnumerable<GameObject>)
Destroys all objects within a cell by destroying them. Override this function to treat disappearing objects differently, e.g. to return them to an object pool.
Declaration
public virtual void DestroyCell(IEnumerable<GameObject> gameObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<GameObject> | gameObjects | The game objects to destroy. |
Dispose()
Declaration
public override void Dispose()
Overrides
EvaluateSpawnCandidate(int, GlobalPosition, CancellationToken)
Declaration
protected virtual UniTask<GameObject> EvaluateSpawnCandidate(int seed, GlobalPosition globalPosition, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| int | seed | |
| GlobalPosition | globalPosition | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Cysharp.Threading.Tasks.UniTask<T><GameObject> |
MoveSpawnPosition(GlobalPosition, CancellationToken)
Moves the spawn position.
Declaration
public UniTask MoveSpawnPosition(GlobalPosition position, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The position to move to. |
| CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Cysharp.Threading.Tasks.UniTask |
SpawnCell(Vector2Int, IList<GameObject>, CancellationToken)
Implement to spawn all objects within the given cell.
Declaration
protected abstract UniTask SpawnCell(Vector2Int cellKey, IList<GameObject> spawnedObjects, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2Int | cellKey | The cell key. |
| IList<GameObject> | spawnedObjects | The list to which to add all objects that were spawned. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Cysharp.Threading.Tasks.UniTask |