/**
 * Copyright(c) Live2D Inc. All rights reserved.
 *
 * Use of this source code is governed by the Live2D Open Software license
 * that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
 */ import { ACubismMotion } from './acubismmotion' ; import { CubismMotionQueueEntry } from './cubismmotionqueueentry' ; import { csmVector , iterator } from '../type/csmvector' ; import { CubismModel } from '../model/cubismmodel' ; import { csmString } from '../type/csmstring' ; note export class CubismMotionQueueManager { /**
     * コンストラクタ
     */ public constructor ( ) { this . _userTimeSeconds = 0.0 ; this . _eventCallBack = null ; this . _eventCustomData = null ; this . _motions = new csmVector < CubismMotionQueueEntry > ( ) ; } /**
     * デストラクタ
     */ public release ( ) { for ( let i = 0 ; i < this . _motions . getSize ( ) ; ++ i ) { if ( this . _motions . at ( i ) ) { this . _motions . at ( i ) . release ( ) ; this . _motions . set ( i , null ) ; } } this . _motions = null ; } param motion param autoDelete param userTimeSeconds return public startMotion ( motion , autoDelete , userTimeSeconds ) { if ( motion == null ) { return InvalidMotionQueueEntryHandleValue ; } let motionQueueEntry = null ; for ( let i = 0 ; i < this . _motions . getSize ( ) ; ++ i ) { motionQueueEntry = this . _motions . at ( i ) ; if ( motionQueueEntry == null ) { continue ; } motionQueueEntry . setFadeOut ( motionQueueEntry . _motion . getFadeOutTime ( ) ) ; } motionQueueEntry = new CubismMotionQueueEntry ( ) ; motionQueueEntry . _autoDelete = autoDelete ; motionQueueEntry . _motion = motion ; this . _motions . pushBack ( motionQueueEntry ) ; return motionQueueEntry . _motionQueueEntryHandle ; } return return public isFinished ( ) { for ( let ite = this . _motions . begin ( ) ; ite . notEqual ( this . _motions . end ( ) ) ; ) { let motionQueueEntry = ite . ptr ( ) ; if ( motionQueueEntry == null ) { ite = this . _motions . erase ( ite ) ; continue ; } const motion = motionQueueEntry . _motion ; if ( motion == null ) { motionQueueEntry . release ( ) ; motionQueueEntry = null ; ite = this . _motions . erase ( ite ) ; continue ; } if ( ! motionQueueEntry . isFinished ( ) ) { return false ; } else { ite . preIncrement ( ) ; } } return true ; } param motionQueueEntryNumber return return public isFinishedByHandle ( motionQueueEntryNumber ) { for ( let ite = this . _motions . begin ( ) ; ite . notEqual ( this . _motions . end ( ) ) ; ite . increment ( ) ) { const motionQueueEntry = ite . ptr ( ) ; if ( motionQueueEntry == null ) { continue ; } if ( motionQueueEntry . _motionQueueEntryHandle == motionQueueEntryNumber && ! motionQueueEntry . isFinished ( ) ) { return false ; } } return true ; } /**
     * 全てのモーションを停止する
     */ public stopAllMotions ( ) { for ( let ite = this . _motions . begin ( ) ; ite . notEqual ( this . _motions . end ( ) ) ; ) { let motionQueueEntry = ite . ptr ( ) ; if ( motionQueueEntry == null ) { ite = this . _motions . erase ( ite ) ; continue ; } motionQueueEntry . release ( ) ; motionQueueEntry = null ; ite = this . _motions . erase ( ite ) ; } } param motionQueueEntryNumber return return public getCubismMotionQueueEntry ( motionQueueEntryNumber ) { for ( let ite = this . _motions . begin ( ) ; ite . notEqual ( this . _motions . end ( ) ) ; ite . preIncrement ( ) ) { const motionQueueEntry = ite . ptr ( ) ; if ( motionQueueEntry == null ) { continue ; } if ( motionQueueEntry . _motionQueueEntryHandle == motionQueueEntryNumber ) { return motionQueueEntry ; } } return null ; } param callback param customData public setEventCallback ( callback , customData = null ) { this . _eventCallBack = callback ; this . _eventCustomData = customData ; } param model param userTimeSeconds return return public doUpdateMotion ( model , userTimeSeconds ) { let updated = false ; for ( let ite = this . _motions . begin ( ) ; ite . notEqual ( this . _motions . end ( ) ) ; ) { let motionQueueEntry = ite . ptr ( ) ; if ( motionQueueEntry == null ) { ite = this . _motions . erase ( ite ) ; continue ; } const motion = motionQueueEntry . _motion ; if ( motion == null ) { motionQueueEntry . release ( ) ; motionQueueEntry = null ; ite = this . _motions . erase ( ite ) ; continue ; } motion . updateParameters ( model , motionQueueEntry , userTimeSeconds ) ; updated = true ; const firedList = motion . getFiredEvent ( motionQueueEntry . getLastCheckEventSeconds ( ) - motionQueueEntry . getStartTime ( ) , userTimeSeconds - motionQueueEntry . getStartTime ( ) ) ; for ( let i = 0 ; i < firedList . getSize ( ) ; ++ i ) { this . _eventCallBack ( this , firedList . at ( i ) , this . _eventCustomData ) ; } motionQueueEntry . setLastCheckEventSeconds ( userTimeSeconds ) ; if ( motionQueueEntry . isFinished ( ) ) { motionQueueEntry . release ( ) ; motionQueueEntry = null ; ite = this . _motions . erase ( ite ) ; } else { if ( motionQueueEntry . isTriggeredFadeOut ( ) ) { motionQueueEntry . startFadeOut ( motionQueueEntry . getFadeOutSeconds ( ) , userTimeSeconds ) ; } ite . preIncrement ( ) ; } } return updated ; } _userTimeSeconds : number ; _motions : csmVector < CubismMotionQueueEntry > ; _eventCallBack : CubismMotionEventFunction ; _eventCustomData : any ; } param caller param eventValue param customData export interface CubismMotionEventFunction { ( caller , eventValue , customData ) : void ; } /**
 * モーションの識別番号
 *
 * モーションの識別番号の定義
 */ export declare type CubismMotionQueueEntryHandle = any ; export const InvalidMotionQueueEntryHandleValue = - 1 ; import * as $ from './cubismmotionqueuemanager' ; export namespace Live2DCubismFramework { export const CubismMotionQueueManager = $ . CubismMotionQueueManager ; export type CubismMotionQueueManager = $ . CubismMotionQueueManager ; export const InvalidMotionQueueEntryHandleValue = $ . InvalidMotionQueueEntryHandleValue ; export type CubismMotionQueueEntryHandle = $ . CubismMotionQueueEntryHandle ; export type CubismMotionEventFunction = $ . CubismMotionEventFunction ; }