rust-legion-ecs-gameplay

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Rust Legion ECS Gameplay

Rust Legion ECS 游戏玩法

Use this skill to build ECS gameplay code in Rust, especially in projects using Legion or a Legion-like architecture. Keep components as data, systems as focused logic, and resources as shared singleton state.
使用此技能在Rust中构建ECS游戏玩法代码,尤其适用于采用Legion或类Legion架构的项目。保持组件仅作为数据,系统作为聚焦的逻辑,资源作为共享单例状态。

Core Workflow

核心工作流程

  1. Identify entities, components, systems, and resources from the feature.
  2. Add data-only components before adding systems that consume them.
  3. Put entity construction in spawner functions or factories.
  4. Use queries that request only the components a system needs.
  5. Sequence systems with schedules and flush points when later systems must observe structural changes.
  6. Verify behavior through one small gameplay path before adding more entity types.
  1. 从功能中识别实体、组件、系统和资源。
  2. 在添加使用组件的系统之前,先添加仅包含数据的组件。
  3. 将实体构造放在生成器函数或工厂中。
  4. 使用仅请求系统所需组件的查询。
  5. 当后续系统必须观察结构变化时,使用调度器和刷新点来编排系统顺序。
  6. 在添加更多实体类型之前,通过一条小型游戏玩法路径验证行为。

Read Next

后续阅读

Read
references/ecs-gameplay-patterns.md
for component design, system ordering, spawners, rendering systems, and ECS review checks.
阅读
references/ecs-gameplay-patterns.md
了解组件设计、系统顺序、生成器、渲染系统和ECS审查检查。

Source Notes

来源说明

Guidance is transformed and paraphrased from Hands-On Rust Chapter 6 and the official companion source repository. Current crate context was checked against Legion and Bevy ECS docs. If the target project uses Bevy, hecs, specs, or another ECS, adapt the architecture instead of forcing Legion APIs.
指导内容改编自《Hands-On Rust》第6章及其官方配套源码仓库。当前crate上下文已对照Legion和Bevy ECS文档进行核对。如果目标项目使用Bevy、hecs、specs或其他ECS,请调整架构,不要强行使用Legion API。