@@ -9,6 +9,8 @@ import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
99import { resetStage } from '@/Core/controller/stage/resetStage' ;
1010import { logger } from '@/Core/util/logger' ;
1111import { syncWithOrigine } from './syncWithOrigine' ;
12+ import { stageActions } from '@/store/stageReducer' ;
13+ import { baseTransform , IEffect } from '@/store/stageInterface' ;
1214
1315export const webSocketFunc = ( ) => {
1416 const loc : string = window . location . hostname ;
@@ -101,6 +103,29 @@ export const webSocketFunc = () => {
101103 const command = message . message ;
102104 webgalStore . dispatch ( setFontOptimization ( command === 'true' ) ) ;
103105 }
106+ if ( message . command === DebugCommand . SET_EFFECT ) {
107+ try {
108+ const effect = JSON . parse ( message . message ) as IEffect ;
109+ const targetEffect = webgalStore . getState ( ) . stage . effects . find ( ( e ) => e . target === effect . target ) ;
110+ const targetTransform = targetEffect ?. transform ? targetEffect . transform : baseTransform ;
111+ const newTransform = {
112+ ...targetTransform ,
113+ ...( effect . transform ?? { } ) ,
114+ position : {
115+ ...targetTransform . position ,
116+ ...( effect . transform ?. position ?? { } ) ,
117+ } ,
118+ scale : {
119+ ...targetTransform . scale ,
120+ ...( effect . transform ?. scale ?? { } ) ,
121+ } ,
122+ } ;
123+ webgalStore . dispatch ( stageActions . updateEffect ( { target : effect . target , transform : newTransform } ) ) ;
124+ } catch ( e ) {
125+ logger . error ( `无法设置效果 ${ message . message } , ${ e } ` ) ;
126+ return ;
127+ }
128+ }
104129 } ;
105130 socket . onerror = ( ) => {
106131 logger . info ( '当前没有连接到 Terre 编辑器' ) ;
0 commit comments