@vyr/engine 0.0.1 → 0.0.3
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/package.json +1 -19
- package/src/Category.ts +7 -7
- package/src/Engine.ts +29 -15
- package/src/actor/AnimationUnitActor.ts +3 -3
- package/src/actor/DivActor.ts +6 -6
- package/src/actor/FragmentActor.ts +3 -3
- package/src/actor/HTMActor.ts +19 -16
- package/src/actor/HTMServiceActor.ts +4 -4
- package/src/actor/HTMTransformControllerActor.ts +15 -10
- package/src/asset/Asset.ts +25 -27
- package/src/asset/AssetGraph.ts +4 -4
- package/src/descriptor/DatasetDescriptor.ts +20 -22
- package/src/descriptor/Descriptor.ts +1 -28
- package/src/descriptor/HTMLTransformControllerDescriptor.ts +2 -2
- package/src/descriptor/index.ts +0 -1
- package/src/graphics/Compilation.ts +37 -45
- package/src/graphics/Graphics.ts +80 -68
- package/src/graphics/VariableProxy.ts +8 -8
- package/src/index.ts +2 -1
- package/src/interaction/InteractionDescriptor.ts +96 -0
- package/src/interaction/InteractionExecutor.ts +84 -0
- package/src/interaction/Scriptable.ts +40 -0
- package/src/interaction/index.ts +3 -0
- package/src/interpreter/AnimationUnitInterpreter.ts +5 -5
- package/src/interpreter/DivInterpreter.ts +15 -15
- package/src/interpreter/DynamicInterpreter.ts +9 -9
- package/src/interpreter/FragmentInterpreter.ts +10 -10
- package/src/interpreter/HTMLServiceInterpreter.ts +15 -15
- package/src/interpreter/HTMLTransformControllerInterpreter.ts +15 -15
- package/src/interpreter/Interpreter.ts +9 -9
- package/src/interpreter/ServiceInterpreter.ts +6 -6
- package/src/interpreter/ServiceSchedulerInterpreter.ts +6 -6
- package/src/interpreter/StyleInterpreter.ts +7 -7
- package/src/interpreter/index.ts +0 -1
- package/src/locale/LanguageProvider.ts +4 -2
- package/src/preset/execute/dataset/compile.ts +99 -0
- package/src/preset/execute/dataset/index.ts +2 -1
- package/src/preset/execute/dataset/update.ts +7 -8
- package/src/preset/execute/graphics/invoke.ts +5 -6
- package/src/preset/execute/net/{request.ts → http.ts} +9 -17
- package/src/preset/execute/net/index.ts +1 -1
- package/src/preset/execute/scheduler/switch.ts +8 -8
- package/src/preset/index.ts +2 -2
- package/src/preset/interaction/dataset/compile.ts +27 -0
- package/src/preset/interaction/dataset/index.ts +1 -0
- package/src/preset/interaction/graphics/invoke.ts +27 -0
- package/src/preset/interaction/index.ts +3 -0
- package/src/preset/interaction/scheduler/switch.ts +27 -0
- package/src/utils/AssetProvider.ts +7 -6
- package/src/utils/constants.ts +10 -0
- package/src/utils/index.ts +1 -0
- package/src/Scriptable.ts +0 -27
- package/src/descriptor/RoutineDescriptor.ts +0 -54
- package/src/interpreter/RoutineInterpreter.ts +0 -88
- package/src/preset/routine/graphics/invoke.ts +0 -27
- package/src/preset/routine/index.ts +0 -2
- package/src/preset/routine/scheduler/switch.ts +0 -27
- /package/src/preset/{routine → interaction}/graphics/index.ts +0 -0
- /package/src/preset/{routine → interaction}/scheduler/index.ts +0 -0
|
@@ -5,7 +5,7 @@ import { Generate } from '../Generate'
|
|
|
5
5
|
import { Traverser } from '../Traverser'
|
|
6
6
|
import { ObjectUtils } from '../ObjectUtils'
|
|
7
7
|
import { DeserializationObject, Serialization, SerializationObject } from '../Serialization'
|
|
8
|
-
import {
|
|
8
|
+
import { InteractionPropertyCollection } from '../interaction'
|
|
9
9
|
import { observer } from '../graphics/Observer'
|
|
10
10
|
|
|
11
11
|
/**描述器祖先节点 */
|
|
@@ -30,10 +30,6 @@ interface DescriptorPrefab {
|
|
|
30
30
|
uuid: string
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
interface UpdateArgs {
|
|
34
|
-
delta: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
33
|
interface VariabConfig {
|
|
38
34
|
type: 'key' | 'custom'
|
|
39
35
|
enabled: boolean
|
|
@@ -43,24 +39,6 @@ interface VariabConfig {
|
|
|
43
39
|
interface DescriptorVariables {
|
|
44
40
|
[k: string]: VariabConfig
|
|
45
41
|
}
|
|
46
|
-
interface InteractionInput {
|
|
47
|
-
[param: string]: {
|
|
48
|
-
type?: 'data' | string
|
|
49
|
-
value: any
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface InteractionInputCollection {
|
|
54
|
-
[id: string]: InteractionInput
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface InteractionProperty extends AssetProperty {
|
|
58
|
-
uuid: string
|
|
59
|
-
type: string
|
|
60
|
-
inputs: InteractionInputCollection
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
interface InteractionPropertyCollection extends AssetPropertyCollection<InteractionProperty> { }
|
|
64
42
|
|
|
65
43
|
const privateState = {
|
|
66
44
|
classCollection: new Map<string, typeof Descriptor>(),
|
|
@@ -402,14 +380,9 @@ listenInstance('free', (uuid: string) => {
|
|
|
402
380
|
|
|
403
381
|
export {
|
|
404
382
|
Descriptor,
|
|
405
|
-
UpdateArgs,
|
|
406
383
|
DescriptorAdjacency,
|
|
407
384
|
DescriptorAncestor,
|
|
408
385
|
DescriptorPrefab,
|
|
409
386
|
VariabConfig,
|
|
410
387
|
DescriptorVariables,
|
|
411
|
-
InteractionInput,
|
|
412
|
-
InteractionInputCollection,
|
|
413
|
-
InteractionProperty,
|
|
414
|
-
InteractionPropertyCollection,
|
|
415
388
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DeserializationObject } from "../Serialization"
|
|
2
2
|
import { ControllerDescriptor } from "./ControllerDescriptor"
|
|
3
|
-
import {
|
|
3
|
+
import { ScriptableArgs } from "../interaction"
|
|
4
4
|
|
|
5
|
-
interface HTMLTransformControllerChangeArgs extends
|
|
5
|
+
interface HTMLTransformControllerChangeArgs extends ScriptableArgs<undefined, undefined, undefined> {
|
|
6
6
|
event: {
|
|
7
7
|
type: string
|
|
8
8
|
target: string
|
package/src/descriptor/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './Descriptor'
|
|
|
2
2
|
export * from './DatasetDescriptor'
|
|
3
3
|
export * from './StyleDescriptor'
|
|
4
4
|
export * from './PrefabDescriptor'
|
|
5
|
-
export * from './RoutineDescriptor'
|
|
6
5
|
export * from './PrefabInstanceDescriptor'
|
|
7
6
|
export * from './DynamicDescriptor'
|
|
8
7
|
export * from './HTMLDescriptor'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Engine } from "../Engine";
|
|
2
|
-
import { Graphics } from "./Graphics";
|
|
2
|
+
import { Graphics, TickArgs } from "./Graphics";
|
|
3
3
|
import { Asset } from "../asset";
|
|
4
|
-
import { AnimationUnitDescriptor, ServiceSchedulerDescriptor
|
|
4
|
+
import { AnimationUnitDescriptor, ServiceSchedulerDescriptor } from "../descriptor";
|
|
5
5
|
|
|
6
6
|
class Compilation {
|
|
7
7
|
private collection = new Map<string, Graphics>()
|
|
@@ -10,69 +10,61 @@ class Compilation {
|
|
|
10
10
|
return (this.collection.get(scheduler.uuid) ?? null) as Graphics
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const url = Asset.getUrlByUuid(scheduler.uuid)
|
|
15
|
-
if (url) {
|
|
16
|
-
let graphics = this.collection.get(scheduler.uuid)
|
|
17
|
-
if (graphics === undefined) {
|
|
18
|
-
graphics = new Graphics(url, scheduler, engine)
|
|
19
|
-
this.collection.set(scheduler.uuid, graphics)
|
|
20
|
-
}
|
|
21
|
-
graphics.listen({ delta: 0 })
|
|
22
|
-
|
|
23
|
-
return graphics
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
unlisten(scheduler: ServiceSchedulerDescriptor, engine: Engine) {
|
|
13
|
+
delete(scheduler: ServiceSchedulerDescriptor) {
|
|
28
14
|
const graphics = this.collection.get(scheduler.uuid)
|
|
29
15
|
if (graphics === undefined) return
|
|
30
|
-
graphics.unlisten(
|
|
16
|
+
graphics.unlisten()
|
|
31
17
|
this.collection.delete(scheduler.uuid)
|
|
32
18
|
}
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
ensureExists(url: string, scheduler: ServiceSchedulerDescriptor, engine: Engine) {
|
|
21
|
+
let graphics = this.collection.get(scheduler.uuid)
|
|
22
|
+
if (graphics === undefined) {
|
|
23
|
+
graphics = new Graphics(url, scheduler, engine)
|
|
24
|
+
this.collection.set(scheduler.uuid, graphics)
|
|
25
|
+
}
|
|
26
|
+
return graphics
|
|
27
|
+
}
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
listen(graphics: Graphics) {
|
|
30
|
+
graphics.listen()
|
|
31
|
+
}
|
|
38
32
|
|
|
39
|
-
|
|
33
|
+
unlisten(scheduler: ServiceSchedulerDescriptor) {
|
|
34
|
+
this.delete(scheduler)
|
|
35
|
+
}
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
foreach(executor: (graphics: Graphics) => void) {
|
|
38
|
+
const collection = this.collection.values()
|
|
42
39
|
|
|
43
|
-
|
|
40
|
+
for (const graphics of collection) {
|
|
41
|
+
executor(graphics)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
process(engine: Engine, args: TickArgs) {
|
|
46
|
+
Asset.free()
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
this.foreach((graphics) => {
|
|
49
|
+
graphics.process()
|
|
50
|
+
graphics.clear()
|
|
51
|
+
})
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
engine.trigger(AnimationUnitDescriptor.type, args)
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
engine.trigger('afterRender', args)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
55
|
+
this.foreach((graphics) => graphics.beforeRender())
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
const collection = this.collection.values()
|
|
59
|
-
for (const graphics of collection) graphics.beforeRender(args)
|
|
60
|
-
}
|
|
57
|
+
engine.trigger('beforeRender', args)
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
const collection = this.collection.values()
|
|
64
|
-
for (const graphics of collection) graphics.render(args)
|
|
65
|
-
}
|
|
59
|
+
this.foreach((graphics) => graphics.render())
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
const collection = this.collection.values()
|
|
69
|
-
for (const graphics of collection) graphics.afterRender(args)
|
|
61
|
+
engine.trigger('afterRender', args)
|
|
70
62
|
}
|
|
71
63
|
|
|
72
|
-
clear(
|
|
64
|
+
clear() {
|
|
73
65
|
const collection = this.collection.values()
|
|
74
66
|
for (const graphics of collection) {
|
|
75
|
-
this.unlisten(graphics.scheduler
|
|
67
|
+
this.unlisten(graphics.scheduler)
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
70
|
}
|
package/src/graphics/Graphics.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { language } from '../locale'
|
|
2
2
|
import { ArrayUtils } from "../ArrayUtils";
|
|
3
3
|
import { Asset, Dependencide } from "../asset";
|
|
4
|
-
import { Descriptor, HTMLDescriptor, HTMLServiceDescriptor,
|
|
4
|
+
import { DatasetDescriptor, Descriptor, HTMLDescriptor, HTMLServiceDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor } from "../descriptor";
|
|
5
5
|
import { privateState } from "../interpreter/Interpreter";
|
|
6
|
-
import { Interpreter,
|
|
6
|
+
import { Interpreter, ServiceInterpreter, ServiceSchedulerInterpreter } from "../interpreter";
|
|
7
7
|
import { observer, UpdateDepsWatcherArgs, UpdateWatcherArgs, WatcherArgs } from "./Observer";
|
|
8
8
|
import { Operation, Queue, Unit } from "./Unit";
|
|
9
9
|
import { Actor } from '../actor/Actor';
|
|
10
10
|
import { UnitCollection } from "./Collection";
|
|
11
11
|
import { VariableProxy } from "./VariableProxy";
|
|
12
12
|
import { Engine } from '../Engine';
|
|
13
|
+
import { InteractionDescriptor } from '../interaction';
|
|
14
|
+
|
|
15
|
+
interface TickArgs {
|
|
16
|
+
delta: number
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
interface PickupObject {
|
|
15
20
|
[k: string]: any
|
|
@@ -17,7 +22,7 @@ interface PickupObject {
|
|
|
17
22
|
generatedBy: string
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter
|
|
25
|
+
type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter) => void
|
|
21
26
|
|
|
22
27
|
class Graphics {
|
|
23
28
|
static createInterpreter<T extends Interpreter = Interpreter>(descriptor: Descriptor, graphics: Graphics) {
|
|
@@ -41,6 +46,13 @@ class Graphics {
|
|
|
41
46
|
private readonly _services: ServiceDescriptor[] = []
|
|
42
47
|
private readonly _freeQueue: Unit[] = []
|
|
43
48
|
private _currentCamera = ''
|
|
49
|
+
private _currentArgs: TickArgs = { delta: 0 }
|
|
50
|
+
get args() {
|
|
51
|
+
return this._currentArgs
|
|
52
|
+
}
|
|
53
|
+
set args(args: TickArgs) {
|
|
54
|
+
this._currentArgs = args
|
|
55
|
+
}
|
|
44
56
|
readonly unitCollection = new UnitCollection()
|
|
45
57
|
readonly variableProxy = new VariableProxy()
|
|
46
58
|
readonly scheduler: ServiceSchedulerDescriptor
|
|
@@ -53,7 +65,7 @@ class Graphics {
|
|
|
53
65
|
this.url = url
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
listen(
|
|
68
|
+
listen() {
|
|
57
69
|
observer.listen('add', this.addWatcher)
|
|
58
70
|
observer.listen('remove', this.removeWatcher)
|
|
59
71
|
observer.listen('update', this.updateWatcher)
|
|
@@ -64,22 +76,22 @@ class Graphics {
|
|
|
64
76
|
if (root instanceof Descriptor) this.addRoot(this.url, root)
|
|
65
77
|
|
|
66
78
|
Asset.graph.getDependencide(this.url, this._dependencide)
|
|
67
|
-
this._dependencide.
|
|
79
|
+
this._dependencide.forEachForGraphics(asset => {
|
|
68
80
|
const root = Asset.get<Descriptor>(asset)
|
|
69
81
|
if (root instanceof Descriptor) {
|
|
70
82
|
this._assetCollection.set(asset, this.addRoot(asset, root))
|
|
71
83
|
}
|
|
72
84
|
})
|
|
73
85
|
|
|
74
|
-
const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this
|
|
86
|
+
const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this)
|
|
75
87
|
const interpreter = this.getInterpreter<ServiceSchedulerInterpreter>(descriptor)
|
|
76
|
-
interpreter.install(descriptor
|
|
88
|
+
interpreter.install(descriptor)
|
|
77
89
|
}
|
|
78
90
|
|
|
79
|
-
unlisten(
|
|
80
|
-
const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this
|
|
91
|
+
unlisten() {
|
|
92
|
+
const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this)
|
|
81
93
|
const interpreter = this.getInterpreter<ServiceSchedulerInterpreter>(descriptor)
|
|
82
|
-
interpreter.uninstall(descriptor
|
|
94
|
+
interpreter.uninstall(descriptor)
|
|
83
95
|
|
|
84
96
|
const master = this.unitCollection.get(this.scheduler.uuid) as Unit
|
|
85
97
|
const assets = [...this._assetCollection.values(), master]
|
|
@@ -87,12 +99,12 @@ class Graphics {
|
|
|
87
99
|
for (const asset of assets) {
|
|
88
100
|
const unit = this.removeRoot(asset.queue.url)
|
|
89
101
|
if (unit === null) continue
|
|
90
|
-
unit.queue.iterator(operation => this.do(operation
|
|
102
|
+
unit.queue.iterator(operation => this.do(operation))
|
|
91
103
|
this._assetCollection.delete(asset.queue.url)
|
|
92
104
|
}
|
|
93
105
|
|
|
94
106
|
const _freeQueue = this._freeCollection.values()
|
|
95
|
-
for (const unit of _freeQueue) this.doFree(unit
|
|
107
|
+
for (const unit of _freeQueue) this.doFree(unit)
|
|
96
108
|
|
|
97
109
|
observer.unlisten('add', this.addWatcher)
|
|
98
110
|
observer.unlisten('remove', this.removeWatcher)
|
|
@@ -103,11 +115,11 @@ class Graphics {
|
|
|
103
115
|
this._dependencide.clear()
|
|
104
116
|
}
|
|
105
117
|
|
|
106
|
-
process(
|
|
107
|
-
for (const unit of this._freeQueue) this.doFree(unit
|
|
118
|
+
process() {
|
|
119
|
+
for (const unit of this._freeQueue) this.doFree(unit)
|
|
108
120
|
this._freeQueue.length = 0
|
|
109
121
|
|
|
110
|
-
this.updateStaticAsset(
|
|
122
|
+
this.updateStaticAsset()
|
|
111
123
|
|
|
112
124
|
this._dependencide.clear()
|
|
113
125
|
Asset.graph.getDependencide(this.url, this._dependencide)
|
|
@@ -116,7 +128,7 @@ class Graphics {
|
|
|
116
128
|
|
|
117
129
|
for (const removeAsset of patch.removeQueue) {
|
|
118
130
|
const unit = this.removeRoot(removeAsset)
|
|
119
|
-
if (unit !== null) unit.queue.iterator(operation => this.do(operation
|
|
131
|
+
if (unit !== null) unit.queue.iterator(operation => this.do(operation))
|
|
120
132
|
this._assetCollection.delete(removeAsset)
|
|
121
133
|
}
|
|
122
134
|
for (const addAsset of patch.addQueue) {
|
|
@@ -127,7 +139,7 @@ class Graphics {
|
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
const assets: Unit[] = []
|
|
130
|
-
this._dependencide.
|
|
142
|
+
this._dependencide.forEachForGraphics(asset => {
|
|
131
143
|
const descriptor = Asset.get<Descriptor>(asset)
|
|
132
144
|
const unit = this.unitCollection.get(descriptor.uuid)
|
|
133
145
|
if (unit === undefined) return console.warn(asset, descriptor)
|
|
@@ -136,18 +148,19 @@ class Graphics {
|
|
|
136
148
|
assets.push(...this._staticAssetQueue)
|
|
137
149
|
|
|
138
150
|
for (const asset of assets) {
|
|
139
|
-
asset.queue.iterator(operation => this.do(operation
|
|
151
|
+
asset.queue.iterator(operation => this.do(operation))
|
|
140
152
|
}
|
|
141
153
|
|
|
142
|
-
const master = this.unitCollection.get(this.scheduler.uuid)
|
|
154
|
+
const master = this.unitCollection.get(this.scheduler.uuid)
|
|
155
|
+
if (master === undefined) return
|
|
143
156
|
|
|
144
|
-
master.queue.iterator(operation => this.do(operation
|
|
157
|
+
master.queue.iterator(operation => this.do(operation))
|
|
145
158
|
|
|
146
159
|
for (const asset of assets) {
|
|
147
|
-
asset.queue.iterator(unit => this.doUpdate(unit
|
|
160
|
+
asset.queue.iterator(unit => this.doUpdate(unit), Queue.Update)
|
|
148
161
|
}
|
|
149
162
|
|
|
150
|
-
const invokeQueue = master.queue.iterator(unit => this.doUpdate(unit
|
|
163
|
+
const invokeQueue = master.queue.iterator(unit => this.doUpdate(unit), Queue.Update)
|
|
151
164
|
for (const unit of invokeQueue) {
|
|
152
165
|
const descriptor = Descriptor.get<Descriptor>(unit.uuid)
|
|
153
166
|
this.invoke('mount', descriptor)
|
|
@@ -157,35 +170,35 @@ class Graphics {
|
|
|
157
170
|
this._freeCollection.clear()
|
|
158
171
|
}
|
|
159
172
|
|
|
160
|
-
clear(
|
|
173
|
+
clear() {
|
|
161
174
|
for (const service of this._services) {
|
|
162
|
-
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this
|
|
175
|
+
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
|
|
163
176
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
164
|
-
interpreter.clear(descriptor
|
|
177
|
+
interpreter.clear(descriptor)
|
|
165
178
|
}
|
|
166
179
|
}
|
|
167
180
|
|
|
168
|
-
beforeRender(
|
|
181
|
+
beforeRender() {
|
|
169
182
|
for (const service of this._services) {
|
|
170
|
-
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this
|
|
183
|
+
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
|
|
171
184
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
172
|
-
interpreter.beforeRender(descriptor
|
|
185
|
+
interpreter.beforeRender(descriptor)
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
|
|
176
|
-
render(
|
|
189
|
+
render() {
|
|
177
190
|
for (const service of this._services) {
|
|
178
|
-
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this
|
|
191
|
+
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
|
|
179
192
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
180
|
-
interpreter.render(descriptor
|
|
193
|
+
interpreter.render(descriptor)
|
|
181
194
|
}
|
|
182
195
|
}
|
|
183
196
|
|
|
184
|
-
afterRender(
|
|
197
|
+
afterRender() {
|
|
185
198
|
for (const service of this._services) {
|
|
186
|
-
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this
|
|
199
|
+
const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
|
|
187
200
|
const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
|
|
188
|
-
interpreter.afterRender(descriptor
|
|
201
|
+
interpreter.afterRender(descriptor)
|
|
189
202
|
}
|
|
190
203
|
}
|
|
191
204
|
|
|
@@ -281,7 +294,7 @@ class Graphics {
|
|
|
281
294
|
})
|
|
282
295
|
}
|
|
283
296
|
|
|
284
|
-
private updateStaticAsset(
|
|
297
|
+
private updateStaticAsset() {
|
|
285
298
|
if (this.scheduler.camera !== this._currentCamera) {
|
|
286
299
|
const descriptor = Descriptor.get<Descriptor>(this.scheduler.camera)
|
|
287
300
|
if (descriptor === null) return
|
|
@@ -302,7 +315,7 @@ class Graphics {
|
|
|
302
315
|
const temp = new Map(this._assetCollection)
|
|
303
316
|
const addQueue: string[] = [], removeQueue: string[] = []
|
|
304
317
|
|
|
305
|
-
this._dependencide.
|
|
318
|
+
this._dependencide.forEachForGraphics(asset => {
|
|
306
319
|
temp.has(asset) ? temp.delete(asset) : addQueue.push(asset)
|
|
307
320
|
})
|
|
308
321
|
removeQueue.push(...temp.keys())
|
|
@@ -310,41 +323,41 @@ class Graphics {
|
|
|
310
323
|
return { addQueue, removeQueue }
|
|
311
324
|
}
|
|
312
325
|
|
|
313
|
-
private onMount(unit: Unit
|
|
314
|
-
const parentDescriptor = this.variableProxy.get<Descriptor>(unit.parent, this
|
|
326
|
+
private onMount(unit: Unit) {
|
|
327
|
+
const parentDescriptor = this.variableProxy.get<Descriptor>(unit.parent, this)
|
|
315
328
|
const parentInterpreter = this.getInterpreter(parentDescriptor)
|
|
316
329
|
|
|
317
|
-
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this
|
|
330
|
+
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
318
331
|
const interpreter = this.getInterpreter(descriptor)
|
|
319
332
|
|
|
320
333
|
if (descriptor instanceof ServiceDescriptor) ArrayUtils.insert(this._services, descriptor)
|
|
321
334
|
|
|
322
|
-
interpreter.mount(descriptor,
|
|
335
|
+
interpreter.mount(descriptor, parentInterpreter, parentDescriptor)
|
|
323
336
|
}
|
|
324
337
|
|
|
325
|
-
private onUnmount(unit: Unit
|
|
326
|
-
const parentDescriptor = this.variableProxy.get<Descriptor>(unit.parent, this
|
|
338
|
+
private onUnmount(unit: Unit) {
|
|
339
|
+
const parentDescriptor = this.variableProxy.get<Descriptor>(unit.parent, this)
|
|
327
340
|
const parentInterpreter = this.getInterpreter(parentDescriptor)
|
|
328
341
|
|
|
329
|
-
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this
|
|
342
|
+
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
330
343
|
const interpreter = this.getInterpreter(descriptor)
|
|
331
344
|
|
|
332
345
|
if (descriptor instanceof ServiceDescriptor) ArrayUtils.remove(this._services, descriptor)
|
|
333
346
|
|
|
334
|
-
interpreter.unmount(descriptor,
|
|
347
|
+
interpreter.unmount(descriptor, parentInterpreter, parentDescriptor)
|
|
335
348
|
}
|
|
336
349
|
|
|
337
350
|
getUnit<T extends Unit | null = Unit>(uuid: string) {
|
|
338
351
|
return (this.unitCollection.get(uuid) ?? null) as T
|
|
339
352
|
}
|
|
340
353
|
|
|
341
|
-
do(operation: Operation
|
|
354
|
+
do(operation: Operation) {
|
|
342
355
|
switch (operation.type) {
|
|
343
356
|
case Queue.Add:
|
|
344
|
-
this.onMount(operation.unit
|
|
357
|
+
this.onMount(operation.unit)
|
|
345
358
|
break;
|
|
346
359
|
case Queue.Remove:
|
|
347
|
-
this.onUnmount(operation.unit
|
|
360
|
+
this.onUnmount(operation.unit)
|
|
348
361
|
break;
|
|
349
362
|
default:
|
|
350
363
|
console.log('do', operation.type)
|
|
@@ -352,18 +365,18 @@ class Graphics {
|
|
|
352
365
|
}
|
|
353
366
|
}
|
|
354
367
|
|
|
355
|
-
doUpdate(unit: Unit
|
|
356
|
-
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this
|
|
368
|
+
doUpdate(unit: Unit) {
|
|
369
|
+
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
357
370
|
const interpreter = this.getInterpreter(descriptor)
|
|
358
371
|
const override = this._overwriteUpdate.get(descriptor.uuid)
|
|
359
|
-
override === undefined ? interpreter.update(descriptor
|
|
372
|
+
override === undefined ? interpreter.update(descriptor) : override(descriptor, interpreter)
|
|
360
373
|
}
|
|
361
374
|
|
|
362
|
-
doFree(unit: Unit
|
|
375
|
+
doFree(unit: Unit) {
|
|
363
376
|
const interpreter = this._interpreterCollection.get(unit.uuid)
|
|
364
377
|
if (interpreter === undefined) return
|
|
365
|
-
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this
|
|
366
|
-
interpreter.free(descriptor
|
|
378
|
+
const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
|
|
379
|
+
interpreter.free(descriptor)
|
|
367
380
|
this._interpreterCollection.delete(unit.uuid)
|
|
368
381
|
}
|
|
369
382
|
|
|
@@ -382,18 +395,18 @@ class Graphics {
|
|
|
382
395
|
return Descriptor.get<T>(unit.parent)
|
|
383
396
|
}
|
|
384
397
|
|
|
385
|
-
getActor<T extends Actor = Actor>(descriptor: Descriptor
|
|
398
|
+
getActor<T extends Actor = Actor>(descriptor: Descriptor) {
|
|
386
399
|
const interpreter = this.getInterpreter(descriptor)
|
|
387
|
-
return interpreter.getActor<T>(descriptor
|
|
400
|
+
return interpreter.getActor<T>(descriptor)
|
|
388
401
|
}
|
|
389
402
|
|
|
390
|
-
private _pickupItem(target: Descriptor,
|
|
403
|
+
private _pickupItem(target: Descriptor, result: PickupObject[]) {
|
|
391
404
|
if (target.selectable === false) return
|
|
392
405
|
const interpreter = this._interpreterCollection.get(target.uuid)
|
|
393
406
|
if (interpreter === undefined) return
|
|
394
|
-
interpreter.pickup(target,
|
|
407
|
+
interpreter.pickup(target, result)
|
|
395
408
|
}
|
|
396
|
-
private _pickupScene(
|
|
409
|
+
private _pickupScene(result: PickupObject[]) {
|
|
397
410
|
const master = this.unitCollection.get(this.scheduler.uuid)
|
|
398
411
|
if (master === undefined) return result
|
|
399
412
|
|
|
@@ -401,7 +414,7 @@ class Graphics {
|
|
|
401
414
|
for (const unit of units) {
|
|
402
415
|
const descriptor = Descriptor.get<Descriptor>(unit.uuid)
|
|
403
416
|
if (descriptor instanceof HTMLDescriptor) continue
|
|
404
|
-
this._pickupItem(descriptor,
|
|
417
|
+
this._pickupItem(descriptor, result)
|
|
405
418
|
}
|
|
406
419
|
}
|
|
407
420
|
|
|
@@ -434,28 +447,26 @@ class Graphics {
|
|
|
434
447
|
const args = { delta: 0 }
|
|
435
448
|
if (target instanceof ServiceDescriptor) {
|
|
436
449
|
if (target instanceof HTMLServiceDescriptor) {
|
|
437
|
-
this._pickupItem(target,
|
|
450
|
+
this._pickupItem(target, result)
|
|
438
451
|
} else {
|
|
439
452
|
const interpreter = this.getInterpreter<ServiceInterpreter>(target)
|
|
440
|
-
interpreter.beforePickup(mouse, rect
|
|
441
|
-
this._pickupScene(
|
|
453
|
+
interpreter.beforePickup(mouse, rect)
|
|
454
|
+
this._pickupScene(result)
|
|
442
455
|
interpreter.orderBy(result)
|
|
443
456
|
}
|
|
444
457
|
} else {
|
|
445
|
-
this._pickupItem(target,
|
|
458
|
+
this._pickupItem(target, result)
|
|
446
459
|
}
|
|
447
460
|
|
|
448
461
|
return result
|
|
449
462
|
}
|
|
450
463
|
|
|
451
|
-
invoke(interaction: string, descriptor: Descriptor) {
|
|
464
|
+
async invoke(interaction: string, descriptor: Descriptor) {
|
|
452
465
|
if (descriptor.interactions.length === 0) return
|
|
453
|
-
const eventArgs = { delta: 0, trigger: descriptor }
|
|
454
466
|
for (const inter of descriptor.interactions) {
|
|
455
467
|
if (inter.type === interaction) {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
interpreter.do(inter.inputs, routine, eventArgs)
|
|
468
|
+
const current = Asset.get<InteractionDescriptor>(inter.url)
|
|
469
|
+
if (current !== null) await current.execute(inter.inputs, this, descriptor)
|
|
459
470
|
break
|
|
460
471
|
}
|
|
461
472
|
}
|
|
@@ -471,5 +482,6 @@ class Graphics {
|
|
|
471
482
|
|
|
472
483
|
export {
|
|
473
484
|
PickupObject,
|
|
485
|
+
TickArgs,
|
|
474
486
|
Graphics,
|
|
475
487
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ObjectUtils } from "../ObjectUtils";
|
|
2
2
|
import { Asset } from "../asset";
|
|
3
|
-
import { Scriptable } from "../Scriptable";
|
|
4
|
-
import { Data, DatasetDescriptor, Descriptor,
|
|
3
|
+
import { Scriptable, ScriptableArgs } from "../interaction/Scriptable";
|
|
4
|
+
import { Data, DatasetDescriptor, Descriptor, VariabConfig } from "../descriptor";
|
|
5
5
|
import { Graphics } from "./Graphics";
|
|
6
6
|
|
|
7
7
|
interface ActorCollection { [k: string]: any }
|
|
@@ -34,18 +34,18 @@ class VariableProxy {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
private getVariableValue = (descriptor: Descriptor, data: Data, key: string, config: VariabConfig, graphics: Graphics
|
|
37
|
+
private getVariableValue = (descriptor: Descriptor, data: Data, key: string, config: VariabConfig, graphics: Graphics) => {
|
|
38
38
|
if (config.type === 'key') {
|
|
39
39
|
return ObjectUtils.getValueByKey(data, config.value)
|
|
40
40
|
} else if (config.type === 'custom') {
|
|
41
|
-
const scriptable = Asset.get<Scriptable
|
|
41
|
+
const scriptable = Asset.get<Scriptable<ScriptableArgs<undefined, undefined, undefined>>>(config.value)
|
|
42
42
|
if (scriptable === null) return
|
|
43
|
-
const currentArgs = {
|
|
44
|
-
return scriptable.execute(
|
|
43
|
+
const currentArgs = { key, config, data, input: undefined, result: undefined, trigger: descriptor }
|
|
44
|
+
return scriptable.execute(graphics, currentArgs)
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
get<T extends Descriptor | null = Descriptor | null>(uuid: string, graphics: Graphics
|
|
48
|
+
get<T extends Descriptor | null = Descriptor | null>(uuid: string, graphics: Graphics) {
|
|
49
49
|
const descriptor = Descriptor.get<Descriptor>(uuid)
|
|
50
50
|
if (descriptor === null) return null as unknown as T
|
|
51
51
|
|
|
@@ -63,7 +63,7 @@ class VariableProxy {
|
|
|
63
63
|
for (const key of keys) {
|
|
64
64
|
const variable = descriptor.variables[key]
|
|
65
65
|
if (variable.enabled === false) continue
|
|
66
|
-
const value = this.getVariableValue(descriptor, data, key, variable, graphics
|
|
66
|
+
const value = this.getVariableValue(descriptor, data, key, variable, graphics)
|
|
67
67
|
if (value === undefined) continue
|
|
68
68
|
variables[key] = value
|
|
69
69
|
}
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,8 @@ export { Listener } from './Listener'
|
|
|
15
15
|
export { InputSystem } from './InputSystem'
|
|
16
16
|
export { destroyInstance } from './ObjectPool'
|
|
17
17
|
export * from './AsyncTask'
|
|
18
|
-
export * from './Scriptable'
|
|
18
|
+
export * from './interaction/Scriptable'
|
|
19
|
+
export * from './interaction'
|
|
19
20
|
export * from './descriptor'
|
|
20
21
|
export * from './interpreter'
|
|
21
22
|
export * from './utils'
|