Skip to content

t1k:unity:dots-combat:gamemodes

FieldValue
Moduledots-combat
Version3.33.3
Effortmedium
Tools—
/t1k:unity:dots-combat:gamemodes

DOTS Game Modes — AutoBattler, Survivor, Siege

Section titled “DOTS Game Modes — AutoBattler, Survivor, Siege”

Package: com.the1studio.dots-gamemodes — namespace DOTSGameModes.* Assembly: DOTSGameModes.Runtime Related: t1k-unity-dots-combat-rpg (combat pipeline) · t1k-unity-dots-core-ecs (API) API reference: references/api-surface.md

  • 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.AutoBattler or DOTSCombat.Survivor
Runtime/
AutoBattler/ — RoundPhase FSM, DraftShop, DraftPool, BoardSlot, BenchSlot,
AutoBattlerPlayerHP, AutoBattlerRules
Survivor/ — AutoWeapon, WeaponSlot, WeaponEvolution, DropsXPOnDeath, XPGemPrefab
Siege/ — CartCell, CartCellSlot, CartHealth, CartDamageEvent,
CartFatalHitTag, CartObjectiveTag
TypeKindPurpose
RoundPhaseIComponentDataRound FSM: Phase (Prep/Combat/Result), Timer, CurrentRound
DraftShopIComponentDataGold, RerollCost, BaseIncomePerRound, InterestRate, MaxInterest
AutoBattlerPlayerHPIComponentDataPlayerHP, MaxPlayerHP
AutoBattlerRulesIComponentDataDamagePerSurvivor config (default 2)
DraftPoolIBufferElementData (cap 5)UnitPrefab, Cost, Sold per shop slot
BoardSlotIBufferElementData (cap 16)int2 Position, OccupiedBy Entity
BenchSlotIBufferElementData (cap 4)Unit Entity on reserve bench
BoardPlacementRequestIComponentDataTargetSlotIndex, SourceSlotIndex, UnitEntity, Pending
DraftRerollRequestIComponentData + IEnableableComponentEnableable tag; enable to trigger reroll
SystemGroupRole
RoundManagementSystemCoreSystemGroupPrep→Combat→Result→Prep on timer or PhaseTransitionRequested
DraftSystemCoreSystemGroupReroll shop (deducts gold, resets Sold flags)
GoldInterestSystemCoreSystemGroup (after PlayerHPSystem)Awards BaseIncome + interest on Result entry
BoardPlacementSystemCoreSystemGroupMoves unit to slot position; swaps occupants
PlayerHPSystemCoreSystemGroupSubtracts surviving-enemy damage; triggers GameOver/Victory
var round = SystemAPI.GetSingletonRW<RoundPhase>();
round.ValueRW.PhaseTransitionRequested = true;
TypeKindPurpose
AutoWeaponIComponentDataCooldown, Timer, ProjectilePrefab, Range, Damage, ProjectileSpeed, Level
WeaponSlotIBufferElementData (cap 4)Buffer of weapon entities on the player
WeaponEvolutionIComponentDataEvolvedPrefab, RequiredLevel; removed after evolution fires
DropsXPOnDeathIComponentData (tag)Mark enemies that spawn XP on death
XPGemPrefabIComponentData (singleton)Prefab entity for XP gem pickup
SystemGroupRole
AutoWeaponSystemCombatSystemGroupTicks cooldown, finds nearest enemy, spawns projectile via ECB
WeaponEvolutionSystemCombatSystemGroup (after AutoWeaponSystem)Replaces weapon stats/prefab when Level >= RequiredLevel; removes component
XPDropSystemCombatSystemGroupInstantiates XPGemPrefab at death position for DropsXPOnDeath entities

AutoWeaponSystem writes ProjectileData, MoveDirection, MoveSpeed, TeamId — depends on DOTSCombat.

TypeKindPurpose
CartHealthIComponentData (per cart)CurrentHp, MaxHp (int — integer HP avoids float drift in UI)
CartCellIComponentData (per cell)CellIndex int2, ParentCart, OccupiedBy, OccupantKind
CartCellSlotIBufferElementDataCart→cell entity back-pointer buffer
CartDamageEventIBufferElementData (cap 0)Damage int, Source Entity; cleared each frame
CartFatalHitTagIComponentData + IEnableableComponentToggled on when HP first reaches 0 (single-shot)
CartObjectiveTagIComponentData (tag)Permanent marker; used by AI AttackObjective selector
SystemGroupRole
CartDamageDispatchSystemCombatSystemGroupDrains CartDamageEvent buffer, applies damage, fires CartFatalHitTag
CartHealthClampSystemCombatSystemGroup (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 });
  • Namespace move (Wave 3): DOTSCombat.AutoBattler.* and DOTSCombat.Survivor.* moved to DOTSGameModes.AutoBattler.* and DOTSGameModes.Survivor.*. All types carry [MovedFrom] for auto-API-update but you MUST update using directives manually — the attribute only covers serialized data, not compiled references.
  • Survivor sub-namespace is DOTSGameModes.Survivor, Siege is DOTSGameModes.Siege — there is no single flat DOTSGameModes namespace; always use the sub-namespace.
  • CartHealth uses int, not float — intentionally separate from DOTSCombat.Health (float). Cast design float values explicitly: cartHealth.CurrentHp = (int)designValueFloat.
  • CartFatalHitTag is 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.
  • CartDamageDispatchSystem uses Schedule not Run — required so CartHealthClampSystem inherits the dependency. Changing to Run causes 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.
  • WeaponEvolution is 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.
  • DraftRerollRequest is IEnableableComponent — enable it to trigger a reroll; DraftSystem disables it after processing. Do not add/remove the component each frame (structural change) — toggle the enabled flag instead.
  • XPDropSystem requires GameFlowState and XPGemPrefab singletons — if either is absent the system skips silently. Ensure both are baked into the subscene.