Class ScyllaSparseHexGrid<TCell>.Builder
Fluent builder for constructing ScyllaSparseHexGrid<TCell> instances with
complex or convenient configurations.
Unlike the dense-grid builder, this builder does not offer WithDefaultValue because
sparse grids only store explicitly set cells and have no pre-allocated storage to fill.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class ScyllaSparseHexGrid<TCell>.Builder
Remarks
Call Build() to obtain an IScyllaGrid<TCoord, TCell> interface (which may be a synchronized wrapper), or BuildConcrete() to obtain the concrete ScyllaSparseHexGrid<TCell> directly.
Methods
Build()
Builds and returns the configured sparse grid as an IScyllaGrid<TCoord, TCell> interface. If Synchronized(object) was called, returns a ScyllaSparseHexGrid<TCell>.SynchronizedScyllaSparseHexGrid wrapper; otherwise, returns the concrete ScyllaSparseHexGrid<TCell> directly. If WithBounds(int, int, int, int) or WithHexagonalBounds(int) was not called, the grid is unbounded.
Declaration
public IScyllaGrid<HexCoord, TCell> Build()
Returns
| Type | Description |
|---|---|
| IScyllaGrid<HexCoord, TCell> | An IScyllaGrid<TCoord, TCell> instance configured according to the builder settings. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when WithLayout(HexGridLayout) was not called before building. |
BuildConcrete()
Builds and returns the concrete unsynchronized ScyllaSparseHexGrid<TCell> instance. Use this overload when you need access to the sparse-grid-specific API such as TryRemove(HexCoord, out TCell) or GetNeighborsNonAlloc(HexCoord, Span<HexCoord>).
Declaration
public ScyllaSparseHexGrid<TCell> BuildConcrete()
Returns
| Type | Description |
|---|---|
| ScyllaSparseHexGrid<TCell> | The configured concrete ScyllaSparseHexGrid<TCell> instance. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when Synchronized(object) was called (use Build() instead), or when WithLayout(HexGridLayout) was not called. |
Synchronized(object)
Configures the builder to return a synchronized (thread-safe) wrapper.
Declaration
public ScyllaSparseHexGrid<TCell>.Builder Synchronized(object syncRoot = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | syncRoot | Optional external lock object. |
Returns
| Type | Description |
|---|---|
| ScyllaSparseHexGrid<TCell>.Builder | This builder instance for method chaining. |
WithBounds(int, int, int, int)
Sets inclusive bounds for the sparse grid in axial space.
Declaration
public ScyllaSparseHexGrid<TCell>.Builder WithBounds(int qMin, int rMin, int qMax, int rMax)
Parameters
| Type | Name | Description |
|---|---|---|
| int | qMin | The minimum Q value (inclusive). |
| int | rMin | The minimum R value (inclusive). |
| int | qMax | The maximum Q value (inclusive). |
| int | rMax | The maximum R value (inclusive). |
Returns
| Type | Description |
|---|---|
| ScyllaSparseHexGrid<TCell>.Builder | This builder instance for method chaining. |
WithHexagonalBounds(int)
Configures symmetric hexagonal bounds centered at the origin with the given radius. Q range: [-radius, +radius], R range: [-radius, +radius].
Declaration
public ScyllaSparseHexGrid<TCell>.Builder WithHexagonalBounds(int radius)
Parameters
| Type | Name | Description |
|---|---|---|
| int | radius | The hexagonal radius. Must be at least 0. |
Returns
| Type | Description |
|---|---|
| ScyllaSparseHexGrid<TCell>.Builder | This builder instance for method chaining. |
WithLayout(HexGridLayout)
Sets the spatial layout for world-space conversions.
Declaration
public ScyllaSparseHexGrid<TCell>.Builder WithLayout(HexGridLayout layout)
Parameters
| Type | Name | Description |
|---|---|---|
| HexGridLayout | layout | The layout to use. |
Returns
| Type | Description |
|---|---|
| ScyllaSparseHexGrid<TCell>.Builder | This builder instance for method chaining. |