ecs-framework
ecs-framework copied to clipboard
一套ecs框架,可用于egret/laya/cocos及其他使用ts/js语言的引擎
Bumps [shell-quote](https://github.com/substack/node-shell-quote) from 1.7.2 to 1.7.3. Changelog Sourced from shell-quote's changelog. 1.7.3 Fix a security issue where the regex for windows drive letters allowed some shell meta-characters to escape the...
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. Commits 7efb22a 1.2.6 ef88b93 security notice for additional prototype pollution issue c2b9819 isConstructorOrProto adapted from PR bc8ecee test from prototype pollution PR See full...
Bumps [cached-path-relative](https://github.com/ashaffer/cached-path-relative) from 1.0.2 to 1.1.0. Commits See full diff in compare view [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter...
### 目前问题 不适合使用`QuerySystem`实现`EntitySystem`实体列表更新,主要原因在于: - 缓存有效的前提是查询结果在一段时间内保持稳定 - ECS 的特性是组件频繁变化来表达状态 - 任何变化都会清空`QuerySystem`的全部缓存 具体而言,目前`EntitySystem`主要有三个方面的问题: **一、多系统更新导致的开销占用过大**: 例如我的一个基于2.1.27版本的3D RPG项目,包含16个`EntitySystem`用于处理这些逻辑: `玩家预输入`、`技能的分阶段释放&打断&伤害计算`、`动画状态`与`Root Motion位置重定位`... 系统与系统之间、系统内部之中通过添加与消耗`Component`实现的状态转移,这就意味着几乎每时每刻组件都在发生变化。在新版本中实现这一点需要每一帧执行16次**缓存失效**的Query查询,并且每一次Query查询中会构建各种临时的结构体、数组对象;查询结束后还需要逐一遍历来寻找最近新增、最近删除的实体,这些微小的影响在每帧中累计起来足够造成可观的性能消耗。 **二、`lateUpdate`中直接复用了`update`中的查询结果,可能会得到错误的实体列表** 在`process`中修改的实体不会立刻影响`lastProcess`的参数,这点在特殊场景中影响很严重,例如某些系统需要在`lastProcess`中考虑`process`中增删组件操作的结果 https://github.com/esengine/ecs-framework/blob/a572c8096701074250012694d54440b76397db08/packages/core/src/ECS/Systems/EntitySystem.ts#L582-L584 **三、`EntitySystem`中查询方法导致文件庞大**: 目前为了实现查询功能,在`EntitySystem`中添加了`queryEntities`、`_entityCache`、`updateEntityTracking`、`isSingleCondition`、`executeSingleConditionQuery`、`executeComplexQuery`、`getEntityIdMap`等方法与变量,占用了相当多的篇幅。 ### 主要改进方法 **1.通过组件的变更通知实现精确的增量更新,消除查询开销**: 可以基于目前的`QuerySystem`更新策略进行升级,将源代码中的: https://github.com/esengine/ecs-framework/blob/a572c8096701074250012694d54440b76397db08/packages/core/src/ECS/Entity.ts#L75-L86 重构为: ```typescript /**...
```ts class SystemPipeline { stages: { PreUpdate: EntitySystem[]; Update: EntitySystem[]; PostUpdate: EntitySystem[]; Render: EntitySystem[]; } addSystem(system: EntitySystem, stage: 'PreUpdate' | ...) { this.stages[stage].push(system); } } ```
预制体系统
- 预制体保存/加载 - 创建预制体 - 预制体实例链接 - 预制体编辑模式 - 双击进入编辑模式 - 隔离场景环境 - 编辑完自动保存到.prefab - 应用/还原修改 - Apply按钮:保存到预制体 - Revert按钮:从预制体恢复 - 打断链接:转为普通实体 - 资产浏览器集成 - 预制体显示 - 资产浏览器显示.prefab文件 - 预制体图标...
Component 添加 _dirty 标记,修改时自动设置