Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/webgal/src/Core/controller/gamePlay/nextSentence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const nextSentence = () => {
return;
}

// 如果处于 wait 指令的不可中断状态,那么不进行下一句
if (GUIState.waitNoBreak) {
return;
}

// 第一步,检查是否存在 blockNext 的演出
let isBlockingNext = false;
WebGAL.gameplay.performController.performList.forEach((e) => {
Expand Down
12 changes: 12 additions & 0 deletions packages/webgal/src/Core/gameScripts/wait.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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 毫秒
Expand All @@ -8,6 +11,15 @@ import { IPerform } from '@/Core/Modules/perform/performInterface';
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);
}
Comment thread
xiaoxustudio marked this conversation as resolved.
Outdated

return {
performName,
duration: duration,
Expand Down
6 changes: 6 additions & 0 deletions packages/webgal/src/store/GUIReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const initState: IGuiState = {
isShowLogo: true,
enableAppreciationMode: false, // Paf87
fontOptimization: false,
waitNoBreak: false,
};

/**
Expand Down Expand Up @@ -87,6 +88,10 @@ const GUISlice = createSlice({
setFontOptions: (state, action: PayloadAction<FontOption[]>) => {
state.fontOptions = [...action.payload];
},

setWaitNoBreak: (state, action: PayloadAction<boolean>) => {
state.waitNoBreak = action.payload;
},
},
});

Expand All @@ -98,6 +103,7 @@ export const {
setEnableAppreciationMode,
setFontOptimization,
setFontOptions,
setWaitNoBreak,
} = GUISlice.actions;
export default GUISlice.reducer;

Expand Down
1 change: 1 addition & 0 deletions packages/webgal/src/store/guiInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IGuiState {
isShowLogo: boolean;
enableAppreciationMode: boolean; // Pc102
fontOptimization: boolean; // 字体优化
waitNoBreak: boolean; // 处于不可中断的等待
}

export type componentsVisibility = Pick<
Expand Down