bard-legends-framework 0.10.5 → 0.10.7
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/game-entities/_base/attachable.d.ts +10 -0
- package/dist/game-entities/_base/attachable.js +47 -0
- package/dist/game-entities/_base/attachable.store.d.ts +8 -0
- package/dist/game-entities/_base/attachable.store.js +43 -0
- package/dist/game-entities/_base/attachment-target.d.ts +16 -0
- package/dist/game-entities/_base/attachment-target.js +53 -0
- package/dist/game-entities/_base/destroyable.d.ts +3 -0
- package/dist/game-entities/_base/destroyable.js +10 -0
- package/dist/game-entities/_base/interfaces.d.ts +3 -0
- package/dist/game-entities/_base/interfaces.js +3 -0
- package/dist/game-entities/_base/mixins.d.ts +22 -0
- package/dist/game-entities/_base/mixins.js +60 -0
- package/dist/game-entities/base/attachable.d.ts +8 -7
- package/dist/game-entities/base/attachable.js +47 -21
- package/dist/game-entities/base/attachment-target.d.ts +9 -0
- package/dist/game-entities/base/attachment-target.js +53 -0
- package/dist/game-entities/base/attachment-target.test.d.ts +1 -0
- package/dist/game-entities/base/attachment-target.test.js +131 -0
- package/dist/game-entities/base/destroyable.d.ts +2 -3
- package/dist/game-entities/base/destroyable.js +0 -21
- package/dist/game-entities/base/helpers/attachable.store.d.ts +4 -4
- package/dist/game-entities/base/helpers/attachment-target.store.d.ts +1 -0
- package/dist/game-entities/base/helpers/attachment-target.store.js +40 -0
- package/dist/game-entities/base/helpers/decorate-actions-lib.d.ts +3 -3
- package/dist/game-entities/base/helpers/decorate-actions-lib.js +3 -3
- package/dist/game-entities/base/helpers/referance-variable.d.ts +2 -2
- package/dist/game-entities/base/helpers/referance-variable.js +2 -2
- package/dist/game-entities/base/interfaces.d.ts +8 -8
- package/dist/game-entities/entity/entity.d.ts +4 -4
- package/dist/game-entities/entity/entity.js +9 -2
- package/dist/game-entities/entity/entity.test.js +14 -3
- package/dist/game-entities/entity/singleton-entity.d.ts +0 -9
- package/dist/game-entities/entity/singleton-entity.js +0 -55
- package/dist/game-entities/entity/singleton-entity.test.js +4 -1
- package/dist/game-entities/index.d.ts +1 -1
- package/dist/game-entities/index.js +3 -3
- package/dist/game-entities/scene/scene.d.ts +22 -15
- package/dist/game-entities/scene/scene.js +56 -40
- package/dist/game-entities/scene/scene.test.js +45 -37
- package/dist/game-entities/service/service.test.js +20 -5
- package/dist/game-entities/view/view.d.ts +2 -3
- package/dist/game-entities/view/view.js +4 -4
- package/dist/game-entities/view/view.test.js +5 -2
- package/dist/pixi/components/helpers/smooth-scroller.d.ts +2 -2
- package/dist/pixi/components/helpers/smooth-scroller.js +1 -1
- package/dist/pixi/display-object/container-attributes.d.ts +2 -2
- package/dist/pixi/display-object/container-attributes.js +1 -1
- package/dist/pixi/display-object/container.d.ts +4 -0
- package/dist/pixi/display-object/container.js +14 -0
- package/dist/pixi/game.d.ts +2 -1
- package/dist/pixi/game.js +2 -0
- package/dist/utilities/libraries/animator/animator.d.ts +7 -2
- package/dist/utilities/libraries/animator/animator.js +23 -2
- package/dist/utilities/libraries/animator/animator.test.js +12 -3
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/slide-state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/state-animation.js +1 -1
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts +2 -2
- package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.js +1 -1
- package/package.json +5 -12
|
@@ -48,11 +48,14 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
48
48
|
});
|
|
49
49
|
(0, vitest_1.test)('create scene', () => {
|
|
50
50
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
51
|
+
async init() { }
|
|
52
|
+
update() { }
|
|
53
|
+
async prepareToClose() { }
|
|
51
54
|
};
|
|
52
55
|
SampleScene = __decorate([
|
|
53
56
|
(0, scene_1.SceneDecorator)()
|
|
54
57
|
], SampleScene);
|
|
55
|
-
SampleScene.open(
|
|
58
|
+
SampleScene.open();
|
|
56
59
|
(0, vitest_1.expect)(scene_1.Scene.activeScene.value).toBeDefined();
|
|
57
60
|
(0, vitest_1.expect)(scene_1.Scene.activeScene.value).toBeInstanceOf(SampleScene);
|
|
58
61
|
});
|
|
@@ -62,6 +65,8 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
62
65
|
(0, vitest_1.expect)(input.arg1).toEqual('test');
|
|
63
66
|
(0, vitest_1.expect)(input.arg2).toEqual(1);
|
|
64
67
|
}
|
|
68
|
+
update() { }
|
|
69
|
+
async prepareToClose() { }
|
|
65
70
|
};
|
|
66
71
|
SampleScene = __decorate([
|
|
67
72
|
(0, scene_1.SceneDecorator)()
|
|
@@ -85,49 +90,32 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
85
90
|
async init() {
|
|
86
91
|
(0, vitest_1.expect)(this.sampleService.value).toEqual('test');
|
|
87
92
|
}
|
|
93
|
+
update() { }
|
|
94
|
+
async prepareToClose() { }
|
|
88
95
|
};
|
|
89
96
|
SampleScene = __decorate([
|
|
90
97
|
(0, scene_1.SceneDecorator)(),
|
|
91
98
|
__metadata("design:paramtypes", [SampleService])
|
|
92
99
|
], SampleScene);
|
|
93
|
-
SampleScene.open(
|
|
94
|
-
});
|
|
95
|
-
(0, vitest_1.test)('open scene should destroy the previous scene', async () => {
|
|
96
|
-
var SampleScene1_1;
|
|
97
|
-
let SampleScene1 = class SampleScene1 extends scene_1.Scene {
|
|
98
|
-
static { SampleScene1_1 = this; }
|
|
99
|
-
static { this.destroyCalled = false; }
|
|
100
|
-
afterDestroy() {
|
|
101
|
-
SampleScene1_1.destroyCalled = true;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
SampleScene1 = SampleScene1_1 = __decorate([
|
|
105
|
-
(0, scene_1.SceneDecorator)()
|
|
106
|
-
], SampleScene1);
|
|
107
|
-
let SampleScene2 = class SampleScene2 extends scene_1.Scene {
|
|
108
|
-
};
|
|
109
|
-
SampleScene2 = __decorate([
|
|
110
|
-
(0, scene_1.SceneDecorator)()
|
|
111
|
-
], SampleScene2);
|
|
112
|
-
SampleScene1.open(undefined);
|
|
113
|
-
await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
|
|
114
|
-
(0, vitest_1.expect)(SampleScene1.destroyCalled).toBeFalsy();
|
|
115
|
-
SampleScene2.open(undefined);
|
|
116
|
-
await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
|
|
117
|
-
(0, vitest_1.expect)(scene_1.Scene.activeScene.value).toBeInstanceOf(SampleScene2);
|
|
118
|
-
(0, vitest_1.expect)(SampleScene1.destroyCalled).toBeTruthy();
|
|
100
|
+
SampleScene.open();
|
|
119
101
|
});
|
|
120
102
|
(0, vitest_1.test)('get instance should return the scene with its type', () => {
|
|
121
103
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
104
|
+
async init() { }
|
|
105
|
+
update() { }
|
|
106
|
+
async prepareToClose() { }
|
|
122
107
|
};
|
|
123
108
|
SampleScene = __decorate([
|
|
124
109
|
(0, scene_1.SceneDecorator)()
|
|
125
110
|
], SampleScene);
|
|
126
|
-
SampleScene.open(
|
|
111
|
+
SampleScene.open();
|
|
127
112
|
(0, vitest_1.expect)(SampleScene.getInstanceOrFail()).toBeInstanceOf(SampleScene);
|
|
128
113
|
});
|
|
129
114
|
(0, vitest_1.test)('getInstance should throw error when there is no active scene', () => {
|
|
130
115
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
116
|
+
async init() { }
|
|
117
|
+
update() { }
|
|
118
|
+
async prepareToClose() { }
|
|
131
119
|
};
|
|
132
120
|
SampleScene = __decorate([
|
|
133
121
|
(0, scene_1.SceneDecorator)()
|
|
@@ -136,30 +124,34 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
136
124
|
});
|
|
137
125
|
(0, vitest_1.test)('getInstance should throw error when called while the open scene belongs to another class', () => {
|
|
138
126
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
127
|
+
async init() { }
|
|
128
|
+
update() { }
|
|
129
|
+
async prepareToClose() { }
|
|
139
130
|
};
|
|
140
131
|
SampleScene = __decorate([
|
|
141
132
|
(0, scene_1.SceneDecorator)()
|
|
142
133
|
], SampleScene);
|
|
143
134
|
let SampleScene2 = class SampleScene2 extends scene_1.Scene {
|
|
135
|
+
async init() { }
|
|
136
|
+
update() { }
|
|
137
|
+
async prepareToClose() { }
|
|
144
138
|
};
|
|
145
139
|
SampleScene2 = __decorate([
|
|
146
140
|
(0, scene_1.SceneDecorator)()
|
|
147
141
|
], SampleScene2);
|
|
148
|
-
SampleScene.open(
|
|
142
|
+
SampleScene.open();
|
|
149
143
|
(0, vitest_1.expect)(() => SampleScene2.getInstanceOrFail()).toThrow();
|
|
150
144
|
});
|
|
151
145
|
(0, vitest_1.test)('destroyed scenes should destroy its entities and its views', async () => {
|
|
152
146
|
var SampleEntity_1;
|
|
153
147
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
148
|
+
async init() { }
|
|
149
|
+
update() { }
|
|
150
|
+
async prepareToClose() { }
|
|
154
151
|
};
|
|
155
152
|
SampleScene = __decorate([
|
|
156
153
|
(0, scene_1.SceneDecorator)()
|
|
157
154
|
], SampleScene);
|
|
158
|
-
let SampleScene2 = class SampleScene2 extends scene_1.Scene {
|
|
159
|
-
};
|
|
160
|
-
SampleScene2 = __decorate([
|
|
161
|
-
(0, scene_1.SceneDecorator)()
|
|
162
|
-
], SampleScene2);
|
|
163
155
|
let SampleEntity = class SampleEntity extends entity_1.Entity {
|
|
164
156
|
static { SampleEntity_1 = this; }
|
|
165
157
|
static { this.entityDestroyCalled = false; }
|
|
@@ -181,9 +173,9 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
181
173
|
entity: SampleEntity
|
|
182
174
|
})
|
|
183
175
|
], _SampleView);
|
|
184
|
-
await SampleScene.open(
|
|
176
|
+
await SampleScene.open().onOpen;
|
|
185
177
|
new SampleEntity().attach(scene_1.Scene.getActiveSceneOrFail());
|
|
186
|
-
|
|
178
|
+
await SampleScene.getInstanceOrFail().close();
|
|
187
179
|
await update_cycle_1.UpdateCycle.triggerUpdateTick(1); // Update cycle should take place to destroy functions to be called
|
|
188
180
|
(0, vitest_1.expect)(SampleEntity.entityDestroyCalled).toBeTruthy();
|
|
189
181
|
(0, vitest_1.expect)(viewDestroyCalled).toBeTruthy();
|
|
@@ -193,9 +185,11 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
193
185
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
194
186
|
static { SampleScene_1 = this; }
|
|
195
187
|
static { this.sceneUpdateCalled = false; }
|
|
188
|
+
async init() { }
|
|
196
189
|
update(time, delta) {
|
|
197
190
|
SampleScene_1.sceneUpdateCalled = true;
|
|
198
191
|
}
|
|
192
|
+
async prepareToClose() { }
|
|
199
193
|
};
|
|
200
194
|
SampleScene = SampleScene_1 = __decorate([
|
|
201
195
|
(0, scene_1.SceneDecorator)()
|
|
@@ -220,12 +214,26 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
220
214
|
}),
|
|
221
215
|
__metadata("design:paramtypes", [SampleEntity])
|
|
222
216
|
], _SampleView);
|
|
223
|
-
SampleScene.open(
|
|
217
|
+
SampleScene.open();
|
|
224
218
|
new SampleEntity().attach(scene_1.Scene.getActiveSceneOrFail());
|
|
225
219
|
await (0, helpers_lib_1.Wait)(); // Wait for the async view init to expect the update call
|
|
226
220
|
update_cycle_1.UpdateCycle.triggerUpdateTick(1);
|
|
227
221
|
(0, vitest_1.expect)(SampleScene.sceneUpdateCalled).toBeTruthy();
|
|
228
222
|
(0, vitest_1.expect)(viewUpdateCalled).toBeTruthy();
|
|
229
223
|
});
|
|
224
|
+
(0, vitest_1.test)('closing scene should destroy it', async () => {
|
|
225
|
+
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
226
|
+
async init() { }
|
|
227
|
+
update() { }
|
|
228
|
+
async prepareToClose() { }
|
|
229
|
+
};
|
|
230
|
+
SampleScene = __decorate([
|
|
231
|
+
(0, scene_1.SceneDecorator)()
|
|
232
|
+
], SampleScene);
|
|
233
|
+
await SampleScene.open().onOpen;
|
|
234
|
+
let scene = SampleScene.getInstanceOrFail();
|
|
235
|
+
await scene.close();
|
|
236
|
+
(0, vitest_1.expect)(scene.destroyed).toBeTruthy();
|
|
237
|
+
});
|
|
230
238
|
});
|
|
231
239
|
//# sourceMappingURL=scene.test.js.map
|
|
@@ -64,11 +64,14 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
64
64
|
(0, vitest_1.test)('inject services to views', () => {
|
|
65
65
|
var SampleService_2, SampleView_1;
|
|
66
66
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
67
|
+
async init() { }
|
|
68
|
+
update() { }
|
|
69
|
+
async prepareToClose() { }
|
|
67
70
|
};
|
|
68
71
|
SampleScene = __decorate([
|
|
69
72
|
(0, scene_1.SceneDecorator)()
|
|
70
73
|
], SampleScene);
|
|
71
|
-
SampleScene.open(
|
|
74
|
+
SampleScene.open();
|
|
72
75
|
let SampleService = class SampleService {
|
|
73
76
|
static { SampleService_2 = this; }
|
|
74
77
|
constructor() {
|
|
@@ -130,12 +133,15 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
130
133
|
super();
|
|
131
134
|
this.service2 = service2;
|
|
132
135
|
}
|
|
136
|
+
async init() { }
|
|
137
|
+
update() { }
|
|
138
|
+
async prepareToClose() { }
|
|
133
139
|
};
|
|
134
140
|
SampleScene = __decorate([
|
|
135
141
|
(0, scene_1.SceneDecorator)(),
|
|
136
142
|
__metadata("design:paramtypes", [SampleService2])
|
|
137
143
|
], SampleScene);
|
|
138
|
-
SampleScene.open(
|
|
144
|
+
SampleScene.open();
|
|
139
145
|
(0, vitest_1.expect)(SampleService1.instance).toBeDefined();
|
|
140
146
|
(0, vitest_1.expect)(SampleService2.instance).toBeDefined();
|
|
141
147
|
(0, vitest_1.expect)(SampleScene.getInstanceOrFail().service2).toEqual(SampleService2.instance);
|
|
@@ -184,13 +190,16 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
184
190
|
this.service2 = service2;
|
|
185
191
|
this.service3 = service3;
|
|
186
192
|
}
|
|
193
|
+
async init() { }
|
|
194
|
+
update() { }
|
|
195
|
+
async prepareToClose() { }
|
|
187
196
|
};
|
|
188
197
|
SampleScene = __decorate([
|
|
189
198
|
(0, scene_1.SceneDecorator)(),
|
|
190
199
|
__metadata("design:paramtypes", [SampleService2,
|
|
191
200
|
SampleService3])
|
|
192
201
|
], SampleScene);
|
|
193
|
-
SampleScene.open(
|
|
202
|
+
SampleScene.open();
|
|
194
203
|
(0, vitest_1.expect)(SampleService1.instanceCount).toEqual(1);
|
|
195
204
|
(0, vitest_1.expect)(SampleService2.instanceCount).toEqual(1);
|
|
196
205
|
(0, vitest_1.expect)(SampleService3.instanceCount).toEqual(1);
|
|
@@ -215,23 +224,29 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
215
224
|
super();
|
|
216
225
|
this.service = service;
|
|
217
226
|
}
|
|
227
|
+
async init() { }
|
|
228
|
+
update() { }
|
|
229
|
+
async prepareToClose() { }
|
|
218
230
|
};
|
|
219
231
|
SampleScene = __decorate([
|
|
220
232
|
(0, scene_1.SceneDecorator)(),
|
|
221
233
|
__metadata("design:paramtypes", [SampleService])
|
|
222
234
|
], SampleScene);
|
|
223
|
-
SampleScene.open(
|
|
235
|
+
SampleScene.open();
|
|
224
236
|
(0, vitest_1.expect)(SampleService.instance).toBeDefined();
|
|
225
237
|
(0, vitest_1.expect)(SampleScene.getInstanceOrFail().service).toEqual(SampleService.instance);
|
|
226
238
|
});
|
|
227
239
|
(0, vitest_1.test)('resolve parameters should pass known parameters with falsely values', () => {
|
|
228
240
|
var Parent_1;
|
|
229
241
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
242
|
+
async init() { }
|
|
243
|
+
update() { }
|
|
244
|
+
async prepareToClose() { }
|
|
230
245
|
};
|
|
231
246
|
SampleScene = __decorate([
|
|
232
247
|
(0, scene_1.SceneDecorator)()
|
|
233
248
|
], SampleScene);
|
|
234
|
-
SampleScene.open(
|
|
249
|
+
SampleScene.open();
|
|
235
250
|
let Parent = class Parent extends entity_1.Entity {
|
|
236
251
|
static { Parent_1 = this; }
|
|
237
252
|
static { this.receivedArgs = []; }
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentTarget } from '../base/attachment-target';
|
|
2
2
|
import { Entity } from '../entity/entity';
|
|
3
3
|
export type ViewClassType<EntityType> = new (entity: EntityType, ...services: any[]) => View;
|
|
4
4
|
export interface ViewDecoratorMeta<EntityType> {
|
|
5
5
|
entity: new (...args: any[]) => EntityType;
|
|
6
6
|
}
|
|
7
7
|
export declare function ViewDecorator<EntityType extends Entity>(meta: ViewDecoratorMeta<EntityType>): (ViewClass: ViewClassType<EntityType>) => any;
|
|
8
|
-
export declare abstract class View extends
|
|
8
|
+
export declare abstract class View extends AttachmentTarget {
|
|
9
9
|
private static viewClassNames;
|
|
10
10
|
static getInstance<T extends View>(this: new (...args: any[]) => T, entityId: string): T | undefined;
|
|
11
11
|
static getInstanceOrFail<T extends View>(this: new (...args: any[]) => T, entityId: string): T;
|
|
12
|
-
protected childUpdate: (time: number, delta: number) => void;
|
|
13
12
|
private _entityId;
|
|
14
13
|
constructor();
|
|
15
14
|
protected destroySelf(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.View = exports.ViewDecorator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const attachment_target_1 = require("../base/attachment-target");
|
|
5
5
|
const entity_views_helper_1 = require("../entity/helpers/entity-views.helper");
|
|
6
6
|
const service_1 = require("../service/service");
|
|
7
7
|
const update_cycle_1 = require("../update-cycle");
|
|
@@ -23,7 +23,7 @@ function ViewDecorator(meta) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
exports.ViewDecorator = ViewDecorator;
|
|
26
|
-
class View extends
|
|
26
|
+
class View extends attachment_target_1.AttachmentTarget {
|
|
27
27
|
static { this.viewClassNames = new Set(); }
|
|
28
28
|
static getInstance(entityId) {
|
|
29
29
|
if (entityId.substring(0, entityId.indexOf(':')) !== this.$meta.entityName) {
|
|
@@ -45,13 +45,13 @@ class View extends attachable_1.Attachable {
|
|
|
45
45
|
}
|
|
46
46
|
constructor() {
|
|
47
47
|
super();
|
|
48
|
-
this.childUpdate = this.update.bind(this);
|
|
49
48
|
this.attachToRoot(); // View is always attached to its entity
|
|
50
49
|
this._entityId = entity_views_helper_1.EntityViewsHelper.currentEntityId;
|
|
51
50
|
this.getViewInstances().set(this._entityId, this);
|
|
51
|
+
let originalUpdate = this.update.bind(this);
|
|
52
52
|
this.update = function (time, delta) {
|
|
53
53
|
if (!this.destroyed) {
|
|
54
|
-
|
|
54
|
+
originalUpdate(time, delta);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -46,11 +46,14 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
46
46
|
(0, vitest_1.beforeEach)(() => {
|
|
47
47
|
update_cycle_1.UpdateCycle.hardResetAction.trigger();
|
|
48
48
|
let SampleScene = class SampleScene extends scene_1.Scene {
|
|
49
|
+
async init() { }
|
|
50
|
+
update() { }
|
|
51
|
+
async prepareToClose() { }
|
|
49
52
|
};
|
|
50
53
|
SampleScene = __decorate([
|
|
51
54
|
(0, scene_1.SceneDecorator)()
|
|
52
55
|
], SampleScene);
|
|
53
|
-
SampleScene.open(
|
|
56
|
+
SampleScene.open();
|
|
54
57
|
});
|
|
55
58
|
(0, vitest_1.test)('entity creation should create related view', () => {
|
|
56
59
|
var SampleView_1;
|
|
@@ -425,7 +428,7 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
425
428
|
(0, view_1.ViewDecorator)({ entity: BaseEntity }),
|
|
426
429
|
__metadata("design:paramtypes", [BaseEntity])
|
|
427
430
|
], SampleView);
|
|
428
|
-
(0, vitest_1.expect)(
|
|
431
|
+
(0, vitest_1.expect)(() => SampleView.getInstanceOrFail(sampleEntity.id)).toThrowError();
|
|
429
432
|
});
|
|
430
433
|
(0, vitest_1.test)('destroying entity should not prevent subscription of the view', async () => {
|
|
431
434
|
var Sample_1, SampleView_9;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Vector } from 'helpers-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { Attachable } from '../../../game-entities';
|
|
3
3
|
interface ContainerFrame {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
size: Vector;
|
|
7
7
|
}
|
|
8
|
-
export declare class SmoothScroller extends
|
|
8
|
+
export declare class SmoothScroller extends Attachable {
|
|
9
9
|
private content;
|
|
10
10
|
private areaHeight;
|
|
11
11
|
private padding;
|
|
@@ -5,7 +5,7 @@ const helpers_lib_1 = require("helpers-lib");
|
|
|
5
5
|
const game_entities_1 = require("../../../game-entities");
|
|
6
6
|
const SCROLL_SPEED = 0.65;
|
|
7
7
|
const SCROLL_SPEED_DECAY_RATE = 0.01;
|
|
8
|
-
class SmoothScroller extends game_entities_1.
|
|
8
|
+
class SmoothScroller extends game_entities_1.Attachable {
|
|
9
9
|
get scrollHeight() {
|
|
10
10
|
return this._scrollHeight;
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActionSubscription } from 'actions-lib';
|
|
2
2
|
import { Radian, Vector } from 'helpers-lib';
|
|
3
3
|
import * as PIXI from 'pixi.js';
|
|
4
|
-
import {
|
|
4
|
+
import { AttachmentTarget } from '../../game-entities';
|
|
5
5
|
export declare enum ContainerEventType {
|
|
6
6
|
click = "click",
|
|
7
7
|
mouseover = "mouseover",
|
|
@@ -24,7 +24,7 @@ export declare enum Cursor {
|
|
|
24
24
|
default = "default",
|
|
25
25
|
pointer = "pointer"
|
|
26
26
|
}
|
|
27
|
-
export declare abstract class ContainerAttributes extends
|
|
27
|
+
export declare abstract class ContainerAttributes extends AttachmentTarget {
|
|
28
28
|
protected pixiContainer: PIXI.Container;
|
|
29
29
|
protected constructor();
|
|
30
30
|
get size(): Vector;
|
|
@@ -52,7 +52,7 @@ var Cursor;
|
|
|
52
52
|
Cursor["default"] = "default";
|
|
53
53
|
Cursor["pointer"] = "pointer";
|
|
54
54
|
})(Cursor || (exports.Cursor = Cursor = {}));
|
|
55
|
-
class ContainerAttributes extends game_entities_1.
|
|
55
|
+
class ContainerAttributes extends game_entities_1.AttachmentTarget {
|
|
56
56
|
constructor() {
|
|
57
57
|
super();
|
|
58
58
|
// --------------------- Scale ---------------------
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Rectangle } from 'helpers-lib';
|
|
2
|
+
import { AttachmentTarget } from '../../game-entities';
|
|
2
3
|
import { ContainerAttributes } from './container-attributes';
|
|
3
4
|
import { Filters } from './filters';
|
|
4
5
|
import { Sprite } from './objects/sprite/sprite';
|
|
@@ -15,6 +16,9 @@ export declare class Container extends ContainerAttributes {
|
|
|
15
16
|
cropOverflowingParts: boolean;
|
|
16
17
|
};
|
|
17
18
|
constructor();
|
|
19
|
+
destroy(): void;
|
|
20
|
+
attach(parent: AttachmentTarget | string): this;
|
|
21
|
+
attachToRoot(): this;
|
|
18
22
|
protected destroySelf(): void;
|
|
19
23
|
getBoundingMask(): Sprite;
|
|
20
24
|
displayParent(parent: Container | string, partialOptions?: Partial<SetParentOptions>): this;
|
|
@@ -16,6 +16,20 @@ class Container extends container_attributes_1.ContainerAttributes {
|
|
|
16
16
|
Container.allContainers.set(this.id, this);
|
|
17
17
|
this.filters = new filters_1.Filters(this.pixiContainer);
|
|
18
18
|
}
|
|
19
|
+
// make the destroy function non-internal
|
|
20
|
+
destroy() {
|
|
21
|
+
super.destroy();
|
|
22
|
+
}
|
|
23
|
+
// make the attach function non-internal
|
|
24
|
+
attach(parent) {
|
|
25
|
+
super.attach(parent);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
// make the attachToRoot function non-internal
|
|
29
|
+
attachToRoot() {
|
|
30
|
+
super.attachToRoot();
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
19
33
|
destroySelf() {
|
|
20
34
|
super.destroySelf();
|
|
21
35
|
Container.allContainers.delete(this.id);
|
package/dist/pixi/game.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Variable } from 'actions-lib';
|
|
1
|
+
import { Reducer, Variable } from 'actions-lib';
|
|
2
2
|
import { RGBColor, Vector } from 'helpers-lib';
|
|
3
3
|
import * as PIXI from 'pixi.js';
|
|
4
4
|
import { AssetDefinition, Container } from '.';
|
|
@@ -15,6 +15,7 @@ export interface GameConfiguration {
|
|
|
15
15
|
export declare class Game {
|
|
16
16
|
private static _instance;
|
|
17
17
|
static get instance(): Game;
|
|
18
|
+
static readonly pause: Reducer<boolean, boolean>;
|
|
18
19
|
private static _camera;
|
|
19
20
|
static get camera(): Camera;
|
|
20
21
|
static get time(): number;
|
package/dist/pixi/game.js
CHANGED
|
@@ -37,6 +37,7 @@ class Game {
|
|
|
37
37
|
static get instance() {
|
|
38
38
|
return this._instance;
|
|
39
39
|
}
|
|
40
|
+
static { this.pause = actions_lib_1.Reducer.createOr(); }
|
|
40
41
|
static get camera() {
|
|
41
42
|
return this._camera;
|
|
42
43
|
}
|
|
@@ -90,6 +91,7 @@ class Game {
|
|
|
90
91
|
setTimeout(() => this.setScreenSize());
|
|
91
92
|
});
|
|
92
93
|
Game._camera = new camera_1.Camera();
|
|
94
|
+
// Reminder: If the game should be paused or destroyed, all promises has to be resolved, that relies on update cycle
|
|
93
95
|
this.pixiApp.start();
|
|
94
96
|
this.pixiApp.ticker.add(() => {
|
|
95
97
|
update_cycle_1.UpdateCycle.triggerUpdateTick(this.pixiApp.ticker.deltaMS);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentTarget } from '../../../game-entities';
|
|
2
|
+
import { Attachable } from '../../../game-entities/base/attachable';
|
|
2
3
|
import { AnimatorAnimation } from './animations';
|
|
3
4
|
export interface AnimationState {
|
|
4
5
|
duration: number;
|
|
@@ -25,7 +26,7 @@ export interface AnimationOptions {
|
|
|
25
26
|
reAnimateHandling?: ReAnimateHandlingType;
|
|
26
27
|
completeAnimationsHandling?: CompleteAnimationsHandlingType;
|
|
27
28
|
}
|
|
28
|
-
export declare class Animator<T> extends
|
|
29
|
+
export declare class Animator<T> extends Attachable {
|
|
29
30
|
private target;
|
|
30
31
|
private static animatedObjects;
|
|
31
32
|
private effectOn;
|
|
@@ -39,8 +40,12 @@ export declare class Animator<T> extends Destroyable {
|
|
|
39
40
|
private running;
|
|
40
41
|
private propertyStates;
|
|
41
42
|
private updateCycleSubscription;
|
|
43
|
+
private allResolvers;
|
|
42
44
|
get isAnimating(): boolean;
|
|
43
45
|
constructor(target: T, effectOn: string | string[], options?: AnimationOptions);
|
|
46
|
+
destroy(): void;
|
|
47
|
+
attach(parent: AttachmentTarget | string): this;
|
|
48
|
+
attachToRoot(): this;
|
|
44
49
|
onChange(callback: (target: T) => void): Animator<T>;
|
|
45
50
|
onComplete(callback: (key: string, value: number) => void): Animator<T>;
|
|
46
51
|
protected destroySelf(): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Animator = exports.CompleteAnimationsHandlingType = exports.ReAnimateHandlingType = void 0;
|
|
4
4
|
const helpers_lib_1 = require("helpers-lib");
|
|
5
|
-
const
|
|
5
|
+
const attachable_1 = require("../../../game-entities/base/attachable");
|
|
6
6
|
const update_cycle_1 = require("../../../game-entities/update-cycle");
|
|
7
7
|
const animations_1 = require("./animations");
|
|
8
8
|
var ReAnimateHandlingType;
|
|
@@ -22,7 +22,7 @@ const DEFAULT_ANIMATION = new animations_1.AnimationLineer();
|
|
|
22
22
|
const DEFAULT_LOOP = false;
|
|
23
23
|
const DEFAULT_RE_ANIMATE_HANDLING = ReAnimateHandlingType.throwError;
|
|
24
24
|
const DEFAULT_COMPLETE_ANIMATIONS_HANDLING = CompleteAnimationsHandlingType.stayInCurrentState;
|
|
25
|
-
class Animator extends
|
|
25
|
+
class Animator extends attachable_1.Attachable {
|
|
26
26
|
static { this.animatedObjects = new Map(); }
|
|
27
27
|
get isAnimating() {
|
|
28
28
|
return this.propertyStates.size > 0;
|
|
@@ -33,6 +33,7 @@ class Animator extends destroyable_1.Destroyable {
|
|
|
33
33
|
this.effectOn = new Set();
|
|
34
34
|
this.running = true;
|
|
35
35
|
this.propertyStates = new Map();
|
|
36
|
+
this.allResolvers = new Set();
|
|
36
37
|
if (!helpers_lib_1.Comparator.isObject(target)) {
|
|
37
38
|
this.attachToRoot();
|
|
38
39
|
throw new Error(`Animator: target is not an object! Target: "${target}"`);
|
|
@@ -66,6 +67,20 @@ class Animator extends destroyable_1.Destroyable {
|
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
69
|
}
|
|
70
|
+
// make the destroy function non-internal
|
|
71
|
+
destroy() {
|
|
72
|
+
super.destroy();
|
|
73
|
+
}
|
|
74
|
+
// make the attach function non-internal
|
|
75
|
+
attach(parent) {
|
|
76
|
+
super.attach(parent);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
// make the attachToRoot function non-internal
|
|
80
|
+
attachToRoot() {
|
|
81
|
+
super.attachToRoot();
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
69
84
|
onChange(callback) {
|
|
70
85
|
if (this.onChangeCallback) {
|
|
71
86
|
this.attachToRoot();
|
|
@@ -93,6 +108,9 @@ class Animator extends destroyable_1.Destroyable {
|
|
|
93
108
|
if (animatedObjectProperties.size <= 0) {
|
|
94
109
|
Animator.animatedObjects.delete(this.target);
|
|
95
110
|
}
|
|
111
|
+
this.target = undefined;
|
|
112
|
+
this.allResolvers.forEach(resolver => resolver());
|
|
113
|
+
this.allResolvers.clear();
|
|
96
114
|
}
|
|
97
115
|
getAnimationStateOfKey(key) {
|
|
98
116
|
let propertyState = this.propertyStates.get(key);
|
|
@@ -155,6 +173,7 @@ class Animator extends destroyable_1.Destroyable {
|
|
|
155
173
|
});
|
|
156
174
|
this.checkOngoingAnimations(values, options.reAnimateHandling);
|
|
157
175
|
return new Promise(resolveAll => {
|
|
176
|
+
this.allResolvers.add(resolveAll);
|
|
158
177
|
Promise.all(Object.keys(values).map(key => new Promise(resolve => {
|
|
159
178
|
let duration = options.duration ?? this.defaultDuration;
|
|
160
179
|
let animation = options.animation ?? this.defaultAnimation;
|
|
@@ -184,9 +203,11 @@ class Animator extends destroyable_1.Destroyable {
|
|
|
184
203
|
}
|
|
185
204
|
catch {
|
|
186
205
|
resolveAll();
|
|
206
|
+
this.allResolvers.delete(resolveAll);
|
|
187
207
|
}
|
|
188
208
|
}))).then(() => {
|
|
189
209
|
resolveAll();
|
|
210
|
+
this.allResolvers.delete(resolveAll);
|
|
190
211
|
});
|
|
191
212
|
this.subscribeUpdateCycle();
|
|
192
213
|
});
|
|
@@ -330,16 +330,16 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
330
330
|
});
|
|
331
331
|
});
|
|
332
332
|
(0, vitest_1.describe)('Animation Type Switch', () => {
|
|
333
|
-
(0, vitest_1.test)('re-animation handling option throw error should throw error', () => {
|
|
333
|
+
(0, vitest_1.test)('re-animation handling option throw error should throw error', async () => {
|
|
334
334
|
let obj = { x: 0 };
|
|
335
335
|
let animator = new animator_1.Animator(obj, 'x', {
|
|
336
336
|
duration: 4,
|
|
337
337
|
reAnimateHandling: animator_1.ReAnimateHandlingType.throwError
|
|
338
338
|
}).attachToRoot();
|
|
339
339
|
animator.animate({ x: 1 });
|
|
340
|
-
(0, vitest_1.expect)(
|
|
340
|
+
await (0, vitest_1.expect)(animator.animate({ x: 0 })).rejects.toThrow();
|
|
341
341
|
animator['update'](1);
|
|
342
|
-
(0, vitest_1.expect)(
|
|
342
|
+
await (0, vitest_1.expect)(animator.animate({ x: 0 })).rejects.toThrow();
|
|
343
343
|
});
|
|
344
344
|
(0, vitest_1.test)('re-animation handling option ignore should ignore new animation', () => {
|
|
345
345
|
let obj = { x: 0 };
|
|
@@ -879,6 +879,15 @@ decorate_actions_lib_1.ActionsLibDecorator.decorate(ActionsLib);
|
|
|
879
879
|
await game_entities_1.UpdateCycle.triggerUpdateTick(1);
|
|
880
880
|
(0, vitest_1.expect)(obj.x).toEqual(0);
|
|
881
881
|
});
|
|
882
|
+
(0, vitest_1.test)('destroyed animators animation promises should not get stuck', async () => {
|
|
883
|
+
return new Promise(done => {
|
|
884
|
+
let obj = { x: 0 };
|
|
885
|
+
let animator = new animator_1.Animator(obj, 'x', { duration: 1, animation: new animations_1.AnimationLineer() }).attachToRoot();
|
|
886
|
+
let promise = animator.animate({ x: 1 });
|
|
887
|
+
animator.destroy();
|
|
888
|
+
promise.then(() => done());
|
|
889
|
+
});
|
|
890
|
+
});
|
|
882
891
|
});
|
|
883
892
|
});
|
|
884
893
|
//# sourceMappingURL=animator.test.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentTarget } from '../../../../game-entities';
|
|
2
2
|
import { StateAnimationOptions } from './state-animation';
|
|
3
3
|
export declare enum SlideStateAnimationState {
|
|
4
4
|
appear = "appear",
|
|
5
5
|
disappear = "disappear"
|
|
6
6
|
}
|
|
7
|
-
export declare class SlideStateAnimation extends
|
|
7
|
+
export declare class SlideStateAnimation extends AttachmentTarget {
|
|
8
8
|
private stateAnimation;
|
|
9
9
|
private options;
|
|
10
10
|
private index;
|
|
@@ -11,7 +11,7 @@ var SlideStateAnimationState;
|
|
|
11
11
|
SlideStateAnimationState["appear"] = "appear";
|
|
12
12
|
SlideStateAnimationState["disappear"] = "disappear";
|
|
13
13
|
})(SlideStateAnimationState || (exports.SlideStateAnimationState = SlideStateAnimationState = {}));
|
|
14
|
-
class SlideStateAnimation extends game_entities_1.
|
|
14
|
+
class SlideStateAnimation extends game_entities_1.AttachmentTarget {
|
|
15
15
|
constructor(partialOptions) {
|
|
16
16
|
super();
|
|
17
17
|
this.animationState = 'idle';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentTarget } from '../../../../game-entities';
|
|
2
2
|
import { AnimatorAnimation } from '../animations';
|
|
3
3
|
export interface StateAnimationOptions {
|
|
4
4
|
readonly duration: number;
|
|
5
5
|
readonly animation: AnimatorAnimation;
|
|
6
6
|
}
|
|
7
7
|
type AnimationState = 'idle' | 'transitioning' | 'reverting';
|
|
8
|
-
export declare class StateAnimation<T> extends
|
|
8
|
+
export declare class StateAnimation<T> extends AttachmentTarget {
|
|
9
9
|
private animator;
|
|
10
10
|
private options;
|
|
11
11
|
private value;
|
|
@@ -5,7 +5,7 @@ const actions_lib_1 = require("actions-lib");
|
|
|
5
5
|
const game_entities_1 = require("../../../../game-entities");
|
|
6
6
|
const animations_1 = require("../animations");
|
|
7
7
|
const animator_1 = require("../animator");
|
|
8
|
-
class StateAnimation extends game_entities_1.
|
|
8
|
+
class StateAnimation extends game_entities_1.AttachmentTarget {
|
|
9
9
|
get currentState() {
|
|
10
10
|
return {
|
|
11
11
|
value: this.value,
|
package/dist/utilities/libraries/animator/state-animation/visit-disappear-state-animation.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AttachmentTarget } from '../../../../game-entities';
|
|
2
2
|
import { StateAnimationOptions } from './state-animation';
|
|
3
3
|
type AnimationState = 'hidden' | 'visible' | 'appearing' | 'disappearing' | 'disappearToChange';
|
|
4
|
-
export declare class VisitDisappearStateAnimation<T> extends
|
|
4
|
+
export declare class VisitDisappearStateAnimation<T> extends AttachmentTarget {
|
|
5
5
|
private animator;
|
|
6
6
|
private options;
|
|
7
7
|
private value;
|