[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KGD3KYDGWCFZGZ41A5WHNV":3,"skill-same:01M6KGD3KYDGWCFZGZ41A5WHNV":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":46,"commitSha":47,"skillDirectory":48,"forksCount":49,"repositoryHtmlUrl":50,"repositoryHomepageUrl":6,"ownerHtmlUrl":51,"ownerBlogUrl":6,"ownerDescription":52,"updatedAt":53,"install":54,"resources":66},"01M6KGD3KYDGWCFZGZ41A5WHNV","wave6-ecs-state-machine-design",null,"Choose the correct ECS state representation — enum field, IEnableableComponent, or structural add\u002Fremove — based on transition frequency, state count, and query-filtering requirements.","dyCuong03\u002Funity-agent-team","dyCuong03","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F137050365?v=4","01M6KFXC85HQHXZJC2VC1KY6EZ","CuongND","01M6KFXCCHP6CD5MTA8NECJC36",8,"MIT","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Funity-dots\u002Fwave6-ecs-state-machine-design\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"state","wave6 ecs state machine design","state machine","ecs","machine design","machine","design","state-machine","query","requirements","structural","add","remove","filtering","choose","true","correct","enableable","2026-11-10 10:12:30",false,"﻿---\nname: wave6-ecs-state-machine-design\ndescription: Choose the correct ECS state representation — enum field, IEnableableComponent, or structural add\u002Fremove — based on transition frequency, state count, and query-filtering requirements.\ntags: [enableable, state-machine]\nmetadata:\n  internal-only: true\n  tier: 3\n---\n\n# ECS State Machine Design — Decision Model\n\n## Intent\nChoose the correct ECS state representation — enum field, IEnableableComponent, or structural add\u002Fremove — based on transition frequency, state count, and query-filtering requirements.\n\n## Decision Model\n\n| Criterion | Enum Field | IEnableableComponent | Structural Add\u002FRemove |\n|-----------|-----------|---------------------|----------------------|\n| State count | 3+ exclusive states | Exactly 2 (active\u002Finactive) | Any; data ownership varies |\n| Transition frequency | Any | High (per-frame) | Low (lifecycle) |\n| Downstream query filter | No (branch in system) | Yes (automatic at query level) | Yes (archetype-level) |\n| Memory when inactive | Always present | Always present | Freed |\n| Cost per transition | Field write (cheapest) | Bit flip (O(1)) | Chunk move (10-100x) |\n\n## Senior Pattern — Enum FSM\n```csharp\npublic enum BotState { MoveToTarget, Attack, Retreat, Idle, Dead }\n\npublic struct BotAI : IComponentData\n{\n    public BotState State;\n    public float StateTimer;\n}\n\n[BurstCompile]\npublic partial struct BotFSMJob : IJobEntity\n{\n    public float DeltaTime;\n\n    [BurstCompile]\n    public void Execute(ref BotAI bot, ref LocalTransform t)\n    {\n        switch (bot.State)\n        {\n            case BotState.MoveToTarget:\n                bot.StateTimer -= DeltaTime;\n                if (bot.StateTimer \u003C= 0) bot.State = BotState.Attack;\n                break;\n            case BotState.Attack:\n                \u002F\u002F attack logic\n                break;\n            \u002F\u002F ...\n        }\n    }\n}\n```\n\n## Senior Pattern — Enableable Binary Flag\n```csharp\n\u002F\u002F Zero-size component — just the enabled bit matters:\npublic struct Stealth : IComponentData, IEnableableComponent { }\n\n\u002F\u002F Systems automatically see only active entities:\nnew StealthBehaviorJob().ScheduleParallel(state.Dependency);   \u002F\u002F only enabled\nnew StealthRevealJob().ScheduleParallel(state.Dependency);     \u002F\u002F only enabled\n\n\u002F\u002F Mixed: enum for internal FSM, enableable for external visibility:\npublic struct EnemyAI : IComponentData { public EnemyState State; }\npublic struct DetectedByPlayer : IComponentData, IEnableableComponent { }\n\u002F\u002F Internal transitions via enum field; player detection via enableable\n```\n\n## Senior Pattern — Structural (Lifecycle)\n```csharp\n\u002F\u002F Spawn → Active (ECB adds components once):\necb.AddComponent\u003CEnemyAI>(entity, new EnemyAI { State = EnemyState.Patrol });\necb.AddComponent\u003CPhysicsVelocity>(entity, default);\n\n\u002F\u002F Death (ECB removes components once — entity enters cleanup archetype):\necb.RemoveComponent\u003CEnemyAI>(entity);\necb.AddComponent\u003CDeadTag>(entity);\n```\n\n## Anti-Patterns\n- Structural AddComponent\u002FRemoveComponent for per-frame transitions — 10-100x more expensive than enum write or bit flip; causes archetype churn.\n- IEnableableComponent for 3+ exclusive states — no query can express \"exactly state X of N\"; use enum.\n- Enum fields when downstream systems need to query-filter automatically — requires branch inside every system; enableable components filter at chunk level.\n- Creating a separate entity per state — unnecessary structural complexity; prefer enum or enableable on the same entity.\n\n## Performance Benchmark (from ECS StateChange sample)\n- Enum field write: fastest for single-entity per-frame transitions\n- Enableable bit flip: fastest for bulk query-filtered transitions (no chunk move)\n- Structural change: 10-100x slower; reserve for entity lifecycle only\n\n## Architecture Guidance\n- Mixed approach is valid and common: enum for internal FSM state, IEnableableComponent for external visibility\u002Fbehavior flags.\n- Document state ownership: which system writes state, which systems read it.\n- For 2-state binary: prefer IEnableableComponent when downstream systems should auto-filter; prefer enum field when only one system cares.\n\n## Related Skills\n[[enableable-component]], [[wave6-enabled-ref-rw-in-job]], [[wave6-with-disabled-query-filter]], [[structural-change-cost-model]], [[icleanupcomponentdata-runtime]]\n","# ECS State Machine Design — Decision Model\n\n## Intent\nChoose the correct ECS state representation — enum field, IEnableableComponent, or structural add\u002Fremove — based on transition frequency, state count, and query-filtering requirements.\n\n## Decision Model\n\n| Criterion | Enum Field | IEnableableComponent | Structural Add\u002FRemove |\n|-----------|-----------|---------------------|----------------------|\n| State count | 3+ exclusive states | Exactly 2 (active\u002Finactive) | Any; data ownership varies |\n| Transition frequency | Any | High (per-frame) | Low (lifecycle) |\n| Downstream query filter | No (branch in system) | Yes (automatic at query level) | Yes (archetype-level) |\n| Memory when inactive | Always present | Always present | Freed |\n| Cost per transition | Field write (cheapest) | Bit flip (O(1)) | Chunk move (10-100x) |\n\n## Senior Pattern — Enum FSM\n```csharp\npublic enum BotState { MoveToTarget, Attack, Retreat, Idle, Dead }\n\npublic struct BotAI : IComponentData\n{\n    public BotState State;\n    public float StateTimer;\n}\n\n[BurstCompile]\npublic partial struct BotFSMJob : IJobEntity\n{\n    public float DeltaTime;\n\n    [BurstCompile]\n    public void Execute(ref BotAI bot, ref LocalTransform t)\n    {\n        switch (bot.State)\n        {\n            case BotState.MoveToTarget:\n                bot.StateTimer -= DeltaTime;\n                if (bot.StateTimer \u003C= 0) bot.State = BotState.Attack;\n                break;\n            case BotState.Attack:\n                \u002F\u002F attack logic\n                break;\n            \u002F\u002F ...\n        }\n    }\n}\n```\n\n## Senior Pattern — Enableable Binary Flag\n```csharp\n\u002F\u002F Zero-size component — just the enabled bit matters:\npublic struct Stealth : IComponentData, IEnableableComponent { }\n\n\u002F\u002F Systems automatically see only active entities:\nnew StealthBehaviorJob().ScheduleParallel(state.Dependency);   \u002F\u002F only enabled\nnew StealthRevealJob().ScheduleParallel(state.Dependency);     \u002F\u002F only enabled\n\n\u002F\u002F Mixed: enum for internal FSM, enableable for external visibility:\npublic struct EnemyAI : IComponentData { public EnemyState State; }\npublic struct DetectedByPlayer : IComponentData, IEnableableComponent { }\n\u002F\u002F Internal transitions via enum field; player detection via enableable\n```\n\n## Senior Pattern — Structural (Lifecycle)\n```csharp\n\u002F\u002F Spawn → Active (ECB adds components once):\necb.AddComponent\u003CEnemyAI>(entity, new EnemyAI { State = EnemyState.Patrol });\necb.AddComponent\u003CPhysicsVelocity>(entity, default);\n\n\u002F\u002F Death (ECB removes components once — entity enters cleanup archetype):\necb.RemoveComponent\u003CEnemyAI>(entity);\necb.AddComponent\u003CDeadTag>(entity);\n```\n\n## Anti-Patterns\n- Structural AddComponent\u002FRemoveComponent for per-frame transitions — 10-100x more expensive than enum write or bit flip; causes archetype churn.\n- IEnableableComponent for 3+ exclusive states — no query can express \"exactly state X of N\"; use enum.\n- Enum fields when downstream systems need to query-filter automatically — requires branch inside every system; enableable components filter at chunk level.\n- Creating a separate entity per state — unnecessary structural complexity; prefer enum or enableable on the same entity.\n\n## Performance Benchmark (from ECS StateChange sample)\n- Enum field write: fastest for single-entity per-frame transitions\n- Enableable bit flip: fastest for bulk query-filtered transitions (no chunk move)\n- Structural change: 10-100x slower; reserve for entity lifecycle only\n\n## Architecture Guidance\n- Mixed approach is valid and common: enum for internal FSM state, IEnableableComponent for external visibility\u002Fbehavior flags.\n- Document state ownership: which system writes state, which systems read it.\n- For 2-state binary: prefer IEnableableComponent when downstream systems should auto-filter; prefer enum field when only one system cares.\n\n## Related Skills\n[[enableable-component]], [[wave6-enabled-ref-rw-in-job]], [[wave6-with-disabled-query-filter]], [[structural-change-cost-model]], [[icleanupcomponentdata-runtime]]\n",{"name":5,"tags":42,"metadata":43,"description":7},[36,26],{"tier":44,"internal-only":45},3,true,"main","fe4746b9f07e6c7c2b6d3932002183af9b9f6fa2",".claude\u002Fskills\u002Funity-dots\u002Fwave6-ecs-state-machine-design",0,"https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team","https:\u002F\u002Fgithub.com\u002FdyCuong03","Game developer","2026-07-25 22:22:25",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":45},[56,59,62],{"tool":57,"command":58},"npx","npx skills add dyCuong03\u002Funity-agent-team --skill wave6-ecs-state-machine-design",{"tool":60,"command":61},"bunx","bunx skills add dyCuong03\u002Funity-agent-team --skill wave6-ecs-state-machine-design",{"tool":63,"command":64},"pnpm","pnpm dlx skills add dyCuong03\u002Funity-agent-team --skill wave6-ecs-state-machine-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Funity-dots\u002Fwave6-ecs-state-machine-design\u002FSKILL.md",[],[68,91,115,134,154,174],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":37},"01M6KH55FFS00ET877QSMRYGX4","dots-update-groups","How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup \u002F SimulationSystemGroup \u002F PresentationSystemGroup \u002F FixedStepSimulationSystemGroup \u002F VariableRateSimulationSystemGroup, UpdateBefore \u002F UpdateAfter peer ordering, OrderFirst \u002F OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing \"value visible one frame late\" bugs, or coupling simulation to a fixed timestep.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Fworkspace\u002Fdots-program\u002Fscratch\u002Fwave-2-orchestrator-drafts\u002Fdots-update-groups\u002FSKILL.md",[],[75,76,77,78,79,80,33,81,82,83,84,85,86,87,22,88,89,90],"update","dots update groups","boundary","simulation","how","system","work","use","never","peer","deterministic","how to","coupling","bugs","frame","value",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":37},"01M6KH50PWYEFQDCGYBZ0326F1","dots-transform-patterns","The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent\u002FChild hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent\u002Fchild hierarchies, runtime reparenting (mount\u002Fdismount\u002Fsocket), or choosing transform components at the Baker boundary.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Fworkspace\u002Fdots-program\u002Fscratch\u002Fwave-2-orchestrator-drafts\u002Fdots-transform-patterns\u002FSKILL.md",[],[98,99,100,101,77,80,102,103,82,104,105,106,107,108,109,110,111,112,113,114],"patterns","transform","dots transform patterns","components","mount","model","cost","runtime","systems","input","with","matrix","socket","at","child","custom","hierarchy",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":37},"01M6KH4VW4MA14DQW4KQYPFT0S","dots-singleton-patterns","Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton \u002F GetSingletonRW \u002F HasSingleton \u002F TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the \"exactly one entity\" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Fworkspace\u002Fdots-program\u002Fscratch\u002Fwave-2-orchestrator-drafts\u002Fdots-singleton-patterns\u002FSKILL.md",[],[98,122,123,124,125,19,126,80,103,82,127,128,129,105,130,131,108,89,132,133],"singleton","dots singleton patterns","component","config","game","writer","time","shared","contract","as","ecb","gating",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":37},"01M6KH4PR076AYNDZHD63HHWX6","dots-hybrid-bridge","The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes \u002F Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input\u002FUI must trigger ECS work.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Fworkspace\u002Fdots-program\u002Fscratch\u002Fwave-2-orchestrator-drafts\u002Fdots-hybrid-bridge\u002FSKILL.md",[],[141,142,143,144,101,19,77,145,146,81,147,148,82,105,149,150,107,151,152,153],"bridge","hybrid","dots hybrid bridge","mesh","assets","Rules","read","view","trigger","unity","material","for","managed",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":37},"01M6KH4FGRQ9AP2ND5H5HX4D83","dots-event-driven-ecs","Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event \u002F UnityEvent \u002F static bus anti-patterns. Use when input\u002FUI\u002Fnetwork must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Fworkspace\u002Fdots-program\u002Fscratch\u002Fwave-2-orchestrator-drafts\u002Fdots-event-driven-ecs\u002FSKILL.md",[],[161,162,22,163,164,101,165,166,167,103,81,168,169,98,170,29,107,171,172,173],"event driven","driven","event","dots event driven ecs","change","ui","network","command","anti-patterns","pattern","events","static","request",{"skillNo":175,"name":176,"nameZh":6,"description":177,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":178,"categories":179,"keywords":180,"publishedAt":37},"01M6KH4BWRGCEBJ8PKCKCSGT33","valid_skill","A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.","https:\u002F\u002Fgithub.com\u002FdyCuong03\u002Funity-agent-team\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fvalid_skill\u002FSKILL.md",[],[181,182,183,184,185,186,187,188,189,190,191,192,193,194,150,195,152],"valid skill","valid","code review","testing","review","test","routing","code","validation","projects","fixture skill","task","fixture","basic","complete"]