(sentence: ISentence)
| 13 | * @param sentence |
| 14 | */ |
| 15 | export const setAnimation = (sentence: ISentence): IPerform => { |
| 16 | const animationName = sentence.content; |
| 17 | const animationDuration = getAnimateDuration(animationName); |
| 18 | let target = getStringArgByKey(sentence, 'target') ?? ''; |
| 19 | target = target !== '' ? target : 'default_id'; |
| 20 | const writeDefault = getBooleanArgByKey(sentence, 'writeDefault') ?? false; |
| 21 | const keep = getBooleanArgByKey(sentence, 'keep') ?? false; |
| 22 | const parallel = getBooleanArgByKey(sentence, 'parallel') ?? false; |
| 23 | const writeFullEffect = !parallel && !(getBooleanArgByKey(sentence, 'ignoreDefault') ?? false); |
| 24 | |
| 25 | const key = `${target}-${animationName}-${animationDuration}`; |
| 26 | const performInitName = `animation-${target}`; |
| 27 | const performName = parallel ? `${performInitName}#${animationName}` : performInitName; |
| 28 | let keepAnimationStopped = false; |
| 29 | |
| 30 | if (!parallel) WebGAL.gameplay.performController.unmountPerform(performInitName, true); |
| 31 | const animationTimeline = applyAnimationEndState(animationName, target, writeDefault, writeFullEffect); |
| 32 | |
| 33 | const startFunction = () => { |
| 34 | if (keep && keepAnimationStopped) { |
| 35 | return; |
| 36 | } |
| 37 | WebGAL.gameplay.pixiStage?.stopPresetAnimationOnTarget(target); |
| 38 | const animationObj: IAnimationObject | null = animationTimeline |
| 39 | ? generateTimelineObj(animationTimeline, target, animationDuration, false) |
| 40 | : null; |
| 41 | if (animationObj) { |
| 42 | logger.debug(`动画${animationName}作用在${target}`, animationDuration); |
| 43 | WebGAL.gameplay.pixiStage?.registerAnimation(animationObj, key, target); |
| 44 | } |
| 45 | }; |
| 46 | const stopFunction = () => { |
| 47 | if (keep) { |
| 48 | WebGAL.gameplay.pixiStage?.removeAnimationWithoutSetEndState(key); |
| 49 | keepAnimationStopped = true; |
| 50 | return; |
| 51 | } |
| 52 | WebGAL.gameplay.pixiStage?.removeAnimationWithSetEffects(key); |
| 53 | }; |
| 54 | |
| 55 | return { |
| 56 | performName: performName, |
| 57 | duration: animationDuration, |
| 58 | isHoldOn: keep, |
| 59 | startFunction, |
| 60 | stopFunction, |
| 61 | blockingNext: () => false, |
| 62 | blockingAuto: () => !keep, |
| 63 | }; |
| 64 | }; |
nothing calls this directly
no test coverage detected