using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Ichni.RhythmGame { public class Scale : AnimationBase { public TransformSubmodule targetTransformSubmodule; public FlexibleFloat scaleX, scaleY, scaleZ; public static Scale GenerateElement(string elementName, BaseElement targetObject, FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ) { Scale scale = Lean.Pool.LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent(); scale.NewInitialize(elementName, targetObject); scale.scaleX = scaleX; scale.scaleY = scaleY; scale.scaleZ = scaleZ; scale.animationReturnType = FlexibleReturnType.Before; if (targetObject.transformSubmodule != null) { scale.targetTransformSubmodule = targetObject.transformSubmodule; } else { throw new System.Exception("Target object does not have a TransformSubmodule"); } scale.SetTimeDuration(scaleX, scaleY, scaleZ); return scale; } protected override void UpdateAnimation(float songTime) { scaleX.UpdateFlexibleFloat(songTime); scaleY.UpdateFlexibleFloat(songTime); scaleZ.UpdateFlexibleFloat(songTime); if (scaleX.returnType is FlexibleReturnType.MiddleExecuting || scaleY.returnType is FlexibleReturnType.MiddleExecuting || scaleZ.returnType is FlexibleReturnType.MiddleExecuting) { animationReturnType = FlexibleReturnType.MiddleExecuting; Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value); targetTransformSubmodule.scaleOffset.Add(currentScale); targetTransformSubmodule.scaleDirtyMark = true; } else { animationReturnType = FlexibleReturnType.MiddleInterval; } } } }