Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: backlog record async #617

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ISceneEntry } from '@/Core/Modules/scene';
import { IBacklogItem } from '@/Core/Modules/backlog';
import { SYSTEM_CONFIG } from '@/config';
import { WebGAL } from '@/Core/WebGAL';
import {callBackFunctionOfUpdate, updateFigureFlag, useSetFigure} from "@/Stage/MainStage/useSetFigure";

export const whenChecker = (whenValue: string | undefined): boolean => {
if (whenValue === undefined) {
Expand Down Expand Up @@ -150,7 +151,10 @@ export const scriptExecutor = () => {
// 保存 backlog
if (isSaveBacklog) {
// WebGAL.backlogManager.isSaveBacklogNext = true;
WebGAL.backlogManager.saveCurrentStateToBacklog();
const saveFunction = () => WebGAL.backlogManager.saveCurrentStateToBacklog();
if (updateFigureFlag) {
callBackFunctionOfUpdate.push(saveFunction);
} else saveFunction();
}
}, 0);
WebGAL.sceneManager.sceneData.currentSentenceId++;
Expand Down
25 changes: 20 additions & 5 deletions packages/webgal/src/Stage/MainStage/useSetFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { generateUniversalSoftOffAnimationObj } from '@/Core/controller/stage/pi
import { getEnterExitAnimation } from '@/Core/Modules/animationFunctions';
import { WebGAL } from '@/Core/WebGAL';

export let updateFigureFlag = false;
export const callBackFunctionOfUpdate: Function[] = [];

export function useSetFigure(stageState: IStageState) {
const { figNameLeft, figName, figNameRight, freeFigure, live2dMotion, live2dExpression } = stageState;

Expand Down Expand Up @@ -49,7 +52,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('中立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
logger.debug('移除中立绘');
const currentFigCenter = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand All @@ -61,6 +64,18 @@ export function useSetFigure(stageState: IStageState) {
}
}, [figName]);

const updateFigureToRemoveAnimationWithSetEffects = (softInAniKey: string, duration: number) => {
updateFigureFlag = true;
setTimeout(() => {
WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey);
while (callBackFunctionOfUpdate.length) {
const fun = callBackFunctionOfUpdate.shift();
fun?.();
}
updateFigureFlag = false;
}, duration);
};

useEffect(() => {
/**
* 特殊处理:左侧立绘
Expand All @@ -78,7 +93,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('左立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
logger.debug('移除左立绘');
const currentFigLeft = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand Down Expand Up @@ -107,7 +122,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('右立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
const currentFigRight = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
if (currentFigRight) {
Expand Down Expand Up @@ -138,14 +153,14 @@ export function useSetFigure(stageState: IStageState) {
logger.debug(`${fig.key}立绘已重设`);
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
}
} else {
addFigure(undefined, thisFigKey, fig.name, fig.basePosition);
logger.debug(`${fig.key}立绘已重设`);
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
}
} else {
const currentFigThisKey = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand Down
Loading