@thewhateverapp/tile-sdk 0.15.3 → 0.15.4
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/excalibur/index.d.ts +48 -0
- package/dist/excalibur/index.d.ts.map +1 -0
- package/dist/excalibur/index.js +51 -0
- package/dist/react/ExcaliburGame.d.ts +109 -0
- package/dist/react/ExcaliburGame.d.ts.map +1 -0
- package/dist/react/ExcaliburGame.js +215 -0
- package/dist/react/index.js +3 -3
- package/dist/scene/index.d.ts +3 -41
- package/dist/scene/index.d.ts.map +1 -1
- package/dist/scene/index.js +1 -49
- package/dist/spec/schema.d.ts +12 -12
- package/package.json +7 -7
- package/dist/pixi/index.d.ts +0 -43
- package/dist/pixi/index.d.ts.map +0 -1
- package/dist/pixi/index.js +0 -46
- package/dist/react/PixiGame.d.ts +0 -138
- package/dist/react/PixiGame.d.ts.map +0 -1
- package/dist/react/PixiGame.js +0 -237
- package/dist/scene/SceneContext.d.ts +0 -173
- package/dist/scene/SceneContext.d.ts.map +0 -1
- package/dist/scene/SceneContext.js +0 -89
- package/dist/scene/SceneFromJson.d.ts +0 -34
- package/dist/scene/SceneFromJson.d.ts.map +0 -1
- package/dist/scene/SceneFromJson.js +0 -97
- package/dist/scene/SceneRenderer.d.ts +0 -29
- package/dist/scene/SceneRenderer.d.ts.map +0 -1
- package/dist/scene/SceneRenderer.js +0 -312
- package/dist/scene/camera/CameraController.d.ts +0 -6
- package/dist/scene/camera/CameraController.d.ts.map +0 -1
- package/dist/scene/camera/CameraController.js +0 -90
- package/dist/scene/components/ComponentRunner.d.ts +0 -22
- package/dist/scene/components/ComponentRunner.d.ts.map +0 -1
- package/dist/scene/components/ComponentRunner.js +0 -210
- package/dist/scene/effects/GlowFilter.d.ts +0 -38
- package/dist/scene/effects/GlowFilter.d.ts.map +0 -1
- package/dist/scene/effects/GlowFilter.js +0 -40
- package/dist/scene/effects/ParticleSystem.d.ts +0 -52
- package/dist/scene/effects/ParticleSystem.d.ts.map +0 -1
- package/dist/scene/effects/ParticleSystem.js +0 -107
- package/dist/scene/entities/EntityGraphics.d.ts +0 -26
- package/dist/scene/entities/EntityGraphics.d.ts.map +0 -1
- package/dist/scene/entities/EntityGraphics.js +0 -226
- package/dist/scene/input/InputManager.d.ts +0 -18
- package/dist/scene/input/InputManager.d.ts.map +0 -1
- package/dist/scene/input/InputManager.js +0 -86
- package/dist/scene/physics/PhysicsEngine.d.ts +0 -15
- package/dist/scene/physics/PhysicsEngine.d.ts.map +0 -1
- package/dist/scene/physics/PhysicsEngine.js +0 -260
- package/dist/scene/timeline/TimelineExecutor.d.ts +0 -6
- package/dist/scene/timeline/TimelineExecutor.d.ts.map +0 -1
- package/dist/scene/timeline/TimelineExecutor.js +0 -241
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { useGameLoop } from '../../pixi/index.js';
|
|
3
|
-
import { getEasing } from '@thewhateverapp/scene-sdk';
|
|
4
|
-
/**
|
|
5
|
-
* Hook to execute timeline events
|
|
6
|
-
*/
|
|
7
|
-
export function useTimelineExecutor(context) {
|
|
8
|
-
const { spec, timeline, entities, camera, emitEvent, spawnEntity, bpm, player } = context;
|
|
9
|
-
const timelineEvents = spec.timeline ?? [];
|
|
10
|
-
useGameLoop((delta) => {
|
|
11
|
-
const state = timeline.current;
|
|
12
|
-
const playerState = player.current;
|
|
13
|
-
const elapsedMs = state.elapsedMs;
|
|
14
|
-
const currentBeat = state.currentBeat;
|
|
15
|
-
// Don't process timeline until game has started
|
|
16
|
-
if (!playerState.started) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
// Process pending timeline events
|
|
20
|
-
while (state.nextEventIndex < timelineEvents.length) {
|
|
21
|
-
const event = timelineEvents[state.nextEventIndex];
|
|
22
|
-
// Calculate event trigger time
|
|
23
|
-
let triggerTime;
|
|
24
|
-
if (event.atBeat !== undefined) {
|
|
25
|
-
triggerTime = beatToMs(event.atBeat, bpm);
|
|
26
|
-
}
|
|
27
|
-
else if (event.atTimeMs !== undefined) {
|
|
28
|
-
triggerTime = event.atTimeMs;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
// No timing specified, skip
|
|
32
|
-
state.nextEventIndex++;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
// Check if event should fire
|
|
36
|
-
if (elapsedMs >= triggerTime) {
|
|
37
|
-
executeEvent(event, context);
|
|
38
|
-
state.nextEventIndex++;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Events are ordered, so we can stop here
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// Update active tweens
|
|
46
|
-
updateTweens(state.activeTweens, elapsedMs, context);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Convert beat number to milliseconds
|
|
51
|
-
*/
|
|
52
|
-
function beatToMs(beat, bpm) {
|
|
53
|
-
return (beat / (bpm / 60)) * 1000;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Execute a timeline event
|
|
57
|
-
*/
|
|
58
|
-
function executeEvent(event, context) {
|
|
59
|
-
const { entities, camera, timeline, emitEvent, spawnEntity } = context;
|
|
60
|
-
switch (event.type) {
|
|
61
|
-
case 'tween': {
|
|
62
|
-
const targetEntity = event.target ? entities.current.get(event.target) : null;
|
|
63
|
-
if (!targetEntity)
|
|
64
|
-
break;
|
|
65
|
-
const params = event.params;
|
|
66
|
-
const startValue = params.from ?? getPropertyValue(targetEntity, params.property);
|
|
67
|
-
const endValue = params.to;
|
|
68
|
-
const duration = params.duration;
|
|
69
|
-
// Add to active tweens
|
|
70
|
-
timeline.current.activeTweens.push({
|
|
71
|
-
targetId: event.target,
|
|
72
|
-
property: params.property,
|
|
73
|
-
startValue,
|
|
74
|
-
endValue,
|
|
75
|
-
startTime: timeline.current.elapsedMs,
|
|
76
|
-
duration,
|
|
77
|
-
easing: params.easing ?? 'linear',
|
|
78
|
-
});
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
case 'pulse': {
|
|
82
|
-
const targetEntity = event.target ? entities.current.get(event.target) : null;
|
|
83
|
-
if (!targetEntity)
|
|
84
|
-
break;
|
|
85
|
-
const params = event.params;
|
|
86
|
-
const originalScale = targetEntity.scaleX;
|
|
87
|
-
const targetScale = params.scale ?? 1.2;
|
|
88
|
-
const duration = params.durationMs ?? (params.durationBeats ? beatToMs(params.durationBeats, context.bpm) : 200);
|
|
89
|
-
// Create scale up tween
|
|
90
|
-
timeline.current.activeTweens.push({
|
|
91
|
-
targetId: event.target,
|
|
92
|
-
property: 'scaleX',
|
|
93
|
-
startValue: originalScale,
|
|
94
|
-
endValue: originalScale * targetScale,
|
|
95
|
-
startTime: timeline.current.elapsedMs,
|
|
96
|
-
duration: duration / 2,
|
|
97
|
-
easing: 'easeOut',
|
|
98
|
-
});
|
|
99
|
-
// Create scale down tween (delayed)
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
timeline.current.activeTweens.push({
|
|
102
|
-
targetId: event.target,
|
|
103
|
-
property: 'scaleX',
|
|
104
|
-
startValue: originalScale * targetScale,
|
|
105
|
-
endValue: originalScale,
|
|
106
|
-
startTime: timeline.current.elapsedMs,
|
|
107
|
-
duration: duration / 2,
|
|
108
|
-
easing: 'easeIn',
|
|
109
|
-
});
|
|
110
|
-
}, duration / 2);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
case 'colorSwap': {
|
|
114
|
-
const targetEntity = event.target ? entities.current.get(event.target) : null;
|
|
115
|
-
if (!targetEntity)
|
|
116
|
-
break;
|
|
117
|
-
targetEntity.fill = event.params.to;
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
case 'cameraShake': {
|
|
121
|
-
const params = event.params;
|
|
122
|
-
const duration = params.durationMs ?? (params.durationBeats ? beatToMs(params.durationBeats, context.bpm) : 200);
|
|
123
|
-
camera.current.shakeIntensity = params.strength;
|
|
124
|
-
camera.current.shakeTimeRemaining = duration;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
case 'spawn': {
|
|
128
|
-
const params = event.params;
|
|
129
|
-
if (params.prefabId) {
|
|
130
|
-
const pos = params.at ?? { x: 0, y: 0 };
|
|
131
|
-
spawnEntity(params.prefabId, pos.x, pos.y);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
case 'toggle': {
|
|
136
|
-
const targetEntity = event.target ? entities.current.get(event.target) : null;
|
|
137
|
-
if (!targetEntity)
|
|
138
|
-
break;
|
|
139
|
-
const property = event.params.property ?? 'visible';
|
|
140
|
-
if (property === 'visible') {
|
|
141
|
-
targetEntity.visible = event.params.value ?? !targetEntity.visible;
|
|
142
|
-
}
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
case 'set': {
|
|
146
|
-
const targetEntity = event.target ? entities.current.get(event.target) : null;
|
|
147
|
-
if (!targetEntity)
|
|
148
|
-
break;
|
|
149
|
-
setPropertyValue(targetEntity, event.params.path, event.params.value);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case 'emit': {
|
|
153
|
-
emitEvent(event.params.event, event.params.payload);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Update active tweens
|
|
160
|
-
*/
|
|
161
|
-
function updateTweens(tweens, elapsedMs, context) {
|
|
162
|
-
const { entities } = context;
|
|
163
|
-
const completedIndices = [];
|
|
164
|
-
for (let i = 0; i < tweens.length; i++) {
|
|
165
|
-
const tween = tweens[i];
|
|
166
|
-
const targetEntity = entities.current.get(tween.targetId);
|
|
167
|
-
if (!targetEntity) {
|
|
168
|
-
completedIndices.push(i);
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
const elapsed = elapsedMs - tween.startTime;
|
|
172
|
-
const progress = Math.min(elapsed / tween.duration, 1);
|
|
173
|
-
// Apply easing
|
|
174
|
-
const easingFn = getEasing(tween.easing);
|
|
175
|
-
const easedProgress = easingFn ? easingFn(progress) : progress;
|
|
176
|
-
// Interpolate value
|
|
177
|
-
const value = tween.startValue + (tween.endValue - tween.startValue) * easedProgress;
|
|
178
|
-
// Set property
|
|
179
|
-
setPropertyValue(targetEntity, tween.property, value);
|
|
180
|
-
// Check if complete
|
|
181
|
-
if (progress >= 1) {
|
|
182
|
-
completedIndices.push(i);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Remove completed tweens (in reverse order to preserve indices)
|
|
186
|
-
for (let i = completedIndices.length - 1; i >= 0; i--) {
|
|
187
|
-
tweens.splice(completedIndices[i], 1);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get a property value from an entity
|
|
192
|
-
*/
|
|
193
|
-
function getPropertyValue(entity, path) {
|
|
194
|
-
switch (path) {
|
|
195
|
-
case 'x':
|
|
196
|
-
return entity.x;
|
|
197
|
-
case 'y':
|
|
198
|
-
return entity.y;
|
|
199
|
-
case 'rotation':
|
|
200
|
-
return entity.rotation;
|
|
201
|
-
case 'scaleX':
|
|
202
|
-
return entity.scaleX;
|
|
203
|
-
case 'scaleY':
|
|
204
|
-
return entity.scaleY;
|
|
205
|
-
case 'alpha':
|
|
206
|
-
return entity.alpha;
|
|
207
|
-
default:
|
|
208
|
-
return 0;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Set a property value on an entity
|
|
213
|
-
*/
|
|
214
|
-
function setPropertyValue(entity, path, value) {
|
|
215
|
-
switch (path) {
|
|
216
|
-
case 'x':
|
|
217
|
-
entity.x = value;
|
|
218
|
-
break;
|
|
219
|
-
case 'y':
|
|
220
|
-
entity.y = value;
|
|
221
|
-
break;
|
|
222
|
-
case 'rotation':
|
|
223
|
-
entity.rotation = value;
|
|
224
|
-
break;
|
|
225
|
-
case 'scaleX':
|
|
226
|
-
entity.scaleX = value;
|
|
227
|
-
break;
|
|
228
|
-
case 'scaleY':
|
|
229
|
-
entity.scaleY = value;
|
|
230
|
-
break;
|
|
231
|
-
case 'alpha':
|
|
232
|
-
entity.alpha = value;
|
|
233
|
-
break;
|
|
234
|
-
case 'visible':
|
|
235
|
-
entity.visible = value;
|
|
236
|
-
break;
|
|
237
|
-
case 'fill':
|
|
238
|
-
entity.fill = value;
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
}
|