From 12f84fad120027dfe5186f90532b498c72589965 Mon Sep 17 00:00:00 2001 From: Yuki Shimada Date: Tue, 25 Jul 2023 23:19:06 +0900 Subject: [PATCH] !refactor: delete some methods --- .../Animation/AnimationComponent.ts | 153 ++++++------------ 1 file changed, 45 insertions(+), 108 deletions(-) diff --git a/src/foundation/components/Animation/AnimationComponent.ts b/src/foundation/components/Animation/AnimationComponent.ts index c7f822bb6..34d8d8f0a 100644 --- a/src/foundation/components/Animation/AnimationComponent.ts +++ b/src/foundation/components/Animation/AnimationComponent.ts @@ -306,43 +306,6 @@ export class AnimationComponent extends Component { this.entity.getTransform()._backupTransformAsRest(); } - public getStartInputValueOfAnimation(animationTrackName?: string): number { - const name = animationTrackName ?? this.__currentActiveAnimationTrackName; - if (name === undefined) { - const array = Array.from(AnimationComponent.__animationGlobalInfo.values()); - if (array.length === 0) { - return 0; - } - const firstAnimationInfo = array[0] as unknown as AnimationInfo; - return firstAnimationInfo.maxEndInputTime; - } - const maxStartInputTime = valueWithDefault({ - value: AnimationComponent.__animationGlobalInfo.get(name), - defaultValue: defaultAnimationInfo, - }).minStartInputTime; - - return maxStartInputTime; - } - - public getEndInputValueOfAnimation(animationTrackName?: string): number { - const name = animationTrackName ?? this.__currentActiveAnimationTrackName; - - if (name === undefined) { - const array = Array.from(AnimationComponent.__animationGlobalInfo.values()); - if (array.length === 0) { - return 0; - } - const firstAnimationInfo = array[0] as unknown as AnimationInfo; - return firstAnimationInfo.maxEndInputTime; - } - const maxEndInputTime = valueWithDefault({ - value: AnimationComponent.__animationGlobalInfo.get(name), - defaultValue: defaultAnimationInfo, - }).maxEndInputTime; - - return maxEndInputTime; - } - /** * get the Array of Animation Track Name * @returns Array of Animation Track Name @@ -382,77 +345,6 @@ export class AnimationComponent extends Component { return this.__isAnimating; } - static get startInputValue() { - const components = ComponentRepository.getComponentsWithType( - AnimationComponent - ) as AnimationComponent[]; - if (components.length === 0) { - return 0; - } else { - const infoArray = Array.from(this.__animationGlobalInfo.values()); - const lastInfo = infoArray[infoArray.length - 1]; - return lastInfo.minStartInputTime; - } - } - - static get endInputValue() { - const components = ComponentRepository.getComponentsWithType( - AnimationComponent - ) as AnimationComponent[]; - if (components.length === 0) { - return 0; - } else { - const infoArray = Array.from(this.__animationGlobalInfo.values()); - const lastInfo = infoArray[infoArray.length - 1]; - return lastInfo.maxEndInputTime; - } - } - - static get componentTID(): ComponentTID { - return WellKnownComponentTIDs.AnimationComponentTID; - } - - get componentTID(): ComponentTID { - return WellKnownComponentTIDs.AnimationComponentTID; - } - - /** - * get the entity which has this component. - * @returns the entity which has this component - */ - get entity(): IAnimationEntity { - return EntityRepository.getEntity(this.__entityUid) as unknown as IAnimationEntity; - } - - /** - * @override - * Add this component to the entity - * @param base the target entity - * @param _componentClass the component class to add - */ - addThisComponentToEntity( - base: EntityBase, - _componentClass: SomeComponentClass - ) { - class AnimationEntity extends (base.constructor as any) { - constructor( - entityUID: EntityUID, - isAlive: boolean, - components?: Map - ) { - super(entityUID, isAlive, components); - } - - getAnimation() { - return this.getComponentByComponentTID( - WellKnownComponentTIDs.AnimationComponentTID - ) as AnimationComponent; - } - } - applyMixins(base, AnimationEntity); - return base as unknown as ComponentToComponentMethods & EntityBase; - } - addKeyFrame( trackName: AnimationTrackName, pathName: AnimationPathName, @@ -686,5 +578,50 @@ export class AnimationComponent extends Component { this.__transformComponent?._backupTransformAsRest(); } + + static get componentTID(): ComponentTID { + return WellKnownComponentTIDs.AnimationComponentTID; + } + + get componentTID(): ComponentTID { + return WellKnownComponentTIDs.AnimationComponentTID; + } + + /** + * get the entity which has this component. + * @returns the entity which has this component + */ + get entity(): IAnimationEntity { + return EntityRepository.getEntity(this.__entityUid) as unknown as IAnimationEntity; + } + + /** + * @override + * Add this component to the entity + * @param base the target entity + * @param _componentClass the component class to add + */ + addThisComponentToEntity( + base: EntityBase, + _componentClass: SomeComponentClass + ) { + class AnimationEntity extends (base.constructor as any) { + constructor( + entityUID: EntityUID, + isAlive: boolean, + components?: Map + ) { + super(entityUID, isAlive, components); + } + + getAnimation() { + return this.getComponentByComponentTID( + WellKnownComponentTIDs.AnimationComponentTID + ) as AnimationComponent; + } + } + applyMixins(base, AnimationEntity); + return base as unknown as ComponentToComponentMethods & EntityBase; + } } ComponentRepository.registerComponentClass(AnimationComponent);