@zylem/behaviors 0.2.0
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/README.md +26 -0
- package/dist/behavior-system-DYbx-x_-.d.ts +307 -0
- package/dist/chunk-2C3Z5GE7.js +176 -0
- package/dist/chunk-2C3Z5GE7.js.map +1 -0
- package/dist/chunk-2CLT36VB.js +241 -0
- package/dist/chunk-2CLT36VB.js.map +1 -0
- package/dist/chunk-3PYGRHAL.js +35 -0
- package/dist/chunk-3PYGRHAL.js.map +1 -0
- package/dist/chunk-4I6E6DGV.js +212 -0
- package/dist/chunk-4I6E6DGV.js.map +1 -0
- package/dist/chunk-4URF65BR.js +44 -0
- package/dist/chunk-4URF65BR.js.map +1 -0
- package/dist/chunk-6C6NXNEW.js +38 -0
- package/dist/chunk-6C6NXNEW.js.map +1 -0
- package/dist/chunk-ARJWUNRE.js +431 -0
- package/dist/chunk-ARJWUNRE.js.map +1 -0
- package/dist/chunk-BXP4K7RF.js +1205 -0
- package/dist/chunk-BXP4K7RF.js.map +1 -0
- package/dist/chunk-DYLH6K7B.js +44 -0
- package/dist/chunk-DYLH6K7B.js.map +1 -0
- package/dist/chunk-EIWQM6U3.js +27 -0
- package/dist/chunk-EIWQM6U3.js.map +1 -0
- package/dist/chunk-EZNCCO4L.js +14 -0
- package/dist/chunk-EZNCCO4L.js.map +1 -0
- package/dist/chunk-F3KRX2V4.js +457 -0
- package/dist/chunk-F3KRX2V4.js.map +1 -0
- package/dist/chunk-FPTWVCPN.js +53 -0
- package/dist/chunk-FPTWVCPN.js.map +1 -0
- package/dist/chunk-GCNRXAKH.js +37 -0
- package/dist/chunk-GCNRXAKH.js.map +1 -0
- package/dist/chunk-GYURWCIQ.js +1985 -0
- package/dist/chunk-GYURWCIQ.js.map +1 -0
- package/dist/chunk-HZMY3TT4.js +244 -0
- package/dist/chunk-HZMY3TT4.js.map +1 -0
- package/dist/chunk-ID5QJYF5.js +50 -0
- package/dist/chunk-ID5QJYF5.js.map +1 -0
- package/dist/chunk-JAN34G6S.js +552 -0
- package/dist/chunk-JAN34G6S.js.map +1 -0
- package/dist/chunk-K3UNLQ7W.js +118 -0
- package/dist/chunk-K3UNLQ7W.js.map +1 -0
- package/dist/chunk-KDY5N6J4.js +82 -0
- package/dist/chunk-KDY5N6J4.js.map +1 -0
- package/dist/chunk-KOZUNIIE.js +413 -0
- package/dist/chunk-KOZUNIIE.js.map +1 -0
- package/dist/chunk-KS72RZHX.js +30 -0
- package/dist/chunk-KS72RZHX.js.map +1 -0
- package/dist/chunk-LD5SMIB3.js +32 -0
- package/dist/chunk-LD5SMIB3.js.map +1 -0
- package/dist/chunk-OHCPV2NT.js +86 -0
- package/dist/chunk-OHCPV2NT.js.map +1 -0
- package/dist/chunk-OYWFPIHF.js +115 -0
- package/dist/chunk-OYWFPIHF.js.map +1 -0
- package/dist/chunk-POZER3MQ.js +407 -0
- package/dist/chunk-POZER3MQ.js.map +1 -0
- package/dist/chunk-RTRVBEIB.js +56 -0
- package/dist/chunk-RTRVBEIB.js.map +1 -0
- package/dist/chunk-RTVRUNYR.js +29 -0
- package/dist/chunk-RTVRUNYR.js.map +1 -0
- package/dist/chunk-SS7ELMJ7.js +406 -0
- package/dist/chunk-SS7ELMJ7.js.map +1 -0
- package/dist/chunk-STCCNLPC.js +160 -0
- package/dist/chunk-STCCNLPC.js.map +1 -0
- package/dist/chunk-SVLNF434.js +261 -0
- package/dist/chunk-SVLNF434.js.map +1 -0
- package/dist/chunk-UYFOLI2X.js +24 -0
- package/dist/chunk-UYFOLI2X.js.map +1 -0
- package/dist/chunk-VAN4WW3F.js +67 -0
- package/dist/chunk-VAN4WW3F.js.map +1 -0
- package/dist/chunk-WOMHL23C.js +369 -0
- package/dist/chunk-WOMHL23C.js.map +1 -0
- package/dist/chunk-WWVD5DR5.js +120 -0
- package/dist/chunk-WWVD5DR5.js.map +1 -0
- package/dist/chunk-XG2YMCJW.js +201 -0
- package/dist/chunk-XG2YMCJW.js.map +1 -0
- package/dist/chunk-XIJNE67Y.js +210 -0
- package/dist/chunk-XIJNE67Y.js.map +1 -0
- package/dist/chunk-Y6UJOUE5.js +44 -0
- package/dist/chunk-Y6UJOUE5.js.map +1 -0
- package/dist/chunk-YUO6SKJD.js +348 -0
- package/dist/chunk-YUO6SKJD.js.map +1 -0
- package/dist/components--hjBMTnz.d.ts +120 -0
- package/dist/components-B29WHGQN.d.ts +39 -0
- package/dist/components-BWG1GkZA.d.ts +20 -0
- package/dist/components-XCpL6IYt.d.ts +18 -0
- package/dist/components-qWwOsvwh.d.ts +43 -0
- package/dist/cooldown.d.ts +116 -0
- package/dist/cooldown.js +20 -0
- package/dist/cooldown.js.map +1 -0
- package/dist/coordinators/boundary-ricochet-3d.d.ts +19 -0
- package/dist/coordinators/boundary-ricochet-3d.js +8 -0
- package/dist/coordinators/boundary-ricochet-3d.js.map +1 -0
- package/dist/coordinators/boundary-ricochet.d.ts +34 -0
- package/dist/coordinators/boundary-ricochet.js +8 -0
- package/dist/coordinators/boundary-ricochet.js.map +1 -0
- package/dist/coordinators/first-person-shooter.d.ts +35 -0
- package/dist/coordinators/first-person-shooter.js +9 -0
- package/dist/coordinators/first-person-shooter.js.map +1 -0
- package/dist/coordinators/multidirectional-space-shooter.d.ts +27 -0
- package/dist/coordinators/multidirectional-space-shooter.js +10 -0
- package/dist/coordinators/multidirectional-space-shooter.js.map +1 -0
- package/dist/coordinators/top-down-shooter.d.ts +27 -0
- package/dist/coordinators/top-down-shooter.js +10 -0
- package/dist/coordinators/top-down-shooter.js.map +1 -0
- package/dist/core.d.ts +25 -0
- package/dist/core.js +327 -0
- package/dist/core.js.map +1 -0
- package/dist/destructible-3d.d.ts +42 -0
- package/dist/destructible-3d.js +13 -0
- package/dist/destructible-3d.js.map +1 -0
- package/dist/destructible-prebake.d.ts +28 -0
- package/dist/destructible-prebake.js +23 -0
- package/dist/destructible-prebake.js.map +1 -0
- package/dist/entity-types-CmtQ-IBp.d.ts +15 -0
- package/dist/first-person-perspective-C9Mptl0-.d.ts +23 -0
- package/dist/first-person.d.ts +204 -0
- package/dist/first-person.js +27 -0
- package/dist/first-person.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +263 -0
- package/dist/index.js.map +1 -0
- package/dist/jumper-2d.d.ts +113 -0
- package/dist/jumper-2d.js +27 -0
- package/dist/jumper-2d.js.map +1 -0
- package/dist/jumper-3d.d.ts +164 -0
- package/dist/jumper-3d.js +29 -0
- package/dist/jumper-3d.js.map +1 -0
- package/dist/moveable-BCRpjAQb.d.ts +176 -0
- package/dist/particle-emitter/presets.d.ts +46 -0
- package/dist/particle-emitter/presets.js +15 -0
- package/dist/particle-emitter/presets.js.map +1 -0
- package/dist/particle-emitter.d.ts +78 -0
- package/dist/particle-emitter.js +15 -0
- package/dist/particle-emitter.js.map +1 -0
- package/dist/payload-BQzu-oY_.d.ts +89 -0
- package/dist/platformer-3d.d.ts +347 -0
- package/dist/platformer-3d.js +23 -0
- package/dist/platformer-3d.js.map +1 -0
- package/dist/ricochet-2d.d.ts +274 -0
- package/dist/ricochet-2d.js +16 -0
- package/dist/ricochet-2d.js.map +1 -0
- package/dist/ricochet-3d.d.ts +116 -0
- package/dist/ricochet-3d.js +16 -0
- package/dist/ricochet-3d.js.map +1 -0
- package/dist/runtime-2d.d.ts +2 -0
- package/dist/runtime-2d.js +32 -0
- package/dist/runtime-2d.js.map +1 -0
- package/dist/runtime-pong.d.ts +92 -0
- package/dist/runtime-pong.js +38 -0
- package/dist/runtime-pong.js.map +1 -0
- package/dist/screen-visibility.d.ts +74 -0
- package/dist/screen-visibility.js +10 -0
- package/dist/screen-visibility.js.map +1 -0
- package/dist/screen-wrap.d.ts +86 -0
- package/dist/screen-wrap.js +16 -0
- package/dist/screen-wrap.js.map +1 -0
- package/dist/shooter-2d.d.ts +77 -0
- package/dist/shooter-2d.js +12 -0
- package/dist/shooter-2d.js.map +1 -0
- package/dist/spark-DDlIg1nM.d.ts +148 -0
- package/dist/sync-state-machine-CZyspBpj.d.ts +16 -0
- package/dist/thruster.d.ts +132 -0
- package/dist/thruster.js +26 -0
- package/dist/thruster.js.map +1 -0
- package/dist/top-down-movement.d.ts +40 -0
- package/dist/top-down-movement.js +20 -0
- package/dist/top-down-movement.js.map +1 -0
- package/dist/use-behavior-D_82jAL3.d.ts +13 -0
- package/dist/vector-Bm65-FOG.d.ts +45 -0
- package/dist/world-boundary-2d.d.ts +141 -0
- package/dist/world-boundary-2d.js +21 -0
- package/dist/world-boundary-2d.js.map +1 -0
- package/dist/world-boundary-3d.d.ts +75 -0
- package/dist/world-boundary-3d.js +21 -0
- package/dist/world-boundary-3d.js.map +1 -0
- package/package.json +161 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Texture, Blending, ColorRepresentation } from 'three';
|
|
2
|
+
import { ParticleSystem, RenderMode, RendererEmitterSettings } from 'three.quarks';
|
|
3
|
+
|
|
4
|
+
interface ParticleEffectDefinition {
|
|
5
|
+
create(): ParticleSystem;
|
|
6
|
+
}
|
|
7
|
+
interface ParticlePresetMaterialOptions {
|
|
8
|
+
texture?: Texture;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
depthWrite?: boolean;
|
|
11
|
+
alphaTest?: number;
|
|
12
|
+
blending?: Blending;
|
|
13
|
+
uTileCount?: number;
|
|
14
|
+
vTileCount?: number;
|
|
15
|
+
blendTiles?: boolean;
|
|
16
|
+
}
|
|
17
|
+
type NumericRange = number | readonly [number, number];
|
|
18
|
+
type CurvePoints = readonly [number, number, number, number];
|
|
19
|
+
type ColorStop = readonly [ColorRepresentation, number];
|
|
20
|
+
type AlphaStop = readonly [number, number];
|
|
21
|
+
interface ParticleColorOverLifeConfig {
|
|
22
|
+
colors: readonly ColorStop[];
|
|
23
|
+
alpha: readonly AlphaStop[];
|
|
24
|
+
}
|
|
25
|
+
interface ParticleForceOverLifeConfig {
|
|
26
|
+
x?: NumericRange;
|
|
27
|
+
y?: NumericRange;
|
|
28
|
+
z?: NumericRange;
|
|
29
|
+
}
|
|
30
|
+
interface ParticleNoiseConfig {
|
|
31
|
+
frequency: NumericRange;
|
|
32
|
+
power: NumericRange;
|
|
33
|
+
positionAmount?: NumericRange;
|
|
34
|
+
rotationAmount?: NumericRange;
|
|
35
|
+
}
|
|
36
|
+
interface ParticleOrbitConfig {
|
|
37
|
+
speed: NumericRange;
|
|
38
|
+
axis?: readonly [number, number, number];
|
|
39
|
+
}
|
|
40
|
+
interface ParticleBehaviorOverrides {
|
|
41
|
+
colorOverLife?: ParticleColorOverLifeConfig | null;
|
|
42
|
+
sizeOverLife?: CurvePoints | null;
|
|
43
|
+
speedOverLife?: CurvePoints | null;
|
|
44
|
+
rotationOverLife?: NumericRange | null;
|
|
45
|
+
forceOverLife?: Partial<ParticleForceOverLifeConfig> | null;
|
|
46
|
+
noise?: Partial<ParticleNoiseConfig> | null;
|
|
47
|
+
orbitOverLife?: Partial<ParticleOrbitConfig> | null;
|
|
48
|
+
}
|
|
49
|
+
type ParticleShapeConfig = {
|
|
50
|
+
type: 'point';
|
|
51
|
+
} | {
|
|
52
|
+
type: 'cone';
|
|
53
|
+
radius?: number;
|
|
54
|
+
thickness?: number;
|
|
55
|
+
angle?: number;
|
|
56
|
+
speed?: NumericRange;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'sphere';
|
|
59
|
+
radius?: number;
|
|
60
|
+
thickness?: number;
|
|
61
|
+
speed?: NumericRange;
|
|
62
|
+
};
|
|
63
|
+
type ParticleMagicAlignment = 'arcane' | 'holy' | 'corrupted' | 'nature' | 'void' | 'psychic';
|
|
64
|
+
type ParticleMagicTemperament = 'calm' | 'ominous' | 'playful' | 'regal' | 'predatory';
|
|
65
|
+
type ParticleMagicAgency = 'passive' | 'reactive' | 'seeking' | 'sentient-feeling';
|
|
66
|
+
type ParticleMagicOrder = 'geometric' | 'organic' | 'chaotic';
|
|
67
|
+
type ParticleMagicRealityEffect = 'warping' | 'illuminating' | 'binding' | 'decaying' | 'healing';
|
|
68
|
+
interface ParticleMagicModifierOptions {
|
|
69
|
+
alignment: ParticleMagicAlignment;
|
|
70
|
+
temperament?: ParticleMagicTemperament;
|
|
71
|
+
agency?: ParticleMagicAgency;
|
|
72
|
+
order?: ParticleMagicOrder;
|
|
73
|
+
realityEffect?: ParticleMagicRealityEffect;
|
|
74
|
+
intensity?: number;
|
|
75
|
+
}
|
|
76
|
+
type ParticleMagicModifierInput = ParticleMagicAlignment | ParticleMagicModifierOptions;
|
|
77
|
+
interface SemanticParticlePresetOptions extends ParticlePresetMaterialOptions {
|
|
78
|
+
behaviors?: ParticleBehaviorOverrides;
|
|
79
|
+
color?: ColorRepresentation;
|
|
80
|
+
count?: number;
|
|
81
|
+
duration?: number;
|
|
82
|
+
emissionRate?: number;
|
|
83
|
+
life?: NumericRange;
|
|
84
|
+
looping?: boolean;
|
|
85
|
+
magic?: ParticleMagicModifierInput;
|
|
86
|
+
renderMode?: RenderMode;
|
|
87
|
+
rendererEmitterSettings?: Partial<RendererEmitterSettings>;
|
|
88
|
+
rotation?: NumericRange;
|
|
89
|
+
shape?: ParticleShapeConfig;
|
|
90
|
+
size?: NumericRange;
|
|
91
|
+
speed?: NumericRange;
|
|
92
|
+
worldSpace?: boolean;
|
|
93
|
+
}
|
|
94
|
+
declare function particleEffect(create: () => ParticleSystem): ParticleEffectDefinition;
|
|
95
|
+
|
|
96
|
+
declare function arcane(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
97
|
+
|
|
98
|
+
declare function corrupted(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
99
|
+
|
|
100
|
+
declare function holy(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
101
|
+
|
|
102
|
+
declare function nature(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
103
|
+
|
|
104
|
+
declare function psychic(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
105
|
+
|
|
106
|
+
declare function voidMagic(options?: Omit<ParticleMagicModifierOptions, 'alignment'>): ParticleMagicModifierOptions;
|
|
107
|
+
|
|
108
|
+
declare function arc(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
109
|
+
|
|
110
|
+
declare function pulse(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
111
|
+
|
|
112
|
+
declare function spark$1(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
113
|
+
|
|
114
|
+
declare function storm(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
115
|
+
|
|
116
|
+
declare function surge(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
117
|
+
|
|
118
|
+
declare function haze(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
119
|
+
|
|
120
|
+
declare function miasma(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
121
|
+
|
|
122
|
+
declare function plume(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
123
|
+
|
|
124
|
+
declare function smoke(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
125
|
+
|
|
126
|
+
declare function vapor(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
127
|
+
|
|
128
|
+
declare function drizzle(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
129
|
+
|
|
130
|
+
declare function mist(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
131
|
+
|
|
132
|
+
declare function splash(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
133
|
+
|
|
134
|
+
declare function spray(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
135
|
+
|
|
136
|
+
declare function torrent(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
137
|
+
|
|
138
|
+
declare function blaze(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
139
|
+
|
|
140
|
+
declare function ember(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
141
|
+
|
|
142
|
+
declare function flamelet(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
143
|
+
|
|
144
|
+
declare function smolder(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
145
|
+
|
|
146
|
+
declare function spark(options?: SemanticParticlePresetOptions): ParticleEffectDefinition;
|
|
147
|
+
|
|
148
|
+
export { spark$1 as A, spark as B, splash as C, spray as D, storm as E, surge as F, torrent as G, vapor as H, voidMagic as I, type ParticleEffectDefinition as P, type SemanticParticlePresetOptions as S, type ParticleMagicAgency as a, type ParticleMagicAlignment as b, type ParticleMagicModifierInput as c, type ParticleMagicModifierOptions as d, type ParticleMagicOrder as e, type ParticleMagicRealityEffect as f, type ParticleMagicTemperament as g, type ParticlePresetMaterialOptions as h, arc as i, arcane as j, blaze as k, corrupted as l, drizzle as m, ember as n, flamelet as o, haze as p, holy as q, miasma as r, mist as s, nature as t, particleEffect as u, plume as v, psychic as w, pulse as x, smoke as y, smolder as z };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SyncCallback, StateMachine, ITransition, ILogger } from 'typescript-fsm';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Local wrapper around typescript-fsm's SyncStateMachine.
|
|
5
|
+
*
|
|
6
|
+
* typescript-fsm@1.6.0 incorrectly reports callback-less transitions as
|
|
7
|
+
* unhandled even after moving to the next state, which causes noisy
|
|
8
|
+
* `No transition...` console errors for valid FSM dispatches.
|
|
9
|
+
*/
|
|
10
|
+
declare class SyncStateMachine<STATE extends string | number | symbol, EVENT extends string | number | symbol, CALLBACK extends Record<EVENT, SyncCallback> = Record<EVENT, SyncCallback>> extends StateMachine<STATE, EVENT, CALLBACK> {
|
|
11
|
+
constructor(init: STATE, transitions?: ITransition<STATE, EVENT, CALLBACK[EVENT]>[], logger?: ILogger);
|
|
12
|
+
dispatch<E extends EVENT>(_event: E, ..._args: unknown[]): Promise<void>;
|
|
13
|
+
syncDispatch<E extends EVENT>(event: E, ...args: unknown[]): boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { SyncStateMachine as S };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { T as ThrusterInputComponent, a as ThrusterMovementComponent } from './components-B29WHGQN.js';
|
|
2
|
+
export { b as ThrusterStateComponent, c as createThrusterInputComponent, d as createThrusterMovementComponent, e as createThrusterStateComponent } from './components-B29WHGQN.js';
|
|
3
|
+
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
4
|
+
import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
|
|
5
|
+
import { P as PhysicsBodyComponent } from './components-BWG1GkZA.js';
|
|
6
|
+
import 'typescript-fsm';
|
|
7
|
+
import '@dimforge/rapier3d-compat';
|
|
8
|
+
import 'three';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* ThrusterFSM
|
|
12
|
+
*
|
|
13
|
+
* State machine controller for thruster behavior.
|
|
14
|
+
* FSM does NOT touch physics or ThrusterMovementBehavior - it only writes ThrusterInputComponent.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
declare enum ThrusterState {
|
|
18
|
+
Idle = "idle",
|
|
19
|
+
Active = "active",
|
|
20
|
+
Boosting = "boosting",
|
|
21
|
+
Disabled = "disabled",
|
|
22
|
+
Docked = "docked"
|
|
23
|
+
}
|
|
24
|
+
declare enum ThrusterEvent {
|
|
25
|
+
Activate = "activate",
|
|
26
|
+
Deactivate = "deactivate",
|
|
27
|
+
Boost = "boost",
|
|
28
|
+
EndBoost = "endBoost",
|
|
29
|
+
Disable = "disable",
|
|
30
|
+
Enable = "enable",
|
|
31
|
+
Dock = "dock",
|
|
32
|
+
Undock = "undock"
|
|
33
|
+
}
|
|
34
|
+
interface ThrusterFSMContext {
|
|
35
|
+
input: ThrusterInputComponent;
|
|
36
|
+
}
|
|
37
|
+
interface PlayerInput {
|
|
38
|
+
thrust: number;
|
|
39
|
+
rotate: number;
|
|
40
|
+
thrustX?: number;
|
|
41
|
+
thrustY?: number;
|
|
42
|
+
}
|
|
43
|
+
declare class ThrusterFSM {
|
|
44
|
+
private ctx;
|
|
45
|
+
machine: SyncStateMachine<ThrusterState, ThrusterEvent, never>;
|
|
46
|
+
constructor(ctx: ThrusterFSMContext);
|
|
47
|
+
/**
|
|
48
|
+
* Get current state
|
|
49
|
+
*/
|
|
50
|
+
getState(): ThrusterState;
|
|
51
|
+
/**
|
|
52
|
+
* Dispatch an event to transition state
|
|
53
|
+
*/
|
|
54
|
+
dispatch(event: ThrusterEvent): void;
|
|
55
|
+
/**
|
|
56
|
+
* Update FSM state based on player input.
|
|
57
|
+
* Auto-transitions between Idle/Active to report current state.
|
|
58
|
+
* Does NOT modify input - just observes and reports.
|
|
59
|
+
*/
|
|
60
|
+
update(playerInput: PlayerInput): void;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ZylemWorld {
|
|
64
|
+
collisionMap?: Map<string, GameEntity<any>>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* ThrusterMovementBehavior
|
|
69
|
+
*
|
|
70
|
+
* This is the heart of the thruster movement system - a pure, stateless force generator.
|
|
71
|
+
* Works identically for player, AI, and replay.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Zylem-style Behavior interface
|
|
76
|
+
*/
|
|
77
|
+
interface Behavior {
|
|
78
|
+
update(dt: number): void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Entity with thruster components
|
|
82
|
+
*/
|
|
83
|
+
interface ThrusterEntity {
|
|
84
|
+
physics: PhysicsBodyComponent;
|
|
85
|
+
thruster: ThrusterMovementComponent;
|
|
86
|
+
$thruster: ThrusterInputComponent;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ThrusterMovementBehavior - Force generator for thruster-equipped entities
|
|
90
|
+
*
|
|
91
|
+
* Responsibilities:
|
|
92
|
+
* - Query entities with PhysicsBody, ThrusterMovement, and ThrusterInput components
|
|
93
|
+
* - Apply velocities based on thrust input (2D mode)
|
|
94
|
+
* - Apply angular velocity based on rotation input
|
|
95
|
+
*/
|
|
96
|
+
declare class ThrusterMovementBehavior implements Behavior {
|
|
97
|
+
private world;
|
|
98
|
+
constructor(world: ZylemWorld);
|
|
99
|
+
/**
|
|
100
|
+
* Update a single thruster-enabled entity.
|
|
101
|
+
*/
|
|
102
|
+
updateEntity(gameEntity: any, _dt: number): void;
|
|
103
|
+
update(dt: number): void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Thruster behavior options (typed for entity.use() autocomplete)
|
|
108
|
+
*/
|
|
109
|
+
interface ThrusterBehaviorOptions {
|
|
110
|
+
/** Forward thrust force (default: 10) */
|
|
111
|
+
linearThrust: number;
|
|
112
|
+
/** Rotation torque (default: 5) */
|
|
113
|
+
angularThrust: number;
|
|
114
|
+
/** Optional linear damping override */
|
|
115
|
+
linearDamping?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* ThrusterBehavior - typed descriptor for thruster movement.
|
|
119
|
+
*
|
|
120
|
+
* Uses the existing ThrusterMovementBehavior under the hood.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* import { ThrusterBehavior } from "@zylem/game-lib/behavior";
|
|
125
|
+
*
|
|
126
|
+
* const ship = createSprite({ ... });
|
|
127
|
+
* ship.use(ThrusterBehavior, { linearThrust: 15, angularThrust: 8 });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare const ThrusterBehavior: BehaviorDescriptor<ThrusterBehaviorOptions, Record<string, never>, ThrusterEntity>;
|
|
131
|
+
|
|
132
|
+
export { type Behavior, type PlayerInput, ThrusterBehavior, type ThrusterBehaviorOptions, type ThrusterEntity, ThrusterEvent, ThrusterFSM, type ThrusterFSMContext, ThrusterInputComponent, ThrusterMovementBehavior, ThrusterMovementComponent, ThrusterState };
|
package/dist/thruster.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ThrusterBehavior,
|
|
3
|
+
ThrusterEvent,
|
|
4
|
+
ThrusterFSM,
|
|
5
|
+
ThrusterMovementBehavior,
|
|
6
|
+
ThrusterState
|
|
7
|
+
} from "./chunk-2CLT36VB.js";
|
|
8
|
+
import {
|
|
9
|
+
createThrusterInputComponent,
|
|
10
|
+
createThrusterMovementComponent,
|
|
11
|
+
createThrusterStateComponent
|
|
12
|
+
} from "./chunk-KS72RZHX.js";
|
|
13
|
+
import "./chunk-ID5QJYF5.js";
|
|
14
|
+
import "./chunk-4URF65BR.js";
|
|
15
|
+
import "./chunk-EZNCCO4L.js";
|
|
16
|
+
export {
|
|
17
|
+
ThrusterBehavior,
|
|
18
|
+
ThrusterEvent,
|
|
19
|
+
ThrusterFSM,
|
|
20
|
+
ThrusterMovementBehavior,
|
|
21
|
+
ThrusterState,
|
|
22
|
+
createThrusterInputComponent,
|
|
23
|
+
createThrusterMovementComponent,
|
|
24
|
+
createThrusterStateComponent
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=thruster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { T as TopDownMovementComponent, a as TopDownMovementInputComponent, b as TopDownMovementStateComponent } from './components-XCpL6IYt.js';
|
|
2
|
+
export { c as createTopDownMovementComponent, d as createTopDownMovementInputComponent, e as createTopDownMovementStateComponent } from './components-XCpL6IYt.js';
|
|
3
|
+
import { a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
|
|
4
|
+
|
|
5
|
+
interface TopDownMovementEntity {
|
|
6
|
+
body: {
|
|
7
|
+
linvel(): {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
z: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
transformStore?: {
|
|
14
|
+
velocity: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
z: number;
|
|
18
|
+
};
|
|
19
|
+
dirty: {
|
|
20
|
+
velocity: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
setRotationZ?: (angle: number) => void;
|
|
24
|
+
topDownMovement: TopDownMovementComponent;
|
|
25
|
+
$topDownMovement: TopDownMovementInputComponent;
|
|
26
|
+
topDownMovementState: TopDownMovementStateComponent;
|
|
27
|
+
}
|
|
28
|
+
declare class TopDownMovementRuntimeBehavior {
|
|
29
|
+
updateEntity(entity: TopDownMovementEntity, _delta: number): void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface TopDownMovementBehaviorOptions {
|
|
33
|
+
moveSpeed?: number;
|
|
34
|
+
}
|
|
35
|
+
interface TopDownMovementHandle {
|
|
36
|
+
getFacingAngle(): number;
|
|
37
|
+
}
|
|
38
|
+
declare const TopDownMovementBehavior: BehaviorDescriptor<TopDownMovementBehaviorOptions, TopDownMovementHandle, TopDownMovementEntity>;
|
|
39
|
+
|
|
40
|
+
export { TopDownMovementBehavior, type TopDownMovementBehaviorOptions, TopDownMovementComponent, type TopDownMovementEntity, type TopDownMovementHandle, TopDownMovementInputComponent, TopDownMovementRuntimeBehavior, TopDownMovementStateComponent };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TopDownMovementBehavior,
|
|
3
|
+
TopDownMovementRuntimeBehavior
|
|
4
|
+
} from "./chunk-OYWFPIHF.js";
|
|
5
|
+
import {
|
|
6
|
+
createTopDownMovementComponent,
|
|
7
|
+
createTopDownMovementInputComponent,
|
|
8
|
+
createTopDownMovementStateComponent
|
|
9
|
+
} from "./chunk-EIWQM6U3.js";
|
|
10
|
+
import "./chunk-ID5QJYF5.js";
|
|
11
|
+
import "./chunk-Y6UJOUE5.js";
|
|
12
|
+
import "./chunk-EZNCCO4L.js";
|
|
13
|
+
export {
|
|
14
|
+
TopDownMovementBehavior,
|
|
15
|
+
TopDownMovementRuntimeBehavior,
|
|
16
|
+
createTopDownMovementComponent,
|
|
17
|
+
createTopDownMovementInputComponent,
|
|
18
|
+
createTopDownMovementStateComponent
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=top-down-movement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { G as GameEntity, a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type-safe helper to apply a behavior to an entity and return the entity cast to the behavior's interface.
|
|
5
|
+
*
|
|
6
|
+
* @param entity The entity to apply the behavior to
|
|
7
|
+
* @param descriptor The behavior descriptor
|
|
8
|
+
* @param options Behavior options
|
|
9
|
+
* @returns The entity, cast to E & I (where I is the behavior's interface)
|
|
10
|
+
*/
|
|
11
|
+
declare function useBehavior<E extends GameEntity<any>, O extends Record<string, any>, H extends Record<string, any>, I>(entity: E, descriptor: BehaviorDescriptor<O, H, I>, options?: Partial<O>): E & I;
|
|
12
|
+
|
|
13
|
+
export { useBehavior as u };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Vector3, Vector2 } from 'three';
|
|
2
|
+
import { Vector3 as Vector3$1 } from '@dimforge/rapier3d-compat';
|
|
3
|
+
|
|
4
|
+
type Vec2 = Vector2;
|
|
5
|
+
type Vec3 = Vector3 | Vector3$1;
|
|
6
|
+
type Vec2Components = {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
type Vec3Components = {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
z: number;
|
|
14
|
+
};
|
|
15
|
+
type Vec2Tuple = readonly [number?, number?] & {
|
|
16
|
+
x?: number;
|
|
17
|
+
y?: number;
|
|
18
|
+
};
|
|
19
|
+
type Vec3Tuple = readonly [number?, number?, number?] & {
|
|
20
|
+
x?: number;
|
|
21
|
+
y?: number;
|
|
22
|
+
z?: number;
|
|
23
|
+
};
|
|
24
|
+
type Vec2Input = Vec2 | {
|
|
25
|
+
x?: number;
|
|
26
|
+
y?: number;
|
|
27
|
+
} | Vec2Tuple;
|
|
28
|
+
type Vec3Input = Vec3 | {
|
|
29
|
+
x?: number;
|
|
30
|
+
y?: number;
|
|
31
|
+
z?: number;
|
|
32
|
+
} | Vec3Tuple;
|
|
33
|
+
declare const VEC2_ZERO: Readonly<Vec2Components>;
|
|
34
|
+
declare const VEC2_ONE: Readonly<Vec2Components>;
|
|
35
|
+
declare const VEC3_ZERO: Readonly<Vec3Components>;
|
|
36
|
+
declare const VEC3_ONE: Readonly<Vec3Components>;
|
|
37
|
+
declare function isVec2Input(value: unknown): value is Vec2Input;
|
|
38
|
+
declare function isVec3Input(value: unknown): value is Vec3Input;
|
|
39
|
+
declare function normalizeVec2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vec2Components;
|
|
40
|
+
declare function normalizeVec3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vec3Components;
|
|
41
|
+
declare function toThreeVector2(input?: Vec2Input | null, defaults?: Vec2Input | Partial<Vec2Components>): Vector2;
|
|
42
|
+
declare function toThreeVector3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vector3;
|
|
43
|
+
declare function toRapierVector3(input?: Vec3Input | null, defaults?: Vec3Input | Partial<Vec3Components>): Vector3$1;
|
|
44
|
+
|
|
45
|
+
export { VEC2_ONE as V, VEC2_ZERO as a, VEC3_ONE as b, VEC3_ZERO as c, type Vec2 as d, type Vec2Components as e, type Vec2Input as f, type Vec3 as g, type Vec3Components as h, type Vec3Input as i, isVec2Input as j, isVec3Input as k, normalizeVec3 as l, toThreeVector2 as m, normalizeVec2 as n, toThreeVector3 as o, toRapierVector3 as t };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { a as BehaviorDescriptor } from './behavior-system-DYbx-x_-.js';
|
|
2
|
+
import { S as SyncStateMachine } from './sync-state-machine-CZyspBpj.js';
|
|
3
|
+
import 'typescript-fsm';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WorldBoundary2DFSM
|
|
7
|
+
*
|
|
8
|
+
* Minimal FSM + extended state to track which world boundaries were hit.
|
|
9
|
+
*
|
|
10
|
+
* Notes:
|
|
11
|
+
* - "Hit boundaries" is inherently a *set* (can hit left+bottom in one frame),
|
|
12
|
+
* so we store it as extended state (`lastHits`) rather than a single FSM state.
|
|
13
|
+
* - The FSM state is still useful for coarse status like "inside" vs "touching".
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type WorldBoundary2DHit = 'top' | 'bottom' | 'left' | 'right';
|
|
17
|
+
type WorldBoundary2DHits = Record<WorldBoundary2DHit, boolean>;
|
|
18
|
+
interface WorldBoundary2DPosition {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
interface WorldBoundary2DBounds {
|
|
23
|
+
top: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
left: number;
|
|
26
|
+
right: number;
|
|
27
|
+
}
|
|
28
|
+
declare enum WorldBoundary2DState {
|
|
29
|
+
Inside = "inside",
|
|
30
|
+
Touching = "touching"
|
|
31
|
+
}
|
|
32
|
+
declare enum WorldBoundary2DEvent {
|
|
33
|
+
EnterInside = "enter-inside",
|
|
34
|
+
TouchBoundary = "touch-boundary"
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Compute which boundaries are being hit for a position and bounds.
|
|
38
|
+
* This matches the semantics of the legacy `boundary2d` behavior:
|
|
39
|
+
* - left hit if x <= left
|
|
40
|
+
* - right hit if x >= right
|
|
41
|
+
* - bottom hit if y <= bottom
|
|
42
|
+
* - top hit if y >= top
|
|
43
|
+
*/
|
|
44
|
+
declare function computeWorldBoundary2DHits(position: WorldBoundary2DPosition, bounds: WorldBoundary2DBounds): WorldBoundary2DHits;
|
|
45
|
+
declare function hasAnyWorldBoundary2DHit(hits: WorldBoundary2DHits): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* FSM wrapper with "extended state" (lastHits / lastPosition).
|
|
48
|
+
* Systems should call `update(...)` once per frame.
|
|
49
|
+
*/
|
|
50
|
+
declare class WorldBoundary2DFSM {
|
|
51
|
+
readonly machine: SyncStateMachine<WorldBoundary2DState, WorldBoundary2DEvent, never>;
|
|
52
|
+
private lastHits;
|
|
53
|
+
private lastPosition;
|
|
54
|
+
private lastUpdatedAtMs;
|
|
55
|
+
constructor();
|
|
56
|
+
getState(): WorldBoundary2DState;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the last computed hits (always available after first update call).
|
|
59
|
+
*/
|
|
60
|
+
getLastHits(): WorldBoundary2DHits;
|
|
61
|
+
/**
|
|
62
|
+
* Returns adjusted movement values based on boundary hits.
|
|
63
|
+
* If the entity is touching a boundary and trying to move further into it,
|
|
64
|
+
* that axis component is zeroed out.
|
|
65
|
+
*
|
|
66
|
+
* @param moveX - The desired X movement
|
|
67
|
+
* @param moveY - The desired Y movement
|
|
68
|
+
* @returns Adjusted { moveX, moveY } with boundary-blocked axes zeroed
|
|
69
|
+
*/
|
|
70
|
+
getMovement(moveX: number, moveY: number): {
|
|
71
|
+
moveX: number;
|
|
72
|
+
moveY: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Returns the last position passed to `update`, if any.
|
|
76
|
+
*/
|
|
77
|
+
getLastPosition(): WorldBoundary2DPosition | null;
|
|
78
|
+
/**
|
|
79
|
+
* Best-effort timestamp (ms) of the last `update(...)` call.
|
|
80
|
+
* This is optional metadata; systems can ignore it.
|
|
81
|
+
*/
|
|
82
|
+
getLastUpdatedAtMs(): number | null;
|
|
83
|
+
/**
|
|
84
|
+
* Update FSM + extended state based on current position and bounds.
|
|
85
|
+
* Returns the computed hits for convenience.
|
|
86
|
+
*/
|
|
87
|
+
update(position: WorldBoundary2DPosition, bounds: WorldBoundary2DBounds): WorldBoundary2DHits;
|
|
88
|
+
private dispatch;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface WorldBoundary2DOptions {
|
|
92
|
+
/**
|
|
93
|
+
* World boundaries (in world units).
|
|
94
|
+
* - left hit if x <= left
|
|
95
|
+
* - right hit if x >= right
|
|
96
|
+
* - bottom hit if y <= bottom
|
|
97
|
+
* - top hit if y >= top
|
|
98
|
+
*/
|
|
99
|
+
boundaries: WorldBoundary2DBounds;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handle methods provided by WorldBoundary2DBehavior
|
|
103
|
+
*/
|
|
104
|
+
interface WorldBoundary2DHandle {
|
|
105
|
+
/**
|
|
106
|
+
* Get the last computed boundary hits.
|
|
107
|
+
* Returns null until entity is spawned and FSM is initialized.
|
|
108
|
+
*/
|
|
109
|
+
getLastHits(): WorldBoundary2DHits | null;
|
|
110
|
+
/**
|
|
111
|
+
* Get adjusted movement values based on boundary hits.
|
|
112
|
+
* Zeros out movement into boundaries the entity is touching.
|
|
113
|
+
*/
|
|
114
|
+
getMovement(moveX: number, moveY: number): {
|
|
115
|
+
moveX: number;
|
|
116
|
+
moveY: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* WorldBoundary2DBehavior
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { WorldBoundary2DBehavior } from "@zylem/game-lib/behavior";
|
|
125
|
+
*
|
|
126
|
+
* const ship = createSprite({ ... });
|
|
127
|
+
* const boundary = ship.use(WorldBoundary2DBehavior, {
|
|
128
|
+
* boundaries: { left: -10, right: 10, bottom: -7.5, top: 7.5 },
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* ship.onUpdate(({ me }) => {
|
|
132
|
+
* let moveX = ..., moveY = ...;
|
|
133
|
+
* const hits = boundary.getLastHits(); // Fully typed!
|
|
134
|
+
* ({ moveX, moveY } = boundary.getMovement(moveX, moveY));
|
|
135
|
+
* me.moveXY(moveX, moveY);
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare const WorldBoundary2DBehavior: BehaviorDescriptor<WorldBoundary2DOptions, WorldBoundary2DHandle, unknown>;
|
|
140
|
+
|
|
141
|
+
export { WorldBoundary2DBehavior, type WorldBoundary2DBounds, WorldBoundary2DEvent, WorldBoundary2DFSM, type WorldBoundary2DHandle, type WorldBoundary2DHit, type WorldBoundary2DHits, type WorldBoundary2DOptions, type WorldBoundary2DPosition, WorldBoundary2DState, computeWorldBoundary2DHits, hasAnyWorldBoundary2DHit };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
WorldBoundary2DBehavior,
|
|
3
|
+
WorldBoundary2DEvent,
|
|
4
|
+
WorldBoundary2DFSM,
|
|
5
|
+
WorldBoundary2DState,
|
|
6
|
+
computeWorldBoundary2DHits,
|
|
7
|
+
hasAnyWorldBoundary2DHit
|
|
8
|
+
} from "./chunk-XG2YMCJW.js";
|
|
9
|
+
import "./chunk-KDY5N6J4.js";
|
|
10
|
+
import "./chunk-Y6UJOUE5.js";
|
|
11
|
+
import "./chunk-4URF65BR.js";
|
|
12
|
+
import "./chunk-EZNCCO4L.js";
|
|
13
|
+
export {
|
|
14
|
+
WorldBoundary2DBehavior,
|
|
15
|
+
WorldBoundary2DEvent,
|
|
16
|
+
WorldBoundary2DFSM,
|
|
17
|
+
WorldBoundary2DState,
|
|
18
|
+
computeWorldBoundary2DHits,
|
|
19
|
+
hasAnyWorldBoundary2DHit
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=world-boundary-2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|