@shimotsuki/core 2.0.34 → 2.0.36

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/index.d.ts CHANGED
@@ -999,6 +999,9 @@ declare class TimerManager extends BaseManager {
999
999
  private update;
1000
1000
  }
1001
1001
 
1002
+ declare const AudioEffect: <T extends string>(effect?: T, callBackFun?: Function) => MethodDecorator;
1003
+ declare const ButtonLock: (lockTime?: number, callBackFun?: Function) => (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
1004
+
1002
1005
  /**
1003
1006
  * @describe 管理类
1004
1007
  * @author 游金宇(KM)
@@ -1007,7 +1010,10 @@ declare class TimerManager extends BaseManager {
1007
1010
  declare class Manager {
1008
1011
  #private;
1009
1012
  static get instance(): Manager;
1013
+ /**APP初始化事务 */
1010
1014
  readonly onAppInitDelegate: AsyncDelegate<() => (Promise<void> | void)>;
1015
+ /**插件初始化事务 */
1016
+ readonly onPlugInInitDelegate: AsyncDelegate<() => (Promise<void> | void)>;
1011
1017
  get audio(): AudioManager;
1012
1018
  get event(): EventEmitter$1<string | symbol, any>;
1013
1019
  get gui(): Gui;
@@ -1030,4 +1036,4 @@ declare class Manager {
1030
1036
  }
1031
1037
  declare const cat: Manager;
1032
1038
 
1033
- export { AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, BaseStore, CoreBlackMask, CoreNotice, type CoreNoticeProps, CoreReconnection, CoreShowLoading, type CoreShowLoadingProps, CoreStore, CoreToast, CoreUIContainer, CoreUIModal, type CoreUIModalProps, CoreUtil, GlobalEventConstant, Gui, GuiManager, type HOOK, type ICloseOptions, type IDirection, type IOpenOptions, type IUIOption, LayerType, Manager, ReconnectPrompt, RootUILayer, type SceneComponentType, type SceneDataType, SceneLayer, type ScenePropsType, TimerManager, type ToastProps, ToastType, type UIComponentType, UILayer, WrapperSocialGameClient, cat };
1039
+ export { AudioEffect, AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, BaseStore, ButtonLock, CoreBlackMask, CoreNotice, type CoreNoticeProps, CoreReconnection, CoreShowLoading, type CoreShowLoadingProps, CoreStore, CoreToast, CoreUIContainer, CoreUIModal, type CoreUIModalProps, CoreUtil, GlobalEventConstant, Gui, GuiManager, type HOOK, type ICloseOptions, type IDirection, type IOpenOptions, type IUIOption, LayerType, Manager, ReconnectPrompt, RootUILayer, type SceneComponentType, type SceneDataType, SceneLayer, type ScenePropsType, TimerManager, type ToastProps, ToastType, type UIComponentType, UILayer, WrapperSocialGameClient, cat };
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ const { ccclass: ccclass$b, menu: menu$9 } = _decorator;
31
31
  * 注:用playOneShot播放的音乐效果,在播放期间暂时没办法即时关闭音乐
32
32
  */
33
33
  /** 游戏音效 */
34
- class AudioEffect extends CommonAudio {
34
+ let AudioEffect$1 = class AudioEffect extends CommonAudio {
35
35
  effects = new Map();
36
36
  /**
37
37
  * 加载音效并播放
@@ -57,7 +57,7 @@ class AudioEffect extends CommonAudio {
57
57
  }
58
58
  this.effects.clear();
59
59
  }
60
- }
60
+ };
61
61
 
62
62
  /**
63
63
  * @describe 音乐
@@ -185,7 +185,7 @@ class AudioManager extends BaseManager {
185
185
  this.music = music.addComponent(AudioMusic).initAudio(cat);
186
186
  var effect = new Node('UIEffect');
187
187
  effect.parent = node;
188
- this.effect = effect.addComponent(AudioEffect).initAudio(cat);
188
+ this.effect = effect.addComponent(AudioEffect$1).initAudio(cat);
189
189
  this.load();
190
190
  }
191
191
  /**
@@ -2760,6 +2760,45 @@ class TimerManager extends BaseManager {
2760
2760
  }
2761
2761
  }
2762
2762
 
2763
+ const AudioEffect = (effect, callBackFun) => {
2764
+ return (_target, _propertyKey, descriptor) => {
2765
+ let oldFun = descriptor.value;
2766
+ descriptor.value = function (...args) {
2767
+ if (effect) {
2768
+ cat.audio.playEffect(effect);
2769
+ }
2770
+ else {
2771
+ console.warn(`请添加音效路径参数`);
2772
+ }
2773
+ if (callBackFun) {
2774
+ callBackFun();
2775
+ }
2776
+ oldFun.apply(this, args);
2777
+ };
2778
+ return descriptor;
2779
+ };
2780
+ };
2781
+ const ButtonLock = (lockTime = 1, callBackFun) => {
2782
+ return function (_target, _propertyKey, descriptor) {
2783
+ let oldFun = descriptor.value;
2784
+ let isLock = false;
2785
+ descriptor.value = function (...args) {
2786
+ if (isLock) {
2787
+ if (callBackFun) {
2788
+ callBackFun();
2789
+ }
2790
+ return;
2791
+ }
2792
+ isLock = true;
2793
+ setTimeout(() => {
2794
+ isLock = false;
2795
+ }, lockTime * 1000);
2796
+ oldFun.apply(this, args);
2797
+ };
2798
+ return descriptor;
2799
+ };
2800
+ };
2801
+
2763
2802
  /**
2764
2803
  * @describe 管理类
2765
2804
  * @author 游金宇(KM)
@@ -2771,7 +2810,10 @@ class Manager {
2771
2810
  static get instance() {
2772
2811
  return this.#ins ?? (this.#ins = new Manager());
2773
2812
  }
2813
+ /**APP初始化事务 */
2774
2814
  onAppInitDelegate = new AsyncDelegate();
2815
+ /**插件初始化事务 */
2816
+ onPlugInInitDelegate = new AsyncDelegate();
2775
2817
  /**音频 */
2776
2818
  #audio = null;
2777
2819
  get audio() {
@@ -2863,12 +2905,16 @@ class Manager {
2863
2905
  }
2864
2906
  }
2865
2907
  const cat = Manager.instance;
2866
- // 项目数据初始化之后的处理APP初始化事务
2908
+ /**
2909
+ * 项目数据初始化之后的处理APP初始化事务
2910
+ * 执行顺序 onAppInitDelegate -> onPlugInInitDelegate
2911
+ */
2867
2912
  game.onPostProjectInitDelegate.add(async () => {
2868
2913
  console.time('[Init App]');
2869
2914
  try {
2870
2915
  await cat.boot();
2871
2916
  await cat.onAppInitDelegate.dispatch();
2917
+ await cat.onPlugInInitDelegate.dispatch();
2872
2918
  }
2873
2919
  catch (err) {
2874
2920
  error(`[Init App] 初始化失败: ${err instanceof Error ? err.message : String(err)}`);
@@ -2879,4 +2925,4 @@ game.onPostProjectInitDelegate.add(async () => {
2879
2925
  }
2880
2926
  });
2881
2927
 
2882
- export { AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, BaseStore, CoreBlackMask, CoreNotice, CoreReconnection, CoreShowLoading, CoreStore, CoreToast, CoreUIContainer, CoreUIModal, CoreUtil, GlobalEventConstant, Gui, GuiManager, LayerType, Manager, ReconnectPrompt, RootUILayer, SceneLayer, TimerManager, ToastType, UILayer, WrapperSocialGameClient, cat };
2928
+ export { AudioEffect, AudioEventConstant, AudioManager, AudioSourceBaseComponent, AudioSourceUILayer, AudioTypeEnum, BaseComponent, BaseManager, BasePrefab, BaseStore, ButtonLock, CoreBlackMask, CoreNotice, CoreReconnection, CoreShowLoading, CoreStore, CoreToast, CoreUIContainer, CoreUIModal, CoreUtil, GlobalEventConstant, Gui, GuiManager, LayerType, Manager, ReconnectPrompt, RootUILayer, SceneLayer, TimerManager, ToastType, UILayer, WrapperSocialGameClient, cat };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shimotsuki/core",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",