-
-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathwait.ts
More file actions
33 lines (30 loc) · 1002 Bytes
/
wait.ts
File metadata and controls
33 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ISentence } from '@/Core/controller/scene/sceneInterface';
import { IPerform } from '@/Core/Modules/perform/performInterface';
import { setWaitNoBreak } from '@/store/GUIReducer';
import { webgalStore } from '@/store/store';
import { getBooleanArgByKey } from '../util/getSentenceArg';
/**
* 等待 n 毫秒
* @param sentence
*/
export const wait = (sentence: ISentence): IPerform => {
const duration = Number(sentence.content);
const performName = `wait${Math.random().toString()}`;
const nobreak = getBooleanArgByKey(sentence, 'nobreak') ?? false;
if (nobreak) {
webgalStore.dispatch(setWaitNoBreak(true));
setTimeout(() => {
webgalStore.dispatch(setWaitNoBreak(false));
}, duration);
}
return {
performName,
duration: duration,
goNextWhenOver: true,
isHoldOn: false,
stopFunction: () => {},
blockingNext: () => false,
blockingAuto: () => true,
stopTimeout: undefined, // 暂时不用,后面会交给自动清除
};
};