The faction roster currently in use.
The metadata channel key ownership is stored under.
Whether the layer is currently drawn.
Replace the faction roster (colors, names). Cell ownership is untouched.
Raw stored ownership for a cell — a faction id, an influence record, or null.
The faction holding a cell — the sole owner, or the largest share of a
contested cell. null when unowned. Ties resolve to the roster order so
the answer is stable across calls.
Per-faction influence on a cell, normalized to sum to 1. An outright claim
reads as { [ownerId]: 1 }. null when unowned.
Every cell whose dominant owner is factionId.
Cell counts per faction id, for scoreboards. Unowned cells are not counted.
Give a cell outright to a faction. Out-of-bounds cells are skipped.
Give many cells to one faction — a conquest, a starting region, a flood fill.
Mark a cell contested, with a weight per faction (any positive scale — they are normalized on read). Weights of zero or less are dropped; an empty result releases the cell.
Return a cell to no-one.
Return many cells to no-one.
Wipe all ownership from the map, leaving every other metadata key intact.
OptionalfactionId: stringLimit the wipe to one faction's holdings.
Show or hide the whole layer without discarding ownership data.
Rebuild only if something changed since the last build. Cheap to call every frame.
Rebuild the territory geometry now: one vertex-colored fill over every owned cell (contested cells carrying their blended tint) plus one outline per faction.
Remove this layer's overlays. Ownership data on the map is left alone.
Per-cell ownership: who holds which hex, drawn as translucent faction tints with an outline around each faction's holdings.
Ownership lives in the map's metadata channel (
HexMap.cellData), so it serializes with the map for free — save throughserializeMap/serializeMapJSON/.hexpackand the borders come back exactly as they were, no companion file. The layer itself holds no cell state; it is a view over that data plus a faction roster.A cell can be held outright (
claim) or contested (setInfluence), where several factions hold fractional weights and the fill is their weighted color blend. Contested cells count toward whichever faction has the largest share for border and ownedCells purposes.Mutations only mark the layer dirty; call update once per frame (or refresh straight after a batch of edits) to rebuild the geometry, so a thousand-cell flood fill costs one rebuild instead of a thousand.
Example