Skip to content

Commit c1ff0e0

Browse files
fix: An issue where multiple performance records were unexpectedly stored in the state table when loading a save; An issue where performances with ID-based sound effects were not completely cleared after stopping playback; Deduplication of performance lists in the state table and performance controller upon insertion
1 parent 368f613 commit c1ff0e0

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

packages/webgal/src/Core/Modules/perform/performController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cloneDeep from 'lodash/cloneDeep';
55
import { resetStageState, stageActions } from '@/store/stageReducer';
66
import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
77
import { IRunPerform } from '@/store/stageInterface';
8+
import { WEBGAL_NONE } from '@/Core/constants';
89

910
/**
1011
* 获取随机演出名称
@@ -34,7 +35,7 @@ export class PerformController {
3435
}
3536

3637
// 语句不执行演出
37-
if (perform.performName === 'none') {
38+
if (perform.performName === WEBGAL_NONE) {
3839
return;
3940
}
4041
// 同步演出状态

packages/webgal/src/Core/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ export const STAGE_KEYS = {
44
FIG_L: 'fig-left',
55
FIG_R: 'fig-right',
66
};
7+
8+
export const WEBGAL_NONE = 'none';

packages/webgal/src/Core/controller/storage/jumpFromBacklog.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { sceneFetcher } from '../scene/sceneFetcher';
33
import { sceneParser } from '../../parser/sceneParser';
44
import { IStageState } from '@/store/stageInterface';
55
import { webgalStore } from '@/store/store';
6-
import { resetStageState } from '@/store/stageReducer';
6+
import { resetStageState, stageActions } from '@/store/stageReducer';
77
import { setVisibility } from '@/store/GUIReducer';
88
import { runScript } from '@/Core/controller/gamePlay/runScript';
99
import { stopAllPerform } from '@/Core/controller/gamePlay/stopAllPerform';
@@ -18,7 +18,10 @@ import { WebGAL } from '@/Core/WebGAL';
1818
*/
1919
export const restorePerform = () => {
2020
const stageState = webgalStore.getState().stage;
21-
stageState.PerformList.forEach((e) => {
21+
const performToRestore = cloneDeep(stageState.PerformList);
22+
// 清除状态表中演出序列
23+
webgalStore.dispatch(stageActions.removeAllPerform());
24+
performToRestore.forEach((e) => {
2225
runScript(e.script);
2326
});
2427
};

packages/webgal/src/Core/gameScripts/playEffect.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getSentenceArgByKey } from '@/Core/util/getSentenceArg';
55
import { IPerform } from '@/Core/Modules/perform/performInterface';
66
import { useSelector } from 'react-redux';
77
import { WebGAL } from '@/Core/WebGAL';
8+
import { WEBGAL_NONE } from '@/Core/constants';
89

910
/**
1011
* 播放一段效果音
@@ -27,6 +28,21 @@ export const playEffect = (sentence: ISentence): IPerform => {
2728
isLoop = true;
2829
}
2930
let isOver = false;
31+
if (!url || url === WEBGAL_NONE) {
32+
return {
33+
performName: WEBGAL_NONE,
34+
duration: 0,
35+
isHoldOn: false,
36+
blockingAuto(): boolean {
37+
return false;
38+
},
39+
blockingNext(): boolean {
40+
return false;
41+
},
42+
stopFunction(): void {},
43+
stopTimeout: undefined,
44+
};
45+
}
3046
return {
3147
performName: 'none',
3248
blockingAuto(): boolean {

packages/webgal/src/store/stageReducer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ const stageSlice = createSlice({
148148
}
149149
}
150150
},
151+
removeAllPerform: (state) => {
152+
state.PerformList.splice(0, state.PerformList.length);
153+
},
151154
removeAllPixiPerforms: (state, action: PayloadAction<undefined>) => {
152155
for (let i = 0; i < state.PerformList.length; i++) {
153156
const performItem: IRunPerform = state.PerformList[i];
@@ -218,7 +221,6 @@ const stageSlice = createSlice({
218221
if (action.payload[3]) {
219222
if (state.figureMetaData[action.payload[0]]) delete state.figureMetaData[action.payload[0]];
220223
} else {
221-
console.log('yeah');
222224
// 初始化对象
223225
if (!state.figureMetaData[action.payload[0]]) {
224226
state.figureMetaData[action.payload[0]] = {};

0 commit comments

Comments
 (0)