@typeonce/ritmo 0.7.0 → 0.9.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 +3 -2
- package/dist/Clock.d.ts +19 -4
- package/dist/Clock.d.ts.map +1 -1
- package/dist/Clock.js +18 -2
- package/dist/Clock.js.map +1 -1
- package/dist/Command.d.ts +181 -40
- package/dist/Command.d.ts.map +1 -1
- package/dist/Command.js +31 -11
- package/dist/Command.js.map +1 -1
- package/dist/Condition.d.ts +12 -1
- package/dist/Condition.d.ts.map +1 -1
- package/dist/Condition.js.map +1 -1
- package/dist/Debug.d.ts +127 -13
- package/dist/Debug.d.ts.map +1 -1
- package/dist/Descriptor.d.ts +61 -10
- package/dist/Descriptor.d.ts.map +1 -1
- package/dist/Descriptor.js +22 -10
- package/dist/Descriptor.js.map +1 -1
- package/dist/Entity.d.ts +22 -7
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js.map +1 -1
- package/dist/EntityScope.d.ts +20 -1
- package/dist/EntityScope.d.ts.map +1 -1
- package/dist/EntityScope.js +8 -2
- package/dist/EntityScope.js.map +1 -1
- package/dist/FixedLoop.d.ts +106 -0
- package/dist/FixedLoop.d.ts.map +1 -0
- package/dist/FixedLoop.js +97 -0
- package/dist/FixedLoop.js.map +1 -0
- package/dist/HostClock.d.ts +1 -1
- package/dist/HostClock.d.ts.map +1 -1
- package/dist/HostClock.js +2 -1
- package/dist/HostClock.js.map +1 -1
- package/dist/Machine.d.ts +59 -34
- package/dist/Machine.d.ts.map +1 -1
- package/dist/Machine.js +10 -3
- package/dist/Machine.js.map +1 -1
- package/dist/Query.d.ts +100 -14
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +34 -5
- package/dist/Query.js.map +1 -1
- package/dist/Relation.d.ts +5 -14
- package/dist/Relation.d.ts.map +1 -1
- package/dist/Relation.js +0 -32
- package/dist/Relation.js.map +1 -1
- package/dist/Runtime.d.ts +61 -15
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +594 -70
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +24 -15
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +2 -1
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +233 -48
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +33 -7
- package/dist/Schema.js.map +1 -1
- package/dist/Snapshot.d.ts +90 -1
- package/dist/Snapshot.d.ts.map +1 -1
- package/dist/Snapshot.js +42 -1
- package/dist/Snapshot.js.map +1 -1
- package/dist/System.d.ts +132 -31
- package/dist/System.d.ts.map +1 -1
- package/dist/System.js +32 -0
- package/dist/System.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +2 -0
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +34 -8
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/debug.d.ts +10 -0
- package/dist/internal/debug.d.ts.map +1 -1
- package/dist/internal/debug.js +171 -12
- package/dist/internal/debug.js.map +1 -1
- package/dist/internal/equal.d.ts +8 -0
- package/dist/internal/equal.d.ts.map +1 -0
- package/dist/internal/equal.js +38 -0
- package/dist/internal/equal.js.map +1 -0
- package/dist/internal/fragments.d.ts +2 -6
- package/dist/internal/fragments.d.ts.map +1 -1
- package/dist/internal/fragments.js +36 -3
- package/dist/internal/fragments.js.map +1 -1
- package/dist/internal/game.d.ts +2 -0
- package/dist/internal/game.d.ts.map +1 -1
- package/dist/internal/game.js +48 -7
- package/dist/internal/game.js.map +1 -1
- package/dist/internal/order.d.ts.map +1 -1
- package/dist/internal/order.js +4 -2
- package/dist/internal/order.js.map +1 -1
- package/dist/internal/queries.d.ts.map +1 -1
- package/dist/internal/queries.js +57 -26
- package/dist/internal/queries.js.map +1 -1
- package/dist/internal/relations.d.ts +10 -0
- package/dist/internal/relations.d.ts.map +1 -0
- package/dist/internal/relations.js +32 -0
- package/dist/internal/relations.js.map +1 -0
- package/dist/internal/requirements.d.ts +26 -0
- package/dist/internal/requirements.d.ts.map +1 -0
- package/dist/internal/requirements.js +46 -0
- package/dist/internal/requirements.js.map +1 -0
- package/dist/internal/streams.d.ts +2 -0
- package/dist/internal/streams.d.ts.map +1 -1
- package/dist/internal/streams.js +10 -0
- package/dist/internal/streams.js.map +1 -1
- package/dist/internal/world.d.ts +7 -1
- package/dist/internal/world.d.ts.map +1 -1
- package/dist/internal/world.js +53 -3
- package/dist/internal/world.js.map +1 -1
- package/package.json +1 -1
- package/src/Clock.ts +29 -4
- package/src/Command.ts +281 -67
- package/src/Condition.ts +17 -1
- package/src/Debug.ts +124 -15
- package/src/Descriptor.ts +92 -21
- package/src/Entity.ts +23 -7
- package/src/EntityScope.ts +21 -2
- package/src/FixedLoop.ts +218 -0
- package/src/HostClock.ts +2 -1
- package/src/Machine.ts +72 -35
- package/src/Query.ts +118 -17
- package/src/Relation.ts +5 -67
- package/src/Runtime.ts +659 -85
- package/src/Schedule.ts +31 -19
- package/src/Schema.ts +297 -57
- package/src/Snapshot.ts +94 -2
- package/src/System.ts +151 -29
- package/src/index.ts +4 -0
- package/src/internal/cells.ts +42 -10
- package/src/internal/debug.ts +179 -14
- package/src/internal/equal.ts +31 -0
- package/src/internal/fragments.ts +35 -5
- package/src/internal/game.ts +69 -7
- package/src/internal/order.ts +8 -4
- package/src/internal/queries.ts +62 -12
- package/src/internal/relations.ts +52 -0
- package/src/internal/requirements.ts +71 -0
- package/src/internal/streams.ts +11 -0
- package/src/internal/world.ts +60 -4
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ pnpm add @typeonce/ritmo
|
|
|
14
14
|
```ts
|
|
15
15
|
import { Descriptor, Schema } from "@typeonce/ritmo"
|
|
16
16
|
|
|
17
|
-
const Position = Descriptor.Component<{ x: number; y: number }>()("Position")
|
|
17
|
+
const Position = Descriptor.Component<{ x: number; y: number }>()("Example/Position")
|
|
18
18
|
const Game = Schema.bind(Schema.fragment({ components: { Position } }))
|
|
19
19
|
```
|
|
20
20
|
|
|
@@ -23,9 +23,10 @@ Modules are also importable by path, for example `@typeonce/ritmo/Result`.
|
|
|
23
23
|
Related packages, released together with the same version:
|
|
24
24
|
|
|
25
25
|
- [`@typeonce/ritmo-math`](https://www.npmjs.com/package/@typeonce/ritmo-math): validated vectors, sizes, and bounding boxes
|
|
26
|
-
- [`@typeonce/ritmo-browser`](https://www.npmjs.com/package/@typeonce/ritmo-browser): fixed-step loop and
|
|
26
|
+
- [`@typeonce/ritmo-browser`](https://www.npmjs.com/package/@typeonce/ritmo-browser): animation-frame ticks for the fixed-step loop, keyboard, pointer, and touch input
|
|
27
27
|
- [`@typeonce/ritmo-render`](https://www.npmjs.com/package/@typeonce/ritmo-render): entity-to-node sync for any renderer
|
|
28
28
|
- [`@typeonce/ritmo-pixi`](https://www.npmjs.com/package/@typeonce/ritmo-pixi): Pixi container adapter for the render-node registry
|
|
29
29
|
- [`@typeonce/ritmo-devtools`](https://www.npmjs.com/package/@typeonce/ritmo-devtools): headless debug sessions and trace reports
|
|
30
|
+
- [`@typeonce/oxlint-plugin-ritmo`](https://www.npmjs.com/package/@typeonce/oxlint-plugin-ritmo): oxlint rules that keep simulation code deterministic and headless
|
|
30
31
|
|
|
31
32
|
Source: https://github.com/typeonce-dev/ritmo
|
package/dist/Clock.d.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* - `Clock.system(Game, { name, resource, hold })` advances it every tick:
|
|
10
10
|
* `step + 1` and `dt = 1/hz`, or `dt = 0` while a `hold` condition passes.
|
|
11
11
|
* - `Clock.duration(step, 0.5)` is a span in whole steps; `Clock.every(t, d)`
|
|
12
|
-
* is true on the step each period begins
|
|
12
|
+
* is true on the step each period begins after the start (steps `d`,
|
|
13
|
+
* `2d`, ...); `Clock.elapsed(t)` is exact.
|
|
13
14
|
*
|
|
14
15
|
* Time is counted in steps, never accumulated in floating point: elapsed
|
|
15
16
|
* seconds are `step / hz`.
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
* const Time = Clock.resource("Game/Time", step)
|
|
21
22
|
* const Game = Schema.bind(Schema.fragment({ resources: { Time } }))
|
|
22
23
|
* const AdvanceTime = Clock.system(Game, { name: "Game/AdvanceTime", resource: Time, hold: [paused] })
|
|
23
|
-
* const runtime = Game.Runtime.make({ services, resources: { Time: Clock.start(step) } })
|
|
24
|
+
* const runtime = Game.Runtime.make({ services, resources: { Time: Clock.start(step) } }).value
|
|
24
25
|
* ```
|
|
25
26
|
*
|
|
26
27
|
* @module Clock
|
|
@@ -170,16 +171,30 @@ export type ValidDuration<Hz extends number, Seconds extends number> = number ex
|
|
|
170
171
|
* rounded to the nearest whole step (half up), so `Clock.duration(Clock.hz(60), 0.025)`
|
|
171
172
|
* is 2 steps (1.5 rounds up). Shorter than one step is a compile error
|
|
172
173
|
* ("0.001s is shorter than one step (1/60s)"). For seconds read from data,
|
|
173
|
-
* use `durationRaw`.
|
|
174
|
+
* use `durationRaw`; for a count of steps, `durationOfSteps`.
|
|
174
175
|
*/
|
|
175
176
|
export declare const duration: <Hz extends number, const Seconds extends number>(step: Step<Hz>, seconds: ValidDuration<Hz, Seconds>) => Duration<Hz>;
|
|
176
177
|
/** Seconds from data as whole steps of `step`, the same rules as `duration`, as a `Result`. */
|
|
177
178
|
export declare const durationRaw: <Hz extends number>(step: Step<Hz>, seconds: number) => Result.Result<Duration<Hz>, InvalidDuration>;
|
|
179
|
+
type StepsMessage = "Clock.durationOfSteps needs a positive whole number of steps";
|
|
180
|
+
/** `N` when it is a positive whole number (or a computed `number`); otherwise the message. */
|
|
181
|
+
export type ValidSteps<N extends number> = number extends N ? N : `${N}` extends `-${string}` | `${string}.${string}` | `${string}e${string}` | "0" ? StepsMessage : N;
|
|
182
|
+
/**
|
|
183
|
+
* A whole number of steps of `step` as a duration: `Clock.durationOfSteps(Clock.hz(60), 3)`.
|
|
184
|
+
* Use it when the length is counted in steps (an animation of 3 frames, a
|
|
185
|
+
* cooldown stored as steps); use `duration` for literal seconds and
|
|
186
|
+
* `durationRaw` for seconds from data. A count cannot round, so nothing can
|
|
187
|
+
* fail for a positive whole number: a literal zero, negative, or fraction is
|
|
188
|
+
* a compile error, and a computed one throws.
|
|
189
|
+
*/
|
|
190
|
+
export declare const durationOfSteps: <Hz extends number, const N extends number>(step: Step<Hz>, steps: ValidSteps<N>) => Duration<Hz>;
|
|
178
191
|
/** The whole steps a duration spans. */
|
|
179
192
|
export declare const steps: (duration: Duration) => number;
|
|
180
193
|
/**
|
|
181
194
|
* Whether a period of `duration` begins on this tick: the clock advanced
|
|
182
|
-
* (not held) to a step that is a multiple of the period. False while held
|
|
195
|
+
* (not held) to a step that is a multiple of the period. False while held,
|
|
196
|
+
* and on the first step (0), which no advance reached: the first period
|
|
197
|
+
* begins at step `duration`.
|
|
183
198
|
*/
|
|
184
199
|
export declare const every: <Hz extends number>(time: Time<Hz>, duration: Duration<NoInfer<Hz>>) => boolean;
|
|
185
200
|
export {};
|
package/dist/Clock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clock.d.ts","sourceRoot":"","sources":["../src/Clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,gBAAgB,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,QAAQ,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAI1C,OAAO,CA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AAE,eAAe,CAG3H,CAAA;AAED,KAAK,YAAY,GAAG,8DAA8D,CAAA;AAElF,8FAA8F;AAC9F,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,IACrC,MAAM,SAAS,CAAC,GAAG,CAAC,GAClB,GAAG,CAAC,EAAE,SAAS,IAAI,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,GAAG,GAAG,GAAG,YAAY,GAChG,CAAC,CAAA;AAEL;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,EAAE,SAAS,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,QAAQ,IAAI,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,KAAG,QAAQ,CAAC,EAAE,CAI5H,CAAA;AAED,wCAAwC;AACxC,eAAO,MAAM,KAAK,aAAc,QAAQ,KAAG,MAAwB,CAAA;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAAI,EAAE,SAAS,MAAM,QAAQ,IAAI,CAAC,EAAE,CAAC,YAAY,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAG,OAC1C,CAAA"}
|
package/dist/Clock.js
CHANGED
|
@@ -88,7 +88,7 @@ const stepsOf = (hz, seconds) => {
|
|
|
88
88
|
* rounded to the nearest whole step (half up), so `Clock.duration(Clock.hz(60), 0.025)`
|
|
89
89
|
* is 2 steps (1.5 rounds up). Shorter than one step is a compile error
|
|
90
90
|
* ("0.001s is shorter than one step (1/60s)"). For seconds read from data,
|
|
91
|
-
* use `durationRaw`.
|
|
91
|
+
* use `durationRaw`; for a count of steps, `durationOfSteps`.
|
|
92
92
|
*/
|
|
93
93
|
export const duration = (step, seconds) => {
|
|
94
94
|
const steps = stepsOf(step.hz, seconds);
|
|
@@ -101,11 +101,27 @@ export const durationRaw = (step, seconds) => {
|
|
|
101
101
|
const steps = stepsOf(step.hz, seconds);
|
|
102
102
|
return steps.ok ? Result.success({ kind: "ClockDuration", steps: steps.value, hz: step.hz }) : steps;
|
|
103
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* A whole number of steps of `step` as a duration: `Clock.durationOfSteps(Clock.hz(60), 3)`.
|
|
106
|
+
* Use it when the length is counted in steps (an animation of 3 frames, a
|
|
107
|
+
* cooldown stored as steps); use `duration` for literal seconds and
|
|
108
|
+
* `durationRaw` for seconds from data. A count cannot round, so nothing can
|
|
109
|
+
* fail for a positive whole number: a literal zero, negative, or fraction is
|
|
110
|
+
* a compile error, and a computed one throws.
|
|
111
|
+
*/
|
|
112
|
+
export const durationOfSteps = (step, steps) => {
|
|
113
|
+
const count = steps;
|
|
114
|
+
if (!Number.isSafeInteger(count) || count <= 0)
|
|
115
|
+
throw new Error(`Clock.durationOfSteps needs a positive whole number of steps, got ${count}`);
|
|
116
|
+
return { kind: "ClockDuration", steps: count, hz: step.hz };
|
|
117
|
+
};
|
|
104
118
|
/** The whole steps a duration spans. */
|
|
105
119
|
export const steps = (duration) => duration.steps;
|
|
106
120
|
/**
|
|
107
121
|
* Whether a period of `duration` begins on this tick: the clock advanced
|
|
108
|
-
* (not held) to a step that is a multiple of the period. False while held
|
|
122
|
+
* (not held) to a step that is a multiple of the period. False while held,
|
|
123
|
+
* and on the first step (0), which no advance reached: the first period
|
|
124
|
+
* begins at step `duration`.
|
|
109
125
|
*/
|
|
110
126
|
export const every = (time, duration) => time.dt > 0 && time.step % duration.steps === 0;
|
|
111
127
|
//# sourceMappingURL=Clock.js.map
|
package/dist/Clock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Clock.js","sourceRoot":"","sources":["../src/Clock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Clock.js","sourceRoot":"","sources":["../src/Clock.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,gBAAgB,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,MAAM,MAAM,aAAa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AG,QAAQ,CAAC,KAAK,KAAK,CAAC,CAAA"}
|
package/dist/Command.d.ts
CHANGED
|
@@ -65,7 +65,8 @@ import * as Entity from "./Entity.ts";
|
|
|
65
65
|
import type * as EntityScope from "./EntityScope.ts";
|
|
66
66
|
import type * as Relation from "./Relation.ts";
|
|
67
67
|
import * as Result from "./Result.ts";
|
|
68
|
-
import type {
|
|
68
|
+
import type { ReadonlyValue } from "./Query.ts";
|
|
69
|
+
import type { RequirementPair, Schema } from "./Schema.ts";
|
|
69
70
|
/**
|
|
70
71
|
* Type-level helpers for staged entity construction.
|
|
71
72
|
*
|
|
@@ -90,7 +91,7 @@ export declare namespace Draft {
|
|
|
90
91
|
/**
|
|
91
92
|
* A typed descriptor/value pair used by the flat command authoring APIs.
|
|
92
93
|
*/
|
|
93
|
-
export type Entry<D extends Descriptor<"component", string, any>> = readonly [D, Descriptor.Value<D
|
|
94
|
+
export type Entry<D extends Descriptor<"component", string, any>> = readonly [D, ReadonlyValue<Descriptor.Value<D>>];
|
|
94
95
|
/**
|
|
95
96
|
* Extracts the component-descriptor union from a schema.
|
|
96
97
|
*/
|
|
@@ -117,10 +118,13 @@ type EntryValue<T> = [
|
|
|
117
118
|
/**
|
|
118
119
|
* Folds entries into the component proof of the resulting draft.
|
|
119
120
|
*/
|
|
120
|
-
export type FoldEntries<Entries extends ReadonlyArray<SpawnEntry<any>>, P extends Entity.ComponentProof = {}> =
|
|
121
|
+
export type FoldEntries<Entries extends ReadonlyArray<SpawnEntry<any>>, P extends Entity.ComponentProof = {}> = Entries extends readonly [
|
|
121
122
|
infer Head extends SpawnEntry<any>,
|
|
122
|
-
...infer Tail extends
|
|
123
|
-
] ? FoldEntries<Tail, Draft.InsertEntry<P, EntryValue<Head>>> :
|
|
123
|
+
...infer Tail extends ReadonlyArray<SpawnEntry<any>>
|
|
124
|
+
] ? FoldEntries<Tail, Draft.InsertEntry<P, EntryValue<Head>>> : Entries extends readonly [
|
|
125
|
+
...infer Init extends ReadonlyArray<SpawnEntry<any>>,
|
|
126
|
+
infer Last extends SpawnEntry<any>
|
|
127
|
+
] ? FoldEntries<Init, Draft.InsertEntry<P, EntryValue<Last>>> : number extends Entries["length"] ? P & MaybeEntries<EntryValue<Entries[number]>> : P;
|
|
124
128
|
/** The proof of entries that may each be present: every component they can hold, optional. */
|
|
125
129
|
type MaybeEntries<Entry> = {
|
|
126
130
|
readonly [E in Entry as E extends readonly [infer D extends Descriptor<"component", string, any>, unknown] ? Descriptor.Name<D> : never]?: E extends readonly [infer D extends Descriptor<"component", string, any>, unknown] ? Descriptor.Value<D> : never;
|
|
@@ -136,9 +140,9 @@ export type EntryErrors<Entries extends ReadonlyArray<SpawnEntry<any>>> = {
|
|
|
136
140
|
* The draft produced from `Entries`, wrapped in a `Result` exactly when at
|
|
137
141
|
* least one entry is a `Result` and can therefore fail.
|
|
138
142
|
*/
|
|
139
|
-
export type DraftFor<S extends Schema.Any, Entries extends ReadonlyArray<SpawnEntry<S>>, P extends Entity.ComponentProof, Root> = [Extract<Entries[number], {
|
|
143
|
+
export type DraftFor<S extends Schema.Any, Entries extends ReadonlyArray<SpawnEntry<S>>, P extends Entity.ComponentProof, Root, Relates = never> = [Extract<Entries[number], {
|
|
140
144
|
readonly ok: boolean;
|
|
141
|
-
}>] extends [never] ? Entity.EntityDraft<S, FoldEntries<Entries, P>, Root> : Result.Result<Entity.EntityDraft<S, FoldEntries<Entries, P>, Root>, EntryErrors<Entries>>;
|
|
145
|
+
}>] extends [never] ? Entity.EntityDraft<S, FoldEntries<Entries, P>, Root, Relates> : Result.Result<Entity.EntityDraft<S, FoldEntries<Entries, P>, Root, Relates>, EntryErrors<Entries>>;
|
|
142
146
|
/**
|
|
143
147
|
* A deferred world mutation.
|
|
144
148
|
*
|
|
@@ -164,9 +168,10 @@ export type DeferredCommand<S extends Schema.Any> = {
|
|
|
164
168
|
export interface InternalWorld<S extends Schema.Any> {
|
|
165
169
|
/**
|
|
166
170
|
* Creates the entity for an id reserved by `commands.spawn(...)` with its
|
|
167
|
-
* staged components.
|
|
171
|
+
* staged components. Returns `false`, creating nothing, when the
|
|
172
|
+
* components break a `Schema.requires` requirement.
|
|
168
173
|
*/
|
|
169
|
-
readonly spawnEntity: (id: Entity.EntityId<S, any>, components: ReadonlyArray<Entity.StagedComponent>) =>
|
|
174
|
+
readonly spawnEntity: (id: Entity.EntityId<S, any>, components: ReadonlyArray<Entity.StagedComponent>) => boolean;
|
|
170
175
|
/**
|
|
171
176
|
* Removes an entity and its outgoing and incoming relations.
|
|
172
177
|
*/
|
|
@@ -180,13 +185,21 @@ export interface InternalWorld<S extends Schema.Any> {
|
|
|
180
185
|
*/
|
|
181
186
|
readonly destroyEntityScope: (scope: EntityScope.EntityScope.Any) => void;
|
|
182
187
|
/**
|
|
183
|
-
* Removes
|
|
188
|
+
* Removes components from a live entity, all or none: nothing is removed
|
|
189
|
+
* when that would leave a component without one it requires.
|
|
184
190
|
*/
|
|
185
|
-
readonly
|
|
191
|
+
readonly removeComponents: (id: Entity.EntityId<S, any>, descriptors: ReadonlyArray<Descriptor<"component", string, any>>) => void;
|
|
186
192
|
/**
|
|
187
|
-
* Inserts or replaces
|
|
193
|
+
* Inserts or replaces components on a live entity, all or none: nothing is
|
|
194
|
+
* written when an inserted component would miss one it requires.
|
|
188
195
|
*/
|
|
189
|
-
readonly
|
|
196
|
+
readonly insertComponents: (id: Entity.EntityId<S, any>, entries: ReadonlyArray<Entity.StagedComponent>) => void;
|
|
197
|
+
/**
|
|
198
|
+
* Reports a `despawn` or `remove` given a numeric id this run did not
|
|
199
|
+
* spawn: an id kept from an earlier run, or a raw id that erased types let
|
|
200
|
+
* through. The command is skipped.
|
|
201
|
+
*/
|
|
202
|
+
readonly reportStaleTarget: (command: "despawn" | "remove", id: Entity.EntityId<S, any>) => void;
|
|
190
203
|
/**
|
|
191
204
|
* Attempts to attach one relation edge between two live entities.
|
|
192
205
|
*/
|
|
@@ -203,10 +216,11 @@ export interface InternalWorld<S extends Schema.Any> {
|
|
|
203
216
|
/**
|
|
204
217
|
* Creates a typed component entry.
|
|
205
218
|
*/
|
|
206
|
-
export declare const entry: <D extends Descriptor<"component", string, any>>(descriptor: D, value: Descriptor.Value<D
|
|
219
|
+
export declare const entry: <D extends Descriptor<"component", string, any>>(descriptor: D, value: ReadonlyValue<Descriptor.Value<D>>) => Entry<D>;
|
|
207
220
|
/**
|
|
208
221
|
* Validates raw input through a constructed descriptor's own validator and
|
|
209
|
-
* returns an entry result for `spawn(...)` / `
|
|
222
|
+
* returns an entry result for `Game.Command.spawn(...)` / `extend(...)`.
|
|
223
|
+
* `commands.insert` takes valid entries only: check the result first.
|
|
210
224
|
*
|
|
211
225
|
* This is the one way to put unvalidated data on an entity: the descriptor
|
|
212
226
|
* owns its validator (`Descriptor.ConstructedComponent(...)`, built with
|
|
@@ -234,13 +248,13 @@ export declare const entryRaw: <D extends DescriptorModule.ConstructedDescriptor
|
|
|
234
248
|
* Use this while building what a spawn will hold. Use `commands.insert` to
|
|
235
249
|
* add or replace components on an entity that already exists.
|
|
236
250
|
*/
|
|
237
|
-
export declare const extend: <S extends Schema.Any, P extends Entity.ComponentProof, Root, const Entries extends ReadonlyArray<SpawnEntry<S
|
|
251
|
+
export declare const extend: <S extends Schema.Any, P extends Entity.ComponentProof, Root, const Entries extends ReadonlyArray<SpawnEntry<S>>, Relates = never>(draft: Entity.EntityDraft<S, P, Root, Relates>, ...entries: Entries) => DraftFor<S, Entries, P, Root, Relates>;
|
|
238
252
|
/**
|
|
239
253
|
* Starts a staged entity from component entries.
|
|
240
254
|
*
|
|
241
255
|
* Drafts are plain values: build them anywhere (including small factories),
|
|
242
256
|
* then queue them with `commands.spawn(...)`. Entries may be `[Descriptor,
|
|
243
|
-
* value]` pairs or results from `entryRaw(...)`; see `
|
|
257
|
+
* value]` pairs or results from `entryRaw(...)`; see `extend(...)` for how
|
|
244
258
|
* failures are reported.
|
|
245
259
|
*
|
|
246
260
|
* @example
|
|
@@ -258,7 +272,7 @@ export declare const spawn: <S extends Schema.Any, Root = unknown, const Entries
|
|
|
258
272
|
* Drafts stay pure: this only records intent so the runtime can attempt to
|
|
259
273
|
* attach the relation when the spawn command is applied.
|
|
260
274
|
*/
|
|
261
|
-
export declare const relate: <S extends Schema.Any, P extends Entity.ComponentProof, R extends Relation.Relation.Any, Root = unknown>(draft: Entity.EntityDraft<S, P, Root>, relation: R, target: Entity.EntityId<S, Root>) => Entity.EntityDraft<S, P, Root>;
|
|
275
|
+
export declare const relate: <S extends Schema.Any, P extends Entity.ComponentProof, R extends Relation.Relation.Any, Root = unknown, Relates = never>(draft: Entity.EntityDraft<S, P, Root, Relates>, relation: R, target: Entity.EntityId<S, Root>) => Entity.EntityDraft<S, P, Root, Relates | R>;
|
|
262
276
|
/** One permission of `Game.System.commands(...)`: a kind of command, and what it may touch. */
|
|
263
277
|
export interface Permission<out Kind extends PermissionKind, out Value> {
|
|
264
278
|
readonly permission: Kind;
|
|
@@ -270,25 +284,25 @@ type ComponentDescriptor = Descriptor<"component", string, any>;
|
|
|
270
284
|
* Allows `spawn` / `spawnIn` of drafts whose components are all among `components`.
|
|
271
285
|
* Use it for entities the system creates; use `extend` on a draft to build one.
|
|
272
286
|
*/
|
|
273
|
-
export declare const spawns: <const Components extends ReadonlyArray<ComponentDescriptor
|
|
287
|
+
export declare const spawns: <const Components extends readonly [ComponentDescriptor, ...ReadonlyArray<ComponentDescriptor>]>(...components: Components) => Permission<"spawns", Components[number]>;
|
|
274
288
|
/**
|
|
275
289
|
* Allows `insert(entity, [X, value])` with `X` among `components`: add or
|
|
276
290
|
* replace at the next `applyDeferred()`. To change a value now, on an entity
|
|
277
291
|
* you matched, write through a query (`Game.Query.write`) instead.
|
|
278
292
|
*/
|
|
279
|
-
export declare const inserts: <const Components extends ReadonlyArray<ComponentDescriptor
|
|
293
|
+
export declare const inserts: <const Components extends readonly [ComponentDescriptor, ...ReadonlyArray<ComponentDescriptor>]>(...components: Components) => Permission<"inserts", Components[number]>;
|
|
280
294
|
/** Allows `remove(entity, X)` with `X` among `components`. */
|
|
281
|
-
export declare const removes: <const Components extends ReadonlyArray<ComponentDescriptor
|
|
295
|
+
export declare const removes: <const Components extends readonly [ComponentDescriptor, ...ReadonlyArray<ComponentDescriptor>]>(...components: Components) => Permission<"removes", Components[number]>;
|
|
282
296
|
/**
|
|
283
297
|
* Allows `despawn(entity)` where `entity` comes from a query match proving one
|
|
284
298
|
* of `components` (`match.entity`), never a raw id: the system can only
|
|
285
299
|
* despawn what it has proven is, for example, an `Enemy`.
|
|
286
300
|
*/
|
|
287
|
-
export declare const despawns: <const Components extends ReadonlyArray<ComponentDescriptor
|
|
301
|
+
export declare const despawns: <const Components extends readonly [ComponentDescriptor, ...ReadonlyArray<ComponentDescriptor>]>(...components: Components) => Permission<"despawns", Components[number]>;
|
|
288
302
|
/** Allows `despawnScope(scope)` for this scope. */
|
|
289
303
|
export declare const despawnsScope: <const Scope extends EntityScope.EntityScope.Any>(scope: Scope) => Permission<"despawnsScope", Scope>;
|
|
290
304
|
/** Allows `relate`, `unrelate`, and `reorderChildren` for these relations. */
|
|
291
|
-
export declare const relates: <const Relations extends ReadonlyArray<Relation.Relation.Any
|
|
305
|
+
export declare const relates: <const Relations extends readonly [Relation.Relation.Any, ...ReadonlyArray<Relation.Relation.Any>]>(...relations: Relations) => Permission<"relates", Relations[number]>;
|
|
292
306
|
type PermissionValue<Permissions, Kind extends PermissionKind> = Permissions extends Permission<Kind, infer Value> ? Value : never;
|
|
293
307
|
/**
|
|
294
308
|
* The commands a system may queue, declared in its spec as
|
|
@@ -317,6 +331,10 @@ type Names<D> = D extends {
|
|
|
317
331
|
} ? Name : never;
|
|
318
332
|
/** Every key of every member of a union of proofs (a draft with a conditional entry is a union). */
|
|
319
333
|
type AllKeys<P> = P extends unknown ? keyof P & string : never;
|
|
334
|
+
/** Relations staged on a draft need `relates`, like `commands.relate`. */
|
|
335
|
+
type DraftRelationsAllowed<Relates, Declared> = [
|
|
336
|
+
Exclude<Relates, Declared>
|
|
337
|
+
] extends [never] ? unknown : Fix<`${Names<Exclude<Relates, Declared>>} is related by this draft but not declared in this system's commands: add it to Game.System.relates(...)`>;
|
|
320
338
|
type DraftAllowed<P, Spawns> = [
|
|
321
339
|
Exclude<AllKeys<P>, Names<Spawns>>
|
|
322
340
|
] extends [never] ? unknown : Fix<`${Exclude<AllKeys<P>, Names<Spawns>>} is not declared in this system's commands: add it to Game.System.spawns(...)`>;
|
|
@@ -326,22 +344,121 @@ type EntriesAllowed<Entries extends ReadonlyArray<readonly [ComponentDescriptor,
|
|
|
326
344
|
type RemoveAllowed<D, Removes> = [
|
|
327
345
|
D
|
|
328
346
|
] extends [Removes] ? unknown : Fix<`${Names<D>} is not declared in this system's commands: add it to Game.System.removes(...)`>;
|
|
329
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Why each possible target of a despawn is not allowed (`never` when it is).
|
|
349
|
+
* Computed per member, so a target chosen from several queries
|
|
350
|
+
* (`cond ? a.entity : b.entity`) must pass for every one of them.
|
|
351
|
+
*/
|
|
352
|
+
type DespawnRejections<E, Despawns> = E extends {
|
|
330
353
|
readonly kind: "EntityRef" | "EntityMut";
|
|
331
|
-
readonly __proves?: (_:
|
|
332
|
-
} ? [Extract<Proves, Despawns>] extends [never] ?
|
|
354
|
+
readonly __proves?: (_: infer Proves) => void;
|
|
355
|
+
} ? [Extract<Proves, Despawns>] extends [never] ? `despawn needs an entity from a query proving ${Names<Despawns>} (declared in despawns)` : never : E extends {
|
|
333
356
|
readonly [spawnedTypeId]: (_: never) => infer Spawned;
|
|
334
|
-
} ? [Extract<Spawned, Names<Despawns>>] extends [never] ?
|
|
357
|
+
} ? [Extract<Spawned, Names<Despawns>>] extends [never] ? `despawn needs an entity spawned with ${Names<Despawns>} (declared in despawns)` : never : `despawn needs an entity from a query proving ${Names<Despawns>} (declared in despawns), not a raw id: pass match.entity`;
|
|
358
|
+
type DespawnAllowed<E, Despawns> = [
|
|
359
|
+
DespawnRejections<E, Despawns>
|
|
360
|
+
] extends [never] ? unknown : Fix<DespawnRejections<E, Despawns>>;
|
|
335
361
|
declare const spawnedTypeId: unique symbol;
|
|
336
362
|
/**
|
|
337
363
|
* The id `spawn` / `spawnIn` return: an `EntityId` that also records the
|
|
338
364
|
* components its draft holds in every case, so the system that queued it can
|
|
339
365
|
* `despawn` it before the next `applyDeferred()` (no query can match it yet).
|
|
366
|
+
* It is valid only in the run that spawned it: kept in a closure or a
|
|
367
|
+
* resource and passed to `despawn` / `remove` in a later run, the command is
|
|
368
|
+
* skipped and reported (the `stale-target` lint). Keep the entity id or a
|
|
369
|
+
* handle and resolve it again through a query instead.
|
|
340
370
|
* Stored as a plain `EntityId`, it is a raw id again.
|
|
341
371
|
*/
|
|
342
372
|
export type SpawnedId<S extends Schema.Any, Root, Components extends string> = Entity.EntityId<S, Root> & {
|
|
343
373
|
readonly [spawnedTypeId]: (_: never) => Components;
|
|
344
374
|
};
|
|
375
|
+
/** One message per missing requirement: `"Player requires Velocity"`. */
|
|
376
|
+
type MissingMessages<Pairs> = Pairs extends readonly [infer From extends string, infer To extends string] ? `${From} requires ${To}` : never;
|
|
377
|
+
/** The requirements (`[requirer, required]`) of the components in `From` that `Held` lacks. */
|
|
378
|
+
type MissingPairsFrom<S extends Schema.Any, From extends string, Held extends string> = Extract<Schema.Requires<S>, readonly [From, string]> extends infer Pair ? Pair extends readonly [string, infer To extends string] ? To extends Held ? never : Pair : never : never;
|
|
379
|
+
/**
|
|
380
|
+
* The requirements a draft may break. A draft's proof is a union of
|
|
381
|
+
* alternatives when an entry is conditional, and has optional keys for
|
|
382
|
+
* spread entries: in each alternative, every component it may hold needs
|
|
383
|
+
* every component it requires surely held. Direct requirements are enough:
|
|
384
|
+
* each required component must be held too, with its own requirements.
|
|
385
|
+
*/
|
|
386
|
+
type DraftViolations<S extends Schema.Any, P> = P extends unknown ? MissingPairsFrom<S, keyof P & string, RequiredKeys<P>> : never;
|
|
387
|
+
type DraftRequirementsMet<S extends Schema.Any, P> = [
|
|
388
|
+
DraftViolations<S, P>
|
|
389
|
+
] extends [never] ? unknown : Fix<`${MissingMessages<DraftViolations<S, P>>}: add the missing entries to the draft`>;
|
|
390
|
+
/** What one possible target holds: a query match's proof, or a `SpawnedId`'s draft. A raw id proves nothing. */
|
|
391
|
+
type HeldBy<E> = E extends {
|
|
392
|
+
readonly kind: "EntityRef" | "EntityMut";
|
|
393
|
+
readonly __proves?: (_: infer Proves) => void;
|
|
394
|
+
} ? Names<Proves> : E extends {
|
|
395
|
+
readonly [spawnedTypeId]: (_: never) => infer Spawned extends string;
|
|
396
|
+
} ? Spawned : never;
|
|
397
|
+
/** What one possible target's query proves absent: its `without`. */
|
|
398
|
+
type LackedBy<E> = E extends {
|
|
399
|
+
readonly kind: "EntityRef" | "EntityMut";
|
|
400
|
+
readonly __lacks?: (_: infer Lacks) => void;
|
|
401
|
+
} ? Names<Lacks> : never;
|
|
402
|
+
/** The names in `All` that some member of `E` does not hold (or lack). */
|
|
403
|
+
type MissingFromHeld<E, All> = E extends unknown ? Exclude<All, HeldBy<E>> : never;
|
|
404
|
+
type MissingFromLacked<E, All> = E extends unknown ? Exclude<All, LackedBy<E>> : never;
|
|
405
|
+
/**
|
|
406
|
+
* What an insert or remove target is known to hold. For a target chosen
|
|
407
|
+
* from several queries (`cond ? a.entity : b.entity`), only what every one
|
|
408
|
+
* of them proves.
|
|
409
|
+
*/
|
|
410
|
+
type TargetHolds<E> = Exclude<HeldBy<E>, MissingFromHeld<E, HeldBy<E>>>;
|
|
411
|
+
/** What a remove target is known to lack: its query's `without` (for several queries, what all of them exclude). */
|
|
412
|
+
type TargetLacks<E> = Exclude<LackedBy<E>, MissingFromLacked<E, LackedBy<E>>>;
|
|
413
|
+
type EntryNames<Entries extends ReadonlyArray<readonly [ComponentDescriptor, unknown]>> = Names<Entries[number][0]>;
|
|
414
|
+
/** The names one entry surely holds: none when it is conditional between descriptors. */
|
|
415
|
+
type SureEntryNames<Entry, All extends string = EntryNamesOf<Entry>> = Exclude<All, Entry extends unknown ? Exclude<All, EntryNamesOf<Entry>> : never>;
|
|
416
|
+
type EntryNamesOf<Entry> = Entry extends readonly [infer D, unknown] ? Names<D> : never;
|
|
417
|
+
/** The names surely inserted: fixed entries, not spread or conditional ones. */
|
|
418
|
+
type SurelyInserted<Entries> = Entries extends readonly [infer Head, ...infer Tail] ? SureEntryNames<Head> | SurelyInserted<Tail> : Entries extends readonly [...infer Init, infer Last] ? SureEntryNames<Last> | SurelyInserted<Init> : never;
|
|
419
|
+
/**
|
|
420
|
+
* Inserted components (any entry may be one) with requirements neither
|
|
421
|
+
* surely inserted alongside nor proven held by the target.
|
|
422
|
+
*/
|
|
423
|
+
type InsertViolations<S extends Schema.Any, E, Entries extends ReadonlyArray<readonly [ComponentDescriptor, unknown]>> = MissingPairsFrom<S, EntryNames<Entries>, SurelyInserted<Entries> | TargetHolds<E>>;
|
|
424
|
+
type InsertRequirementsMet<S extends Schema.Any, E, Entries extends ReadonlyArray<readonly [ComponentDescriptor, unknown]>> = [
|
|
425
|
+
InsertViolations<S, E, Entries>
|
|
426
|
+
] extends [never] ? unknown : Fix<`${MissingMessages<InsertViolations<S, E, Entries>>}: insert it in the same call, or pass match.entity from a query that proves it`>;
|
|
427
|
+
/**
|
|
428
|
+
* Removing `Removed` is sound when every component that requires one of
|
|
429
|
+
* them is removed in the same call or proven absent by the target's query
|
|
430
|
+
* (`without`): otherwise the entity may keep a requirer without its
|
|
431
|
+
* requirement.
|
|
432
|
+
*/
|
|
433
|
+
type RemoveViolations<S extends Schema.Any, E, Removed extends string> = Extract<Schema.Requires<S>, readonly [string, Removed]> extends infer Pair ? Pair extends readonly [infer From extends string, infer To extends string] ? From extends Removed | TargetLacks<E> ? never : `${To} is required by ${From}: remove ${From} in the same call, or match the entity with a query that has without: [${From}]` : never : never;
|
|
434
|
+
type RemoveRequirementsMet<S extends Schema.Any, E, Removed extends string> = [
|
|
435
|
+
RemoveViolations<S, E, Removed>
|
|
436
|
+
] extends [never] ? unknown : Fix<RemoveViolations<S, E, Removed>>;
|
|
437
|
+
/** A remove target: `match.entity`, or the id `spawn` returned in this run; never a raw id, not even as one of several. */
|
|
438
|
+
type RemoveTargetRejections<S extends Schema.Any, Root, E> = E extends {
|
|
439
|
+
readonly kind: "EntityRef" | "EntityMut";
|
|
440
|
+
readonly id: Entity.EntityId<S, Root>;
|
|
441
|
+
} ? never : E extends SpawnedId<S, Root, string> ? never : "remove needs an entity from a query (pass match.entity) or the id spawn returned in this run, not a raw id";
|
|
442
|
+
type RemoveTargetAllowed<S extends Schema.Any, Root, E> = [
|
|
443
|
+
RemoveTargetRejections<S, Root, E>
|
|
444
|
+
] extends [never] ? unknown : Fix<RemoveTargetRejections<S, Root, E>>;
|
|
445
|
+
/** The transitive closure of the names `N` require (cycles stop). */
|
|
446
|
+
type RequiredClosure<Pairs extends RequirementPair, N extends string, Seen extends string = never> = [
|
|
447
|
+
Exclude<N, Seen>
|
|
448
|
+
] extends [never] ? Seen : RequiredClosure<Pairs, Extract<Pairs, readonly [Exclude<N, Seen>, string]>[1], Seen | N>;
|
|
449
|
+
/**
|
|
450
|
+
* The component descriptors that `Names` require, transitively
|
|
451
|
+
* (`Schema.requires`): what `Game.System.spawns(...)` also allows.
|
|
452
|
+
*/
|
|
453
|
+
export type RequiredDescriptors<S extends Schema.Any, Names extends string> = 0 extends 1 & Names ? never : string extends Names ? never : [Extract<Schema.Requires<S>, readonly [Names, string]>] extends [never] ? never : Extract<Schema.ComponentDescriptor<S>, {
|
|
454
|
+
readonly name: Exclude<RequiredClosure<Schema.Requires<S>, Names>, Names>;
|
|
455
|
+
}>;
|
|
456
|
+
type SchemaComponent<S extends Schema.Any> = Extract<Schema.Components<S>[keyof Schema.Components<S>], ComponentDescriptor>;
|
|
457
|
+
/** An entity a system has proven something about: `match.entity`, or the id `spawn` returned. */
|
|
458
|
+
type EntityTarget<S extends Schema.Any, Root> = {
|
|
459
|
+
readonly kind: "EntityRef" | "EntityMut";
|
|
460
|
+
readonly id: Entity.EntityId<S, Root>;
|
|
461
|
+
} | SpawnedId<S, Root, string>;
|
|
345
462
|
/** The keys every member of a union of proofs requires (what a draft holds in every case). */
|
|
346
463
|
type RequiredKeys<P> = P extends unknown ? {
|
|
347
464
|
[K in keyof P]-?: {} extends Pick<P, K> ? never : K;
|
|
@@ -358,7 +475,8 @@ type HeldNames<P> = Exclude<AllKeys<P>, MissingSomewhere<P, AllKeys<P>>>;
|
|
|
358
475
|
* `spawn` needs `Game.System.spawns(...)` listing every component of the
|
|
359
476
|
* draft, `insert` needs `inserts`, `remove` needs `removes`, `despawn` needs
|
|
360
477
|
* `despawns` and an entity from a query proving one of them, `despawnScope`
|
|
361
|
-
* needs `despawnsScope`, and relation edits need `relates
|
|
478
|
+
* needs `despawnsScope`, and relation edits need `relates`, including
|
|
479
|
+
* relations a spawned draft stages with `Game.Command.relate(...)`.
|
|
362
480
|
*
|
|
363
481
|
* Resource and event writes are not commands: they go through the
|
|
364
482
|
* `writeResource(...)` / `writeEvent(...)` access a system declares.
|
|
@@ -366,22 +484,35 @@ type HeldNames<P> = Exclude<AllKeys<P>, MissingSomewhere<P, AllKeys<P>>>;
|
|
|
366
484
|
export interface CommandsApi<S extends Schema.Any, Root = unknown, Spawns = never, Inserts = never, Removes = never, Despawns = never, Scopes = never, Relates = never> {
|
|
367
485
|
/**
|
|
368
486
|
* Queues a staged entity for spawning and returns its stable runtime id.
|
|
487
|
+
*
|
|
488
|
+
* The draft must hold every component its components require
|
|
489
|
+
* (`Schema.requires`); drafts are checked here, so a partial draft built
|
|
490
|
+
* with `Game.Command.spawn(...)` and completed with `extend(...)` is fine.
|
|
491
|
+
* A component the draft may hold (a conditional or spread entry) needs
|
|
492
|
+
* what it requires surely held.
|
|
369
493
|
*/
|
|
370
|
-
readonly spawn: [Spawns] extends [never] ? MethodNotDeclared<"spawn", "spawns"> : <P extends Entity.ComponentProof>(draft: Entity.EntityDraft<S, P, Root> & DraftAllowed<P, Spawns>) => SpawnedId<S, Root, HeldNames<P>>;
|
|
494
|
+
readonly spawn: [Spawns] extends [never] ? MethodNotDeclared<"spawn", "spawns"> : <P extends Entity.ComponentProof, R = never>(draft: Entity.EntityDraft<S, P, Root, R> & DraftAllowed<P, Spawns> & DraftRequirementsMet<S, P> & DraftRelationsAllowed<R, Relates>) => SpawnedId<S, Root, HeldNames<P>>;
|
|
371
495
|
/**
|
|
372
496
|
* Queues an entity spawn owned by one lifetime scope (removed together
|
|
373
|
-
* with `despawnScope(...)`).
|
|
497
|
+
* with `despawnScope(...)`). The draft is checked like `spawn(...)`.
|
|
374
498
|
*/
|
|
375
|
-
readonly spawnIn: [Spawns] extends [never] ? MethodNotDeclared<"spawnIn", "spawns"> : <P extends Entity.ComponentProof>(scope: EntityScope.EntityScope<string, Root>, draft: Entity.EntityDraft<S, P, Root> & DraftAllowed<P, Spawns>) => SpawnedId<S, Root, HeldNames<P>>;
|
|
499
|
+
readonly spawnIn: [Spawns] extends [never] ? MethodNotDeclared<"spawnIn", "spawns"> : <P extends Entity.ComponentProof, R = never>(scope: EntityScope.EntityScope<string, Root>, draft: Entity.EntityDraft<S, P, Root, R> & DraftAllowed<P, Spawns> & DraftRequirementsMet<S, P> & DraftRelationsAllowed<R, Relates>) => SpawnedId<S, Root, HeldNames<P>>;
|
|
376
500
|
/**
|
|
377
501
|
* Queues component inserts (or replacements) on an existing entity, applied
|
|
378
502
|
* at the next `applyDeferred()`. To change a value now, on an entity you
|
|
379
|
-
* matched, write through a query (`Game.Query.write`) instead
|
|
503
|
+
* matched, write through a query (`Game.Query.write`) instead; components
|
|
504
|
+
* declared `immutable: true` change only through `insert`.
|
|
505
|
+
*
|
|
506
|
+
* Pass `match.entity`: its query proves what the entity holds, which must
|
|
507
|
+
* cover what the inserted components require (`Schema.requires`) together
|
|
508
|
+
* with the entries inserted in the same call. The id `spawn` returned in
|
|
509
|
+
* this run proves its draft. A raw `EntityId` proves nothing, so it only
|
|
510
|
+
* inserts components without requirements.
|
|
380
511
|
*
|
|
381
512
|
* Entries must already be valid; validate raw input with
|
|
382
513
|
* `Game.Command.entryRaw(...)` first.
|
|
383
514
|
*/
|
|
384
|
-
readonly insert: [Inserts] extends [never] ? MethodNotDeclared<"insert", "inserts"> : <const Entries extends ReadonlyArray<SchemaEntry<S>>>(entity:
|
|
515
|
+
readonly insert: [Inserts] extends [never] ? MethodNotDeclared<"insert", "inserts"> : <const E extends Entity.EntityId<S, Root> | EntityTarget<S, Root>, const Entries extends ReadonlyArray<SchemaEntry<S>>>(entity: E, ...entries: Entries & EntriesAllowed<Entries, Inserts> & InsertRequirementsMet<S, E, Entries>) => Entity.EntityId<S, Root>;
|
|
385
516
|
/**
|
|
386
517
|
* Queues an entity removal. A despawned entity stays visible to queries
|
|
387
518
|
* until the next `applyDeferred()`, and despawns never count as writers for
|
|
@@ -391,15 +522,21 @@ export interface CommandsApi<S extends Schema.Any, Root = unknown, Spawns = neve
|
|
|
391
522
|
* components, or the id `spawn` returned in this run (it holds its draft's
|
|
392
523
|
* components); never a raw id.
|
|
393
524
|
*/
|
|
394
|
-
readonly despawn: [Despawns] extends [never] ? MethodNotDeclared<"despawn", "despawns"> : <const E>(entity: E
|
|
525
|
+
readonly despawn: [Despawns] extends [never] ? MethodNotDeclared<"despawn", "despawns"> : <const E>(entity: unknown extends DespawnAllowed<E, Despawns> ? E : DespawnAllowed<E, Despawns>) => void;
|
|
395
526
|
/**
|
|
396
527
|
* Queues removal of every entity owned by one lifetime scope.
|
|
397
528
|
*/
|
|
398
529
|
readonly despawnScope: [Scopes] extends [never] ? MethodNotDeclared<"despawnScope", "despawnsScope"> : (scope: Scopes) => void;
|
|
399
530
|
/**
|
|
400
|
-
* Queues
|
|
531
|
+
* Queues the removal of one or more components from an existing entity,
|
|
532
|
+
* applied together at the next `applyDeferred()`.
|
|
533
|
+
*
|
|
534
|
+
* Pass `match.entity` from a query, or the id `spawn` returned in this run;
|
|
535
|
+
* never a raw id. A component another one requires (`Schema.requires`) can
|
|
536
|
+
* only go together with that requirer, in the same call, or from an
|
|
537
|
+
* entity whose query has `without: [Requirer]`.
|
|
401
538
|
*/
|
|
402
|
-
readonly remove: [Removes] extends [never] ? MethodNotDeclared<"remove", "removes"> : <
|
|
539
|
+
readonly remove: [Removes] extends [never] ? MethodNotDeclared<"remove", "removes"> : <const E, const Ds extends readonly [SchemaComponent<S>, ...Array<SchemaComponent<S>>]>(entity: unknown extends RemoveTargetAllowed<S, Root, E> ? E : RemoveTargetAllowed<S, Root, E>, ...descriptors: Ds & RemoveAllowed<Ds[number], Removes> & RemoveRequirementsMet<S, E, Names<Ds[number]>>) => Entity.EntityId<S, Root>;
|
|
403
540
|
/**
|
|
404
541
|
* Queues one live relation mutation for deferred application.
|
|
405
542
|
*/
|
|
@@ -415,14 +552,18 @@ export interface CommandsApi<S extends Schema.Any, Root = unknown, Spawns = neve
|
|
|
415
552
|
}
|
|
416
553
|
/** The command queue the runtime gives each system: every command, unchecked, and `flush`. */
|
|
417
554
|
export interface CommandQueue<S extends Schema.Any, Root = unknown> {
|
|
418
|
-
readonly spawn: (draft: Entity.EntityDraft<S, any, Root>) => Entity.EntityId<S, Root>;
|
|
419
|
-
readonly spawnIn: (scope: EntityScope.EntityScope<string, Root>, draft: Entity.EntityDraft<S, any, Root>) => Entity.EntityId<S, Root>;
|
|
420
|
-
readonly insert: (entity: Entity.EntityId<S, Root
|
|
555
|
+
readonly spawn: (draft: Entity.EntityDraft<S, any, Root, any>) => Entity.EntityId<S, Root>;
|
|
556
|
+
readonly spawnIn: (scope: EntityScope.EntityScope<string, Root>, draft: Entity.EntityDraft<S, any, Root, any>) => Entity.EntityId<S, Root>;
|
|
557
|
+
readonly insert: (entity: Entity.EntityId<S, Root> | {
|
|
558
|
+
readonly id: Entity.EntityId<S, Root>;
|
|
559
|
+
}, ...entries: ReadonlyArray<SchemaEntry<S>>) => Entity.EntityId<S, Root>;
|
|
421
560
|
readonly despawn: (entity: Entity.EntityId<S, Root> | {
|
|
422
561
|
readonly id: Entity.EntityId<S, Root>;
|
|
423
562
|
}) => void;
|
|
424
563
|
readonly despawnScope: (scope: EntityScope.EntityScope<string, Root>) => void;
|
|
425
|
-
readonly remove: (entity: Entity.EntityId<S, Root
|
|
564
|
+
readonly remove: (entity: Entity.EntityId<S, Root> | {
|
|
565
|
+
readonly id: Entity.EntityId<S, Root>;
|
|
566
|
+
}, ...descriptors: ReadonlyArray<ComponentDescriptor>) => Entity.EntityId<S, Root>;
|
|
426
567
|
readonly relate: (entity: Entity.EntityId<S, Root>, relation: Relation.Relation.Any, target: Entity.EntityId<S, Root>) => void;
|
|
427
568
|
readonly unrelate: (entity: Entity.EntityId<S, Root>, relation: Relation.Relation.Any) => void;
|
|
428
569
|
readonly reorderChildren: (entity: Entity.EntityId<S, Root>, relation: Relation.Relation.Hierarchy, children: ReadonlyArray<Entity.EntityId<S, Root>>) => void;
|