@@ -39,13 +39,20 @@ export const useGame = /* @__PURE__ */ create(
39
39
40
40
idle : ( ) => {
41
41
set ( ( state ) => {
42
+ const customAnimationActive = state . animationSet ?. custom
43
+ ? Object . values ( state . animationSet . custom ) . includes (
44
+ state . curAnimation
45
+ )
46
+ : false ;
47
+
42
48
if ( state . curAnimation === state . animationSet . jumpIdle ) {
43
49
return { curAnimation : state . animationSet . jumpLand } ;
44
50
} else if (
45
51
state . curAnimation !== state . animationSet . action1 &&
46
52
state . curAnimation !== state . animationSet . action2 &&
47
53
state . curAnimation !== state . animationSet . action3 &&
48
- state . curAnimation !== state . animationSet . action4
54
+ state . curAnimation !== state . animationSet . action4 &&
55
+ ! customAnimationActive
49
56
) {
50
57
return { curAnimation : state . animationSet . idle } ;
51
58
}
@@ -144,11 +151,14 @@ export const useGame = /* @__PURE__ */ create(
144
151
/**
145
152
* Additional animations
146
153
*/
147
- // triggerFunction: ()=>{
148
- // set((state) => {
149
- // return { curAnimation: state.animationSet.additionalAnimation };
150
- // });
151
- // }
154
+ setCustomAnimation : ( animation : string ) => {
155
+ set ( ( state ) => {
156
+ if ( state . animationSet . custom [ animation ] ) {
157
+ return { curAnimation : state . animationSet . custom [ animation ] } ;
158
+ }
159
+ return { } ;
160
+ } ) ;
161
+ } ,
152
162
153
163
/**
154
164
* Set/get point to move point
@@ -196,6 +206,8 @@ export type AnimationSet = {
196
206
action2 ?: string ;
197
207
action3 ?: string ;
198
208
action4 ?: string ;
209
+ // Custom actions
210
+ custom ?: Record < string , string > ;
199
211
} ;
200
212
201
213
type State = {
@@ -208,11 +220,12 @@ type State = {
208
220
setMoveToPoint : ( point : THREE . Vector3 ) => void ;
209
221
getMoveToPoint : ( ) => {
210
222
moveToPoint : THREE . Vector3 ;
211
- }
223
+ } ;
212
224
setCameraBased : ( isCameraBased : boolean ) => void ;
213
225
getCameraBased : ( ) => {
214
226
isCameraBased : boolean ;
215
- }
227
+ } ;
228
+ setCustomAnimation : ( animation : string ) => void ;
216
229
} & {
217
- [ key in keyof AnimationSet ] : ( ) => void ;
230
+ [ key in keyof Omit < AnimationSet , "custom" > ] : ( ) => void ;
218
231
} ;
0 commit comments