@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
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { BooleanProps, Immutable } from "./types-DvzdpbLu.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/components/component.d.ts
|
|
4
|
+
type ComponentTypeUid = string | number;
|
|
5
|
+
/**
|
|
6
|
+
* The `IComponent` interface provides the main storage mechanism of `IEntity` state, and can be accessed and modified by `Systems`.
|
|
7
|
+
*
|
|
8
|
+
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
9
|
+
*/
|
|
10
|
+
interface IComponent {
|
|
11
|
+
/**
|
|
12
|
+
* The `ComponentTypeUid` is a unique identifier for each Component type.
|
|
13
|
+
* @type {ComponentTypeUid}
|
|
14
|
+
*/
|
|
15
|
+
readonly componentType: ComponentTypeUid;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
18
|
+
* This is useful if the state needs to be replicated or updated through remote updates (e.g., coming from the server or peers).
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
readonly isSerializable: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @optional
|
|
24
|
+
* Specifies the current version of the component.
|
|
25
|
+
* This is useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
readonly version?: number;
|
|
29
|
+
/**
|
|
30
|
+
* @optional
|
|
31
|
+
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
32
|
+
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
33
|
+
* @returns {string | object} The serialized form of the Component.
|
|
34
|
+
*/
|
|
35
|
+
toJSON?(): string | object;
|
|
36
|
+
/**
|
|
37
|
+
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
38
|
+
* The default behavior simply overwrites the fields with the target state.
|
|
39
|
+
* @param {this} targetState The target state to load from.
|
|
40
|
+
*/
|
|
41
|
+
load?(targetState: this): void;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/entities/entity-proxies.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
47
|
+
*/
|
|
48
|
+
interface IEntityProxy {
|
|
49
|
+
/**
|
|
50
|
+
* The type of the entity that the proxy points to.
|
|
51
|
+
*/
|
|
52
|
+
readonly entityType: EntityTypeUid;
|
|
53
|
+
/**
|
|
54
|
+
* The unique identifier of the entity that the proxy points to.
|
|
55
|
+
*/
|
|
56
|
+
readonly entityUid: EntityUid;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A utility extension of `IEntityProxy`.
|
|
60
|
+
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
61
|
+
*
|
|
62
|
+
* @template TEntity - The type of the entity that the proxy points to.
|
|
63
|
+
*/
|
|
64
|
+
interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {}
|
|
65
|
+
/**
|
|
66
|
+
* A helper type to create a typed entity proxy.
|
|
67
|
+
*/
|
|
68
|
+
type TypedEntityProxy<T extends EntityTypeUid> = {
|
|
69
|
+
entityType: T;
|
|
70
|
+
entityUid: EntityUid;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A mapped type that transforms an array of EntityType into an array of TypedEntityProxy.
|
|
74
|
+
*/
|
|
75
|
+
type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = [...{ [I in keyof TProxyTypes]: TypedEntityProxy<TProxyTypes[I]> }, ...IEntityProxy[]];
|
|
76
|
+
/**
|
|
77
|
+
* A repository for managing entity-to-entity relationships (proxies).
|
|
78
|
+
* This centralized repository is the single source of truth for all proxy data.
|
|
79
|
+
*/
|
|
80
|
+
interface IEntityProxyRepository {
|
|
81
|
+
/**
|
|
82
|
+
* Registers a bi-directional proxy relationship between a source and a target.
|
|
83
|
+
* @param source - The proxy of the source entity.
|
|
84
|
+
* @param target - The proxy of the target entity.
|
|
85
|
+
* @param cleanup - If true, any existing proxies of the same type on the source and target will be removed before registering the new one.
|
|
86
|
+
*/
|
|
87
|
+
register(source: IEntityProxy, target: IEntityProxy, cleanup?: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Registers multiple bi-directional proxy relationships for a source entity.
|
|
90
|
+
* @param source - The proxy of the source entity.
|
|
91
|
+
* @param targets - The proxies of the target entities.
|
|
92
|
+
* @param cleanup - If true, any existing proxies of the same types as the new targets will be removed from the source before registering.
|
|
93
|
+
*/
|
|
94
|
+
registerMany(source: IEntityProxy, targets: readonly IEntityProxy[], cleanup?: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Removes a bi-directional proxy relationship between a source and a target.
|
|
97
|
+
* @param source - The proxy of the source entity.
|
|
98
|
+
* @param target - The proxy of the target entity.
|
|
99
|
+
*/
|
|
100
|
+
remove(source: IEntityProxy, target: IEntityProxy): void;
|
|
101
|
+
/**
|
|
102
|
+
* Removes all proxies from a source entity, optionally filtered by the target entity type.
|
|
103
|
+
* This will also remove the corresponding back-references from the target entities.
|
|
104
|
+
* @param source - The proxy of the source entity.
|
|
105
|
+
* @param targetType - The optional entity type of the targets to remove. If not provided, all proxies for the source are removed.
|
|
106
|
+
*/
|
|
107
|
+
removeAllFor(source: IEntityProxy, targetType?: EntityTypeUid): void;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves a single proxy of a specific type for a source entity.
|
|
110
|
+
* If multiple proxies of the same type exist, it returns the first one found.
|
|
111
|
+
* @param source - The proxy of the source entity.
|
|
112
|
+
* @param targetType - The entity type of the target proxy to retrieve.
|
|
113
|
+
* @returns The entity proxy, or null if not found.
|
|
114
|
+
*/
|
|
115
|
+
get(source: IEntityProxy, targetType: EntityTypeUid): IEntityProxy | null;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves all proxies of a specific type for a source entity.
|
|
118
|
+
* @param source - The proxy of the source entity.
|
|
119
|
+
* @param targetType - The entity type of the target proxies to retrieve.
|
|
120
|
+
* @returns A readonly array of entity proxies.
|
|
121
|
+
*/
|
|
122
|
+
getMany(source: IEntityProxy, targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves all proxies for a source entity.
|
|
125
|
+
* @param source - The proxy of the source entity.
|
|
126
|
+
* @returns A readonly map of entity type UIDs to an array of their proxies.
|
|
127
|
+
*/
|
|
128
|
+
getAll(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/entities/entity.d.ts
|
|
132
|
+
/**
|
|
133
|
+
* Represents the unique identifier for an entity type.
|
|
134
|
+
* Can be either a string or a number.
|
|
135
|
+
*/
|
|
136
|
+
type EntityTypeUid = string | number;
|
|
137
|
+
/**
|
|
138
|
+
* Represents the unique identifier for an entity.
|
|
139
|
+
* Can be either a string or a number.
|
|
140
|
+
*/
|
|
141
|
+
type EntityUid = string | number;
|
|
142
|
+
/**
|
|
143
|
+
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
144
|
+
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
|
145
|
+
*
|
|
146
|
+
* The Features property can be used to toggle Entity features on and off.
|
|
147
|
+
*
|
|
148
|
+
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
149
|
+
* Defaults to `unknown` if not provided.
|
|
150
|
+
*/
|
|
151
|
+
interface IEntityModel {
|
|
152
|
+
/**
|
|
153
|
+
* The unique identifier of the entity.
|
|
154
|
+
*/
|
|
155
|
+
readonly uid: EntityUid;
|
|
156
|
+
/**
|
|
157
|
+
* Optional proxies of the entity.
|
|
158
|
+
*/
|
|
159
|
+
readonly proxies?: readonly IEntityProxy[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Base interface for entity models that require feature flags.
|
|
163
|
+
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
164
|
+
*/
|
|
165
|
+
interface IEntityModelWithFeatures<TFeatures extends BooleanProps<TFeatures> = unknown> extends IEntityModel {
|
|
166
|
+
readonly features: TFeatures;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Base interface for entity models that require specific proxies.
|
|
170
|
+
* @template TProxyTypes An array of EntityType that are required as proxies.
|
|
171
|
+
*/
|
|
172
|
+
interface IEntityModelWithRequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> extends Omit<IEntityModel, 'proxies'> {
|
|
173
|
+
readonly proxies: RequiredProxies<TProxyTypes>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The `IEntity` interface represents a container of Components and Entity Proxies.
|
|
177
|
+
* It is designed to be immutable and only modifiable through System operations.
|
|
178
|
+
*
|
|
179
|
+
* Implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies`,
|
|
180
|
+
* but should not contain any state-changing logic apart from quick-access functionality.
|
|
181
|
+
*/
|
|
182
|
+
interface IEntity {
|
|
183
|
+
/**
|
|
184
|
+
* A Map of Components associated with this Entity.
|
|
185
|
+
* The keys are ComponentTypeUid, and the values are IComponent instances.
|
|
186
|
+
*/
|
|
187
|
+
readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
|
|
188
|
+
/**
|
|
189
|
+
* The IdentityComponent represents mandatory state any Entity needs to have.
|
|
190
|
+
* It is a readonly reference to an IdentityComponent instance, which contains the minimal-required information
|
|
191
|
+
* needed for instantiating the Entity.
|
|
192
|
+
*/
|
|
193
|
+
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
194
|
+
/**
|
|
195
|
+
* A reference to the own Proxy of this Entity.
|
|
196
|
+
* It is a readonly reference to an IEntityProxy instance, which points to this Entity.
|
|
197
|
+
* This is useful for quick access of Proxy data.
|
|
198
|
+
*/
|
|
199
|
+
readonly myProxy: Readonly<EntityProxy<this>>;
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/components/identity-component.d.ts
|
|
203
|
+
/**
|
|
204
|
+
* The `BasicComponentType` enum defines the types of basic components available.
|
|
205
|
+
*/
|
|
206
|
+
declare enum BasicComponentType {
|
|
207
|
+
identity = "identity",
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* IdentityComponent interface represents the basic information regarding what makes the current Entity unique.
|
|
211
|
+
* It extends the IComponent interface.
|
|
212
|
+
*
|
|
213
|
+
* @template TModel - The type of the model that extends IEntityModel.
|
|
214
|
+
*/
|
|
215
|
+
interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
216
|
+
/**
|
|
217
|
+
* The Entity Type that defines what Category type the Entity is part of.
|
|
218
|
+
* There can be multiple Entities sharing the same EntityType.
|
|
219
|
+
*/
|
|
220
|
+
readonly entityType: EntityTypeUid;
|
|
221
|
+
/**
|
|
222
|
+
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
223
|
+
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
224
|
+
*
|
|
225
|
+
* @type {Immutable<TModel>}
|
|
226
|
+
*/
|
|
227
|
+
readonly model: Immutable<TModel>;
|
|
228
|
+
/**
|
|
229
|
+
* Keeps track when the Entity's systems have ran last.
|
|
230
|
+
* Useful to calculate the `DeltaTime` between runs.
|
|
231
|
+
*
|
|
232
|
+
* @type {Date | undefined}
|
|
233
|
+
*/
|
|
234
|
+
readonly lastUpdated?: Date;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { BasicComponentType, ComponentTypeUid, EntityProxy, EntityTypeUid, EntityUid, IComponent, IEntity, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, IdentityComponent, RequiredProxies, TypedEntityProxy };
|
|
238
|
+
//# sourceMappingURL=identity-component-BDWEtAXA.d.cts.map
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { BooleanProps, Immutable } from "./types-yh4pOGEm.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/component.d.ts
|
|
4
|
+
type ComponentTypeUid = string | number;
|
|
5
|
+
/**
|
|
6
|
+
* The `IComponent` interface provides the main storage mechanism of `IEntity` state, and can be accessed and modified by `Systems`.
|
|
7
|
+
*
|
|
8
|
+
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
9
|
+
*/
|
|
10
|
+
interface IComponent {
|
|
11
|
+
/**
|
|
12
|
+
* The `ComponentTypeUid` is a unique identifier for each Component type.
|
|
13
|
+
* @type {ComponentTypeUid}
|
|
14
|
+
*/
|
|
15
|
+
readonly componentType: ComponentTypeUid;
|
|
16
|
+
/**
|
|
17
|
+
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
18
|
+
* This is useful if the state needs to be replicated or updated through remote updates (e.g., coming from the server or peers).
|
|
19
|
+
* @type {boolean}
|
|
20
|
+
*/
|
|
21
|
+
readonly isSerializable: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* @optional
|
|
24
|
+
* Specifies the current version of the component.
|
|
25
|
+
* This is useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
readonly version?: number;
|
|
29
|
+
/**
|
|
30
|
+
* @optional
|
|
31
|
+
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
32
|
+
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
33
|
+
* @returns {string | object} The serialized form of the Component.
|
|
34
|
+
*/
|
|
35
|
+
toJSON?(): string | object;
|
|
36
|
+
/**
|
|
37
|
+
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
38
|
+
* The default behavior simply overwrites the fields with the target state.
|
|
39
|
+
* @param {this} targetState The target state to load from.
|
|
40
|
+
*/
|
|
41
|
+
load?(targetState: this): void;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/entities/entity-proxies.d.ts
|
|
45
|
+
/**
|
|
46
|
+
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
47
|
+
*/
|
|
48
|
+
interface IEntityProxy {
|
|
49
|
+
/**
|
|
50
|
+
* The type of the entity that the proxy points to.
|
|
51
|
+
*/
|
|
52
|
+
readonly entityType: EntityTypeUid;
|
|
53
|
+
/**
|
|
54
|
+
* The unique identifier of the entity that the proxy points to.
|
|
55
|
+
*/
|
|
56
|
+
readonly entityUid: EntityUid;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A utility extension of `IEntityProxy`.
|
|
60
|
+
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
61
|
+
*
|
|
62
|
+
* @template TEntity - The type of the entity that the proxy points to.
|
|
63
|
+
*/
|
|
64
|
+
interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {}
|
|
65
|
+
/**
|
|
66
|
+
* A helper type to create a typed entity proxy.
|
|
67
|
+
*/
|
|
68
|
+
type TypedEntityProxy<T extends EntityTypeUid> = {
|
|
69
|
+
entityType: T;
|
|
70
|
+
entityUid: EntityUid;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A mapped type that transforms an array of EntityType into an array of TypedEntityProxy.
|
|
74
|
+
*/
|
|
75
|
+
type RequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> = [...{ [I in keyof TProxyTypes]: TypedEntityProxy<TProxyTypes[I]> }, ...IEntityProxy[]];
|
|
76
|
+
/**
|
|
77
|
+
* A repository for managing entity-to-entity relationships (proxies).
|
|
78
|
+
* This centralized repository is the single source of truth for all proxy data.
|
|
79
|
+
*/
|
|
80
|
+
interface IEntityProxyRepository {
|
|
81
|
+
/**
|
|
82
|
+
* Registers a bi-directional proxy relationship between a source and a target.
|
|
83
|
+
* @param source - The proxy of the source entity.
|
|
84
|
+
* @param target - The proxy of the target entity.
|
|
85
|
+
* @param cleanup - If true, any existing proxies of the same type on the source and target will be removed before registering the new one.
|
|
86
|
+
*/
|
|
87
|
+
register(source: IEntityProxy, target: IEntityProxy, cleanup?: boolean): void;
|
|
88
|
+
/**
|
|
89
|
+
* Registers multiple bi-directional proxy relationships for a source entity.
|
|
90
|
+
* @param source - The proxy of the source entity.
|
|
91
|
+
* @param targets - The proxies of the target entities.
|
|
92
|
+
* @param cleanup - If true, any existing proxies of the same types as the new targets will be removed from the source before registering.
|
|
93
|
+
*/
|
|
94
|
+
registerMany(source: IEntityProxy, targets: readonly IEntityProxy[], cleanup?: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* Removes a bi-directional proxy relationship between a source and a target.
|
|
97
|
+
* @param source - The proxy of the source entity.
|
|
98
|
+
* @param target - The proxy of the target entity.
|
|
99
|
+
*/
|
|
100
|
+
remove(source: IEntityProxy, target: IEntityProxy): void;
|
|
101
|
+
/**
|
|
102
|
+
* Removes all proxies from a source entity, optionally filtered by the target entity type.
|
|
103
|
+
* This will also remove the corresponding back-references from the target entities.
|
|
104
|
+
* @param source - The proxy of the source entity.
|
|
105
|
+
* @param targetType - The optional entity type of the targets to remove. If not provided, all proxies for the source are removed.
|
|
106
|
+
*/
|
|
107
|
+
removeAllFor(source: IEntityProxy, targetType?: EntityTypeUid): void;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves a single proxy of a specific type for a source entity.
|
|
110
|
+
* If multiple proxies of the same type exist, it returns the first one found.
|
|
111
|
+
* @param source - The proxy of the source entity.
|
|
112
|
+
* @param targetType - The entity type of the target proxy to retrieve.
|
|
113
|
+
* @returns The entity proxy, or null if not found.
|
|
114
|
+
*/
|
|
115
|
+
get(source: IEntityProxy, targetType: EntityTypeUid): IEntityProxy | null;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves all proxies of a specific type for a source entity.
|
|
118
|
+
* @param source - The proxy of the source entity.
|
|
119
|
+
* @param targetType - The entity type of the target proxies to retrieve.
|
|
120
|
+
* @returns A readonly array of entity proxies.
|
|
121
|
+
*/
|
|
122
|
+
getMany(source: IEntityProxy, targetType: EntityTypeUid): Readonly<IEntityProxy[]>;
|
|
123
|
+
/**
|
|
124
|
+
* Retrieves all proxies for a source entity.
|
|
125
|
+
* @param source - The proxy of the source entity.
|
|
126
|
+
* @returns A readonly map of entity type UIDs to an array of their proxies.
|
|
127
|
+
*/
|
|
128
|
+
getAll(source: IEntityProxy): ReadonlyMap<EntityTypeUid, Readonly<IEntityProxy[]>>;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/entities/entity.d.ts
|
|
132
|
+
/**
|
|
133
|
+
* Represents the unique identifier for an entity type.
|
|
134
|
+
* Can be either a string or a number.
|
|
135
|
+
*/
|
|
136
|
+
type EntityTypeUid = string | number;
|
|
137
|
+
/**
|
|
138
|
+
* Represents the unique identifier for an entity.
|
|
139
|
+
* Can be either a string or a number.
|
|
140
|
+
*/
|
|
141
|
+
type EntityUid = string | number;
|
|
142
|
+
/**
|
|
143
|
+
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
144
|
+
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
|
145
|
+
*
|
|
146
|
+
* The Features property can be used to toggle Entity features on and off.
|
|
147
|
+
*
|
|
148
|
+
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
149
|
+
* Defaults to `unknown` if not provided.
|
|
150
|
+
*/
|
|
151
|
+
interface IEntityModel {
|
|
152
|
+
/**
|
|
153
|
+
* The unique identifier of the entity.
|
|
154
|
+
*/
|
|
155
|
+
readonly uid: EntityUid;
|
|
156
|
+
/**
|
|
157
|
+
* Optional proxies of the entity.
|
|
158
|
+
*/
|
|
159
|
+
readonly proxies?: readonly IEntityProxy[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Base interface for entity models that require feature flags.
|
|
163
|
+
* @template TFeatures - A type that extends `BooleanProps<TFeatures>` to represent the features of the entity.
|
|
164
|
+
*/
|
|
165
|
+
interface IEntityModelWithFeatures<TFeatures extends BooleanProps<TFeatures> = unknown> extends IEntityModel {
|
|
166
|
+
readonly features: TFeatures;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Base interface for entity models that require specific proxies.
|
|
170
|
+
* @template TProxyTypes An array of EntityType that are required as proxies.
|
|
171
|
+
*/
|
|
172
|
+
interface IEntityModelWithRequiredProxies<TProxyTypes extends readonly EntityTypeUid[]> extends Omit<IEntityModel, 'proxies'> {
|
|
173
|
+
readonly proxies: RequiredProxies<TProxyTypes>;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The `IEntity` interface represents a container of Components and Entity Proxies.
|
|
177
|
+
* It is designed to be immutable and only modifiable through System operations.
|
|
178
|
+
*
|
|
179
|
+
* Implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies`,
|
|
180
|
+
* but should not contain any state-changing logic apart from quick-access functionality.
|
|
181
|
+
*/
|
|
182
|
+
interface IEntity {
|
|
183
|
+
/**
|
|
184
|
+
* A Map of Components associated with this Entity.
|
|
185
|
+
* The keys are ComponentTypeUid, and the values are IComponent instances.
|
|
186
|
+
*/
|
|
187
|
+
readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
|
|
188
|
+
/**
|
|
189
|
+
* The IdentityComponent represents mandatory state any Entity needs to have.
|
|
190
|
+
* It is a readonly reference to an IdentityComponent instance, which contains the minimal-required information
|
|
191
|
+
* needed for instantiating the Entity.
|
|
192
|
+
*/
|
|
193
|
+
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
194
|
+
/**
|
|
195
|
+
* A reference to the own Proxy of this Entity.
|
|
196
|
+
* It is a readonly reference to an IEntityProxy instance, which points to this Entity.
|
|
197
|
+
* This is useful for quick access of Proxy data.
|
|
198
|
+
*/
|
|
199
|
+
readonly myProxy: Readonly<EntityProxy<this>>;
|
|
200
|
+
}
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/components/identity-component.d.ts
|
|
203
|
+
/**
|
|
204
|
+
* The `BasicComponentType` enum defines the types of basic components available.
|
|
205
|
+
*/
|
|
206
|
+
declare enum BasicComponentType {
|
|
207
|
+
identity = "identity",
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* IdentityComponent interface represents the basic information regarding what makes the current Entity unique.
|
|
211
|
+
* It extends the IComponent interface.
|
|
212
|
+
*
|
|
213
|
+
* @template TModel - The type of the model that extends IEntityModel.
|
|
214
|
+
*/
|
|
215
|
+
interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
216
|
+
/**
|
|
217
|
+
* The Entity Type that defines what Category type the Entity is part of.
|
|
218
|
+
* There can be multiple Entities sharing the same EntityType.
|
|
219
|
+
*/
|
|
220
|
+
readonly entityType: EntityTypeUid;
|
|
221
|
+
/**
|
|
222
|
+
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
223
|
+
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
224
|
+
*
|
|
225
|
+
* @type {Immutable<TModel>}
|
|
226
|
+
*/
|
|
227
|
+
readonly model: Immutable<TModel>;
|
|
228
|
+
/**
|
|
229
|
+
* Keeps track when the Entity's systems have ran last.
|
|
230
|
+
* Useful to calculate the `DeltaTime` between runs.
|
|
231
|
+
*
|
|
232
|
+
* @type {Date | undefined}
|
|
233
|
+
*/
|
|
234
|
+
readonly lastUpdated?: Date;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { BasicComponentType, ComponentTypeUid, EntityProxy, EntityTypeUid, EntityUid, IComponent, IEntity, IEntityModel, IEntityModelWithFeatures, IEntityModelWithRequiredProxies, IEntityProxy, IEntityProxyRepository, IdentityComponent, RequiredProxies, TypedEntityProxy };
|
|
238
|
+
//# sourceMappingURL=identity-component-CR1ULadR.d.ts.map
|