Class PoolBucket
Group of reusable entity instances of the same spawn type. Manages active and available instances for pooling.
Inherited Members
Namespace: Serenity.GameSpawner.Domain.Entities
Assembly: Serenity.GameSpawner.Domain.dll
Syntax
public class PoolBucket
Constructors
PoolBucket(SpawnType)
Creates a new PoolBucket for the specified spawn type.
Declaration
public PoolBucket(SpawnType type)
Parameters
| Type | Name | Description |
|---|---|---|
| SpawnType | type | The spawn type this bucket manages. |
Properties
ActiveCount
Gets the number of currently active instances.
Declaration
public int ActiveCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
ActiveHandles
Gets a read-only view of the currently active handles.
Declaration
public IReadOnlyList<SpawnHandle> ActiveHandles { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<SpawnHandle> |
AvailableCount
Gets the number of available (pooled) instances.
Declaration
public int AvailableCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
TotalCount
Gets the total number of instances (active + available).
Declaration
public int TotalCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Type
Gets the spawn type this bucket manages.
Declaration
public SpawnType Type { get; }
Property Value
| Type | Description |
|---|---|
| SpawnType |
Methods
Acquire()
Acquires an instance from the pool or creates a new one.
Declaration
public SpawnHandle Acquire()
Returns
| Type | Description |
|---|---|
| SpawnHandle | A SpawnHandle for the acquired instance. |
Release(SpawnHandle)
Releases an instance back into the pool.
Declaration
public bool Release(SpawnHandle handle)
Parameters
| Type | Name | Description |
|---|---|---|
| SpawnHandle | handle | The handle to release. |
Returns
| Type | Description |
|---|---|
| bool | True if the handle was found and released; otherwise false. |
ToSnapshot()
Creates a snapshot of the current pool state.
Declaration
public PoolStateSnapshot ToSnapshot()
Returns
| Type | Description |
|---|---|
| PoolStateSnapshot | A read-only snapshot of the pool state. |