@georgeluo/ecs 0.1.0

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/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @simeval/ecs
2
+
3
+ Reusable ECS core extracted from `workspaces/Describing_Simulation_0/src/core`.
4
+
5
+ ## Monorepo Layout
6
+
7
+ - Canonical ECS implementation lives in `packages/ecs/src`.
8
+ - The SimEval workspace keeps `workspaces/Describing_Simulation_0/src/core/**` as compatibility shims that re-export this package.
9
+ - This keeps historical/spec path layout without duplicating implementation logic.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @simeval/ecs
15
+ ```
16
+
17
+ ```bash
18
+ pnpm add @simeval/ecs
19
+ ```
20
+
21
+ ```bash
22
+ yarn add @simeval/ecs
23
+ ```
24
+
25
+ For this monorepo before publish, use a local file dependency:
26
+
27
+ ```json
28
+ {
29
+ "dependencies": {
30
+ "@simeval/ecs": "file:../../packages/ecs"
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Import
36
+
37
+ ```ts
38
+ import {
39
+ EntityManager,
40
+ ComponentManager,
41
+ SystemManager,
42
+ SimulationPlayer,
43
+ EvaluationPlayer,
44
+ Bus,
45
+ FrameFilter,
46
+ SimulationMessageType,
47
+ EvaluationMessageType,
48
+ type Frame,
49
+ type Acknowledgement,
50
+ type System,
51
+ } from '@simeval/ecs';
52
+ ```
53
+
54
+ ## Inject systems into EvaluationPlayer
55
+
56
+ ```ts
57
+ const entities = new EntityManager();
58
+ const components = new ComponentManager();
59
+ const systems = new SystemManager(entities, components);
60
+ const inbound = new Bus<unknown>();
61
+ const outbound = new Bus<Frame | Acknowledgement>();
62
+ const player = new EvaluationPlayer(systems, inbound, outbound, new FrameFilter());
63
+
64
+ const systemId = player.injectSystem({ system: myEvaluationSystem });
65
+ player.ejectSystem({ systemId });
66
+ ```
67
+
68
+ ## Inject frames into EvaluationPlayer
69
+
70
+ ```ts
71
+ inbound.publish({
72
+ type: EvaluationMessageType.INJECT_FRAME,
73
+ payload: {
74
+ messageId: 'frame-1',
75
+ frame: { tick: 1, entities: {} },
76
+ },
77
+ });
78
+ ```
79
+
80
+ Or call directly:
81
+
82
+ ```ts
83
+ player.injectFrame({
84
+ messageId: 'frame-1',
85
+ frame: { tick: 1, entities: {} },
86
+ });
87
+ ```