Skip to content

t1k:unity:dots-combat:puzzle

FieldValue
Moduledots-combat
Version2.3.8
Efforthigh
Tools

Keywords: DOTS, game mechanics, puzzle

/t1k:unity:dots-combat:puzzle

Package: com.the1studio.dots-puzzle | Namespace: DOTSPuzzle

Related skills: dots-ecs-core, dots-rpg, dots-inventory-grid, puzzle-game-design


  • Using DOTSPuzzle.* namespace
  • Creating or querying BoardConfig, BoardCell, PieceData, PieceGridPosition
  • Implementing match detection, cascade chains, scoring
  • Adding special pieces (bomb, row-clear, rainbow)
  • Configuring CascadeState machine transitions
  • Working with SwapRequest, SwapResult, FallSystem

ComponentTypeFields
BoardConfigIComponentData (singleton)int Width, Height, PieceTypeCount
BoardCellIBufferElementData (singleton)Entity PieceEntity, byte IsOccupied
CascadeStateIComponentData (singleton)CascadePhase Phase, int IterationCount
ScoreStateIComponentData (singleton)int TotalScore, int ComboMultiplier, int ChainCount
ComponentTypeFields
PieceDataIComponentDatabyte PieceType, PieceSpecialType SpecialType
PieceGridPositionIComponentDataint GridX, GridY
PieceVisualStateIComponentDatafloat3 VisualPosition, float Scale, float Alpha
FallingTagIEnableableComponent— piece is falling
MatchedTagIEnableableComponent— part of a match
PieceDestroyedTagIEnableableComponent— scheduled removal
ComponentTypeFields
SwapRequestIComponentDataint2 FromPos, int2 ToPos
SwapResultIComponentDatabool IsValid, int MatchCount
ScoreEventIBufferElementData (singleton)int Points, int2 GridPos, ScoreReason Reason

PuzzleSystemGroup (SimulationSystemGroup)
InputSystem [OrderFirst]
SwapValidationSystem [UpdateAfter(Input)]
SwapExecutionSystem [UpdateAfter(Validation)]
MatchDetectionSystem [UpdateAfter(Swap)]
CascadeControlSystem [UpdateAfter(Match)]
PieceFallSystem [UpdateAfter(Cascade)]
BoardRefillSystem [UpdateAfter(Fall)]
ScoringSystem [UpdateAfter(Cascade)]
VisualSyncSystem [OrderLast]

// Trigger a swap
ecb.CreateEntity().AddComponent(new SwapRequest { FromPos = new int2(2,3), ToPos = new int2(3,3) });
// Read board state
var cells = SystemAPI.GetBuffer<BoardCell>(boardSingleton);
var config = SystemAPI.GetComponent<BoardConfig>(boardSingleton);
var pieceEntity = cells[gridY * config.Width + gridX].PieceEntity;
// Check cascade phase before accepting input
var cascade = SystemAPI.GetComponent<CascadeState>(boardSingleton);
if (cascade.Phase == CascadePhase.Idle) { /* safe */ }

  • Board grid positions: int2 — never use float2 for grid logic
  • BoardCell flat array index: y * Width + x
  • MatchedTag, PieceDestroyedTag, FallingTag are IEnableableComponent — never add/remove, only SetComponentEnabled
  • CascadeControlSystem uses SystemBase (not ISystem) — two-pass ECB in same frame
  • Never write to BoardCell outside SwapExecutionSystem, PieceFallSystem, BoardRefillSystem

See cascade-scoring-guide.md for state machine, scoring formula, special pieces, and gotchas.


QueuePuzzle Module (Queue-to-Grid Puzzles)

Section titled “QueuePuzzle Module (Queue-to-Grid Puzzles)”

Sub-namespace: DOTSPuzzle.QueuePuzzle — generic queue-to-grid puzzle systems (NOT game-specific).

Player taps queue lane → batch created → characters spawn → move to cells → fill → grid shifts → evaluate win/lose.

  • Game State: QueuePuzzleGameState (singleton, int Phase), QueuePuzzleResult, QueuePuzzleTransitionRequest
  • Grid Extensions: FillableCellTag, ObstacleCellTag, CellColorRequirement, CellReserved, GridVisibilityWindow, CellJustFilled
  • Queue: QueueLaneTag, QueueBlock (buffer), QueueSelectionRequest
  • SharedList: SharedListConfig, PendingBatch (buffer)
  • Character: CharacterData, CharacterTargetCell, CharacterMoving, CharacterArrived
  • Settlement: SettlementState (counter-based)

QueueSelectionSystem → SharedListSpawnSystem → CharacterMovementSystem → GridFillSystem → NeighborEffectSystem → SettlementTrackingSystem → GridShiftSystem → ResultEvaluationSystem → QueuePuzzlePhaseTransitionSystem (OrderLast)

QueuePuzzlePhaseIdle=10, Dispatching=11, Moving=12, Settling=13, Shifting=14, Evaluating=15

NEVER use game-specific names in library code. “QueuePuzzle” is generic. Demo-specific names (ColorFit, etc.) belong only in Assets/Demos/.


  • PuzzleVisualConfig base class is missing from the library — 5 puzzle demos each define a local PuzzleVisualConfig ScriptableObject for cell size, gap, tile sprites, and color palettes. These are nearly identical. A shared DOTSPuzzle.PuzzleVisualConfig base class with virtual overrides per puzzle type belongs in com.the1studio.dots-puzzle. Until extracted, keep demo-local configs but avoid copy-pasting — extract shared constants to PuzzleConstants. Source: review-260520-round5-extraction-skills.md §B P1
FileContent
cascade-scoring-guide.mdState machine, scoring formula, special pieces, gotchas