@rpgjs/server 5.0.0-alpha.28 → 5.0.0-alpha.29

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.
@@ -129,35 +129,50 @@ export declare class RpgPlayer extends RpgPlayer_base {
129
129
  save(): Promise<string>;
130
130
  load(snapshot: string): Promise<void>;
131
131
  /**
132
- * Set the current animation of the player's sprite
132
+ * @deprecated Use setGraphicAnimation instead.
133
+ * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
134
+ * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
135
+ */
136
+ setAnimation(animationName: string, nbTimes?: number): void;
137
+ /**
138
+ * @deprecated Use setGraphicAnimation instead.
139
+ * @param graphic - The graphic to use for the animation (e.g., 'attack', 'skill', 'walk')
140
+ * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
141
+ * @param replaceGraphic - Whether to replace the player's graphic (default: false)
142
+ */
143
+ showAnimation(graphic: string, animationName: string, replaceGraphic?: boolean): void;
144
+ /**
145
+ * Set the current animation of the player's sprite
146
+ *
147
+ * This method changes the animation state of the player's current sprite.
148
+ * It's used to trigger character animations like attack, skill, or custom movements.
149
+ * When `nbTimes` is set to a finite number, the animation will play that many times
150
+ * before returning to the previous animation state.
151
+ *
152
+ * If `animationFixed` is true, this method will not change the animation.
153
+ *
154
+ * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
155
+ * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
156
+ */
157
+ setGraphicAnimation(animationName: string, nbTimes: number): void;
158
+ /**
159
+ * Set the current animation of the player's sprite with a temporary graphic change
160
+ *
161
+ * This method changes the animation state of the player's current sprite and temporarily
162
+ * changes the player's graphic (sprite sheet) during the animation. The graphic is
163
+ * automatically reset when the animation finishes.
133
164
  *
134
- * This method changes the animation state of the player's current sprite.
135
- * It's used to trigger character animations like attack, skill, or custom movements.
136
165
  * When `nbTimes` is set to a finite number, the animation will play that many times
137
- * before returning to the previous animation state.
166
+ * before returning to the previous animation state and graphic.
138
167
  *
139
168
  * If `animationFixed` is true, this method will not change the animation.
140
169
  *
141
170
  * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
171
+ * @param graphic - The graphic(s) to temporarily use during the animation
142
172
  * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
143
- *
144
- * @example
145
- * ```ts
146
- * // Set continuous walk animation
147
- * player.setAnimation('walk');
148
- *
149
- * // Play attack animation 3 times then return to previous state
150
- * player.setAnimation('attack', 3);
151
- *
152
- * // Lock animation to prevent automatic changes
153
- * player.animationFixed = true;
154
- * player.setAnimation('skill'); // This will be ignored
155
- *
156
- * // Set idle/stand animation
157
- * player.setAnimation('stand');
158
- * ```
159
173
  */
160
- setAnimation(animationName: string, nbTimes?: number): void;
174
+ setGraphicAnimation(animationName: string, graphic: string | string[], nbTimes: number): void;
175
+ setGraphicAnimation(animationName: string, graphic: string | string[]): void;
161
176
  /**
162
177
  * Run the change detection cycle. Normally, as soon as a hook is called in a class, the cycle is started. But you can start it manually
163
178
  * The method calls the `onChanges` method on events and synchronizes all map data with the client.
package/dist/index.js CHANGED
@@ -21712,48 +21712,56 @@ const _RpgPlayer = class _RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
21712
21712
  return dataLoaded;
21713
21713
  }
21714
21714
  /**
21715
- * Set the current animation of the player's sprite
21716
- *
21717
- * This method changes the animation state of the player's current sprite.
21718
- * It's used to trigger character animations like attack, skill, or custom movements.
21719
- * When `nbTimes` is set to a finite number, the animation will play that many times
21720
- * before returning to the previous animation state.
21721
- *
21722
- * If `animationFixed` is true, this method will not change the animation.
21723
- *
21715
+ * @deprecated Use setGraphicAnimation instead.
21724
21716
  * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
21725
21717
  * @param nbTimes - Number of times to repeat the animation (default: Infinity for continuous)
21726
- *
21727
- * @example
21728
- * ```ts
21729
- * // Set continuous walk animation
21730
- * player.setAnimation('walk');
21731
- *
21732
- * // Play attack animation 3 times then return to previous state
21733
- * player.setAnimation('attack', 3);
21734
- *
21735
- * // Lock animation to prevent automatic changes
21736
- * player.animationFixed = true;
21737
- * player.setAnimation('skill'); // This will be ignored
21738
- *
21739
- * // Set idle/stand animation
21740
- * player.setAnimation('stand');
21741
- * ```
21742
21718
  */
21743
21719
  setAnimation(animationName, nbTimes = Infinity) {
21720
+ console.warn("setAnimation is deprecated. Use setGraphicAnimation instead.");
21721
+ this.setGraphicAnimation(animationName, nbTimes);
21722
+ }
21723
+ /**
21724
+ * @deprecated Use setGraphicAnimation instead.
21725
+ * @param graphic - The graphic to use for the animation (e.g., 'attack', 'skill', 'walk')
21726
+ * @param animationName - The name of the animation to play (e.g., 'attack', 'skill', 'walk')
21727
+ * @param replaceGraphic - Whether to replace the player's graphic (default: false)
21728
+ */
21729
+ showAnimation(graphic, animationName, replaceGraphic = false) {
21730
+ if (replaceGraphic) {
21731
+ console.warn("showAnimation is deprecated. Use player.setGraphicAnimation instead.");
21732
+ this.setGraphicAnimation(animationName, graphic);
21733
+ } else {
21734
+ console.warn("showAnimation is deprecated. Use map.showAnimation instead.");
21735
+ const map2 = this.getCurrentMap();
21736
+ map2?.showAnimation({ x: this.x(), y: this.y() }, graphic, animationName);
21737
+ }
21738
+ }
21739
+ setGraphicAnimation(animationName, graphicOrNbTimes, nbTimes = 1) {
21744
21740
  if (this.animationFixed) {
21745
21741
  return;
21746
21742
  }
21743
+ let graphic;
21744
+ let finalNbTimes = Infinity;
21745
+ if (typeof graphicOrNbTimes === "number") {
21746
+ finalNbTimes = graphicOrNbTimes;
21747
+ } else if (graphicOrNbTimes !== void 0) {
21748
+ graphic = graphicOrNbTimes;
21749
+ finalNbTimes = nbTimes ?? Infinity;
21750
+ } else {
21751
+ finalNbTimes = Infinity;
21752
+ }
21747
21753
  const map2 = this.getCurrentMap();
21748
21754
  if (!map2) return;
21749
- if (nbTimes === Infinity) {
21755
+ if (finalNbTimes === Infinity) {
21756
+ if (graphic) this.setGraphic(graphic);
21750
21757
  this.animationName.set(animationName);
21751
21758
  } else {
21752
21759
  map2.$broadcast({
21753
21760
  type: "setAnimation",
21754
21761
  value: {
21755
21762
  animationName,
21756
- nbTimes,
21763
+ graphic,
21764
+ nbTimes: finalNbTimes,
21757
21765
  object: this.id
21758
21766
  }
21759
21767
  });
@@ -23511,7 +23519,7 @@ class Doc {
23511
23519
  const version = {
23512
23520
  major: 4,
23513
23521
  minor: 2,
23514
- patch: 0,
23522
+ patch: 1,
23515
23523
  };
23516
23524
 
23517
23525
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {