Class HexCornerMap<TData>
Lightweight dictionary wrapper that stores data keyed by HexCornerCoord. Useful for storing per-corner data such as settlements, trade posts, or elevation markers at hex vertices.
Inherited Members
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public sealed class HexCornerMap<TData>
Type Parameters
| Name | Description |
|---|---|
| TData | The type of data stored per corner. May be a reference or value type. |
Remarks
Keys must be canonical HexCornerCoord values (position is N or S). Non-canonical representations of the same physical vertex (expressed relative to a different neighbor hex) will not match and will be treated as separate entries. Use GetCornersOfCellNonAlloc(HexCoord, Span<HexCornerCoord>) to enumerate the six canonical corners of a given cell.
Iteration is allocation-free when performed on the concrete type using
foreach. The value-type HexCornerMap<TData>.Enumerator yields
(Coord, Value) tuples for all populated corners.
Constructors
HexCornerMap()
Creates a new empty hex corner map with the default initial capacity.
Declaration
public HexCornerMap()
HexCornerMap(int)
Creates a new empty hex corner map with the specified initial capacity. Pre-sizing avoids resize allocations when the approximate number of corners is known in advance.
Declaration
public HexCornerMap(int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | capacity | The initial capacity of the underlying dictionary. Must be non-negative. A capacity of 0 is treated as the default initial capacity. |
Properties
Count
Gets the number of corners that currently have data stored in this map.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Removes all stored corner data from this map, resetting Count to zero.
Declaration
public void Clear()
Contains(HexCornerCoord)
Determines whether any data has been stored at the specified canonical corner coordinate.
Declaration
public bool Contains(HexCornerCoord coord)
Parameters
| Type | Name | Description |
|---|---|---|
| HexCornerCoord | coord | The corner coordinate to check. |
Returns
| Type | Description |
|---|---|
| bool |
GetEnumerator()
Returns a value-type HexCornerMap<TData>.Enumerator that iterates through all stored corner data without allocating on the heap when used with foreach on the concrete type.
Declaration
public HexCornerMap<TData>.Enumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| HexCornerMap<TData>.Enumerator | An HexCornerMap<TData>.Enumerator for allocation-free iteration over (Coord, Value) pairs. |
Set(HexCornerCoord, TData)
Stores value at the specified corner coordinate, inserting a new entry
or overwriting any existing entry.
Declaration
public void Set(HexCornerCoord coord, TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexCornerCoord | coord | The canonical corner coordinate at which to store the data. |
| TData | value | The data to associate with this corner. |
TryGet(HexCornerCoord, out TData)
Attempts to retrieve the data stored at the specified canonical corner coordinate.
Declaration
public bool TryGet(HexCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexCornerCoord | coord | The canonical corner coordinate to look up. |
| TData | value | When this method returns, contains the data associated with |
Returns
| Type | Description |
|---|---|
| bool |
TryRemove(HexCornerCoord, out TData)
Attempts to remove the data stored at the specified canonical corner coordinate.
Declaration
public bool TryRemove(HexCornerCoord coord, out TData value)
Parameters
| Type | Name | Description |
|---|---|---|
| HexCornerCoord | coord | The corner coordinate to remove. |
| TData | value | When this method returns, contains the removed data if found;
otherwise, contains the default value for |
Returns
| Type | Description |
|---|---|
| bool | true if data was found and removed; false if no entry existed. |