@awesome-ecs/abstract 0.2.4 → 0.3.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/LICENSE +21 -21
- package/dist/entities/entity-event.d.ts +27 -0
- package/dist/entities/{entity-trigger.js → entity-event.js} +1 -1
- package/dist/entities/entity-event.js.map +1 -0
- package/dist/entities/entity-queue.d.ts +2 -4
- package/dist/entities/entity-queue.js.map +1 -1
- package/dist/entities/entity.d.ts +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/systems/system-pipeline-context.d.ts +25 -19
- package/package.json +4 -4
- package/dist/components/component-factory.d.ts +0 -4
- package/dist/components/component-factory.js +0 -2
- package/dist/components/component-factory.js.map +0 -1
- package/dist/entities/entity-model.d.ts +0 -4
- package/dist/entities/entity-model.js +0 -2
- package/dist/entities/entity-model.js.map +0 -1
- package/dist/entities/entity-trigger.d.ts +0 -17
- package/dist/entities/entity-trigger.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Andrei C
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Andrei C
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IEntityProxy } from "./entity-proxy";
|
|
2
|
+
export declare type EntityEventUid = string | number;
|
|
3
|
+
export declare type EntityEventSubscriptionFilter = (event: IEntityEvent<IEventData>) => boolean;
|
|
4
|
+
export interface IEventData {
|
|
5
|
+
uid: EntityEventUid;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Entity Events represent the basic building blocks for a Pub/Sub pattern, to synchronize
|
|
9
|
+
* state between multiple Entities.
|
|
10
|
+
*
|
|
11
|
+
* The Events are past actions that already happened within a state. They are scheduled as part of the EntityUpdate model.
|
|
12
|
+
* Other Systems subscribe and receive updates with the Events included in their SystemContext model.
|
|
13
|
+
*/
|
|
14
|
+
export interface IEntityEvent<TEventData extends IEventData> {
|
|
15
|
+
origin: IEntityProxy;
|
|
16
|
+
target?: IEntityProxy;
|
|
17
|
+
data: TEventData;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The EntityEventsManager represents the Pub/Sub broker for EntityEvents.
|
|
21
|
+
*/
|
|
22
|
+
export interface IEntityEventsManager {
|
|
23
|
+
subscribe(uid: EntityEventUid, entity: IEntityProxy, filter?: EntityEventSubscriptionFilter): void;
|
|
24
|
+
unsubscribe(uid: EntityEventUid, entity: IEntityProxy): void;
|
|
25
|
+
getSubscriptions(event: IEntityEvent<IEventData>): IEntityProxy[];
|
|
26
|
+
clearSubscriptions(uid?: EntityEventUid): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-event.js","sourceRoot":"","sources":["../../src/entities/entity-event.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EntityTriggerUid } from "..";
|
|
2
1
|
import { IEntityModel } from "./entity";
|
|
2
|
+
import { IEntityEvent, IEventData } from "./entity-event";
|
|
3
3
|
import { IEntityProxy } from "./entity-proxy";
|
|
4
|
-
import { IEntityTrigger, ITriggerData } from "./entity-trigger";
|
|
5
4
|
/**
|
|
6
5
|
* The Entity update state for this change.
|
|
7
6
|
*/
|
|
@@ -16,8 +15,7 @@ export interface IEntityUpdate {
|
|
|
16
15
|
type: EntityUpdateType;
|
|
17
16
|
entity: IEntityProxy;
|
|
18
17
|
model?: IEntityModel;
|
|
19
|
-
|
|
20
|
-
forceUpdate?: boolean;
|
|
18
|
+
events?: IEntityEvent<IEventData>[];
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
21
|
* The Entity Updates will be queued up, and can be picked up in order.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-queue.js","sourceRoot":"","sources":["../../src/entities/entity-queue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"entity-queue.js","sourceRoot":"","sources":["../../src/entities/entity-queue.ts"],"names":[],"mappings":";;;AAIA;;GAEG;AACH,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;AACnB,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IdentityComponent } from "../components/identity-component";
|
|
2
2
|
import { ComponentUid, IComponent } from "../components/component";
|
|
3
|
-
import { EntityTriggerUid, IEntityTrigger, ITriggerData } from "./entity-trigger";
|
|
4
3
|
import { IEntityProxy } from "./entity-proxy";
|
|
5
4
|
export declare type EntityTypeUid = string | number;
|
|
6
5
|
export declare type EntityUid = string | number;
|
|
@@ -13,7 +12,6 @@ export interface IEntityModel {
|
|
|
13
12
|
export interface IEntity {
|
|
14
13
|
readonly components: Map<ComponentUid, IComponent>;
|
|
15
14
|
readonly proxies: Map<EntityTypeUid, Map<EntityUid, IEntityProxy>>;
|
|
16
|
-
readonly triggers: Map<EntityTriggerUid, IEntityTrigger<ITriggerData>[]>;
|
|
17
15
|
readonly identity: IdentityComponent<IEntityModel>;
|
|
18
16
|
readonly myProxy: IEntityProxy;
|
|
19
17
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from './components/component';
|
|
2
2
|
export * from './components/identity-component';
|
|
3
3
|
export * from './entities/entity';
|
|
4
|
+
export * from './entities/entity-event';
|
|
4
5
|
export * from './entities/entity-proxy';
|
|
5
6
|
export * from './entities/entity-queue';
|
|
6
7
|
export * from './entities/entity-repository';
|
|
7
8
|
export * from './entities/entity-scheduler';
|
|
8
|
-
export * from './entities/entity-trigger';
|
|
9
9
|
export * from './pipelines/middleware';
|
|
10
10
|
export * from './pipelines/pipeline';
|
|
11
11
|
export * from './systems/system-middleware';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -13,11 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
17
|
__exportStar(require("./components/component"), exports);
|
|
14
18
|
__exportStar(require("./components/identity-component"), exports);
|
|
15
19
|
__exportStar(require("./entities/entity"), exports);
|
|
20
|
+
__exportStar(require("./entities/entity-event"), exports);
|
|
16
21
|
__exportStar(require("./entities/entity-proxy"), exports);
|
|
17
22
|
__exportStar(require("./entities/entity-queue"), exports);
|
|
18
23
|
__exportStar(require("./entities/entity-repository"), exports);
|
|
19
24
|
__exportStar(require("./entities/entity-scheduler"), exports);
|
|
20
|
-
__exportStar(require("./entities/entity-trigger"), exports);
|
|
21
25
|
__exportStar(require("./pipelines/middleware"), exports);
|
|
22
26
|
__exportStar(require("./pipelines/pipeline"), exports);
|
|
23
27
|
__exportStar(require("./systems/system-middleware"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC;AACtC,kEAA+C;AAE/C,oDAAiC;AACjC,0DAAuC;AACvC,0DAAuC;AACvC,0DAAuC;AACvC,+DAA4C;AAC5C,8DAA2C;AAE3C,yDAAsC;AACtC,uDAAoC;AAEpC,8DAA2C;AAC3C,4DAAyC;AACzC,oEAAiD;AACjD,iEAA8C;AAC9C,2DAAwC;AAExC,4DAAyC"}
|
|
@@ -1,30 +1,36 @@
|
|
|
1
1
|
import { EntityTypeUid, IEntity, IEntityModel } from "../entities/entity";
|
|
2
|
+
import { EntityEventUid, IEntityEvent, IEventData } from "../entities/entity-event";
|
|
2
3
|
import { EntityProxy, IEntityProxy } from "../entities/entity-proxy";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
intervalMs?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface ISystemPipelineContext<TEntity extends IEntity> {
|
|
9
|
-
readonly entity: TEntity;
|
|
10
|
-
addEntity(entityType: EntityTypeUid, model: IEntityModel, triggers?: ITriggerData[]): void;
|
|
4
|
+
export interface ISystemContextRepository {
|
|
5
|
+
addEntity(entityType: EntityTypeUid, model: IEntityModel, events?: IEntityEvent<IEventData>[]): void;
|
|
6
|
+
getEntity<TEntity extends IEntity>(proxy: EntityProxy<TEntity>): TEntity;
|
|
11
7
|
updateEntity(target?: IEntityProxy, model?: IEntityModel): void;
|
|
12
8
|
removeEntity(target?: IEntityProxy): void;
|
|
9
|
+
}
|
|
10
|
+
export interface ISystemContextScheduler {
|
|
13
11
|
scheduleUpdateOnInterval(target?: IEntityProxy, intervalMs?: number): void;
|
|
14
12
|
clearUpdateOnInterval(target?: IEntityProxy): void;
|
|
15
|
-
|
|
13
|
+
}
|
|
14
|
+
export interface ISystemContextProxies {
|
|
16
15
|
registerProxy(proxy: IEntityProxy, cleanup?: boolean): void;
|
|
17
16
|
registerProxies(proxies: IEntityProxy[], cleanup?: boolean): void;
|
|
18
17
|
removeProxy(proxy: IEntityProxy): void;
|
|
19
18
|
removeProxies(proxyEntityType?: EntityTypeUid): void;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
}
|
|
20
|
+
export interface ISystemContextEvents {
|
|
21
|
+
dispatchEvent<TEventData extends IEventData>(data: TEventData, ...targets: IEntityProxy[]): void;
|
|
22
|
+
dispatchEvents<TEventData extends IEventData>(data: TEventData[], ...targets: IEntityProxy[]): void;
|
|
23
|
+
getEvent<TEventData extends IEventData>(uid: EntityEventUid): IEntityEvent<TEventData>;
|
|
24
|
+
hasEvent(uid?: EntityEventUid): boolean;
|
|
25
|
+
subscribeTo<TEventData extends IEventData>(uid: EntityEventUid, filter?: (event: IEntityEvent<TEventData>) => boolean): void;
|
|
26
|
+
unsubscribeFrom(uid: EntityEventUid): void;
|
|
27
|
+
clearSubscriptions(uid?: EntityEventUid): void;
|
|
28
|
+
setContextEvents(events: IEntityEvent<IEventData>[]): void;
|
|
29
|
+
}
|
|
30
|
+
export interface ISystemPipelineContext<TEntity extends IEntity> {
|
|
31
|
+
readonly entity: TEntity;
|
|
32
|
+
readonly repository: ISystemContextRepository;
|
|
33
|
+
readonly scheduler: ISystemContextScheduler;
|
|
34
|
+
readonly proxies: ISystemContextProxies;
|
|
35
|
+
readonly events: ISystemContextEvents;
|
|
30
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesome-ecs/abstract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"typescript": "^4.
|
|
11
|
+
"typescript": "^4.6.2"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "npx tsc"
|
|
14
|
+
"build": "rm -rf ./dist && npx tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"url": "https://github.com/andreicojocaru/awesome-ecs/issues"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/andreicojocaru/awesome-ecs#readme",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "0d3a32919b66610ab4e2a9b735d9cb53f181a3f3"
|
|
36
36
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-factory.js","sourceRoot":"","sources":["../../src/components/component-factory.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-model.js","sourceRoot":"","sources":["../../src/entities/entity-model.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IEntityProxy } from "./entity-proxy";
|
|
2
|
-
import { EntityUpdateType } from "./entity-queue";
|
|
3
|
-
export declare type EntityTriggerUid = string | number;
|
|
4
|
-
export interface ITriggerData {
|
|
5
|
-
uid: EntityTriggerUid;
|
|
6
|
-
action?: EntityUpdateType;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Entity Triggers represent a basic inter-Entity messaging mechanism.
|
|
10
|
-
* Can be used to "trigger" actions in an Entity, from the systems of another Entity.
|
|
11
|
-
*
|
|
12
|
-
* The Triggers will be enqueued as part of an Entity Update envelope.
|
|
13
|
-
*/
|
|
14
|
-
export interface IEntityTrigger<TTriggerData extends ITriggerData> {
|
|
15
|
-
origin: IEntityProxy;
|
|
16
|
-
data: TTriggerData;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-trigger.js","sourceRoot":"","sources":["../../src/entities/entity-trigger.ts"],"names":[],"mappings":""}
|