@rpgjs/common 5.0.0-alpha.4 → 5.0.0-alpha.40

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.
Files changed (62) hide show
  1. package/dist/PerlinNoise.d.ts +167 -0
  2. package/dist/Player.d.ts +92 -89
  3. package/dist/PrebuiltGui.d.ts +3 -1
  4. package/dist/Presets.d.ts +9 -0
  5. package/dist/Shape.d.ts +100 -0
  6. package/dist/Utils.d.ts +1 -0
  7. package/dist/database/Item.d.ts +17 -1
  8. package/dist/database/Skill.d.ts +21 -0
  9. package/dist/database/index.d.ts +1 -0
  10. package/dist/index.d.ts +7 -2
  11. package/dist/index.js +8869 -13605
  12. package/dist/index.js.map +1 -1
  13. package/dist/modules.d.ts +17 -0
  14. package/dist/movement/MovementManager.d.ts +16 -72
  15. package/dist/movement/MovementStrategy.d.ts +1 -39
  16. package/dist/movement/index.d.ts +3 -12
  17. package/dist/rooms/Map.d.ts +498 -21
  18. package/dist/rooms/WorldMaps.d.ts +163 -0
  19. package/dist/services/save.d.ts +12 -0
  20. package/dist/weather.d.ts +27 -0
  21. package/package.json +8 -9
  22. package/src/PerlinNoise.ts +294 -0
  23. package/src/Player.ts +126 -149
  24. package/src/PrebuiltGui.ts +4 -2
  25. package/src/Presets.ts +9 -0
  26. package/src/Shape.ts +149 -0
  27. package/src/Utils.ts +4 -0
  28. package/src/database/Item.ts +27 -6
  29. package/src/database/Skill.ts +35 -0
  30. package/src/database/index.ts +2 -1
  31. package/src/index.ts +8 -3
  32. package/src/modules.ts +29 -1
  33. package/src/movement/MovementManager.ts +38 -119
  34. package/src/movement/MovementStrategy.ts +4 -42
  35. package/src/movement/index.ts +14 -15
  36. package/src/rooms/Map.ts +1505 -85
  37. package/src/rooms/WorldMaps.ts +269 -0
  38. package/src/services/save.ts +14 -0
  39. package/src/weather.ts +29 -0
  40. package/dist/Physic.d.ts +0 -619
  41. package/dist/movement/strategies/CompositeMovement.d.ts +0 -76
  42. package/dist/movement/strategies/Dash.d.ts +0 -52
  43. package/dist/movement/strategies/IceMovement.d.ts +0 -87
  44. package/dist/movement/strategies/Knockback.d.ts +0 -50
  45. package/dist/movement/strategies/LinearMove.d.ts +0 -43
  46. package/dist/movement/strategies/LinearRepulsion.d.ts +0 -55
  47. package/dist/movement/strategies/Oscillate.d.ts +0 -60
  48. package/dist/movement/strategies/PathFollow.d.ts +0 -78
  49. package/dist/movement/strategies/ProjectileMovement.d.ts +0 -138
  50. package/dist/movement/strategies/SeekAvoid.d.ts +0 -27
  51. package/src/Physic.ts +0 -1644
  52. package/src/movement/strategies/CompositeMovement.ts +0 -173
  53. package/src/movement/strategies/Dash.ts +0 -82
  54. package/src/movement/strategies/IceMovement.ts +0 -158
  55. package/src/movement/strategies/Knockback.ts +0 -81
  56. package/src/movement/strategies/LinearMove.ts +0 -58
  57. package/src/movement/strategies/LinearRepulsion.ts +0 -128
  58. package/src/movement/strategies/Oscillate.ts +0 -144
  59. package/src/movement/strategies/PathFollow.ts +0 -156
  60. package/src/movement/strategies/ProjectileMovement.ts +0 -322
  61. package/src/movement/strategies/SeekAvoid.ts +0 -123
  62. package/tests/physic.spec.ts +0 -454
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Perlin Noise 2D Generator
3
+ *
4
+ * A simple, efficient, and performant implementation of 2D Perlin noise.
5
+ * Perlin noise generates smooth, natural-looking random values that are coherent
6
+ * across space, making it ideal for procedural generation and smooth random movements.
7
+ *
8
+ * ## Features
9
+ * - **Deterministic**: Same seed and coordinates always produce the same value
10
+ * - **Smooth**: Values change gradually, creating natural-looking patterns
11
+ * - **Performant**: Optimized for real-time use in movement systems
12
+ * - **Seeded**: Optional seed for reproducible results
13
+ *
14
+ * ## Usage
15
+ * ```ts
16
+ * const noise = new PerlinNoise2D();
17
+ * const value = noise.get(x, y); // Returns value between -1 and 1
18
+ *
19
+ * // With seed for deterministic results
20
+ * const seededNoise = new PerlinNoise2D(12345);
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // Use in movement system for smooth random directions
26
+ * const noise = new PerlinNoise2D();
27
+ * const time = Date.now() * 0.001;
28
+ * const direction = Math.floor(noise.get(player.x(), player.y(), time) * 4) % 4;
29
+ * ```
30
+ */
31
+ export declare class PerlinNoise2D {
32
+ private readonly permutation;
33
+ private readonly p;
34
+ /**
35
+ * Creates a new Perlin noise generator
36
+ *
37
+ * @param seed - Optional seed for deterministic noise generation. If not provided, uses a default seed.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const noise = new PerlinNoise2D(12345);
42
+ * const value = noise.get(10, 20);
43
+ * ```
44
+ */
45
+ constructor(seed?: number);
46
+ /**
47
+ * Generates a permutation table based on seed
48
+ *
49
+ * @param seed - Seed value for permutation generation
50
+ * @returns Array of 256 shuffled values
51
+ */
52
+ private generatePermutation;
53
+ /**
54
+ * Fade function for smooth interpolation (ease curve)
55
+ *
56
+ * @param t - Value between 0 and 1
57
+ * @returns Smoothed value between 0 and 1
58
+ */
59
+ private fade;
60
+ /**
61
+ * Linear interpolation
62
+ *
63
+ * @param a - Start value
64
+ * @param b - End value
65
+ * @param t - Interpolation factor (0 to 1)
66
+ * @returns Interpolated value
67
+ */
68
+ private lerp;
69
+ /**
70
+ * Gradient function - generates a pseudo-random gradient vector
71
+ *
72
+ * @param hash - Hash value from permutation table
73
+ * @param x - X component
74
+ * @param y - Y component
75
+ * @returns Dot product of gradient and position
76
+ */
77
+ private grad;
78
+ /**
79
+ * Gets the noise value at the specified 2D coordinates
80
+ *
81
+ * Returns a value between approximately -1 and 1, though values near the edges
82
+ * are less common. For practical use, you may want to clamp or normalize the result.
83
+ *
84
+ * @param x - X coordinate
85
+ * @param y - Y coordinate
86
+ * @param scale - Optional scale factor (default: 0.1). Lower values create smoother, larger patterns.
87
+ * @returns Noise value between approximately -1 and 1
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const noise = new PerlinNoise2D();
92
+ * const value = noise.get(10, 20); // Basic usage
93
+ * const scaled = noise.get(10, 20, 0.05); // Smoother pattern
94
+ * ```
95
+ */
96
+ get(x: number, y: number, scale?: number): number;
97
+ /**
98
+ * Gets a normalized noise value between 0 and 1
99
+ *
100
+ * Convenience method that normalizes the noise output to a 0-1 range.
101
+ *
102
+ * @param x - X coordinate
103
+ * @param y - Y coordinate
104
+ * @param scale - Optional scale factor (default: 0.1)
105
+ * @returns Noise value between 0 and 1
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const noise = new PerlinNoise2D();
110
+ * const normalized = noise.getNormalized(10, 20);
111
+ * // Returns value between 0 and 1
112
+ * ```
113
+ */
114
+ getNormalized(x: number, y: number, scale?: number): number;
115
+ /**
116
+ * Gets a noise value mapped to a specific range
117
+ *
118
+ * Maps the noise output to a custom min-max range.
119
+ *
120
+ * @param x - X coordinate
121
+ * @param y - Y coordinate
122
+ * @param min - Minimum output value
123
+ * @param max - Maximum output value
124
+ * @param scale - Optional scale factor (default: 0.1)
125
+ * @returns Noise value between min and max
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * const noise = new PerlinNoise2D();
130
+ * const direction = noise.getRange(10, 20, 0, 3); // Returns 0, 1, 2, or 3
131
+ * ```
132
+ */
133
+ getRange(x: number, y: number, min: number, max: number, scale?: number): number;
134
+ /**
135
+ * Gets an integer noise value in a specific range (inclusive)
136
+ *
137
+ * Useful for selecting discrete values like array indices or enum values.
138
+ *
139
+ * @param x - X coordinate
140
+ * @param y - Y coordinate
141
+ * @param min - Minimum integer value (inclusive)
142
+ * @param max - Maximum integer value (inclusive)
143
+ * @param scale - Optional scale factor (default: 0.1)
144
+ * @returns Integer noise value between min and max (inclusive)
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * const noise = new PerlinNoise2D();
149
+ * const directionIndex = noise.getInt(10, 20, 0, 3); // Returns 0, 1, 2, or 3
150
+ * ```
151
+ */
152
+ getInt(x: number, y: number, min: number, max: number, scale?: number): number;
153
+ }
154
+ export declare function getSharedPerlinNoise(seed?: number): PerlinNoise2D;
155
+ /**
156
+ * Resets the shared Perlin noise instance
157
+ *
158
+ * Useful for testing or when you need to change the seed.
159
+ *
160
+ * @param seed - Optional new seed for the instance
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * resetSharedPerlinNoise(12345);
165
+ * ```
166
+ */
167
+ export declare function resetSharedPerlinNoise(seed?: number): void;
package/dist/Player.d.ts CHANGED
@@ -1,6 +1,16 @@
1
- import { Item } from './database';
2
- import { Observable } from 'rxjs';
3
- import * as Matter from 'matter-js';
1
+ import { Item, Skill } from './database';
2
+ import { Constructor } from './Utils';
3
+ export declare enum Control {
4
+ Action = "action",
5
+ Attack = "attack",
6
+ Defense = "defense",
7
+ Skill = "skill",
8
+ Back = "back",
9
+ Up = 1,
10
+ Down = 3,
11
+ Right = 2,
12
+ Left = 4
13
+ }
4
14
  export declare enum Direction {
5
15
  Up = "up",
6
16
  Down = "down",
@@ -37,14 +47,16 @@ export interface AttachShapeOptions {
37
47
  /** If true, walls (static hitboxes) stop vision */
38
48
  limitedByWalls?: boolean;
39
49
  /** Indicate where the shape is placed relative to the player */
40
- positioning?: 'center' | 'top' | 'bottom' | 'left' | 'right';
50
+ positioning?: "center" | "top" | "bottom" | "left" | "right";
41
51
  /** The name of the shape */
42
52
  name?: string;
43
53
  /** An object to retrieve information when interacting with the shape */
44
54
  properties?: object;
45
55
  }
46
- export declare class RpgCommonPlayer {
56
+ export declare abstract class RpgCommonPlayer {
47
57
  id: string;
58
+ name: import('@signe/reactive').WritableSignal<string>;
59
+ type: import('@signe/reactive').WritableSignal<string>;
48
60
  x: import('@signe/reactive').WritableSignal<number>;
49
61
  y: import('@signe/reactive').WritableSignal<number>;
50
62
  z: import('@signe/reactive').WritableSignal<number>;
@@ -56,143 +68,134 @@ export declare class RpgCommonPlayer {
56
68
  hitbox: import('@signe/reactive').WritableObjectSignal<Hitbox>;
57
69
  _gold: import('@signe/reactive').WritableSignal<number>;
58
70
  animationName: import('@signe/reactive').WritableSignal<string>;
59
- _hp: import('@signe/reactive').WritableSignal<number>;
60
- _sp: import('@signe/reactive').WritableSignal<number>;
71
+ hpSignal: import('@signe/reactive').WritableSignal<number>;
72
+ spSignal: import('@signe/reactive').WritableSignal<number>;
61
73
  _exp: import('@signe/reactive').WritableSignal<number>;
62
74
  _level: import('@signe/reactive').WritableSignal<number>;
63
75
  _class: import('@signe/reactive').WritableObjectSignal<{}>;
64
76
  items: import('@signe/reactive').WritableArraySignal<Item[]>;
65
77
  equipments: import('@signe/reactive').WritableArraySignal<any[]>;
66
78
  states: import('@signe/reactive').WritableArraySignal<any[]>;
67
- skills: import('@signe/reactive').WritableArraySignal<any[]>;
79
+ skills: import('@signe/reactive').WritableArraySignal<Skill[]>;
68
80
  _effects: import('@signe/reactive').WritableArraySignal<any[]>;
69
81
  _through: import('@signe/reactive').WritableSignal<boolean>;
70
82
  _throughOtherPlayer: import('@signe/reactive').WritableSignal<boolean>;
71
83
  _throughEvent: import('@signe/reactive').WritableSignal<boolean>;
72
84
  _frequency: import('@signe/reactive').WritableSignal<number>;
85
+ _frames: import('@signe/reactive').WritableArraySignal<{
86
+ x: number;
87
+ y: number;
88
+ ts: number;
89
+ }[]>;
90
+ componentsTop: import('@signe/reactive').WritableSignal<string | null>;
91
+ componentsBottom: import('@signe/reactive').WritableSignal<string | null>;
92
+ componentsCenter: import('@signe/reactive').WritableSignal<string | null>;
93
+ componentsLeft: import('@signe/reactive').WritableSignal<string | null>;
94
+ componentsRight: import('@signe/reactive').WritableSignal<string | null>;
95
+ isConnected: import('@signe/reactive').WritableSignal<boolean>;
73
96
  private _intendedDirection;
97
+ private _directionFixed;
98
+ private _animationFixed;
74
99
  /**
75
- * Change the player's facing direction
100
+ * Get whether direction changes are locked
76
101
  *
77
- * Updates the direction the player is facing, which affects animations
78
- * and directional abilities. This should be called when the player
79
- * intends to move in a specific direction, not when they are pushed
80
- * by physics or sliding.
81
- *
82
- * @param direction - The new direction to face
102
+ * @returns True if direction is locked and cannot be changed automatically
83
103
  *
84
104
  * @example
85
105
  * ```ts
86
- * // Player presses right arrow key
87
- * player.changeDirection(Direction.Right);
106
+ * if (player.directionFixed) {
107
+ * // Direction is locked, won't change automatically
108
+ * }
88
109
  * ```
89
110
  */
90
- changeDirection(direction: Direction): void;
111
+ get directionFixed(): boolean;
91
112
  /**
92
- * Get the current facing direction
113
+ * Set whether direction changes are locked
93
114
  *
94
- * @returns Current direction the player is facing
115
+ * When set to true, the player's direction will not change automatically
116
+ * during movement or from physics engine callbacks.
117
+ *
118
+ * @param value - True to lock direction, false to allow automatic changes
95
119
  *
96
120
  * @example
97
121
  * ```ts
98
- * const currentDirection = player.getDirection();
99
- * if (currentDirection === Direction.Up) {
100
- * // Player is facing up
101
- * }
122
+ * // Lock direction during a special animation
123
+ * player.directionFixed = true;
124
+ * player.setAnimation('attack');
125
+ * // ... later
126
+ * player.directionFixed = false;
102
127
  * ```
103
128
  */
104
- getDirection(): Direction;
129
+ set directionFixed(value: boolean);
105
130
  /**
106
- * Set the intended movement direction
107
- *
108
- * This should be called when the player intends to move in a direction,
109
- * typically from input handling. This direction will be used to update
110
- * the player's facing direction regardless of physics interactions.
131
+ * Get whether animation changes are locked
111
132
  *
112
- * @param direction - The intended movement direction, or null if not moving
133
+ * @returns True if animation is locked and cannot be changed automatically
113
134
  *
114
135
  * @example
115
136
  * ```ts
116
- * // Player presses down arrow key
117
- * player.setIntendedDirection(Direction.Down);
118
- *
119
- * // Player releases all movement keys
120
- * player.setIntendedDirection(null);
137
+ * if (player.animationFixed) {
138
+ * // Animation is locked, won't change automatically
139
+ * }
121
140
  * ```
122
141
  */
123
- setIntendedDirection(direction: Direction | null): void;
142
+ get animationFixed(): boolean;
124
143
  /**
125
- * Get the intended movement direction
144
+ * Set whether animation changes are locked
145
+ *
146
+ * When set to true, the player's animation will not change automatically
147
+ * during movement or from physics engine callbacks.
126
148
  *
127
- * @returns The direction the player intends to move, or null if not moving
149
+ * @param value - True to lock animation, false to allow automatic changes
128
150
  *
129
151
  * @example
130
152
  * ```ts
131
- * const intended = player.getIntendedDirection();
132
- * if (intended === Direction.Left) {
133
- * // Player is trying to move left
134
- * }
153
+ * // Lock animation during a special skill
154
+ * player.animationFixed = true;
155
+ * player.setAnimation('skill');
156
+ * // ... later
157
+ * player.animationFixed = false;
135
158
  * ```
136
159
  */
137
- getIntendedDirection(): Direction | null;
160
+ set animationFixed(value: boolean);
161
+ pendingInputs: any[];
138
162
  /**
139
- * Apply physics body position to player coordinates
163
+ * Change the player's facing direction
140
164
  *
141
- * Synchronizes the player's position with their physics body after
142
- * physics calculations. This method no longer automatically changes
143
- * the player's direction based on position changes, as direction
144
- * should be controlled by intended movement instead.
165
+ * Updates the direction the player is facing, which affects animations
166
+ * and directional abilities. This should be called when the player
167
+ * intends to move in a specific direction, not when they are pushed
168
+ * by physics or sliding.
169
+ *
170
+ * If `directionFixed` is true, this method will not change the direction.
145
171
  *
146
- * @param body - The Matter.js physics body
172
+ * @param direction - The new direction to face
147
173
  *
148
174
  * @example
149
175
  * ```ts
150
- * // Called automatically by physics system
151
- * player.applyPhysic(body);
176
+ * // Player presses right arrow key
177
+ * player.changeDirection(Direction.Right);
178
+ *
179
+ * // Lock direction to prevent automatic changes
180
+ * player.directionFixed = true;
181
+ * player.changeDirection(Direction.Up); // This will be ignored
152
182
  * ```
153
183
  */
154
- applyPhysic(body: Matter.Body): void;
155
- _showAnimation(params: ShowAnimationParams): void;
184
+ changeDirection(direction: Direction): void;
156
185
  /**
157
- * Create a temporary and moving hitbox relative to the player's position
158
- *
159
- * Creates a temporary hitbox that moves through multiple positions sequentially,
160
- * with all coordinates being relative to the player's current position.
161
- * For example, you can use it for player attacks, spells, or area effects
162
- * that should follow the player's position.
163
- *
164
- * The method creates a zone sensor that moves through the specified hitbox positions
165
- * at the given speed, detecting collisions with other players and events at each step.
186
+ * Get the current facing direction
166
187
  *
167
- * @param hitboxes - Array of hitbox positions relative to player position
168
- * @param options - Configuration options for the movement
169
- * @param map - Reference to the map instance for physics access
170
- * @returns Observable that emits arrays of hit entities and completes when movement is finished
188
+ * @returns Current direction the player is facing
171
189
  *
172
190
  * @example
173
191
  * ```ts
174
- * // Create a forward attack relative to player position
175
- * player.createMovingHitbox([
176
- * { x: 0, y: -32, width: 32, height: 32 }, // In front of player
177
- * { x: 0, y: -64, width: 32, height: 32 } // Further in front
178
- * ], { speed: 2 }, map).subscribe({
179
- * next(hits) {
180
- * // hits contains other RpgPlayer or RpgEvent objects that were hit
181
- * console.log('Hit entities:', hits);
182
- * },
183
- * complete() {
184
- * console.log('Attack finished');
185
- * }
186
- * });
192
+ * const currentDirection = player.getDirection();
193
+ * if (currentDirection === Direction.Up) {
194
+ * // Player is facing up
195
+ * }
187
196
  * ```
188
197
  */
189
- createMovingHitbox(hitboxes: Array<{
190
- x: number;
191
- y: number;
192
- width: number;
193
- height: number;
194
- }>, options?: {
195
- speed?: number;
196
- }): Observable<any[]>;
197
- getCurrentMap(): any;
198
+ getDirection(): Direction;
199
+ abstract isEvent(): boolean;
198
200
  }
201
+ export type PlayerCtor<T extends RpgCommonPlayer = RpgCommonPlayer> = Constructor<T>;
@@ -13,6 +13,7 @@
13
13
  * PrebuiltGui.Save | rpg-save
14
14
  * PrebuiltGui.Controls | rpg-controls
15
15
  * PrebuiltGui.Notification | rpg-notification
16
+ * PrebuiltGui.TitleScreen | rpg-title-screen
16
17
  * @memberof PrebuiltGui
17
18
  * */
18
19
  export declare enum PrebuiltGui {
@@ -23,5 +24,6 @@ export declare enum PrebuiltGui {
23
24
  Gameover = "rpg-gameover",
24
25
  Save = "rpg-save",
25
26
  Controls = "rpg-controls",
26
- Notification = "rpg-notification"
27
+ Notification = "rpg-notification",
28
+ TitleScreen = "rpg-title-screen"
27
29
  }
@@ -0,0 +1,9 @@
1
+ export declare const MAXHP: string;
2
+ export declare const MAXSP: string;
3
+ export declare const ATK: string;
4
+ export declare const PDEF: string;
5
+ export declare const SDEF: string;
6
+ export declare const STR: string;
7
+ export declare const AGI: string;
8
+ export declare const INT: string;
9
+ export declare const DEX: string;
@@ -0,0 +1,100 @@
1
+ import { RpgCommonPlayer } from './Player';
2
+ /**
3
+ * Shape positioning relative to the player
4
+ */
5
+ export type ShapePositioning = "center" | "top" | "bottom" | "left" | "right" | "default";
6
+ /**
7
+ * Represents a zone shape attached to a player or event
8
+ *
9
+ * Shapes are used for detection zones, vision cones, and area-of-effect abilities.
10
+ * They are backed by the physic engine's zone system for accurate detection.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * // Create a shape attached to a player
15
+ * const visionShape = player.attachShape("vision", {
16
+ * radius: 150,
17
+ * angle: 120,
18
+ * direction: Direction.Right,
19
+ * name: "Vision Zone",
20
+ * properties: { type: "detection" }
21
+ * });
22
+ *
23
+ * // Check if a player is in the shape
24
+ * if (visionShape.playerIsIn(otherPlayer)) {
25
+ * console.log("Player detected!");
26
+ * }
27
+ *
28
+ * // Get the owner of the shape
29
+ * const owner = visionShape.getPlayerOwner();
30
+ * ```
31
+ */
32
+ export declare class RpgShape {
33
+ /** Name of the shape */
34
+ name: string;
35
+ /** Positioning relative to the player */
36
+ positioning: ShapePositioning;
37
+ /** Width of the shape in pixels */
38
+ width: number;
39
+ /** Height of the shape in pixels */
40
+ height: number;
41
+ /** X position of the shape center */
42
+ x: number;
43
+ /** Y position of the shape center */
44
+ y: number;
45
+ /** Custom properties attached to the shape */
46
+ properties: object;
47
+ /** Internal: Player that owns this shape */
48
+ private _playerOwner?;
49
+ /** Internal: Zone ID in the physic engine */
50
+ private _physicZoneId;
51
+ /** Internal: Map reference for zone queries */
52
+ private _map;
53
+ /**
54
+ * Creates a new RpgShape instance
55
+ *
56
+ * @param config - Shape configuration
57
+ */
58
+ constructor(config: {
59
+ name: string;
60
+ positioning: ShapePositioning;
61
+ width: number;
62
+ height: number;
63
+ x: number;
64
+ y: number;
65
+ properties: object;
66
+ playerOwner?: RpgCommonPlayer;
67
+ physicZoneId: string;
68
+ map: any;
69
+ });
70
+ /**
71
+ * Checks if a player is currently inside this shape
72
+ *
73
+ * @param player - The player to check
74
+ * @returns True if the player is inside the shape
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * const shape = player.attachShape("detection", { radius: 100 });
79
+ * if (shape.playerIsIn(otherPlayer)) {
80
+ * console.log("Player detected in zone");
81
+ * }
82
+ * ```
83
+ */
84
+ playerIsIn(player: RpgCommonPlayer): boolean;
85
+ /**
86
+ * Gets the player that owns this shape
87
+ *
88
+ * Returns the player on which `attachShape()` was called to create this shape.
89
+ *
90
+ * @returns The player owner or undefined if not available
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const shape = player.attachShape("vision", { radius: 150 });
95
+ * const owner = shape.getPlayerOwner();
96
+ * console.log(owner?.name); // Player's name
97
+ * ```
98
+ */
99
+ getPlayerOwner(): RpgCommonPlayer | undefined;
100
+ }
package/dist/Utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type Constructor<T = {}> = new (...args: any[]) => T;
2
+ export declare function delay(cb: () => void, ms?: number): void;
2
3
  export declare function random(min: number, max: number): number;
3
4
  export declare function isBrowser(): boolean;
4
5
  export declare function isFunction(val: unknown): boolean;
@@ -1,10 +1,26 @@
1
1
  import { RpgCommonPlayer } from '../Player';
2
+ interface ItemData {
3
+ name: string;
4
+ description: string;
5
+ price: number;
6
+ quantity: number;
7
+ atk: number;
8
+ pdef: number;
9
+ sdef: number;
10
+ icon: string;
11
+ onAdd: (player: RpgCommonPlayer) => void;
12
+ }
2
13
  export declare class Item {
3
14
  id: import('@signe/reactive').WritableSignal<string>;
4
15
  name: import('@signe/reactive').WritableSignal<string>;
5
16
  description: import('@signe/reactive').WritableSignal<string>;
6
17
  price: import('@signe/reactive').WritableSignal<number>;
18
+ atk: import('@signe/reactive').WritableSignal<number>;
19
+ pdef: import('@signe/reactive').WritableSignal<number>;
20
+ sdef: import('@signe/reactive').WritableSignal<number>;
21
+ icon: import('@signe/reactive').WritableSignal<string>;
7
22
  quantity: import('@signe/reactive').WritableSignal<number>;
8
23
  onAdd: (player: RpgCommonPlayer) => void;
9
- constructor(data: any);
24
+ constructor(data?: ItemData);
10
25
  }
26
+ export {};
@@ -0,0 +1,21 @@
1
+ export interface SkillData {
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ spCost: number;
6
+ hitRate: number;
7
+ power: number;
8
+ coefficient: Record<string, number>;
9
+ icon: string;
10
+ }
11
+ export declare class Skill {
12
+ id: import('@signe/reactive').WritableSignal<string>;
13
+ name: import('@signe/reactive').WritableSignal<string>;
14
+ description: import('@signe/reactive').WritableSignal<string>;
15
+ spCost: import('@signe/reactive').WritableSignal<number>;
16
+ icon: import('@signe/reactive').WritableSignal<string>;
17
+ hitRate: import('@signe/reactive').WritableSignal<number>;
18
+ power: import('@signe/reactive').WritableSignal<number>;
19
+ coefficient: import('@signe/reactive').WritableObjectSignal<{}>;
20
+ constructor(data?: SkillData);
21
+ }
@@ -1 +1,2 @@
1
1
  export * from './Item';
2
+ export * from './Skill';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  export * from './Player';
2
+ export * from './Shape';
2
3
  export * from './rooms/Map';
4
+ export * from './rooms/WorldMaps';
3
5
  export * from './modules';
4
6
  export * from './services/updateMap';
7
+ export * from './services/save';
5
8
  export * from './Utils';
6
9
  export * from './PrebuiltGui';
7
- export * from './movement';
8
- export * as Matter from 'matter-js';
9
10
  export * from './database';
11
+ export * from './PerlinNoise';
12
+ export * from '@rpgjs/physic';
13
+ export * from './Presets';
14
+ export * from './weather';