@@ -10,15 +10,15 @@ import { baseTransform, ITransform } from '@/store/stageInterface';
1010import { AnimationFrame , IUserAnimation } from '../Modules/animations' ;
1111import { generateTransformAnimationObj } from '@/Core/controller/stage/pixi/animations/generateTransformAnimationObj' ;
1212import { WebGAL } from '@/Core/WebGAL' ;
13- import { getAnimateDuration , getAnimationObject } from '../Modules/animationFunctions' ;
14-
13+ import { getAnimateDurationFromObj , getAnimationObject } from '../Modules/animationFunctions' ;
14+ import { v4 as uuid } from 'uuid' ;
1515/**
1616 * 设置变换
1717 * @param sentence
1818 */
1919export const setTransform = ( sentence : ISentence ) : IPerform => {
2020 const startDialogKey = webgalStore . getState ( ) . stage . currentDialogKey ;
21- const animationName = ( Math . random ( ) * 10 ) . toString ( 16 ) ;
21+ const animationName = uuid ( ) ;
2222 const animationString = sentence . content ;
2323 let animationObj : AnimationFrame [ ] ;
2424
@@ -27,14 +27,16 @@ export const setTransform = (sentence: ISentence): IPerform => {
2727 const writeDefault = getBooleanArgByKey ( sentence , 'writeDefault' ) ?? false ;
2828 const target = getStringArgByKey ( sentence , 'target' ) ?? '0' ;
2929 const keep = getBooleanArgByKey ( sentence , 'keep' ) ?? false ;
30+ const parallel = getBooleanArgByKey ( sentence , 'parallel' ) ?? false ;
3031
3132 const performInitName = `animation-${ target } ` ;
3233
33- WebGAL . gameplay . performController . unmountPerform ( performInitName , true ) ;
34+ if ( ! parallel ) WebGAL . gameplay . performController . unmountPerform ( performInitName , true ) ;
3435
3536 try {
3637 const frame = JSON . parse ( animationString ) as AnimationFrame ;
37- animationObj = generateTransformAnimationObj ( target , frame , duration , ease ) ;
38+ // writeDefault时需要完整的当前effect,其他时候不需要
39+ animationObj = generateTransformAnimationObj ( target , frame , duration , ease , writeDefault ) ;
3840 console . log ( 'animationObj:' , animationObj ) ;
3941 } catch ( e ) {
4042 // 解析都错误了,歇逼吧
@@ -43,8 +45,7 @@ export const setTransform = (sentence: ISentence): IPerform => {
4345
4446 const newAnimation : IUserAnimation = { name : animationName , effects : animationObj } ;
4547 WebGAL . animationManager . addAnimation ( newAnimation ) ;
46- const animationDuration = getAnimateDuration ( animationName ) ;
47-
48+ const animationDuration = getAnimateDurationFromObj ( newAnimation ) ;
4849 const key = `${ target } -${ animationName } -${ animationDuration } ` ;
4950 let keepAnimationStopped = false ;
5051 setTimeout ( ( ) => {
@@ -82,5 +83,6 @@ export const setTransform = (sentence: ISentence): IPerform => {
8283 blockingNext : ( ) => false ,
8384 blockingAuto : ( ) => ! keep ,
8485 stopTimeout : undefined , // 暂时不用,后面会交给自动清除
86+ isParallel : parallel ,
8587 } ;
8688} ;
0 commit comments