@awesome-ecs/abstract 0.13.0 → 0.13.2
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/LICENSE.md +201 -201
- package/README.md +99 -99
- package/dist/components/component.d.ts +36 -36
- package/dist/components/component.js +2 -2
- package/dist/components/identity-component.d.ts +24 -24
- package/dist/components/identity-component.js +7 -7
- package/dist/entities/entity-events.d.ts +52 -39
- package/dist/entities/entity-events.js +2 -2
- package/dist/entities/entity-proxies.d.ts +25 -25
- package/dist/entities/entity-proxies.js +2 -2
- package/dist/entities/entity-queue.d.ts +31 -31
- package/dist/entities/entity-queue.js +11 -11
- package/dist/entities/entity-repository.d.ts +16 -16
- package/dist/entities/entity-repository.js +2 -2
- package/dist/entities/entity-scheduler.d.ts +11 -11
- package/dist/entities/entity-scheduler.js +2 -2
- package/dist/entities/entity-snapshot.d.ts +24 -24
- package/dist/entities/entity-snapshot.js +2 -2
- package/dist/entities/entity.d.ts +33 -31
- package/dist/entities/entity.js +2 -2
- package/dist/factories/context-factory.d.ts +9 -9
- package/dist/factories/context-factory.js +2 -2
- package/dist/factories/pipeline-factory.d.ts +11 -11
- package/dist/factories/pipeline-factory.js +2 -2
- package/dist/factories/runtime-factory.d.ts +10 -10
- package/dist/factories/runtime-factory.js +2 -2
- package/dist/index.d.ts +35 -35
- package/dist/index.js +51 -51
- package/dist/index.js.map +1 -1
- package/dist/pipelines/middleware-result.d.ts +5 -5
- package/dist/pipelines/middleware-result.js +2 -2
- package/dist/pipelines/middleware-stop.d.ts +4 -4
- package/dist/pipelines/middleware-stop.js +2 -2
- package/dist/pipelines/middleware.d.ts +24 -24
- package/dist/pipelines/middleware.js +2 -2
- package/dist/pipelines/pipeline-type.d.ts +7 -7
- package/dist/pipelines/pipeline-type.js +11 -11
- package/dist/pipelines/pipeline.d.ts +22 -22
- package/dist/pipelines/pipeline.js +2 -2
- package/dist/runtime/runtime-pipeline.d.ts +11 -11
- package/dist/runtime/runtime-pipeline.js +2 -2
- package/dist/runtime/runtime-result.d.ts +20 -20
- package/dist/runtime/runtime-result.js +2 -2
- package/dist/runtime/runtime-status.d.ts +7 -7
- package/dist/runtime/runtime-status.js +11 -11
- package/dist/systems/context/system-context-events.d.ts +65 -19
- package/dist/systems/context/system-context-events.js +2 -2
- package/dist/systems/context/system-context-proxies.d.ts +12 -12
- package/dist/systems/context/system-context-proxies.js +2 -2
- package/dist/systems/context/system-context-repository.d.ts +15 -15
- package/dist/systems/context/system-context-repository.js +2 -2
- package/dist/systems/context/system-context-scheduler.d.ts +9 -9
- package/dist/systems/context/system-context-scheduler.js +2 -2
- package/dist/systems/context/system-context-snapshot.d.ts +15 -15
- package/dist/systems/context/system-context-snapshot.js +2 -2
- package/dist/systems/runtime/systems-runtime-context.d.ts +18 -18
- package/dist/systems/runtime/systems-runtime-context.js +2 -2
- package/dist/systems/runtime/systems-runtime-middleware.d.ts +8 -8
- package/dist/systems/runtime/systems-runtime-middleware.js +2 -2
- package/dist/systems/system-pipeline-context.d.ts +21 -21
- package/dist/systems/system-pipeline-context.js +2 -2
- package/dist/systems/system-pipeline-middleware.d.ts +8 -8
- package/dist/systems/system-pipeline-middleware.js +2 -2
- package/dist/systems/system-pipeline-type.d.ts +10 -10
- package/dist/systems/system-pipeline-type.js +14 -14
- package/dist/systems/systems-module.d.ts +22 -22
- package/dist/systems/systems-module.js +2 -2
- package/dist/systems/systems-runtime.d.ts +16 -16
- package/dist/systems/systems-runtime.js +2 -2
- package/dist/utils/json-serializer.d.ts +7 -7
- package/dist/utils/json-serializer.js +3 -3
- package/dist/utils/performance-timer.d.ts +11 -11
- package/dist/utils/performance-timer.js +2 -2
- package/dist/utils/types.d.ts +21 -18
- package/dist/utils/types.js +2 -2
- package/package.json +3 -3
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
export type ComponentTypeUid = string | number;
|
|
2
|
-
/**
|
|
3
|
-
* The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
|
|
4
|
-
*
|
|
5
|
-
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
6
|
-
*/
|
|
7
|
-
export interface IComponent {
|
|
8
|
-
/**
|
|
9
|
-
* The `ComponentTypeUid` is an Unique Identifier for each Component type.
|
|
10
|
-
*/
|
|
11
|
-
readonly componentType: ComponentTypeUid;
|
|
12
|
-
/**
|
|
13
|
-
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
14
|
-
* Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
|
|
15
|
-
*/
|
|
16
|
-
readonly isSerializable: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* @optional
|
|
19
|
-
* Specifies the current version of the component.
|
|
20
|
-
* Useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
21
|
-
*/
|
|
22
|
-
readonly version?: number;
|
|
23
|
-
/**
|
|
24
|
-
* @optional
|
|
25
|
-
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
26
|
-
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
27
|
-
*/
|
|
28
|
-
toJSON?(): string | object;
|
|
29
|
-
/**
|
|
30
|
-
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
31
|
-
*
|
|
32
|
-
* The default behavior simply overwrites the fields with the target state.
|
|
33
|
-
* @param component The target component state to apply.
|
|
34
|
-
*/
|
|
35
|
-
load?(targetState: this): void;
|
|
36
|
-
}
|
|
1
|
+
export type ComponentTypeUid = string | number;
|
|
2
|
+
/**
|
|
3
|
+
* The `IComponent` provides the main storage mechanism of `IEntity` state, and can be accessed and modified by Systems.
|
|
4
|
+
*
|
|
5
|
+
* The `IComponent` implementations should not contain any logic methods, apart from quick-access functionality.
|
|
6
|
+
*/
|
|
7
|
+
export interface IComponent {
|
|
8
|
+
/**
|
|
9
|
+
* The `ComponentTypeUid` is an Unique Identifier for each Component type.
|
|
10
|
+
*/
|
|
11
|
+
readonly componentType: ComponentTypeUid;
|
|
12
|
+
/**
|
|
13
|
+
* Specifies whether the Component state should be serialized as part of an `IEntitySnapshot`.
|
|
14
|
+
* Useful if the state needs to be replicated or updated through remote updates (e.g. coming from the server or peers).
|
|
15
|
+
*/
|
|
16
|
+
readonly isSerializable: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @optional
|
|
19
|
+
* Specifies the current version of the component.
|
|
20
|
+
* Useful for keeping backwards-compatibility when the stored state might be of a different version.
|
|
21
|
+
*/
|
|
22
|
+
readonly version?: number;
|
|
23
|
+
/**
|
|
24
|
+
* @optional
|
|
25
|
+
* The custom serialization function of this Component, used to transfer it into a Snapshot, or used for logging the Component stored state.
|
|
26
|
+
* If not provided, the standard `JSON.stringify()` functionality applies.
|
|
27
|
+
*/
|
|
28
|
+
toJSON?(): string | object;
|
|
29
|
+
/**
|
|
30
|
+
* Allows for custom logic when loading the current from an `IEntitySnapshot`.
|
|
31
|
+
*
|
|
32
|
+
* The default behavior simply overwrites the fields with the target state.
|
|
33
|
+
* @param component The target component state to apply.
|
|
34
|
+
*/
|
|
35
|
+
load?(targetState: this): void;
|
|
36
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=component.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { IComponent } from "./component";
|
|
2
|
-
import { EntityTypeUid, IEntityModel } from "../entities/entity";
|
|
3
|
-
import { Immutable } from "../utils/types";
|
|
4
|
-
export declare enum BasicComponentType {
|
|
5
|
-
identity = "identity"
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
|
|
9
|
-
*/
|
|
10
|
-
export interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
11
|
-
/**
|
|
12
|
-
* The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
|
|
13
|
-
*/
|
|
14
|
-
readonly entityType: EntityTypeUid;
|
|
15
|
-
/**
|
|
16
|
-
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
17
|
-
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
18
|
-
*/
|
|
19
|
-
readonly model: Immutable<TModel>;
|
|
20
|
-
/**
|
|
21
|
-
* Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
|
|
22
|
-
*/
|
|
23
|
-
readonly lastUpdated: Date;
|
|
24
|
-
}
|
|
1
|
+
import { IComponent } from "./component";
|
|
2
|
+
import { EntityTypeUid, IEntityModel } from "../entities/entity";
|
|
3
|
+
import { Immutable } from "../utils/types";
|
|
4
|
+
export declare enum BasicComponentType {
|
|
5
|
+
identity = "identity"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The `IdentityComponent` contains basic information regarding what makes the current Entity unique.
|
|
9
|
+
*/
|
|
10
|
+
export interface IdentityComponent<TModel extends IEntityModel> extends IComponent {
|
|
11
|
+
/**
|
|
12
|
+
* The Entity Type that defines what Category type the Entity is part of. There can be multiple Entities sharing the same EntityType.
|
|
13
|
+
*/
|
|
14
|
+
readonly entityType: EntityTypeUid;
|
|
15
|
+
/**
|
|
16
|
+
* The Model is the basic information needed to create an `IEntity` when it's first initialized.
|
|
17
|
+
* It provides a first snapshot of information needed for the successful creation of an Entity instance.
|
|
18
|
+
*/
|
|
19
|
+
readonly model: Immutable<TModel>;
|
|
20
|
+
/**
|
|
21
|
+
* Keeps track when the Entity's systems have ran last. Useful to calculate the `DeltaTime` between runs.
|
|
22
|
+
*/
|
|
23
|
+
readonly lastUpdated: Date;
|
|
24
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasicComponentType = void 0;
|
|
4
|
-
var BasicComponentType;
|
|
5
|
-
(function (BasicComponentType) {
|
|
6
|
-
BasicComponentType["identity"] = "identity";
|
|
7
|
-
})(BasicComponentType = exports.BasicComponentType || (exports.BasicComponentType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicComponentType = void 0;
|
|
4
|
+
var BasicComponentType;
|
|
5
|
+
(function (BasicComponentType) {
|
|
6
|
+
BasicComponentType["identity"] = "identity";
|
|
7
|
+
})(BasicComponentType = exports.BasicComponentType || (exports.BasicComponentType = {}));
|
|
8
8
|
//# sourceMappingURL=identity-component.js.map
|
|
@@ -1,39 +1,52 @@
|
|
|
1
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
2
|
-
export type EntityEventUid = string | number;
|
|
3
|
-
export type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* The `IEventData` contains the event-specific state. At the very least, it contains the `Event Unique Identifier`.
|
|
6
|
-
*/
|
|
7
|
-
export interface IEventData {
|
|
8
|
-
uid: EntityEventUid;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The `IEntityEvent` represents the basic building block for a Pub/Sub pattern, to synchronize state between multiple Entities.
|
|
12
|
-
*
|
|
13
|
-
* The Events are scheduled as part of the `EntityUpdate` model. Systems subscribe and receive updates with the Events included in their `SystemContext`.
|
|
14
|
-
*/
|
|
15
|
-
export interface IEntityEvent<TEventData extends IEventData> {
|
|
16
|
-
origin: IEntityProxy;
|
|
17
|
-
target?: IEntityProxy;
|
|
18
|
-
data: TEventData;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The `IEntityEventsManager` represents the Pub/Sub broker for `IEntityEvent` instances.
|
|
22
|
-
* It keeps track of Entity Subscriptions (as part of the Observer design-pattern).
|
|
23
|
-
*/
|
|
24
|
-
export interface IEntityEventsManager {
|
|
25
|
-
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
26
|
-
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
27
|
-
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
2
|
+
export type EntityEventUid = string | number;
|
|
3
|
+
export type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The `IEventData` contains the event-specific state. At the very least, it contains the `Event Unique Identifier`.
|
|
6
|
+
*/
|
|
7
|
+
export interface IEventData {
|
|
8
|
+
uid: EntityEventUid;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The `IEntityEvent` represents the basic building block for a Pub/Sub pattern, to synchronize state between multiple Entities.
|
|
12
|
+
*
|
|
13
|
+
* The Events are scheduled as part of the `EntityUpdate` model. Systems subscribe and receive updates with the Events included in their `SystemContext`.
|
|
14
|
+
*/
|
|
15
|
+
export interface IEntityEvent<TEventData extends IEventData> {
|
|
16
|
+
origin: IEntityProxy;
|
|
17
|
+
target?: IEntityProxy;
|
|
18
|
+
data: TEventData;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `IEntityEventsManager` represents the Pub/Sub broker for `IEntityEvent` instances.
|
|
22
|
+
* It keeps track of Entity Subscriptions (as part of the Observer design-pattern).
|
|
23
|
+
*/
|
|
24
|
+
export interface IEntityEventsManager {
|
|
25
|
+
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
26
|
+
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
27
|
+
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
28
|
+
/**
|
|
29
|
+
* Removes all Subscriptions for all Entities.
|
|
30
|
+
*/
|
|
31
|
+
clearSubscriptions(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Removes all Subscriptions for the given Event.
|
|
34
|
+
* @param uid The Event UID to remove all Subscribers from.
|
|
35
|
+
*/
|
|
36
|
+
clearSubscriptionsForEvent(uid: EntityEventUid): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes all Event Subscriptions for the given Entity.
|
|
39
|
+
* @param entity The Entity to remove all of it's Event Subscriptions.
|
|
40
|
+
*/
|
|
41
|
+
clearSubscriptionsForEntity(entity: IEntityProxy): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The `IEntityEventsDispatcher` is the main access point for dispatching events to Entities.
|
|
45
|
+
*
|
|
46
|
+
* It can leverage the `IEntityEventsManager` to find Subscribers, and the `IEntityUpdateQueue` to register events
|
|
47
|
+
* into each Observer Entity's next update.
|
|
48
|
+
*/
|
|
49
|
+
export interface IEntityEventsDispatcher {
|
|
50
|
+
dispatchEvent(event: IEntityEvent<IEventData>, ...targets: IEntityProxy[]): void;
|
|
51
|
+
dispatchEvents(events: IEntityEvent<IEventData>[], ...targets: IEntityProxy[]): void;
|
|
52
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-events.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { EntityTypeUid, EntityUid, IEntity } from "./entity";
|
|
2
|
-
/**
|
|
3
|
-
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
4
|
-
*/
|
|
5
|
-
export interface IEntityProxy {
|
|
6
|
-
readonly entityType: EntityTypeUid;
|
|
7
|
-
readonly entityUid: EntityUid;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A utility extension of `IEntityProxy`.
|
|
11
|
-
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
12
|
-
*/
|
|
13
|
-
export interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
|
|
17
|
-
*
|
|
18
|
-
* It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
|
|
19
|
-
*/
|
|
20
|
-
export interface IEntityProxiesManager {
|
|
21
|
-
registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
|
|
22
|
-
registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
23
|
-
removeProxy(entity: IEntity, proxy: IEntityProxy): void;
|
|
24
|
-
removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
|
|
25
|
-
}
|
|
1
|
+
import { EntityTypeUid, EntityUid, IEntity } from "./entity";
|
|
2
|
+
/**
|
|
3
|
+
* The `IEntityProxy` represents a pointer to another `Entity`.
|
|
4
|
+
*/
|
|
5
|
+
export interface IEntityProxy {
|
|
6
|
+
readonly entityType: EntityTypeUid;
|
|
7
|
+
readonly entityUid: EntityUid;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A utility extension of `IEntityProxy`.
|
|
11
|
+
* Useful for providing strong `Type` information when using the IEntityProxy.
|
|
12
|
+
*/
|
|
13
|
+
export interface EntityProxy<TEntity extends IEntity> extends IEntityProxy {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The `IEntityProxiesManager` is a helper to encapsulate logic for registering & removing Entity proxies.
|
|
17
|
+
*
|
|
18
|
+
* It handles the complexities of bi-directional registrations and offers an abstraction for the Proxy handling.
|
|
19
|
+
*/
|
|
20
|
+
export interface IEntityProxiesManager {
|
|
21
|
+
registerProxy(entity: IEntity, proxy: IEntityProxy, cleanup?: boolean): void;
|
|
22
|
+
registerProxies(entity: IEntity, proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
23
|
+
removeProxy(entity: IEntity, proxy: IEntityProxy): void;
|
|
24
|
+
removeProxies(entity: IEntity, proxyEntityType?: EntityTypeUid): void;
|
|
25
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-proxies.js.map
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { IEntityModel } from "./entity";
|
|
2
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
3
|
-
import { IEntitySnapshot } from "./entity-snapshot";
|
|
4
|
-
/**
|
|
5
|
-
* The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
|
|
6
|
-
*/
|
|
7
|
-
export declare enum EntityUpdateType {
|
|
8
|
-
update = "update",
|
|
9
|
-
remove = "remove"
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The `IEntityUpdate` represents an Entity update that should be applied over an (existing) Entity.
|
|
13
|
-
*/
|
|
14
|
-
export interface IEntityUpdate {
|
|
15
|
-
type: EntityUpdateType;
|
|
16
|
-
entity: IEntityProxy;
|
|
17
|
-
model?: IEntityModel;
|
|
18
|
-
snapshot?: IEntitySnapshot;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The `IEntityUpdateQueue` is the main mechanism to queue and retrieve `EntityUpdate` instances.
|
|
22
|
-
*
|
|
23
|
-
* The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
|
|
24
|
-
*/
|
|
25
|
-
export interface IEntityUpdateQueue {
|
|
26
|
-
readonly size: number;
|
|
27
|
-
enqueue(change: IEntityUpdate): void;
|
|
28
|
-
dequeue(): IEntityUpdate;
|
|
29
|
-
peek(): IEntityUpdate;
|
|
30
|
-
clear(): void;
|
|
31
|
-
}
|
|
1
|
+
import { IEntityModel } from "./entity";
|
|
2
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
3
|
+
import { IEntitySnapshot } from "./entity-snapshot";
|
|
4
|
+
/**
|
|
5
|
+
* The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum EntityUpdateType {
|
|
8
|
+
update = "update",
|
|
9
|
+
remove = "remove"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The `IEntityUpdate` represents an Entity update that should be applied over an (existing) Entity.
|
|
13
|
+
*/
|
|
14
|
+
export interface IEntityUpdate {
|
|
15
|
+
type: EntityUpdateType;
|
|
16
|
+
entity: IEntityProxy;
|
|
17
|
+
model?: IEntityModel;
|
|
18
|
+
snapshot?: IEntitySnapshot;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The `IEntityUpdateQueue` is the main mechanism to queue and retrieve `EntityUpdate` instances.
|
|
22
|
+
*
|
|
23
|
+
* The interface can be implemented using a simple queue mechanism, or perhaps, a Priority Queue.
|
|
24
|
+
*/
|
|
25
|
+
export interface IEntityUpdateQueue {
|
|
26
|
+
readonly size: number;
|
|
27
|
+
enqueue(change: IEntityUpdate): void;
|
|
28
|
+
dequeue(): IEntityUpdate;
|
|
29
|
+
peek(): IEntityUpdate;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EntityUpdateType = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
|
|
6
|
-
*/
|
|
7
|
-
var EntityUpdateType;
|
|
8
|
-
(function (EntityUpdateType) {
|
|
9
|
-
EntityUpdateType["update"] = "update";
|
|
10
|
-
EntityUpdateType["remove"] = "remove";
|
|
11
|
-
})(EntityUpdateType = exports.EntityUpdateType || (exports.EntityUpdateType = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityUpdateType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The `EntityUpdateType` specifies whether the current should `update` or `remove` the Entity.
|
|
6
|
+
*/
|
|
7
|
+
var EntityUpdateType;
|
|
8
|
+
(function (EntityUpdateType) {
|
|
9
|
+
EntityUpdateType["update"] = "update";
|
|
10
|
+
EntityUpdateType["remove"] = "remove";
|
|
11
|
+
})(EntityUpdateType = exports.EntityUpdateType || (exports.EntityUpdateType = {}));
|
|
12
12
|
//# sourceMappingURL=entity-queue.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EntityTypeUid, IEntity } from "./entity";
|
|
2
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
3
|
-
/**
|
|
4
|
-
* The `IEntityRepository` is the central storage for keeping track of existing Entities.
|
|
5
|
-
* It provides basic CRUD functionality.
|
|
6
|
-
*/
|
|
7
|
-
export interface IEntityRepository {
|
|
8
|
-
readonly size: number;
|
|
9
|
-
has(proxy: IEntityProxy): boolean;
|
|
10
|
-
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
11
|
-
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
12
|
-
listAll(): IEntity[];
|
|
13
|
-
set(entity: IEntity): void;
|
|
14
|
-
delete(proxy: IEntityProxy): void;
|
|
15
|
-
clear(entityType: EntityTypeUid): void;
|
|
16
|
-
}
|
|
1
|
+
import { EntityTypeUid, IEntity } from "./entity";
|
|
2
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
3
|
+
/**
|
|
4
|
+
* The `IEntityRepository` is the central storage for keeping track of existing Entities.
|
|
5
|
+
* It provides basic CRUD functionality.
|
|
6
|
+
*/
|
|
7
|
+
export interface IEntityRepository {
|
|
8
|
+
readonly size: number;
|
|
9
|
+
has(proxy: IEntityProxy): boolean;
|
|
10
|
+
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
11
|
+
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
12
|
+
listAll(): IEntity[];
|
|
13
|
+
set(entity: IEntity): void;
|
|
14
|
+
delete(proxy: IEntityProxy): void;
|
|
15
|
+
clear(entityType: EntityTypeUid): void;
|
|
16
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-repository.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
2
|
-
/**
|
|
3
|
-
* The `IEntityScheduler` is the main way of queuing `IEntityUpdate` instances on an Interval (based on time or a custom implementation).
|
|
4
|
-
*
|
|
5
|
-
* It usually reads the Entities from the `IEntityRepository`, and uses the `IEntityUpdateQueue` to enqueue Entity updates.
|
|
6
|
-
*/
|
|
7
|
-
export interface IEntityScheduler {
|
|
8
|
-
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
9
|
-
remove(entityProxy: IEntityProxy): void;
|
|
10
|
-
has(entityProxy: IEntityProxy): boolean;
|
|
11
|
-
}
|
|
1
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
2
|
+
/**
|
|
3
|
+
* The `IEntityScheduler` is the main way of queuing `IEntityUpdate` instances on an Interval (based on time or a custom implementation).
|
|
4
|
+
*
|
|
5
|
+
* It usually reads the Entities from the `IEntityRepository`, and uses the `IEntityUpdateQueue` to enqueue Entity updates.
|
|
6
|
+
*/
|
|
7
|
+
export interface IEntityScheduler {
|
|
8
|
+
schedule(entityProxy: IEntityProxy, intervalMs?: number): void;
|
|
9
|
+
remove(entityProxy: IEntityProxy): void;
|
|
10
|
+
has(entityProxy: IEntityProxy): boolean;
|
|
11
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-scheduler.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
-
import { IComponent } from "../components/component";
|
|
3
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
4
|
-
import { IEntity, IEntityModel } from "./entity";
|
|
5
|
-
import { IEntityEvent, IEventData } from "./entity-events";
|
|
6
|
-
/**
|
|
7
|
-
* The `IEntitySnapshot` contains the full or partial serializable state of an Entity.
|
|
8
|
-
*
|
|
9
|
-
* It can be used to capture Entity state changes (deltas) or update existing Entity with changes coming from a remote source (e.g. server or other peers).
|
|
10
|
-
*/
|
|
11
|
-
export interface IEntitySnapshot {
|
|
12
|
-
readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
|
|
13
|
-
readonly components?: IComponent[];
|
|
14
|
-
readonly proxies?: IEntityProxy[];
|
|
15
|
-
readonly events?: IEntityEvent<IEventData>[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The `IEntitySnapshotProvider` is the main provider for both creating snapshots for an Entity,
|
|
19
|
-
* as well as updating Entity state based off an `IEntitySnapshot`.
|
|
20
|
-
*/
|
|
21
|
-
export interface IEntitySnapshotProvider {
|
|
22
|
-
applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
|
|
23
|
-
createSnapshot(entity: IEntity): IEntitySnapshot;
|
|
24
|
-
}
|
|
1
|
+
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
+
import { IComponent } from "../components/component";
|
|
3
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
4
|
+
import { IEntity, IEntityModel } from "./entity";
|
|
5
|
+
import { IEntityEvent, IEventData } from "./entity-events";
|
|
6
|
+
/**
|
|
7
|
+
* The `IEntitySnapshot` contains the full or partial serializable state of an Entity.
|
|
8
|
+
*
|
|
9
|
+
* It can be used to capture Entity state changes (deltas) or update existing Entity with changes coming from a remote source (e.g. server or other peers).
|
|
10
|
+
*/
|
|
11
|
+
export interface IEntitySnapshot {
|
|
12
|
+
readonly identity?: Readonly<IdentityComponent<IEntityModel>>;
|
|
13
|
+
readonly components?: IComponent[];
|
|
14
|
+
readonly proxies?: IEntityProxy[];
|
|
15
|
+
readonly events?: IEntityEvent<IEventData>[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `IEntitySnapshotProvider` is the main provider for both creating snapshots for an Entity,
|
|
19
|
+
* as well as updating Entity state based off an `IEntitySnapshot`.
|
|
20
|
+
*/
|
|
21
|
+
export interface IEntitySnapshotProvider {
|
|
22
|
+
applySnapshot(entity: IEntity, snapshot: IEntitySnapshot): void;
|
|
23
|
+
createSnapshot(entity: IEntity): IEntitySnapshot;
|
|
24
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity-snapshot.js.map
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
-
import { ComponentTypeUid, IComponent } from "../components/component";
|
|
3
|
-
import { IEntityProxy } from "./entity-proxies";
|
|
4
|
-
|
|
5
|
-
export type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { IdentityComponent } from "../components/identity-component";
|
|
2
|
+
import { ComponentTypeUid, IComponent } from "../components/component";
|
|
3
|
+
import { IEntityProxy } from "./entity-proxies";
|
|
4
|
+
import { BooleanProps } from "../utils/types";
|
|
5
|
+
export type EntityTypeUid = string | number;
|
|
6
|
+
export type EntityUid = string | number;
|
|
7
|
+
/**
|
|
8
|
+
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
9
|
+
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
|
10
|
+
*/
|
|
11
|
+
export interface IEntityModel<TFeatures extends BooleanProps<TFeatures> = unknown> {
|
|
12
|
+
readonly uid: EntityUid;
|
|
13
|
+
readonly features?: TFeatures;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The `IEntity` is basically a container of Components and Entity Proxies.
|
|
17
|
+
* Only Systems can manipulate the internal state of the Entity, by altering its Components' data.
|
|
18
|
+
*
|
|
19
|
+
* The implementations of `IEntity` can contain quick-access methods for `Components` or `Proxies` but should not contain any logic
|
|
20
|
+
* apart from quick-access functionality.
|
|
21
|
+
*/
|
|
22
|
+
export interface IEntity {
|
|
23
|
+
readonly components: ReadonlyMap<ComponentTypeUid, IComponent>;
|
|
24
|
+
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
25
|
+
/**
|
|
26
|
+
* The IdentityComponent represents mandatory state any Entity needs to have.
|
|
27
|
+
*/
|
|
28
|
+
readonly identity: Readonly<IdentityComponent<IEntityModel>>;
|
|
29
|
+
/**
|
|
30
|
+
* Own Proxy reference, points to this Entity. Useful for quick access of Proxy data.
|
|
31
|
+
*/
|
|
32
|
+
readonly myProxy: Readonly<IEntityProxy>;
|
|
33
|
+
}
|
package/dist/entities/entity.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=entity.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IEntity } from "../entities/entity";
|
|
2
|
-
import { ISystemPipelineContext } from "../systems/system-pipeline-context";
|
|
3
|
-
/**
|
|
4
|
-
* The IContextFactory can be used as an abstraction layer to quickly create SystemPipelineContext objects,
|
|
5
|
-
* without having to manually resolve all of their dependencies.
|
|
6
|
-
*/
|
|
7
|
-
export interface IContextFactory {
|
|
8
|
-
createPipelineContext<TEntity extends IEntity>(entity: TEntity): ISystemPipelineContext<TEntity>;
|
|
9
|
-
}
|
|
1
|
+
import { IEntity } from "../entities/entity";
|
|
2
|
+
import { ISystemPipelineContext } from "../systems/system-pipeline-context";
|
|
3
|
+
/**
|
|
4
|
+
* The IContextFactory can be used as an abstraction layer to quickly create SystemPipelineContext objects,
|
|
5
|
+
* without having to manually resolve all of their dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export interface IContextFactory {
|
|
8
|
+
createPipelineContext<TEntity extends IEntity>(entity: TEntity): ISystemPipelineContext<TEntity>;
|
|
9
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=context-factory.js.map
|