@awesome-ecs/abstract 0.12.0 → 0.13.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/component.d.ts +1 -1
- package/dist/entities/entity-events.d.ts +16 -3
- package/dist/entities/entity-repository.d.ts +1 -0
- package/dist/entities/entity.d.ts +2 -2
- package/dist/index.d.ts +35 -35
- package/dist/index.js.map +1 -1
- package/dist/pipelines/middleware-result.d.ts +1 -1
- package/dist/pipelines/middleware-stop.d.ts +1 -1
- package/dist/systems/context/system-context-events.d.ts +47 -1
- package/dist/systems/runtime/systems-runtime-middleware.d.ts +1 -1
- package/dist/systems/system-pipeline-middleware.d.ts +1 -1
- package/dist/utils/performance-timer.d.ts +1 -1
- package/dist/utils/types.d.ts +9 -9
- package/package.json +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IEntityProxy } from "./entity-proxies";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type EntityEventUid = string | number;
|
|
3
|
+
export type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
4
4
|
/**
|
|
5
5
|
* The `IEventData` contains the event-specific state. At the very least, it contains the `Event Unique Identifier`.
|
|
6
6
|
*/
|
|
@@ -25,7 +25,20 @@ export interface IEntityEventsManager {
|
|
|
25
25
|
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
26
26
|
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
27
27
|
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
28
|
-
|
|
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;
|
|
29
42
|
}
|
|
30
43
|
/**
|
|
31
44
|
* The `IEntityEventsDispatcher` is the main access point for dispatching events to Entities.
|
|
@@ -5,6 +5,7 @@ import { IEntityProxy } from "./entity-proxies";
|
|
|
5
5
|
* It provides basic CRUD functionality.
|
|
6
6
|
*/
|
|
7
7
|
export interface IEntityRepository {
|
|
8
|
+
readonly size: number;
|
|
8
9
|
has(proxy: IEntityProxy): boolean;
|
|
9
10
|
get<TEntity extends IEntity>(proxy: IEntityProxy): TEntity;
|
|
10
11
|
getAll<TEntity extends IEntity>(entityType: EntityTypeUid): TEntity[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IdentityComponent } from "../components/identity-component";
|
|
2
2
|
import { ComponentTypeUid, IComponent } from "../components/component";
|
|
3
3
|
import { IEntityProxy } from "./entity-proxies";
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type EntityTypeUid = string | number;
|
|
5
|
+
export type EntityUid = string | number;
|
|
6
6
|
/**
|
|
7
7
|
* The `IEntityModel` represents the basic identity information about the current `IEntity`.
|
|
8
8
|
* It's mandatory for each Entity, and it contains the minimal-required information needed for instantiating the Entity.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
12
|
-
export * from
|
|
13
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export * from
|
|
18
|
-
export * from
|
|
19
|
-
export * from
|
|
20
|
-
export * from
|
|
21
|
-
export * from
|
|
22
|
-
export * from
|
|
23
|
-
export * from
|
|
24
|
-
export * from
|
|
25
|
-
export * from
|
|
26
|
-
export * from
|
|
27
|
-
export * from
|
|
28
|
-
export * from
|
|
29
|
-
export * from
|
|
30
|
-
export * from
|
|
31
|
-
export * from
|
|
32
|
-
export * from
|
|
33
|
-
export * from
|
|
34
|
-
export * from
|
|
35
|
-
export * from
|
|
1
|
+
export * from "./components/component";
|
|
2
|
+
export * from "./components/identity-component";
|
|
3
|
+
export * from "./entities/entity";
|
|
4
|
+
export * from "./entities/entity-events";
|
|
5
|
+
export * from "./entities/entity-proxies";
|
|
6
|
+
export * from "./entities/entity-queue";
|
|
7
|
+
export * from "./entities/entity-repository";
|
|
8
|
+
export * from "./entities/entity-scheduler";
|
|
9
|
+
export * from "./entities/entity-snapshot";
|
|
10
|
+
export * from "./factories/context-factory";
|
|
11
|
+
export * from "./factories/pipeline-factory";
|
|
12
|
+
export * from "./factories/runtime-factory";
|
|
13
|
+
export * from "./runtime/runtime-pipeline";
|
|
14
|
+
export * from "./runtime/runtime-result";
|
|
15
|
+
export * from "./runtime/runtime-status";
|
|
16
|
+
export * from "./pipelines/middleware";
|
|
17
|
+
export * from "./pipelines/middleware-result";
|
|
18
|
+
export * from "./pipelines/middleware-stop";
|
|
19
|
+
export * from "./pipelines/pipeline";
|
|
20
|
+
export * from "./pipelines/pipeline-type";
|
|
21
|
+
export * from "./systems/context/system-context-events";
|
|
22
|
+
export * from "./systems/context/system-context-proxies";
|
|
23
|
+
export * from "./systems/context/system-context-repository";
|
|
24
|
+
export * from "./systems/context/system-context-scheduler";
|
|
25
|
+
export * from "./systems/context/system-context-snapshot";
|
|
26
|
+
export * from "./systems/runtime/systems-runtime-context";
|
|
27
|
+
export * from "./systems/runtime/systems-runtime-middleware";
|
|
28
|
+
export * from "./systems/system-pipeline-middleware";
|
|
29
|
+
export * from "./systems/system-pipeline-context";
|
|
30
|
+
export * from "./systems/system-pipeline-type";
|
|
31
|
+
export * from "./systems/systems-module";
|
|
32
|
+
export * from "./systems/systems-runtime";
|
|
33
|
+
export * from "./utils/json-serializer";
|
|
34
|
+
export * from "./utils/performance-timer";
|
|
35
|
+
export * from "./utils/types";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,kEAAgD;AAEhD,oDAAkC;AAClC,2DAAyC;AACzC,4DAA0C;AAC1C,0DAAwC;AACxC,+DAA6C;AAC7C,8DAA4C;AAC5C,6DAA2C;AAE3C,8DAA4C;AAC5C,+DAA6C;AAC7C,8DAA4C;AAE5C,6DAA2C;AAC3C,2DAAyC;AACzC,2DAAyC;AAEzC,yDAAuC;AACvC,gEAA8C;AAC9C,8DAA4C;AAC5C,uDAAqC;AACrC,4DAA0C;AAE1C,0EAAwD;AACxD,2EAAyD;AACzD,8EAA4D;AAC5D,6EAA2D;AAC3D,4EAA0D;AAE1D,4EAA0D;AAC1D,+EAA6D;AAE7D,uEAAqD;AACrD,oEAAkD;AAClD,iEAA+C;AAC/C,2DAAyC;AACzC,4DAA0C;AAE1C,0DAAwC;AACxC,4DAA0C;AAC1C,gDAA8B"}
|
|
@@ -2,4 +2,4 @@ import { IRuntimeResult } from "../runtime/runtime-result";
|
|
|
2
2
|
/**
|
|
3
3
|
* The Middleware could potentially run another Pipeline inside, and so we can propagate that result.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type MiddlewareResult = void | IRuntimeResult;
|
|
@@ -5,15 +5,61 @@ import { IEntityProxy } from "../../entities/entity-proxies";
|
|
|
5
5
|
* The access is made in a SystemMiddleware through the provided ISystemPipelineContext.
|
|
6
6
|
*/
|
|
7
7
|
export interface ISystemContextEvents {
|
|
8
|
+
/**
|
|
9
|
+
* Dispatches and schedules the Event to it's Subscribers or provided Entity Targets.
|
|
10
|
+
* @param data The EventData to dispatch.
|
|
11
|
+
* @param targets (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
|
|
12
|
+
*/
|
|
8
13
|
dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* Dispatches and schedules the Events to their Subscribers or provided Entity Targets.
|
|
16
|
+
* @param data The EventData Array to dispatch.
|
|
17
|
+
* @param targets (optional) The Entities to send this event to. Providing this parameter will not broadcast this event.
|
|
18
|
+
*/
|
|
9
19
|
dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the Event with the given UID if it has been previously set on the current Context.
|
|
22
|
+
* @param uid The Event UID to retrieve.
|
|
23
|
+
*/
|
|
10
24
|
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves all the Events currently set on the Context.
|
|
27
|
+
*/
|
|
11
28
|
listEvents<TEventData extends IEventData>(): IEntityEvent<TEventData>[];
|
|
29
|
+
/**
|
|
30
|
+
* Returns whether the Event with the given UID has previously been set on the current Context.
|
|
31
|
+
* @param uid The Event UID to check for existence.
|
|
32
|
+
*/
|
|
12
33
|
hasEvent(uid?: EntityEventUid): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Subscribes to Events with the given UID. When the matching Event is dispatched,
|
|
36
|
+
* the Entity update loop will set this Event on the Pipeline Context.
|
|
37
|
+
* @param uid The Event UID to subscribe to.
|
|
38
|
+
* @param filter (optional) Provides a callback function that will be executed on all matching Events.
|
|
39
|
+
* Can be used to filter what Event to schedule through to the current Entity update.
|
|
40
|
+
*/
|
|
13
41
|
subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
|
|
42
|
+
/**
|
|
43
|
+
* Stops subscribing to Events with the given UID. The Entity will not receive any future Events with this UID.
|
|
44
|
+
* @param uid The Event UID to stop listening to.
|
|
45
|
+
*/
|
|
14
46
|
unsubscribeFrom(uid: EntityEventUid): void;
|
|
15
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Adds the given Events into the Context instance.
|
|
49
|
+
* @param events The Event instances to be set on the Context.
|
|
50
|
+
*/
|
|
16
51
|
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Adds the given Event into the Context instance.
|
|
54
|
+
* @param event The Event instance to be set on the Context.
|
|
55
|
+
*/
|
|
17
56
|
setContextEvent(event: IEntityEvent<IEventData>): void;
|
|
57
|
+
/**
|
|
58
|
+
* Removes all the Events currently set on the Context instance.
|
|
59
|
+
*/
|
|
18
60
|
clearContextEvents(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Removes all the Event Subscriptions for the current Entity.
|
|
63
|
+
*/
|
|
64
|
+
clearSubscriptions(): void;
|
|
19
65
|
}
|
|
@@ -5,4 +5,4 @@ import { ISystemsRuntimeContext } from "./systems-runtime-context";
|
|
|
5
5
|
* The ISystemsRuntimeMiddleware represents the building blocks of executing SystemsModule registered Pipelines.
|
|
6
6
|
* It receives the current State in the Context, and can decide which SystemPipelines to execute.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type ISystemsRuntimeMiddleware<TEntity extends IEntity> = IMiddleware<ISystemsRuntimeContext<TEntity>>;
|
|
@@ -5,4 +5,4 @@ import { ISystemPipelineContext } from "./system-pipeline-context";
|
|
|
5
5
|
* The SystemMiddleware is the basic System implementation that can be registered as a Middleware in a SystemPipeline.
|
|
6
6
|
* It provides a SystemPipelineContext to it's exposed methods.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type ISystemMiddleware<TEntity extends IEntity> = IMiddleware<ISystemPipelineContext<TEntity>>;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Mutable<T> = {
|
|
2
2
|
-readonly [K in keyof T]: T[K];
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type MutableDeep<T> = {
|
|
5
5
|
-readonly [K in keyof T]: Mutable<T[K]>;
|
|
6
6
|
};
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
7
|
+
type ImmutablePrimitive = undefined | null | boolean | string | number | Function;
|
|
8
|
+
export type Immutable<T> = T extends ImmutablePrimitive ? T : T extends Array<infer U> ? ImmutableArray<U> : T extends Map<infer K, infer V> ? ImmutableMap<K, V> : T extends Set<infer M> ? ImmutableSet<M> : ImmutableObject<T>;
|
|
9
|
+
export type ImmutableArray<T> = ReadonlyArray<Immutable<T>>;
|
|
10
|
+
export type ImmutableMap<K, V> = ReadonlyMap<Immutable<K>, Immutable<V>>;
|
|
11
|
+
export type ImmutableSet<T> = ReadonlySet<Immutable<T>>;
|
|
12
|
+
export type ImmutableObject<T> = {
|
|
13
13
|
readonly [K in keyof T]: T[K];
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type ImmutableObjectDeep<T> = {
|
|
16
16
|
readonly [K in keyof T]: Immutable<T[K]>;
|
|
17
17
|
};
|
|
18
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesome-ecs/abstract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "A comprehensive Entity-Component-System (ECS) Architecture implementation. Abstract components.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
-
"devDependencies": {
|
|
11
|
-
"typescript": "^4.8.2"
|
|
12
|
-
},
|
|
13
10
|
"scripts": {
|
|
14
11
|
"build": "rimraf ./dist && npx tsc --build"
|
|
15
12
|
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^18.11.18",
|
|
15
|
+
"typescript": "^4.9.5"
|
|
16
|
+
},
|
|
16
17
|
"repository": {
|
|
17
18
|
"type": "git",
|
|
18
19
|
"url": "git+https://github.com/andreicojocaru/awesome-ecs.git"
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"url": "https://github.com/andreicojocaru/awesome-ecs/issues"
|
|
33
34
|
},
|
|
34
35
|
"homepage": "https://github.com/andreicojocaru/awesome-ecs#readme",
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "f8f3bafbb56bf01e7e0f5603b915e7209fdd5c50"
|
|
36
37
|
}
|