@dojoengine/recs

中文文档
2.1.0发布于 2026/04/22MITES Module近 30 天下载 4107

recs 以反应为心. Components 财务报告和审定财务报表 Queries 曝光一个 update$ 溪流,该 Systems 可以作出反应.

中文使用文档

dros - 反应实体组件系统

recs 以反应为心. Components 财务报告和审定财务报表 Queries 曝光一个 update$ 溪流,该 Systems 可以作出反应.

要建立一些基本的直觉 关于ECS,看看 我们的MUD ECS介绍。 。 。 .

recs 与其他 MUD 库无缝地融合,但可以独立使用.

详细文件请查看 泥浆. dev/雷克。 。 。 .

特征

  • 反应组件、查询和系统
  • 强大的查询,包括高级间接关系查询
  • 与其他大学和大学部图书馆和服务无缝融合
  • 简单、声明性 API
  • 超高性能
  • 类型脚本支持

示例

import {
  createWorld,
  defineComponent,
  createEntity,
  withValue,
  defineSystem,
  Has,
  getComponentValue,
  setComponent,
} from "@latticexyz/recs";

// Create a new World
const World = createWorld();

// Define a couple components
const Position = defineComponent(world, { x: Type.Number, y: Type.Number });
const Movable = defineComponent(world, { speed: Type.Number });

// Create a new entity
const entity1 = createEntity(world, [withValue(Position, { x: 0, y: 0 }), withValue(Movable, { speed: 10 })]);

// Define a system that reacts to updates of movable entities with a position
defineSystem(world, [Has(Position), Has(Movable)], (update) => {
  console.log("Entity", update.entity, "moved to", update.value);
  // ... do stuff, like rendering the entity on the screen, etc
});

// Move the entity around
setInterval(() => {
  const currentPosition = getComponentValue(Position, entity1);
  const newPosition = { x: position.x + 1, y: position.y + 1 };
  setComponent(Position, entity1, newPosition);
}, 1000);

鸣谢

版本与发布记录

@dojoengine/recs 共发布 4 个版本,首次发布于 2023/11/07;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.1.0latest2026/04/226 个月前
2.0.132024/06/202 年前
2.0.122024/06/202 年前
0.1.352023/11/073 年前

关于 @dojoengine/recs 的常见问题

@dojoengine/recs 是什么?

recs 以反应为心. Components 财务报告和审定财务报表 Queries 曝光一个 update$ 溪流,该 Systems 可以作出反应.

如何安装 @dojoengine/recs?

在项目目录运行 npm install @dojoengine/recs,或使用 pnpm add / yarn add / bun add。

@dojoengine/recs 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dojoengine__recs 是否存在。

@dojoengine/recs 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dojoengine/recs 可以商用吗?

@dojoengine/recs 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dojoengine/recs 的下载量有多少?

根据 npm 官方下载统计,@dojoengine/recs 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,107 次,日均约 137 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dojoengine/recs 还在维护吗?

最新版本 2.1.0 发布于 2026/04/22(6 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/11/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。