@waica/behaviors 0.25.0 → 0.26.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.
@@ -0,0 +1,58 @@
1
+ import { Component, type ComponentSpace } from '@waica/engine';
2
+ /**
3
+ * Walks and jumps a 3D character (ADR 0028): beside a kinematic `RigidBody`
4
+ * and its `Collider`, it turns the player's actions into the body's desired
5
+ * velocity on the world axes and a jump. The engine's character controller
6
+ * does the moving (walls, steps, slopes, gravity); this only asks. Movement is
7
+ * relative to the world, not to the camera, and `-z` is forward; a diagonal
8
+ * is normalized, so it moves at `speed` like a cardinal direction. The jump
9
+ * press is consumed only when the body jumped, so a press in the air stays
10
+ * readable (a double jump, a glide). With no kinematic body beside it, it
11
+ * does nothing (`validate_project` reports it). Actions with no binding read
12
+ * 0, so a Game without bindings stands still.
13
+ */
14
+ export declare class CharacterMotor extends Component {
15
+ static componentName: string;
16
+ static space: ComponentSpace;
17
+ static params: {
18
+ speed: {
19
+ label: string;
20
+ min: number;
21
+ max: number;
22
+ step: number;
23
+ };
24
+ jumpSpeed: {
25
+ label: string;
26
+ min: number;
27
+ max: number;
28
+ step: number;
29
+ };
30
+ leftAction: {
31
+ label: string;
32
+ };
33
+ rightAction: {
34
+ label: string;
35
+ };
36
+ forwardAction: {
37
+ label: string;
38
+ };
39
+ backAction: {
40
+ label: string;
41
+ };
42
+ jumpAction: {
43
+ label: string;
44
+ };
45
+ };
46
+ /** Walking speed in units per second. */
47
+ speed: number;
48
+ /** Launch speed of a jump in units per second. */
49
+ jumpSpeed: number;
50
+ leftAction: string;
51
+ rightAction: string;
52
+ /** Walks toward -z. */
53
+ forwardAction: string;
54
+ /** Walks toward +z. */
55
+ backAction: string;
56
+ jumpAction: string;
57
+ onUpdate(): void;
58
+ }
@@ -0,0 +1,51 @@
1
+ import { Component, RigidBody } from '@waica/engine';
2
+ /**
3
+ * Walks and jumps a 3D character (ADR 0028): beside a kinematic `RigidBody`
4
+ * and its `Collider`, it turns the player's actions into the body's desired
5
+ * velocity on the world axes and a jump. The engine's character controller
6
+ * does the moving (walls, steps, slopes, gravity); this only asks. Movement is
7
+ * relative to the world, not to the camera, and `-z` is forward; a diagonal
8
+ * is normalized, so it moves at `speed` like a cardinal direction. The jump
9
+ * press is consumed only when the body jumped, so a press in the air stays
10
+ * readable (a double jump, a glide). With no kinematic body beside it, it
11
+ * does nothing (`validate_project` reports it). Actions with no binding read
12
+ * 0, so a Game without bindings stands still.
13
+ */
14
+ export class CharacterMotor extends Component {
15
+ static componentName = 'CharacterMotor';
16
+ static space = '3d';
17
+ static params = {
18
+ speed: { label: 'Speed', min: 0, max: 30, step: 0.5 },
19
+ jumpSpeed: { label: 'Jump speed', min: 0, max: 30, step: 0.5 },
20
+ leftAction: { label: 'Left action' },
21
+ rightAction: { label: 'Right action' },
22
+ forwardAction: { label: 'Forward action' },
23
+ backAction: { label: 'Back action' },
24
+ jumpAction: { label: 'Jump action' },
25
+ };
26
+ /** Walking speed in units per second. */
27
+ speed = 6;
28
+ /** Launch speed of a jump in units per second. */
29
+ jumpSpeed = 6;
30
+ leftAction = 'left';
31
+ rightAction = 'right';
32
+ /** Walks toward -z. */
33
+ forwardAction = 'up';
34
+ /** Walks toward +z. */
35
+ backAction = 'down';
36
+ jumpAction = 'jump';
37
+ onUpdate() {
38
+ const body = this.entity.get(RigidBody);
39
+ if (body?.type !== 'kinematic')
40
+ return;
41
+ const { input } = this.game;
42
+ const x = input.axis(this.leftAction, this.rightAction);
43
+ const z = -input.axis(this.backAction, this.forwardAction);
44
+ // Like TopDownMotor: diagonals match the cardinal speed.
45
+ const length = Math.hypot(x, z);
46
+ const scale = length > 1 ? this.speed / length : this.speed;
47
+ body.desiredVelocity = { x: x * scale, z: z * scale };
48
+ if (input.justPressed(this.jumpAction) && body.jump(this.jumpSpeed))
49
+ input.consume(this.jumpAction);
50
+ }
51
+ }
package/dist/chaser.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, type RoleDefinition, type RoleGraph } from '@waica/engine';
1
+ import { Component, type ComponentSpace, type RoleDefinition, type RoleGraph } from '@waica/engine';
2
2
  export type ChaserMode = 'walker' | 'ghost' | 'flyer';
