File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,21 @@ export class PerformController {
18
18
public timeoutList : Array < ReturnType < typeof setTimeout > > = [ ] ;
19
19
20
20
public arrangeNewPerform ( perform : IPerform , script : ISentence , syncPerformState = true ) {
21
+ // 检查演出列表内是否有相同的演出,如果有,一定是出了什么问题
22
+ const dupPerformIndex = this . performList . findIndex ( ( p ) => p . performName === perform . performName ) ;
23
+ if ( dupPerformIndex > - 1 ) {
24
+ // 结束并删除全部重复演出
25
+ for ( let i = 0 ; i < this . performList . length ; i ++ ) {
26
+ const e = this . performList [ i ] ;
27
+ if ( e . performName === perform . performName ) {
28
+ e . stopFunction ( ) ;
29
+ clearTimeout ( e . stopTimeout as unknown as number ) ;
30
+ this . performList . splice ( i , 1 ) ;
31
+ i -- ;
32
+ }
33
+ }
34
+ }
35
+
21
36
// 语句不执行演出
22
37
if ( perform . performName === 'none' ) {
23
38
return ;
Original file line number Diff line number Diff line change @@ -56,14 +56,15 @@ export const playEffect = (sentence: ISentence): IPerform => {
56
56
const seVol = mainVol * 0.01 * ( userDataState . optionData ?. seVolume ?? 100 ) * 0.01 * volume * 0.01 ;
57
57
seElement . volume = seVol ;
58
58
seElement . currentTime = 0 ;
59
- const perform = {
59
+ const perform : IPerform = {
60
60
performName : performInitName ,
61
61
duration : 1000 * 60 * 60 ,
62
62
isHoldOn : isLoop ,
63
63
skipNextCollect : true ,
64
64
stopFunction : ( ) => {
65
65
// 演出已经结束了,所以不用播放效果音了
66
66
seElement . pause ( ) ;
67
+ seElement . remove ( ) ;
67
68
} ,
68
69
blockingNext : ( ) => false ,
69
70
blockingAuto : ( ) => {
Original file line number Diff line number Diff line change @@ -124,6 +124,19 @@ const stageSlice = createSlice({
124
124
}
125
125
} ,
126
126
addPerform : ( state , action : PayloadAction < IRunPerform > ) => {
127
+ // 先检查是否有重复的,全部干掉
128
+ const dupPerformIndex = state . PerformList . findIndex ( ( p ) => p . id === action . payload . id ) ;
129
+ if ( dupPerformIndex > - 1 ) {
130
+ const dupId = action . payload . id ;
131
+ // 删除全部重复演出
132
+ for ( let i = 0 ; i < state . PerformList . length ; i ++ ) {
133
+ const performItem : IRunPerform = state . PerformList [ i ] ;
134
+ if ( performItem . id === dupId ) {
135
+ state . PerformList . splice ( i , 1 ) ;
136
+ i -- ;
137
+ }
138
+ }
139
+ }
127
140
state . PerformList . push ( action . payload ) ;
128
141
} ,
129
142
removePerformByName : ( state , action : PayloadAction < string > ) => {
You can’t perform that action at this time.
0 commit comments