t1k:unity:dots-combat:gamemodes
| Field | Value |
|---|---|
| Module | dots-combat |
| Version | 3.33.3 |
| Effort | medium |
| Tools | — |
How to invoke
Section titled “How to invoke”/t1k:unity:dots-combat:gamemodesDOTS Game Modes — AutoBattler, Survivor, Siege
Section titled “DOTS Game Modes — AutoBattler, Survivor, Siege”Package:
com.the1studio.dots-gamemodes— namespaceDOTSGameModes.*Assembly:DOTSGameModes.RuntimeRelated:t1k-unity-dots-combat-rpg(combat pipeline) ·t1k-unity-dots-core-ecs(API) API reference:references/api-surface.md
When This Skill Triggers
Section titled “When This Skill Triggers”- Building an auto-battler with draft shop, round phases, and board placement
- Implementing Survivor / bullet-heaven auto-weapons, weapon evolution, and XP pickups
- Adding a Siege cart objective with polyomino footprint, HP, and fatal-hit detection
- Migrating code that previously used
DOTSCombat.AutoBattlerorDOTSCombat.Survivor
Package Layout
Section titled “Package Layout”Runtime/ AutoBattler/ — RoundPhase FSM, DraftShop, DraftPool, BoardSlot, BenchSlot, AutoBattlerPlayerHP, AutoBattlerRules Survivor/ — AutoWeapon, WeaponSlot, WeaponEvolution, DropsXPOnDeath, XPGemPrefab Siege/ — CartCell, CartCellSlot, CartHealth, CartDamageEvent, CartFatalHitTag, CartObjectiveTagAutoBattler
Section titled “AutoBattler”Key Components (singletons unless noted)
Section titled “Key Components (singletons unless noted)”| Type | Kind | Purpose |
|---|---|---|
RoundPhase | IComponentData | Round FSM: Phase (Prep/Combat/Result), Timer, CurrentRound |
DraftShop | IComponentData | Gold, RerollCost, BaseIncomePerRound, InterestRate, MaxInterest |
AutoBattlerPlayerHP | IComponentData | PlayerHP, MaxPlayerHP |
AutoBattlerRules | IComponentData | DamagePerSurvivor config (default 2) |
DraftPool | IBufferElementData (cap 5) | UnitPrefab, Cost, Sold per shop slot |
BoardSlot | IBufferElementData (cap 16) | int2 Position, OccupiedBy Entity |
BenchSlot | IBufferElementData (cap 4) | Unit Entity on reserve bench |
BoardPlacementRequest | IComponentData | TargetSlotIndex, SourceSlotIndex, UnitEntity, Pending |
DraftRerollRequest | IComponentData + IEnableableComponent | Enableable tag; enable to trigger reroll |
Key Systems
Section titled “Key Systems”| System | Group | Role |
|---|---|---|
RoundManagementSystem | CoreSystemGroup | Prep→Combat→Result→Prep on timer or PhaseTransitionRequested |
DraftSystem | CoreSystemGroup | Reroll shop (deducts gold, resets Sold flags) |
GoldInterestSystem | CoreSystemGroup (after PlayerHPSystem) | Awards BaseIncome + interest on Result entry |
BoardPlacementSystem | CoreSystemGroup | Moves unit to slot position; swaps occupants |
PlayerHPSystem | CoreSystemGroup | Subtracts surviving-enemy damage; triggers GameOver/Victory |
Force phase transition
Section titled “Force phase transition”var round = SystemAPI.GetSingletonRW<RoundPhase>();round.ValueRW.PhaseTransitionRequested = true;Survivor
Section titled “Survivor”Key Components
Section titled “Key Components”| Type | Kind | Purpose |
|---|---|---|
AutoWeapon | IComponentData | Cooldown, Timer, ProjectilePrefab, Range, Damage, ProjectileSpeed, Level |
WeaponSlot | IBufferElementData (cap 4) | Buffer of weapon entities on the player |
WeaponEvolution | IComponentData | EvolvedPrefab, RequiredLevel; removed after evolution fires |
DropsXPOnDeath | IComponentData (tag) | Mark enemies that spawn XP on death |
XPGemPrefab | IComponentData (singleton) | Prefab entity for XP gem pickup |
Key Systems
Section titled “Key Systems”| System | Group | Role |
|---|---|---|
AutoWeaponSystem | CombatSystemGroup | Ticks cooldown, finds nearest enemy, spawns projectile via ECB |
WeaponEvolutionSystem | CombatSystemGroup (after AutoWeaponSystem) | Replaces weapon stats/prefab when Level >= RequiredLevel; removes component |
XPDropSystem | CombatSystemGroup | Instantiates XPGemPrefab at death position for DropsXPOnDeath entities |
AutoWeaponSystem writes ProjectileData, MoveDirection, MoveSpeed, TeamId — depends on DOTSCombat.
Key Components
Section titled “Key Components”| Type | Kind | Purpose |
|---|---|---|
CartHealth | IComponentData (per cart) | CurrentHp, MaxHp (int — integer HP avoids float drift in UI) |
CartCell | IComponentData (per cell) | CellIndex int2, ParentCart, OccupiedBy, OccupantKind |
CartCellSlot | IBufferElementData | Cart→cell entity back-pointer buffer |
CartDamageEvent | IBufferElementData (cap 0) | Damage int, Source Entity; cleared each frame |
CartFatalHitTag | IComponentData + IEnableableComponent | Toggled on when HP first reaches 0 (single-shot) |
CartObjectiveTag | IComponentData (tag) | Permanent marker; used by AI AttackObjective selector |
Key Systems
Section titled “Key Systems”| System | Group | Role |
|---|---|---|
CartDamageDispatchSystem | CombatSystemGroup | Drains CartDamageEvent buffer, applies damage, fires CartFatalHitTag |
CartHealthClampSystem | CombatSystemGroup (after Dispatch) | Clamps CurrentHp to [0, MaxHp] |
Push damage to a cart:
var events = SystemAPI.GetBuffer<CartDamageEvent>(cartEntity);events.Add(new CartDamageEvent { Damage = 30, Source = attackerEntity });Hard rules
Section titled “Hard rules”- Namespace move (Wave 3):
DOTSCombat.AutoBattler.*andDOTSCombat.Survivor.*moved toDOTSGameModes.AutoBattler.*andDOTSGameModes.Survivor.*. All types carry[MovedFrom]for auto-API-update but you MUST updateusingdirectives manually — the attribute only covers serialized data, not compiled references. - Survivor sub-namespace is
DOTSGameModes.Survivor, Siege isDOTSGameModes.Siege— there is no single flatDOTSGameModesnamespace; always use the sub-namespace. CartHealthusesint, notfloat— intentionally separate fromDOTSCombat.Health(float). Cast design float values explicitly:cartHealth.CurrentHp = (int)designValueFloat.CartFatalHitTagis single-shot — subsequent damage frames do NOT re-enable it once it fires. Consumers must disable it after handling; a downstream event component is the correct pattern for repeating death signals.CartDamageDispatchSystemusesSchedulenotRun— required soCartHealthClampSysteminherits the dependency. Changing toRuncauses a safety system parallel-write error.[WithPresent(typeof(CartFatalHitTag))]is required on the dispatch job — without it, IJobEntity filters out carts whose tag is disabled, making them invincible until the tag is enabled by other means.WeaponEvolutionis one-time — after evolving, the component is removed via ECB. Re-adding it will trigger another evolution on the next frame if Level still qualifies.DraftRerollRequestis IEnableableComponent — enable it to trigger a reroll;DraftSystemdisables it after processing. Do not add/remove the component each frame (structural change) — toggle the enabled flag instead.XPDropSystemrequiresGameFlowStateandXPGemPrefabsingletons — if either is absent the system skips silently. Ensure both are baked into the subscene.