3
3
  /**
4
4
  * Pursuit toward the player while they are within sight range, in one of
@@ -11,6 +11,7 @@ export type ChaserMode = 'walker' | 'ghost' | 'flyer';
11
11
  */
12
12
  export declare class Chaser extends Component {
13
13
  static componentName: string;
14
+ static space: ComponentSpace;
14
15
  static params: {
15
16
  mode: {
16
17
  label: string;
package/dist/chaser.js CHANGED
@@ -11,6 +11,7 @@ import { isPlayer } from './player-identity.js';
11
11
  */
12
12
  export class Chaser extends Component {
13
13
  static componentName = 'Chaser';
14
+ static space = '2d';
14
15
  static params = {
15
16
  mode: { label: 'Mode', options: ['walker', 'ghost', 'flyer'] },
16
17
  range: { label: 'Sight range', min: 1, max: 30, step: 0.5 },
@@ -1,4 +1,4 @@
1
- import { Component, type Entity, type StateContext } from '@waica/engine';
1
+ import { Component, type ComponentSpace, type Entity, type StateContext } from '@waica/engine';
2
2
  import { type GridPoint } from './navigation-grid.js';
3
3
  interface GroundOrder {
4
4
  kind: 'ground';
@@ -35,6 +35,7 @@ interface ClickToMoveMotor {
35
35
  */
36
36
  export declare class ClickToMove extends Component {
37
37
  static componentName: string;
38
+ static space: ComponentSpace;
38
39
  static displayName: string;
39
40
  static params: {
40
41
  arrivalTolerance: {
@@ -20,6 +20,7 @@ const NPC_REPLAN_DISTANCE = ATTACK_REPLAN_DISTANCE;
20
20
  */
21
21
  export class ClickToMove extends Component {
22
22
  static componentName = 'ClickToMove';
23
+ static space = '2d';
23
24
  static displayName = 'Click to move';
24
25
  static params = {
25
26
  arrivalTolerance: { label: 'Arrival tolerance', min: 0.05, max: 1, step: 0.05 },
@@ -1,4 +1,4 @@
1
- import { Component } from '@waica/engine';
1
+ import { Component, type ComponentSpace } from '@waica/engine';
2
2
  /**
3
3
  * A puff from this entity's ParticleEmitter wherever
4
4
  * damage lands. Health announces every accepted hit on `game.events` as
@@ -9,6 +9,7 @@ import { Component } from '@waica/engine';
9
9
  */
10
10
  export declare class DamagePuff extends Component {
11
11
  static componentName: string;
12
+ static space: ComponentSpace;
12
13
  static displayName: string;
13
14
  static params: {
14
15
  count: {
@@ -9,6 +9,7 @@ import { Component, Entity, ParticleEmitter } from '@waica/engine';
9
9
  */
10
10
  export class DamagePuff extends Component {
11
11
  static componentName = 'DamagePuff';
12
+ static space = '2d';
12
13
  static displayName = 'Damage puff';
13
14
  static params = {
14
15
  count: { label: 'Particles', min: 1, max: 64, step: 1 },
@@ -1,4 +1,4 @@
1
- import { Component } from '@waica/engine';
1
+ import { Component, type ComponentSpace } from '@waica/engine';
2
2
  /**
3
3
  * Dust from this entity's own ParticleEmitter at the
4
4
  * two moments a platformer body meets the ground hard — a small puff when a
@@ -25,6 +25,7 @@ import { Component } from '@waica/engine';
25
25
  */
26
26
  export declare class DustPuffs extends Component {
27
27
  static componentName: string;
28
+ static space: ComponentSpace;
28
29
  static displayName: string;
29
30
  static params: {
30
31
  jumpCount: {
@@ -30,6 +30,7 @@ const AIR_STATES = ['jump', 'fall'];
30
30
  */
31
31
  export class DustPuffs extends Component {
32
32
  static componentName = 'DustPuffs';
33
+ static space = '2d';
33
34
  static displayName = 'Dust puffs';
34
35
  static params = {
35
36
  jumpCount: { label: 'Jump puff', min: 0, max: 64, step: 1 },
@@ -1,4 +1,4 @@
1
- import { Component } from '@waica/engine';
1
+ import { Component, type ComponentSpace } from '@waica/engine';
2
2
  /**
3
3
  * A soft dust trail while this entity walks. The
4
4
  * ParticleEmitter on the same entity does the continuous emission (its
@@ -12,6 +12,7 @@ import { Component } from '@waica/engine';
12
12
  */
13
13
  export declare class DustTrail extends Component {
14
14
  static componentName: string;
15
+ static space: ComponentSpace;
15
16
  static displayName: string;
16
17
  static params: {
17
18
  state: {
@@ -12,6 +12,7 @@ import { Component, ParticleEmitter, StateMachine } from '@waica/engine';
12
12
  */
13
13
  export class DustTrail extends Component {
14
14
  static componentName = 'DustTrail';
15
+ static space = '2d';
15
16
  static displayName = 'Dust trail';
16
17
  static params = {
17
18
  state: { label: 'State' },
@@ -1,7 +1,8 @@
1
- import { Component, type AnimationFacingProvider, type CameraVelocity, type CameraVelocityProvider } from '@waica/engine';
1
+ import { Component, type AnimationFacingProvider, type CameraVelocity, type CameraVelocityProvider, type ComponentSpace } from '@waica/engine';
2
2
  /** Shared velocity, collision and provider behavior for square-grid motors. */
3
3
  export declare abstract class GridMotor extends Component implements CameraVelocityProvider, AnimationFacingProvider {
4
4
  static displayName: string;
5
+ static space: ComponentSpace;
5
6
  static params: {
6
7
  moveSpeed: {
7
8
  label: string;
@@ -2,6 +2,7 @@ import { Component, resolveSolidAxis, THREE, } from '@waica/engine';
2
2
  /** Shared velocity, collision and provider behavior for square-grid motors. */
3
3
  export class GridMotor extends Component {
4
4
  static displayName = 'Motor';
5
+ static space = '2d';
5
6
  static params = {
6
7
  moveSpeed: { label: 'Speed', min: 1, max: 30, step: 0.5 },
7
8
  acceleration: { label: 'Acceleration', min: 5, max: 200, step: 5 },
package/dist/hazard.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, type Entity } from '@waica/engine';
1
+ import { Component, type Entity, type ComponentSpace } from '@waica/engine';
2
2
  export type HazardTouch = 'stomp' | 'hurt';
3
3
  /**
4
4
  * Touching a hazard by stomping it from above (falling, with the feet
@@ -19,6 +19,7 @@ export declare function resolveHazardTouch(playerVy: number, playerBottom: numbe
19
19
  */
20
20
  export declare class Hazard extends Component {
21
21
  static componentName: string;
22
+ static space: ComponentSpace;
22
23
  static params: {
23
24
  stompable: {
24
25
  label: string;
package/dist/hazard.js CHANGED
@@ -25,6 +25,7 @@ export function resolveHazardTouch(playerVy, playerBottom, hazardY, stompable) {
25
25
  */
26
26
  export class Hazard extends Component {
27
27
  static componentName = 'Hazard';
28
+ static space = '2d';
28
29
  static params = {
29
30
  stompable: { label: 'Stompable' },
30
31
  bounce: { label: 'Stomp bounce', min: 0, max: 30, step: 0.5 },
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { PlatformerMotor } from './platformer-motor.js';
2
+ export { CharacterMotor } from './character-motor.js';
2
3
  export { PLAYER_ROLE, PLAYER_STATE_GRAPH, playerUpdate } from './player-states.js';
3
4
  export { TopDownMotor, type TopDownFacing } from './topdown-motor.js';
4
5
  export { IsoMotor, type IsoFacing } from './iso-motor.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { PlatformerMotor } from './platformer-motor.js';
2
+ export { CharacterMotor } from './character-motor.js';
2
3
  export { PLAYER_ROLE, PLAYER_STATE_GRAPH, playerUpdate } from './player-states.js';
3
4
  export { TopDownMotor } from './topdown-motor.js';
4
5
  export { IsoMotor } from './iso-motor.js';
@@ -1,4 +1,4 @@
1
- import { Component, type Entity, type Game, type StateContext } from '@waica/engine';
1
+ import { Component, type ComponentSpace, type Entity, type Game, type StateContext } from '@waica/engine';
2
2
  /**
3
3
  * Something the player can talk to or examine: a dialogue line and the
4
4
  * radius it can be triggered from. The component is pure data — the
@@ -7,6 +7,7 @@ import { Component, type Entity, type Game, type StateContext } from '@waica/eng
7
7
  */
8
8
  export declare class Interactable extends Component {
9
9
  static componentName: string;
10
+ static space: ComponentSpace;
10
11
  static params: {
11
12
  line: {
12
13
  label: string;
@@ -8,6 +8,7 @@ import { anchorHeight } from './anchor-height.js';
8
8
  */
9
9
  export class Interactable extends Component {
10
10
  static componentName = 'Interactable';
11
+ static space = '2d';
11
12
  static params = {
12
13
  line: { label: 'Line' },
13
14
  radius: { label: 'Radius', min: 0.5, max: 10, step: 0.25 },
@@ -1,4 +1,4 @@
1
- import { Component, type Entity } from '@waica/engine';
1
+ import { Component, type ComponentSpace, type Entity } from '@waica/engine';
2
2
  /**
3
3
  * A short frontal strike. Passive like a motor: state code decides when it
4
4
  * happens (the player's `attack` state) and calls strike(facing); this only
@@ -9,6 +9,7 @@ import { Component, type Entity } from '@waica/engine';
9
9
  */
10
10
  export declare class MeleeAttack extends Component {
11
11
  static componentName: string;
12
+ static space: ComponentSpace;
12
13
  static displayName: string;
13
14
  static params: {
14
15
  damage: {
@@ -11,6 +11,7 @@ import { Health } from './health.js';
11
11
  */
12
12
  export class MeleeAttack extends Component {
13
13
  static componentName = 'MeleeAttack';
14
+ static space = '2d';
14
15
  static displayName = 'Melee attack';
15
16
  static params = {
16
17
  damage: { label: 'Damage', min: 0, max: 20, step: 1 },
package/dist/patrol.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, type AnimationFacingProvider, type RoleDefinition, type RoleGraph } from '@waica/engine';
1
+ import { Component, type AnimationFacingProvider, type ComponentSpace, type RoleDefinition, type RoleGraph } from '@waica/engine';
2
2
  export type PatrolAxis = 'horizontal' | 'vertical';
3
3
  /**
4
4
  * Rail patrol: back and forth `distance` units from the starting
@@ -12,6 +12,7 @@ export type PatrolAxis = 'horizontal' | 'vertical';
12
12
  */
13
13
  export declare class Patrol extends Component implements AnimationFacingProvider {
14
14
  static componentName: string;
15
+ static space: ComponentSpace;
15
16
  static params: {
16
17
  axis: {
17
18
  label: string;
package/dist/patrol.js CHANGED
@@ -16,6 +16,7 @@ const DEATH_SECONDS = 0.5;
16
16
  */
17
17
  export class Patrol extends Component {
18
18
  static componentName = 'Patrol';
19
+ static space = '2d';
19
20
  static params = {
20
21
  axis: { label: 'Axis', options: ['horizontal', 'vertical'] },
21
22
  distance: { label: 'Distance', min: 0.5, max: 20, step: 0.5 },
@@ -1,4 +1,4 @@
1
- import { Component, type CameraVelocity, type CameraVelocityProvider } from '@waica/engine';
1
+ import { Component, type CameraVelocity, type CameraVelocityProvider, type ComponentSpace } from '@waica/engine';
2
2
  /**
3
3
  * Passive platformer motor: tuning params, physical state and movement
4
4
  * methods for state code to call. It has no onUpdate of its own — the
@@ -11,6 +11,7 @@ import { Component, type CameraVelocity, type CameraVelocityProvider } from '@wa
11
11
  */
12
12
  export declare class PlatformerMotor extends Component implements CameraVelocityProvider {
13
13
  static componentName: string;
14
+ static space: ComponentSpace;
14
15
  static displayName: string;
15
16
  static params: {
16
17
  moveSpeed: {
@@ -11,6 +11,7 @@ import { Component, resolveSolidAxis, THREE, } from '@waica/engine';
11
11
  */
12
12
  export class PlatformerMotor extends Component {
13
13
  static componentName = 'PlatformerMotor';
14
+ static space = '2d';
14
15
  static displayName = 'Motor';
15
16
  static params = {
16
17
  moveSpeed: { label: 'Speed', min: 1, max: 30, step: 0.5 },
@@ -1,4 +1,4 @@
1
- import { Component } from '@waica/engine';
1
+ import { Component, type ComponentSpace } from '@waica/engine';
2
2
  /**
3
3
  * A burst of sparks from this entity's own
4
4
  * ParticleEmitter each time its StateMachine enters the swing state. The
@@ -12,6 +12,7 @@ import { Component } from '@waica/engine';
12
12
  */
13
13
  export declare class SwingSparks extends Component {
14
14
  static componentName: string;
15
+ static space: ComponentSpace;
15
16
  static displayName: string;
16
17
  static params: {
17
18
  state: {
@@ -12,6 +12,7 @@ import { Component, ParticleEmitter, StateMachine } from '@waica/engine';
12
12
  */
13
13
  export class SwingSparks extends Component {
14
14
  static componentName = 'SwingSparks';
15
+ static space = '2d';
15
16
  static displayName = 'Swing sparks';
16
17
  static params = {
17
18
  state: { label: 'State' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waica/behaviors",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Waica built-in behaviors — the curated game-feel library",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,6 +19,6 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@waica/engine": "^0.25.0"
22
+ "@waica/engine": "^0.26.0"
23
23
  }
24
24
  }