@awesome-ecs/abstract 0.21.0 → 0.21.1
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/dist/components/index.cjs +10 -32
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +3 -2
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +11 -8
- package/dist/components/index.js.map +1 -1
- package/dist/entities/index.cjs +11 -33
- package/dist/entities/index.cjs.map +1 -1
- package/dist/entities/index.d.cts +4 -34
- package/dist/entities/index.d.ts +4 -34
- package/dist/entities/index.js +12 -9
- package/dist/entities/index.js.map +1 -1
- package/dist/factories/index.cjs +0 -18
- package/dist/factories/index.d.cts +44 -42
- package/dist/factories/index.d.ts +44 -42
- package/dist/factories/index.js +0 -1
- package/dist/identity-component-BDWEtAXA.d.cts +238 -0
- package/dist/identity-component-CR1ULadR.d.ts +238 -0
- package/dist/index-C3UGZqUG.d.ts +288 -0
- package/dist/index-CKh4A7mH.d.cts +460 -0
- package/dist/index-ChV4Q5j6.d.cts +137 -0
- package/dist/index-Cm-YSPhK.d.ts +254 -0
- package/dist/index-D81Fo9XN.d.cts +254 -0
- package/dist/index-DLm-DKAk.d.cts +288 -0
- package/dist/index-oenqxDCa.d.ts +137 -0
- package/dist/index-zpj0YApu.d.ts +460 -0
- package/dist/pipelines/index.cjs +28 -35
- package/dist/pipelines/index.cjs.map +1 -1
- package/dist/pipelines/index.d.cts +4 -89
- package/dist/pipelines/index.d.ts +4 -89
- package/dist/pipelines/index.js +29 -11
- package/dist/pipelines/index.js.map +1 -1
- package/dist/systems/index.cjs +31 -35
- package/dist/systems/index.cjs.map +1 -1
- package/dist/systems/index.d.cts +7 -114
- package/dist/systems/index.d.ts +7 -114
- package/dist/systems/index.js +32 -11
- package/dist/systems/index.js.map +1 -1
- package/dist/{types-cZ-1lGPD.d.ts → types-DvzdpbLu.d.cts} +9 -17
- package/dist/{types-cZ-1lGPD.d.cts → types-yh4pOGEm.d.ts} +9 -17
- package/dist/utils/index.cjs +25 -35
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +3 -92
- package/dist/utils/index.d.ts +3 -92
- package/dist/utils/index.js +26 -11
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/entity-repository-BlSpo-x2.d.ts +0 -253
- package/dist/entity-repository-DJ1xbvaN.d.cts +0 -253
- package/dist/factories/index.cjs.map +0 -1
- package/dist/factories/index.js.map +0 -1
- package/dist/index-B1KXekZD.d.ts +0 -199
- package/dist/index-CnlpX7ys.d.cts +0 -199
- package/dist/performance-timer-BVyl0SRs.d.cts +0 -45
- package/dist/performance-timer-BVyl0SRs.d.ts +0 -45
- package/dist/pipeline-9bVMwJKD.d.ts +0 -161
- package/dist/pipeline-CzwetuCd.d.cts +0 -161
- package/dist/systems-runtime-context-Bz9hIdKT.d.cts +0 -330
- package/dist/systems-runtime-context-C_Tsvoym.d.ts +0 -330
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { I as IEntityProxy, f as IdentityComponent, b as IEntityModel, g as IComponent, c as IEntity, E as EntityTypeUid } from './index-CnlpX7ys.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a unique identifier for an entity event.
|
|
5
|
-
* Can be either a string or a number.
|
|
6
|
-
*/
|
|
7
|
-
type EntityEventUid = string | number;
|
|
8
|
-
/**
|
|
9
|
-
* A filter function for entity event subscriptions.
|
|
10
|
-
* Returns true if the event should be processed, false otherwise.
|
|
11
|
-
*/
|
|
12
|
-
type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The `IEventData` interface represents the data associated with an entity event.
|
|
15
|
-
* It contains at least the `Event Unique Identifier`.
|
|
16
|
-
*/
|
|
17
|
-
interface IEventData {
|
|
18
|
-
uid: EntityEventUid;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The `IEntityEvent` interface represents a basic building block for a Publish/Subscribe pattern.
|
|
22
|
-
* It is used to synchronize state between multiple entities.
|
|
23
|
-
*
|
|
24
|
-
* The events are scheduled as part of the `EntityUpdate` model.
|
|
25
|
-
* Systems subscribe and receive updates with the events included in their `SystemContext`.
|
|
26
|
-
*/
|
|
27
|
-
interface IEntityEvent<TEventData extends IEventData> {
|
|
28
|
-
origin: IEntityProxy;
|
|
29
|
-
target?: IEntityProxy;
|
|
30
|
-
data: TEventData;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The `IEntityEventsManager` interface represents a Publish/Subscribe broker for `IEntityEvent` instances.
|
|
34
|
-
* It keeps track of entity subscriptions (as part of the Observer design pattern).
|
|
35
|
-
*/
|
|
36
|
-
interface IEntityEventsManager {
|
|
37
|
-
/**
|
|
38
|
-
* Subscribes an entity to a specific event.
|
|
39
|
-
* @param uid - The unique identifier of the event.
|
|
40
|
-
* @param entity - The entity subscribing to the event.
|
|
41
|
-
* @param filter - An optional filter function to determine if the event should be processed.
|
|
42
|
-
*/
|
|
43
|
-
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
44
|
-
/**
|
|
45
|
-
* Unsubscribes an entity from a specific event.
|
|
46
|
-
* @param uid - The unique identifier of the event.
|
|
47
|
-
* @param entity - The entity unsubscribing from the event.
|
|
48
|
-
*/
|
|
49
|
-
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
50
|
-
/**
|
|
51
|
-
* Retrieves the entities subscribed to a specific event.
|
|
52
|
-
* @param event - The event to retrieve subscriptions for.
|
|
53
|
-
* @returns An array of entities subscribed to the event.
|
|
54
|
-
*/
|
|
55
|
-
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
56
|
-
/**
|
|
57
|
-
* Retrieves the unique identifiers of events subscribed to by a specific entity.
|
|
58
|
-
* @param entity - The entity to retrieve subscriptions for.
|
|
59
|
-
* @returns An array of unique identifiers of events subscribed to by the entity.
|
|
60
|
-
*/
|
|
61
|
-
getSubscriptionsForEntity(entity: IEntityProxy): EntityEventUid[];
|
|
62
|
-
/**
|
|
63
|
-
* Removes all subscriptions for all entities.
|
|
64
|
-
*/
|
|
65
|
-
clearSubscriptions(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Removes all subscriptions for a specific event.
|
|
68
|
-
* @param uid - The unique identifier of the event to remove subscriptions from.
|
|
69
|
-
*/
|
|
70
|
-
clearSubscriptionsForEvent(uid: EntityEventUid): void;
|
|
71
|
-
/**
|
|
72
|
-
* Removes all subscriptions for a specific entity.
|
|
73
|
-
* @param entity - The entity to remove subscriptions from.
|
|
74
|
-
*/
|
|
75
|
-
clearSubscriptionsForEntity(entity: IEntityProxy): void;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The `IEntityEventsDispatcher` interface represents the main access point for dispatching events to entities.
|
|
79
|
-
* It can leverage the `IEntityEventsManager` to find subscribers and the `IEntityUpdateQueue` to register events
|
|
80
|
-
* into each observer entity's next update.
|
|
81
|
-
*/
|
|
82
|
-
interface IEntityEventsDispatcher {
|
|
83
|
-
/**
|
|
84
|
-
* Dispatches a single event to entities.
|
|
85
|
-
* @param event - The event to dispatch.
|
|
86
|
-
* @param targets - The entities to dispatch the event to.
|
|
87
|
-
*/
|
|
88
|
-
dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
|
|
89
|
-
/**
|
|
90
|
-
* Dispatches multiple events to entities.
|
|
91
|
-
* @param events - The events to dispatch.
|
|
92
|
-
* @param targets - The entities to dispatch the events to.
|
|
93
|
-
*/
|
|
94
|
-
dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* The `IEntitySnapshot` interface represents a serializable state of an Entity.
|
|
99
|
-
* It can contain the full or partial state of the Entity, including its identity, components, proxies, and events.
|
|
100
|
-
* This interface is used to capture Entity state changes (deltas) or update existing Entity with changes from a remote source.
|
|
101
|
-
*/
|
|
102
|
-
interface IEntitySnapshot {
|
|
103
|
-
/**
|
|
104
|
-
* The identity of the Entity.
|
|
105
|
-
*/
|
|
106
|
-
readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
|
|
107
|
-
/**
|
|
108
|
-
* An array of components associated with the Entity.
|
|
109
|
-
*/
|
|
110
|
-
readonly components?: IComponent[];
|
|
111
|
-
/**
|
|
112
|
-
* An array of proxies associated with the Entity.
|
|
113
|
-
*/
|
|
114
|
-
readonly proxies?: IEntityProxy[];
|
|
115
|
-
/**
|
|
116
|
-
* An array of events associated with the Entity.
|
|
117
|
-
*/
|
|
118
|
-
readonly events?: IEntityEvent<IEventData>[];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* The `IEntitySnapshotProvider` interface is the main provider for creating and updating Entity snapshots.
|
|
122
|
-
* It provides methods to apply a snapshot to an Entity and to create a snapshot from an Entity.
|
|
123
|
-
*/
|
|
124
|
-
interface IEntitySnapshotProvider {
|
|
125
|
-
/**
|
|
126
|
-
* Applies a snapshot to an Entity.
|
|
127
|
-
* This method updates the Entity's state based on the provided snapshot.
|
|
128
|
-
*
|
|
129
|
-
* @param entity - The Entity to apply the snapshot to.
|
|
130
|
-
* @param snapshot - The snapshot to apply to the Entity.
|
|
131
|
-
*/
|
|
132
|
-
applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
|
|
133
|
-
/**
|
|
134
|
-
* Creates a snapshot from an Entity.
|
|
135
|
-
* This method captures the current state of the Entity and returns it as a snapshot.
|
|
136
|
-
*
|
|
137
|
-
* @param entity - The Entity to create a snapshot from.
|
|
138
|
-
* @returns The created snapshot.
|
|
139
|
-
*/
|
|
140
|
-
createSnapshot(entity: IEntity): IEntitySnapshot;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* The `EntityUpdateType` enum specifies whether the current Entity should be `updated` or `removed`.
|
|
145
|
-
*/
|
|
146
|
-
declare enum EntityUpdateType {
|
|
147
|
-
update = "update",
|
|
148
|
-
remove = "remove"
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* The `IEntityUpdate` interface represents an Entity update that should be applied over an existing Entity.
|
|
152
|
-
*/
|
|
153
|
-
interface IEntityUpdate {
|
|
154
|
-
/**
|
|
155
|
-
* The type of the update, which can be either `update` or `remove`.
|
|
156
|
-
*/
|
|
157
|
-
type: EntityUpdateType;
|
|
158
|
-
/**
|
|
159
|
-
* The proxy of the Entity that needs to be updated.
|
|
160
|
-
*/
|
|
161
|
-
entity: IEntityProxy;
|
|
162
|
-
/**
|
|
163
|
-
* Optional. The model of the Entity that needs to be updated.
|
|
164
|
-
*/
|
|
165
|
-
model?: IEntityModel;
|
|
166
|
-
/**
|
|
167
|
-
* Optional. The snapshot of the Entity that needs to be updated.
|
|
168
|
-
*/
|
|
169
|
-
snapshot?: IEntitySnapshot;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* The `IEntityUpdateQueue` interface is the main mechanism to queue and retrieve `EntityUpdate` instances.
|
|
173
|
-
*
|
|
174
|
-
* The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
|
|
175
|
-
*/
|
|
176
|
-
interface IEntityUpdateQueue {
|
|
177
|
-
/**
|
|
178
|
-
* The number of `EntityUpdate` instances currently in the queue.
|
|
179
|
-
*/
|
|
180
|
-
readonly size: number;
|
|
181
|
-
/**
|
|
182
|
-
* Adds an `EntityUpdate` instance to the end of the queue.
|
|
183
|
-
* @param change - The `EntityUpdate` instance to be added.
|
|
184
|
-
*/
|
|
185
|
-
enqueue(change: IEntityUpdate): void;
|
|
186
|
-
/**
|
|
187
|
-
* Removes and returns the `EntityUpdate` instance at the front of the queue.
|
|
188
|
-
* @returns The `EntityUpdate` instance at the front of the queue.
|
|
189
|
-
*/
|
|
190
|
-
dequeue(): IEntityUpdate;
|
|
191
|
-
/**
|
|
192
|
-
* Returns the `EntityUpdate` instance at the front of the queue without removing it.
|
|
193
|
-
* @returns The `EntityUpdate` instance at the front of the queue.
|
|
194
|
-
*/
|
|
195
|
-
peek(): IEntityUpdate;
|
|
196
|
-
/**
|
|
197
|
-
* Removes all `EntityUpdate` instances from the queue.
|
|
198
|
-
*/
|
|
199
|
-
clear(): void;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* The `IEntityRepository` is the central storage for keeping track of existing Entities.
|
|
204
|
-
* It provides basic CRUD functionality.
|
|
205
|
-
*/
|
|
206
|
-
interface IEntityRepository {
|
|
207
|
-
/**
|
|
208
|
-
* Returns the number of entities in the repository.
|
|
209
|
-
*/
|
|
210
|
-
readonly size: number;
|
|
211
|
-
/**
|
|
212
|
-
* Checks if the repository contains an entity represented by the given proxy.
|
|
213
|
-
* @param proxy - The proxy of the entity to check.
|
|
214
|
-
* @returns True if the repository contains the entity, false otherwise.
|
|
215
|
-
*/
|
|
216
|
-
has(proxy: IEntityProxy): boolean;
|
|
217
|
-
/**
|
|
218
|
-
* Retrieves an entity from the repository by its proxy.
|
|
219
|
-
* @template TEntity - The type of the entity to retrieve.
|
|
220
|
-
* @param proxy - The proxy of the entity to retrieve.
|
|
221
|
-
* @returns The retrieved entity.
|
|
222
|
-
*/
|
|
223
|
-
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
224
|
-
/**
|
|
225
|
-
* Retrieves all entities of a specific type from the repository.
|
|
226
|
-
* @template TEntity - The type of the entities to retrieve.
|
|
227
|
-
* @param entityType - The type UID of the entities to retrieve.
|
|
228
|
-
* @returns An array of the retrieved entities.
|
|
229
|
-
*/
|
|
230
|
-
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
231
|
-
/**
|
|
232
|
-
* Iterator over all entities in the repository.
|
|
233
|
-
* @returns An iterator of all entities in the repository.
|
|
234
|
-
*/
|
|
235
|
-
listAll(): IterableIterator<IEntity>;
|
|
236
|
-
/**
|
|
237
|
-
* Adds or updates an entity in the repository.
|
|
238
|
-
* @param entity - The entity to add or update.
|
|
239
|
-
*/
|
|
240
|
-
set(entity: IEntity): void;
|
|
241
|
-
/**
|
|
242
|
-
* Deletes an entity from the repository by its proxy.
|
|
243
|
-
* @param proxy - The proxy of the entity to delete.
|
|
244
|
-
*/
|
|
245
|
-
delete(proxy: IEntityProxy): void;
|
|
246
|
-
/**
|
|
247
|
-
* Clears all entities of a specific type from the repository.
|
|
248
|
-
* @param entityType - The type UID of the entities to clear.
|
|
249
|
-
*/
|
|
250
|
-
clear(entityType: EntityTypeUid): void;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export { type EntityEventUid as E, type IEventData as I, type EntityEventSubscriptionFilter as a, type IEntityEvent as b, type IEntityEventsManager as c, type IEntityEventsDispatcher as d, EntityUpdateType as e, type IEntityUpdate as f, type IEntityUpdateQueue as g, type IEntityRepository as h, type IEntitySnapshot as i, type IEntitySnapshotProvider as j };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/factories/index.ts"],"sourcesContent":["export * from './context-factory';\nexport * from './pipeline-factory';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index-B1KXekZD.d.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { B as BooleanProps, I as Immutable } from './types-cZ-1lGPD.js';
|
|
2
|
-
|
|
3
|
-
type ComponentTypeUid = string | number;
|
|
4
|
-
/**
|
|
5
|
-
* The `IComponent` interface provides the main storage mechanism of `IEntity` state, and can be accessed and modified by `Systems`.
|
|
6
|
-
*
|
|
7
|
-
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
8
|
-
*/
|
|
9
|
-
interface IComponent {
|
|
10
|
-
/**
|
|
11
|
-
* The `ComponentTypeUid` is a unique identifier for each Component type.
|
|
12
|
-
* @type {ComponentTypeUid}
|
|
13
|
-
*/
|
|
14
|
-
readonly componentType: ComponentTypeUid;
|
|
15
|
-
/**
|
|
16
|
-
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
17
|
-
* This is useful if the state needs to be replicated or updated through remote updates (e.g., coming from the server or peers).
|
|
18
|
-
* @type {boolean}
|
|
19
|
-
*/
|
|
20
|
-
readonly isSerializable: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* @optional
|
|
23
|
-
* Specifies the current version of the component.
|
|
24
|
-
* This is useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
|
-
readonly version?: number;
|
|
28
|
-
/**
|
|
29
|
-
* @optional
|
|
30
|
-
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
31
|
-
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
32
|
-
* @returns {string | object} The serialized form of the Component.
|
|
33
|
-
*/
|
|
34
|
-
toJSON?(): string | object;
|
|
35
|
-
/**
|
|
36
|
-
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
37
|
-
* The default behavior simply overwrites the fields with the target state.
|
|
38
|
-
* @param {this} targetState The target state to load from.
|
|
39
|
-
*/
|
|
40
|
-
load?(targetState: this): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
45
|
-
*/
|
|
46
|
-
interface IEntityProxy {
|
|
47
|
-
/**
|
|
48
|
-
* The type of the entity that the proxy points to.
|
|
49
|
-
*/
|
|
50
|
-
readonly entityType: EntityTypeUid;
|
|
51
|
-
/**
|
|
52
|
-
* The unique identifier of the entity that the proxy points to.
|
|
53
|
-
*/
|
|
54
|
-
readonly entityUid: EntityUid;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A utility extension of `IEntityProxy`.
|
|
58
|
-
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
59
|
-
*
|
|
60
|
-
* @template TEntity - The type of the entity that the proxy points to.
|
|
61
|
-
*/
|
|
62
|
-
interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
|
|
66
|
-
*
|
|
67
|
-
* It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
|
|
68
|
-
*/
|
|
69
|
-
interface IEntityProxiesManager {
|
|
70
|
-
/**
|
|
71
|
-
* Registers a single proxy for an entity.
|
|
72
|
-
*
|
|
73
|
-
* @param entity - The entity to register the proxy for.
|
|
74
|
-
* @param proxy - The proxy to register.
|
|
75
|
-
* @param cleanup - If true, any existing proxies of the same type will be removed before registering the new one.
|
|
76
|
-
*/
|
|
77
|
-
registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
|
|
78
|
-
/**
|
|
79
|
-
* Registers multiple proxies for an entity.
|
|
80
|
-
*
|
|
81
|
-
* @param entity - The entity to register the proxies for.
|
|
82
|
-
* @param proxies - The proxies to register.
|
|
83
|
-
* @param cleanup - If true, any existing proxies of the same type will be removed before registering the new ones.
|
|
84
|
-
*/
|
|
85
|
-
registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
86
|
-
/**
|
|
87
|
-
* Removes a single proxy from an entity.
|
|
88
|
-
*
|
|
89
|
-
* @param entity - The entity to remove the proxy from.
|
|
90
|
-
* @param proxy - The proxy to remove.
|
|
91
|
-
*/
|
|
92
|
-
removeProxy(entity: IEntity, proxy: IEntityProxy): void;
|
|
93
|
-
/**
|
|
94
|
-
* Removes all proxies from an entity, optionally filtering by proxy entity type.
|
|
95
|
-
*
|
|
96
|
-
* @param entity - The entity to remove the proxies from.
|
|
97
|
-
* @param proxyEntityType - The type of the proxy entity to filter by.
|
|
98
|
-
*/
|
|
99
|
-
removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Represents the unique identifier for an entity type.
|
|
104
|
-
* Can be either a string or a number.
|
|
105
|
-
*/
|
|
106
|
-
type EntityTypeUid = string | number;
|
|
107
|
-
/**
|
|
108
|
-
* Represents the unique identifier for an entity.
|
|
109
|
-
* Can be either a string or a number.
|
|
110
|
-
*/
|
|
111
|
-
type EntityUid = string | number;
|
|
112
|
-
/**
|
|
113
|
-
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
114
|
-
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
|
115
|
-
*
|
|
116
|
-
* The Features property can be used to toggle Entity features on and off.
|
|
117
|
-
*
|
|
118
|
-
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
119
|
-
* Defaults to `unknown` if not provided.
|
|
120
|
-
*/
|
|
121
|
-
interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
|
|
122
|
-
/**
|
|
123
|
-
* The unique identifier of the entity.
|
|
124
|
-
*/
|
|
125
|
-
readonly uid: EntityUid;
|
|
126
|
-
/**
|
|
127
|
-
* Optional features of the entity.
|
|
128
|
-
* The type of this property should extend `BooleanProps<TFeatures>`.
|
|
129
|
-
*/
|
|
130
|
-
readonly features?: TFeatures;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* The `IEntity` interface represents a container of Components and Entity Proxies.
|
|
134
|
-
* It is designed to be immutable and only modifiable through System operations.
|
|
135
|
-
*
|
|
136
|
-
* Implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies`,
|
|
137
|
-
* but should not contain any state-changing logic apart from quick-access functionality.
|
|
138
|
-
*/
|
|
139
|
-
interface IEntity {
|
|
140
|
-
/**
|
|
141
|
-
* A Map of Components associated with this Entity.
|
|
142
|
-
* The keys are ComponentTypeUid, and the values are IComponent instances.
|
|
143
|
-
*/
|
|
144
|
-
readonly components: Map<ComponentTypeUid, IComponent>;
|
|
145
|
-
/**
|
|
146
|
-
* A Map of Entity Proxies associated with this Entity.
|
|
147
|
-
* The outer Map's keys are EntityTypeUid, and the inner Map's keys are EntityUid.
|
|
148
|
-
* The values are IEntityProxy instances.
|
|
149
|
-
*/
|
|
150
|
-
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
151
|
-
/**
|
|
152
|
-
* The IdentityComponent represents mandatory state any Entity needs to have.
|
|
153
|
-
* It is a readonly reference to an IdentityComponent instance, which contains the minimal-required information
|
|
154
|
-
* needed for instantiating the Entity.
|
|
155
|
-
*/
|
|
156
|
-
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
157
|
-
/**
|
|
158
|
-
* A reference to the own Proxy of this Entity.
|
|
159
|
-
* It is a readonly reference to an IEntityProxy instance, which points to this Entity.
|
|
160
|
-
* This is useful for quick access of Proxy data.
|
|
161
|
-
*/
|
|
162
|
-
readonly myProxy: Readonly<IEntityProxy>;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* The `BasicComponentType` enum defines the types of basic components available.
|
|
167
|
-
*/
|
|
168
|
-
declare enum BasicComponentType {
|
|
169
|
-
identity = "identity"
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* IdentityComponent interface represents the basic information regarding what makes the current Entity unique.
|
|
173
|
-
* It extends the IComponent interface.
|
|
174
|
-
*
|
|
175
|
-
* @template TModel - The type of the model that extends IEntityModel.
|
|
176
|
-
*/
|
|
177
|
-
interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
178
|
-
/**
|
|
179
|
-
* The Entity Type that defines what Category type the Entity is part of.
|
|
180
|
-
* There can be multiple Entities sharing the same EntityType.
|
|
181
|
-
*/
|
|
182
|
-
readonly entityType: EntityTypeUid;
|
|
183
|
-
/**
|
|
184
|
-
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
185
|
-
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
186
|
-
*
|
|
187
|
-
* @type {Immutable<TModel>}
|
|
188
|
-
*/
|
|
189
|
-
readonly model: Immutable<TModel>;
|
|
190
|
-
/**
|
|
191
|
-
* Keeps track when the Entity's systems have ran last.
|
|
192
|
-
* Useful to calculate the `DeltaTime` between runs.
|
|
193
|
-
*
|
|
194
|
-
* @type {Date | undefined}
|
|
195
|
-
*/
|
|
196
|
-
readonly lastUpdated?: Date;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { B as BooleanProps, I as Immutable } from './types-cZ-1lGPD.cjs';
|
|
2
|
-
|
|
3
|
-
type ComponentTypeUid = string | number;
|
|
4
|
-
/**
|
|
5
|
-
* The `IComponent` interface provides the main storage mechanism of `IEntity` state, and can be accessed and modified by `Systems`.
|
|
6
|
-
*
|
|
7
|
-
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
8
|
-
*/
|
|
9
|
-
interface IComponent {
|
|
10
|
-
/**
|
|
11
|
-
* The `ComponentTypeUid` is a unique identifier for each Component type.
|
|
12
|
-
* @type {ComponentTypeUid}
|
|
13
|
-
*/
|
|
14
|
-
readonly componentType: ComponentTypeUid;
|
|
15
|
-
/**
|
|
16
|
-
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
17
|
-
* This is useful if the state needs to be replicated or updated through remote updates (e.g., coming from the server or peers).
|
|
18
|
-
* @type {boolean}
|
|
19
|
-
*/
|
|
20
|
-
readonly isSerializable: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* @optional
|
|
23
|
-
* Specifies the current version of the component.
|
|
24
|
-
* This is useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
25
|
-
* @type {number}
|
|
26
|
-
*/
|
|
27
|
-
readonly version?: number;
|
|
28
|
-
/**
|
|
29
|
-
* @optional
|
|
30
|
-
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
31
|
-
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
32
|
-
* @returns {string | object} The serialized form of the Component.
|
|
33
|
-
*/
|
|
34
|
-
toJSON?(): string | object;
|
|
35
|
-
/**
|
|
36
|
-
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
37
|
-
* The default behavior simply overwrites the fields with the target state.
|
|
38
|
-
* @param {this} targetState The target state to load from.
|
|
39
|
-
*/
|
|
40
|
-
load?(targetState: this): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
45
|
-
*/
|
|
46
|
-
interface IEntityProxy {
|
|
47
|
-
/**
|
|
48
|
-
* The type of the entity that the proxy points to.
|
|
49
|
-
*/
|
|
50
|
-
readonly entityType: EntityTypeUid;
|
|
51
|
-
/**
|
|
52
|
-
* The unique identifier of the entity that the proxy points to.
|
|
53
|
-
*/
|
|
54
|
-
readonly entityUid: EntityUid;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A utility extension of `IEntityProxy`.
|
|
58
|
-
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
59
|
-
*
|
|
60
|
-
* @template TEntity - The type of the entity that the proxy points to.
|
|
61
|
-
*/
|
|
62
|
-
interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
|
|
66
|
-
*
|
|
67
|
-
* It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
|
|
68
|
-
*/
|
|
69
|
-
interface IEntityProxiesManager {
|
|
70
|
-
/**
|
|
71
|
-
* Registers a single proxy for an entity.
|
|
72
|
-
*
|
|
73
|
-
* @param entity - The entity to register the proxy for.
|
|
74
|
-
* @param proxy - The proxy to register.
|
|
75
|
-
* @param cleanup - If true, any existing proxies of the same type will be removed before registering the new one.
|
|
76
|
-
*/
|
|
77
|
-
registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
|
|
78
|
-
/**
|
|
79
|
-
* Registers multiple proxies for an entity.
|
|
80
|
-
*
|
|
81
|
-
* @param entity - The entity to register the proxies for.
|
|
82
|
-
* @param proxies - The proxies to register.
|
|
83
|
-
* @param cleanup - If true, any existing proxies of the same type will be removed before registering the new ones.
|
|
84
|
-
*/
|
|
85
|
-
registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
86
|
-
/**
|
|
87
|
-
* Removes a single proxy from an entity.
|
|
88
|
-
*
|
|
89
|
-
* @param entity - The entity to remove the proxy from.
|
|
90
|
-
* @param proxy - The proxy to remove.
|
|
91
|
-
*/
|
|
92
|
-
removeProxy(entity: IEntity, proxy: IEntityProxy): void;
|
|
93
|
-
/**
|
|
94
|
-
* Removes all proxies from an entity, optionally filtering by proxy entity type.
|
|
95
|
-
*
|
|
96
|
-
* @param entity - The entity to remove the proxies from.
|
|
97
|
-
* @param proxyEntityType - The type of the proxy entity to filter by.
|
|
98
|
-
*/
|
|
99
|
-
removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Represents the unique identifier for an entity type.
|
|
104
|
-
* Can be either a string or a number.
|
|
105
|
-
*/
|
|
106
|
-
type EntityTypeUid = string | number;
|
|
107
|
-
/**
|
|
108
|
-
* Represents the unique identifier for an entity.
|
|
109
|
-
* Can be either a string or a number.
|
|
110
|
-
*/
|
|
111
|
-
type EntityUid = string | number;
|
|
112
|
-
/**
|
|
113
|
-
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
114
|
-
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
|
115
|
-
*
|
|
116
|
-
* The Features property can be used to toggle Entity features on and off.
|
|
117
|
-
*
|
|
118
|
-
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
119
|
-
* Defaults to `unknown` if not provided.
|
|
120
|
-
*/
|
|
121
|
-
interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
|
|
122
|
-
/**
|
|
123
|
-
* The unique identifier of the entity.
|
|
124
|
-
*/
|
|
125
|
-
readonly uid: EntityUid;
|
|
126
|
-
/**
|
|
127
|
-
* Optional features of the entity.
|
|
128
|
-
* The type of this property should extend `BooleanProps<TFeatures>`.
|
|
129
|
-
*/
|
|
130
|
-
readonly features?: TFeatures;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* The `IEntity` interface represents a container of Components and Entity Proxies.
|
|
134
|
-
* It is designed to be immutable and only modifiable through System operations.
|
|
135
|
-
*
|
|
136
|
-
* Implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies`,
|
|
137
|
-
* but should not contain any state-changing logic apart from quick-access functionality.
|
|
138
|
-
*/
|
|
139
|
-
interface IEntity {
|
|
140
|
-
/**
|
|
141
|
-
* A Map of Components associated with this Entity.
|
|
142
|
-
* The keys are ComponentTypeUid, and the values are IComponent instances.
|
|
143
|
-
*/
|
|
144
|
-
readonly components: Map<ComponentTypeUid, IComponent>;
|
|
145
|
-
/**
|
|
146
|
-
* A Map of Entity Proxies associated with this Entity.
|
|
147
|
-
* The outer Map's keys are EntityTypeUid, and the inner Map's keys are EntityUid.
|
|
148
|
-
* The values are IEntityProxy instances.
|
|
149
|
-
*/
|
|
150
|
-
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
151
|
-
/**
|
|
152
|
-
* The IdentityComponent represents mandatory state any Entity needs to have.
|
|
153
|
-
* It is a readonly reference to an IdentityComponent instance, which contains the minimal-required information
|
|
154
|
-
* needed for instantiating the Entity.
|
|
155
|
-
*/
|
|
156
|
-
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
157
|
-
/**
|
|
158
|
-
* A reference to the own Proxy of this Entity.
|
|
159
|
-
* It is a readonly reference to an IEntityProxy instance, which points to this Entity.
|
|
160
|
-
* This is useful for quick access of Proxy data.
|
|
161
|
-
*/
|
|
162
|
-
readonly myProxy: Readonly<IEntityProxy>;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* The `BasicComponentType` enum defines the types of basic components available.
|
|
167
|
-
*/
|
|
168
|
-
declare enum BasicComponentType {
|
|
169
|
-
identity = "identity"
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* IdentityComponent interface represents the basic information regarding what makes the current Entity unique.
|
|
173
|
-
* It extends the IComponent interface.
|
|
174
|
-
*
|
|
175
|
-
* @template TModel - The type of the model that extends IEntityModel.
|
|
176
|
-
*/
|
|
177
|
-
interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
178
|
-
/**
|
|
179
|
-
* The Entity Type that defines what Category type the Entity is part of.
|
|
180
|
-
* There can be multiple Entities sharing the same EntityType.
|
|
181
|
-
*/
|
|
182
|
-
readonly entityType: EntityTypeUid;
|
|
183
|
-
/**
|
|
184
|
-
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
185
|
-
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
186
|
-
*
|
|
187
|
-
* @type {Immutable<TModel>}
|
|
188
|
-
*/
|
|
189
|
-
readonly model: Immutable<TModel>;
|
|
190
|
-
/**
|
|
191
|
-
* Keeps track when the Entity's systems have ran last.
|
|
192
|
-
* Useful to calculate the `DeltaTime` between runs.
|
|
193
|
-
*
|
|
194
|
-
* @type {Date | undefined}
|
|
195
|
-
*/
|
|
196
|
-
readonly lastUpdated?: Date;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export { BasicComponentType as B, type ComponentTypeUid as C, type EntityTypeUid as E, type IEntityProxy as I, type EntityUid as a, type IEntityModel as b, type IEntity as c, type EntityProxy as d, type IEntityProxiesManager as e, type IdentityComponent as f, type IComponent as g };
|