@esengine/ecs-framework 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/ECS/Core/FluentAPI.d.ts +0 -21
- package/bin/ECS/Core/FluentAPI.d.ts.map +1 -1
- package/bin/ECS/Core/FluentAPI.js +0 -33
- package/bin/ECS/Core/FluentAPI.js.map +1 -1
- package/bin/ECS/Entity.d.ts +23 -70
- package/bin/ECS/Entity.d.ts.map +1 -1
- package/bin/ECS/Entity.js +18 -66
- package/bin/ECS/Entity.js.map +1 -1
- package/bin/ECS/index.d.ts +0 -1
- package/bin/ECS/index.d.ts.map +1 -1
- package/bin/ECS/index.js +1 -2
- package/bin/ECS/index.js.map +1 -1
- package/bin/Utils/Extensions/index.d.ts +0 -1
- package/bin/Utils/Extensions/index.d.ts.map +1 -1
- package/bin/Utils/Extensions/index.js +0 -1
- package/bin/Utils/Extensions/index.js.map +1 -1
- package/bin/Utils/index.d.ts +0 -1
- package/bin/Utils/index.d.ts.map +1 -1
- package/bin/Utils/index.js +0 -1
- package/bin/Utils/index.js.map +1 -1
- package/bin/index.d.ts +0 -2
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +0 -3
- package/bin/index.js.map +1 -1
- package/package.json +7 -1
- package/README.md +0 -277
- package/bin/ECS/Transform.d.ts +0 -178
- package/bin/ECS/Transform.d.ts.map +0 -1
- package/bin/ECS/Transform.js +0 -249
- package/bin/ECS/Transform.js.map +0 -1
- package/bin/Math/Edge.d.ts +0 -23
- package/bin/Math/Edge.d.ts.map +0 -1
- package/bin/Math/Edge.js +0 -24
- package/bin/Math/Edge.js.map +0 -1
- package/bin/Math/MathHelper.d.ts +0 -75
- package/bin/Math/MathHelper.d.ts.map +0 -1
- package/bin/Math/MathHelper.js +0 -91
- package/bin/Math/MathHelper.js.map +0 -1
- package/bin/Math/Rectangle.d.ts +0 -126
- package/bin/Math/Rectangle.d.ts.map +0 -1
- package/bin/Math/Rectangle.js +0 -181
- package/bin/Math/Rectangle.js.map +0 -1
- package/bin/Math/Vector2.d.ts +0 -229
- package/bin/Math/Vector2.d.ts.map +0 -1
- package/bin/Math/Vector2.js +0 -338
- package/bin/Math/Vector2.js.map +0 -1
- package/bin/Math/index.d.ts +0 -5
- package/bin/Math/index.d.ts.map +0 -1
- package/bin/Math/index.js +0 -6
- package/bin/Math/index.js.map +0 -1
- package/bin/Utils/Extensions/EdgeExt.d.ts +0 -26
- package/bin/Utils/Extensions/EdgeExt.d.ts.map +0 -1
- package/bin/Utils/Extensions/EdgeExt.js +0 -41
- package/bin/Utils/Extensions/EdgeExt.js.map +0 -1
- package/bin/Utils/Screen.d.ts +0 -12
- package/bin/Utils/Screen.d.ts.map +0 -1
- package/bin/Utils/Screen.js +0 -14
- package/bin/Utils/Screen.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Utils/Extensions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Utils/Extensions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Utils/Extensions/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Utils/Extensions/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/bin/Utils/index.d.ts
CHANGED
package/bin/Utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
package/bin/Utils/index.js
CHANGED
package/bin/Utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Utils/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
package/bin/index.d.ts
CHANGED
|
@@ -12,8 +12,6 @@ export { TimerManager } from './Utils/Timers/TimerManager';
|
|
|
12
12
|
export { ITimer } from './Utils/Timers/ITimer';
|
|
13
13
|
export { Timer } from './Utils/Timers/Timer';
|
|
14
14
|
export * from './ECS';
|
|
15
|
-
export * from './Math';
|
|
16
|
-
export { Screen } from './Utils/Screen';
|
|
17
15
|
export * from './Utils/Pool';
|
|
18
16
|
export * from './Utils/PerformanceMonitor';
|
|
19
17
|
export * from './Utils/Extensions';
|
package/bin/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,cAAc,OAAO,CAAC;AAGtB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,cAAc,OAAO,CAAC;AAGtB,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AAGnC,cAAc,SAAS,CAAC"}
|
package/bin/index.js
CHANGED
|
@@ -14,10 +14,7 @@ export { TimerManager } from './Utils/Timers/TimerManager';
|
|
|
14
14
|
export { Timer } from './Utils/Timers/Timer';
|
|
15
15
|
// ECS核心
|
|
16
16
|
export * from './ECS';
|
|
17
|
-
// 数学库
|
|
18
|
-
export * from './Math';
|
|
19
17
|
// 工具类
|
|
20
|
-
export { Screen } from './Utils/Screen';
|
|
21
18
|
export * from './Utils/Pool';
|
|
22
19
|
export * from './Utils/PerformanceMonitor';
|
|
23
20
|
export * from './Utils/Extensions';
|
package/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO;AACP,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,WAAW;AACX,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,QAAQ;AACR,cAAc,OAAO,CAAC;AAEtB,MAAM;AACN,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO;AACP,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,WAAW;AACX,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,QAAQ;AACR,cAAc,OAAO,CAAC;AAEtB,MAAM;AACN,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AAEnC,OAAO;AACP,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esengine/ecs-framework",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "用于Laya、Cocos等游戏引擎的高性能ECS框架",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"types": "bin/index.d.ts",
|
|
@@ -21,11 +21,17 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc",
|
|
23
23
|
"build:watch": "tsc --watch",
|
|
24
|
+
"build:dev": "tsc -p tsconfig.dev.json",
|
|
25
|
+
"build:dev:watch": "tsc -p tsconfig.dev.json --watch",
|
|
24
26
|
"clean": "rimraf bin",
|
|
27
|
+
"clean:dev": "rimraf dev-bin",
|
|
28
|
+
"clean:all": "rimraf bin dev-bin",
|
|
25
29
|
"rebuild": "npm run clean && npm run build",
|
|
30
|
+
"rebuild:dev": "npm run clean:dev && npm run build:dev",
|
|
26
31
|
"test": "jest",
|
|
27
32
|
"test:watch": "jest --watch",
|
|
28
33
|
"test:coverage": "jest --coverage",
|
|
34
|
+
"test:framework:benchmark": "npm run build:dev && node dev-bin/Testing/framework-benchmark-test.js",
|
|
29
35
|
"lint": "eslint src --ext .ts",
|
|
30
36
|
"lint:fix": "eslint src --ext .ts --fix",
|
|
31
37
|
"prepublishOnly": "npm run rebuild",
|
package/README.md
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
# ECS Framework
|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/%40esengine%2Fecs-framework)
|
|
4
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
|
|
6
|
-
一个轻量级的 TypeScript ECS(Entity-Component-System)框架,专为小游戏开发设计,适用于 Laya、Cocos 等游戏引擎。
|
|
7
|
-
|
|
8
|
-
## ✨ 特性
|
|
9
|
-
|
|
10
|
-
- 🚀 **轻量级 ECS 架构** - 基于实体组件系统,提供清晰的代码结构
|
|
11
|
-
- 📡 **事件系统** - 内置 Emitter 事件发射器,支持类型安全的事件管理
|
|
12
|
-
- ⏰ **定时器系统** - 完整的定时器管理,支持延迟和重复任务
|
|
13
|
-
- 🔍 **查询系统** - 基于位掩码的高性能实体查询
|
|
14
|
-
- 🛠️ **性能监控** - 内置性能监控工具,帮助优化游戏性能
|
|
15
|
-
- 🎯 **对象池** - 内存管理优化,减少垃圾回收压力
|
|
16
|
-
- 📊 **数学库** - 完整的 2D 数学运算支持
|
|
17
|
-
|
|
18
|
-
## 📦 安装
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm install @esengine/ecs-framework
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## 🚀 快速开始
|
|
25
|
-
|
|
26
|
-
### 1. 初始化框架
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
import * as es from '@esengine/ecs-framework';
|
|
30
|
-
|
|
31
|
-
// 创建 Core 实例
|
|
32
|
-
const core = es.Core.create(true); // true 表示开启调试模式
|
|
33
|
-
|
|
34
|
-
// 在游戏循环中更新框架
|
|
35
|
-
function gameLoop() {
|
|
36
|
-
// 发送帧更新事件
|
|
37
|
-
es.Core.emitter.emit(es.CoreEvents.frameUpdated);
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### 2. 创建场景
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
class GameScene extends es.Scene {
|
|
45
|
-
public initialize() {
|
|
46
|
-
// 创建玩家实体
|
|
47
|
-
const player = this.createEntity("Player");
|
|
48
|
-
|
|
49
|
-
// 设置位置
|
|
50
|
-
player.position = new es.Vector2(100, 100);
|
|
51
|
-
|
|
52
|
-
// 添加自定义组件
|
|
53
|
-
const movement = player.addComponent(new MovementComponent());
|
|
54
|
-
|
|
55
|
-
// 添加系统
|
|
56
|
-
this.addEntityProcessor(new MovementSystem());
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public onStart() {
|
|
60
|
-
console.log("游戏场景已启动");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 设置当前场景
|
|
65
|
-
es.Core.scene = new GameScene();
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 3. 创建组件
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
class MovementComponent extends es.Component {
|
|
72
|
-
public speed: number = 100;
|
|
73
|
-
public direction: es.Vector2 = es.Vector2.zero;
|
|
74
|
-
|
|
75
|
-
public update() {
|
|
76
|
-
if (this.direction.length > 0) {
|
|
77
|
-
const movement = this.direction.multiply(this.speed * es.Time.deltaTime);
|
|
78
|
-
this.entity.position = this.entity.position.add(movement);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 4. 创建系统
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
class MovementSystem extends es.EntitySystem {
|
|
88
|
-
protected process(entities: es.Entity[]) {
|
|
89
|
-
for (const entity of entities) {
|
|
90
|
-
const movement = entity.getComponent(MovementComponent);
|
|
91
|
-
if (movement) {
|
|
92
|
-
movement.update();
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## 📚 核心概念
|
|
100
|
-
|
|
101
|
-
### Entity(实体)
|
|
102
|
-
实体是游戏世界中的基本对象,包含位置、旋转、缩放等基本属性,可以添加组件来扩展功能。
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
const entity = scene.createEntity("MyEntity");
|
|
106
|
-
entity.position = new es.Vector2(100, 200);
|
|
107
|
-
entity.rotation = Math.PI / 4;
|
|
108
|
-
entity.scale = new es.Vector2(2, 2);
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
### Component(组件)
|
|
112
|
-
组件包含数据和行为,定义了实体的特性。
|
|
113
|
-
|
|
114
|
-
```typescript
|
|
115
|
-
class HealthComponent extends es.Component {
|
|
116
|
-
public maxHealth: number = 100;
|
|
117
|
-
public currentHealth: number = 100;
|
|
118
|
-
|
|
119
|
-
public takeDamage(damage: number) {
|
|
120
|
-
this.currentHealth = Math.max(0, this.currentHealth - damage);
|
|
121
|
-
if (this.currentHealth <= 0) {
|
|
122
|
-
this.entity.destroy();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### System(系统)
|
|
129
|
-
系统处理实体集合,实现游戏逻辑。
|
|
130
|
-
|
|
131
|
-
```typescript
|
|
132
|
-
class HealthSystem extends es.EntitySystem {
|
|
133
|
-
protected process(entities: es.Entity[]) {
|
|
134
|
-
for (const entity of entities) {
|
|
135
|
-
const health = entity.getComponent(HealthComponent);
|
|
136
|
-
if (health && health.currentHealth <= 0) {
|
|
137
|
-
entity.destroy();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 🎮 高级功能
|
|
145
|
-
|
|
146
|
-
### 事件系统
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
// 监听事件
|
|
150
|
-
es.Core.emitter.addObserver(es.CoreEvents.frameUpdated, this.onFrameUpdate, this);
|
|
151
|
-
|
|
152
|
-
// 发射自定义事件
|
|
153
|
-
es.Core.emitter.emit("playerDied", { player: entity, score: 1000 });
|
|
154
|
-
|
|
155
|
-
// 移除监听
|
|
156
|
-
es.Core.emitter.removeObserver(es.CoreEvents.frameUpdated, this.onFrameUpdate);
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### 定时器系统
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
// 延迟执行
|
|
163
|
-
es.Core.schedule(2.0, false, this, (timer) => {
|
|
164
|
-
console.log("2秒后执行");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// 重复执行
|
|
168
|
-
es.Core.schedule(1.0, true, this, (timer) => {
|
|
169
|
-
console.log("每秒执行一次");
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### 实体查询
|
|
174
|
-
|
|
175
|
-
```typescript
|
|
176
|
-
// 按名称查找
|
|
177
|
-
const player = scene.findEntity("Player");
|
|
178
|
-
|
|
179
|
-
// 按标签查找
|
|
180
|
-
const enemies = scene.findEntitiesByTag(1);
|
|
181
|
-
|
|
182
|
-
// 按ID查找
|
|
183
|
-
const entity = scene.findEntityById(123);
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### 性能监控
|
|
187
|
-
|
|
188
|
-
```typescript
|
|
189
|
-
// 获取性能数据
|
|
190
|
-
const monitor = es.PerformanceMonitor.instance;
|
|
191
|
-
console.log("平均FPS:", monitor.averageFPS);
|
|
192
|
-
console.log("内存使用:", monitor.memoryUsage);
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## 🛠️ 开发工具
|
|
196
|
-
|
|
197
|
-
### 对象池
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
// 创建对象池
|
|
201
|
-
class BulletPool extends es.Pool<Bullet> {
|
|
202
|
-
protected createObject(): Bullet {
|
|
203
|
-
return new Bullet();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const bulletPool = new BulletPool();
|
|
208
|
-
|
|
209
|
-
// 获取对象
|
|
210
|
-
const bullet = bulletPool.obtain();
|
|
211
|
-
|
|
212
|
-
// 释放对象
|
|
213
|
-
bulletPool.free(bullet);
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### 实体调试
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
// 获取实体调试信息
|
|
220
|
-
const debugInfo = entity.getDebugInfo();
|
|
221
|
-
console.log("实体信息:", debugInfo);
|
|
222
|
-
|
|
223
|
-
// 获取场景统计
|
|
224
|
-
const stats = scene.getStats();
|
|
225
|
-
console.log("场景统计:", stats);
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## 📖 文档
|
|
229
|
-
|
|
230
|
-
- [快速入门](docs/getting-started.md) - 从零开始学习框架使用
|
|
231
|
-
- [核心概念](docs/core-concepts.md) - 深入了解 ECS 架构和设计原理
|
|
232
|
-
- [查询系统使用指南](docs/query-system-usage.md) - 学习高性能查询系统的详细用法
|
|
233
|
-
|
|
234
|
-
## 🔗 扩展库
|
|
235
|
-
|
|
236
|
-
- [路径寻找库](https://github.com/esengine/ecs-astar) - A*、广度优先、Dijkstra、GOAP 算法
|
|
237
|
-
- [AI 系统](https://github.com/esengine/BehaviourTree-ai) - 行为树、效用 AI 系统
|
|
238
|
-
|
|
239
|
-
## 🤝 贡献
|
|
240
|
-
|
|
241
|
-
欢迎提交 Issue 和 Pull Request!
|
|
242
|
-
|
|
243
|
-
### 开发环境设置
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
# 克隆项目
|
|
247
|
-
git clone https://github.com/esengine/ecs-framework.git
|
|
248
|
-
|
|
249
|
-
# 进入源码目录
|
|
250
|
-
cd ecs-framework/source
|
|
251
|
-
|
|
252
|
-
# 安装依赖
|
|
253
|
-
npm install
|
|
254
|
-
|
|
255
|
-
# 构建项目
|
|
256
|
-
npm run build
|
|
257
|
-
|
|
258
|
-
# 运行测试
|
|
259
|
-
npm test
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### 构建要求
|
|
263
|
-
|
|
264
|
-
- Node.js >= 14.0.0
|
|
265
|
-
- TypeScript >= 4.0.0
|
|
266
|
-
|
|
267
|
-
## 📄 许可证
|
|
268
|
-
|
|
269
|
-
本项目采用 [MIT](LICENSE) 许可证。
|
|
270
|
-
|
|
271
|
-
## 💬 交流群
|
|
272
|
-
|
|
273
|
-
加入 QQ 群讨论:[ecs游戏框架交流](https://jq.qq.com/?_wv=1027&k=29w1Nud6)
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
|
-
**ECS Framework** - 让游戏开发更简单、更高效!
|
package/bin/ECS/Transform.d.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { Vector2 } from '../Math/Vector2';
|
|
2
|
-
/**
|
|
3
|
-
* 变换组件类
|
|
4
|
-
*
|
|
5
|
-
* 管理游戏对象的空间变换信息,包括位置、旋转和缩放。
|
|
6
|
-
* 支持父子层级关系,可以构建复杂的变换层次结构。
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const transform = new Transform();
|
|
11
|
-
* transform.setPosition(100, 200);
|
|
12
|
-
* transform.setRotationDegrees(45);
|
|
13
|
-
* transform.setScale(2, 2);
|
|
14
|
-
*
|
|
15
|
-
* // 设置父子关系
|
|
16
|
-
* childTransform.setParent(transform);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export declare class Transform {
|
|
20
|
-
/**
|
|
21
|
-
* 本地位置坐标
|
|
22
|
-
*
|
|
23
|
-
* 相对于父变换的位置,如果没有父变换则为世界坐标。
|
|
24
|
-
*/
|
|
25
|
-
position: Vector2;
|
|
26
|
-
/**
|
|
27
|
-
* 本地旋转角度
|
|
28
|
-
*
|
|
29
|
-
* 以弧度为单位的旋转角度,相对于父变换的旋转。
|
|
30
|
-
*/
|
|
31
|
-
rotation: number;
|
|
32
|
-
/**
|
|
33
|
-
* 本地缩放比例
|
|
34
|
-
*
|
|
35
|
-
* 相对于父变换的缩放比例。
|
|
36
|
-
*/
|
|
37
|
-
scale: Vector2;
|
|
38
|
-
/**
|
|
39
|
-
* 父变换引用
|
|
40
|
-
*
|
|
41
|
-
* 指向父级变换,如果为null则表示这是根变换。
|
|
42
|
-
*/
|
|
43
|
-
parent: Transform | null;
|
|
44
|
-
/**
|
|
45
|
-
* 子变换集合
|
|
46
|
-
*
|
|
47
|
-
* 存储所有子级变换的数组。
|
|
48
|
-
*/
|
|
49
|
-
private _children;
|
|
50
|
-
/**
|
|
51
|
-
* 创建变换实例
|
|
52
|
-
*
|
|
53
|
-
* @param position - 初始位置,默认为零向量
|
|
54
|
-
* @param rotation - 初始旋转角度(弧度),默认为0
|
|
55
|
-
* @param scale - 初始缩放,默认为单位向量
|
|
56
|
-
*/
|
|
57
|
-
constructor(position?: Vector2, rotation?: number, scale?: Vector2);
|
|
58
|
-
/**
|
|
59
|
-
* 获取旋转角度(度数)
|
|
60
|
-
*
|
|
61
|
-
* @returns 以度数为单位的旋转角度
|
|
62
|
-
*/
|
|
63
|
-
get rotationDegrees(): number;
|
|
64
|
-
/**
|
|
65
|
-
* 设置旋转角度(度数)
|
|
66
|
-
*
|
|
67
|
-
* @param value - 以度数为单位的旋转角度
|
|
68
|
-
*/
|
|
69
|
-
set rotationDegrees(value: number);
|
|
70
|
-
/**
|
|
71
|
-
* 获取世界坐标位置
|
|
72
|
-
*
|
|
73
|
-
* 计算并返回在世界坐标系中的绝对位置。
|
|
74
|
-
*
|
|
75
|
-
* @returns 世界坐标位置
|
|
76
|
-
*/
|
|
77
|
-
get worldPosition(): Vector2;
|
|
78
|
-
/**
|
|
79
|
-
* 获取世界旋转角度
|
|
80
|
-
*
|
|
81
|
-
* 计算并返回在世界坐标系中的绝对旋转角度。
|
|
82
|
-
*
|
|
83
|
-
* @returns 世界旋转角度(弧度)
|
|
84
|
-
*/
|
|
85
|
-
get worldRotation(): number;
|
|
86
|
-
/**
|
|
87
|
-
* 获取世界缩放比例
|
|
88
|
-
*
|
|
89
|
-
* 计算并返回在世界坐标系中的绝对缩放比例。
|
|
90
|
-
*
|
|
91
|
-
* @returns 世界缩放比例
|
|
92
|
-
*/
|
|
93
|
-
get worldScale(): Vector2;
|
|
94
|
-
/**
|
|
95
|
-
* 获取子变换数量
|
|
96
|
-
*
|
|
97
|
-
* @returns 子变换的数量
|
|
98
|
-
*/
|
|
99
|
-
get childCount(): number;
|
|
100
|
-
/**
|
|
101
|
-
* 获取指定索引的子变换
|
|
102
|
-
*
|
|
103
|
-
* @param index - 子变换的索引
|
|
104
|
-
* @returns 子变换实例,如果索引无效则返回null
|
|
105
|
-
*/
|
|
106
|
-
getChild(index: number): Transform | null;
|
|
107
|
-
/**
|
|
108
|
-
* 设置父变换
|
|
109
|
-
*
|
|
110
|
-
* 建立或断开与父变换的层级关系。
|
|
111
|
-
*
|
|
112
|
-
* @param parent - 新的父变换,传入null表示断开父子关系
|
|
113
|
-
*/
|
|
114
|
-
setParent(parent: Transform | null): void;
|
|
115
|
-
/**
|
|
116
|
-
* 设置本地位置
|
|
117
|
-
*
|
|
118
|
-
* @param x - X坐标
|
|
119
|
-
* @param y - Y坐标
|
|
120
|
-
*/
|
|
121
|
-
setPosition(x: number, y: number): void;
|
|
122
|
-
/**
|
|
123
|
-
* 设置本地旋转角度(弧度)
|
|
124
|
-
*
|
|
125
|
-
* @param radians - 旋转角度(弧度)
|
|
126
|
-
*/
|
|
127
|
-
setRotation(radians: number): void;
|
|
128
|
-
/**
|
|
129
|
-
* 设置本地旋转角度(度数)
|
|
130
|
-
*
|
|
131
|
-
* @param degrees - 旋转角度(度数)
|
|
132
|
-
*/
|
|
133
|
-
setRotationDegrees(degrees: number): void;
|
|
134
|
-
/**
|
|
135
|
-
* 设置本地缩放比例
|
|
136
|
-
*
|
|
137
|
-
* @param scale - 缩放向量
|
|
138
|
-
*/
|
|
139
|
-
setScale(scale: Vector2): void;
|
|
140
|
-
/**
|
|
141
|
-
* 设置本地缩放比例
|
|
142
|
-
*
|
|
143
|
-
* @param x - X轴缩放比例
|
|
144
|
-
* @param y - Y轴缩放比例
|
|
145
|
-
*/
|
|
146
|
-
setScale(x: number, y: number): void;
|
|
147
|
-
/**
|
|
148
|
-
* 朝向指定位置
|
|
149
|
-
*
|
|
150
|
-
* 调整旋转角度使变换朝向目标位置。
|
|
151
|
-
*
|
|
152
|
-
* @param target - 目标位置
|
|
153
|
-
*/
|
|
154
|
-
lookAt(target: Vector2): void;
|
|
155
|
-
/**
|
|
156
|
-
* 平移变换
|
|
157
|
-
*
|
|
158
|
-
* 在当前位置基础上添加偏移量。
|
|
159
|
-
*
|
|
160
|
-
* @param offset - 位置偏移量
|
|
161
|
-
*/
|
|
162
|
-
translate(offset: Vector2): void;
|
|
163
|
-
/**
|
|
164
|
-
* 旋转
|
|
165
|
-
* @param radians 旋转角度(弧度)
|
|
166
|
-
*/
|
|
167
|
-
rotate(radians: number): void;
|
|
168
|
-
/**
|
|
169
|
-
* 复制另一个变换的值
|
|
170
|
-
* @param other 另一个变换
|
|
171
|
-
*/
|
|
172
|
-
copyFrom(other: Transform): void;
|
|
173
|
-
/**
|
|
174
|
-
* 克隆变换
|
|
175
|
-
*/
|
|
176
|
-
clone(): Transform;
|
|
177
|
-
}
|
|
178
|
-
//# sourceMappingURL=Transform.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.d.ts","sourceRoot":"","sources":["../../src/ECS/Transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAS;IAClB;;;;OAIG;IACI,QAAQ,EAAE,OAAO,CAAgB;IAExC;;;;OAIG;IACI,QAAQ,EAAE,MAAM,CAAK;IAE5B;;;;OAIG;IACI,KAAK,EAAE,OAAO,CAAe;IAEpC;;;;OAIG;IACI,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEvC;;;;OAIG;IACH,OAAO,CAAC,SAAS,CAAmB;IAEpC;;;;;;OAMG;gBACS,QAAQ,CAAC,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAU,EAAE,KAAK,CAAC,EAAE,OAAO;IAMrE;;;;OAIG;IACH,IAAW,eAAe,IAAI,MAAM,CAEnC;IAED;;;;OAIG;IACH,IAAW,eAAe,CAAC,KAAK,EAAE,MAAM,EAEvC;IAED;;;;;;OAMG;IACH,IAAW,aAAa,IAAI,OAAO,CAgBlC;IAED;;;;;;OAMG;IACH,IAAW,aAAa,IAAI,MAAM,CAKjC;IAED;;;;;;OAMG;IACH,IAAW,UAAU,IAAI,OAAO,CAK/B;IAED;;;;OAIG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;;;;OAKG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAOhD;;;;;;OAMG;IACI,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;IAkBhD;;;;;OAKG;IACI,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAI9C;;;;OAIG;IACI,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIzC;;;;OAIG;IACI,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIhD;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IACrC;;;;;OAKG;IACI,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAS3C;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAKpC;;;;;;OAMG;IACI,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAIvC;;;OAGG;IACI,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIpC;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAMvC;;OAEG;IACI,KAAK,IAAI,SAAS;CAI5B"}
|