using System; using System.Collections; using System.Collections.Generic; using Ichni.RhythmGame.Beatmap; using Lean.Pool; using UnityEngine; namespace Ichni.RhythmGame { public partial class Swirl : AnimationBase { private TransformSubmodule targetTransformSubmodule; public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ; public static Swirl GenerateElement(string elementName, Guid id, List tags, bool isFirstGenerated, GameElement animatedObject, FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ) { Swirl swirl = Instantiate(GameManager.instance.basePrefabs.emptyObject).AddComponent(); swirl.Initialize(elementName, id, tags, isFirstGenerated, animatedObject); swirl.animatedObject = animatedObject; swirl.eulerAngleX = eulerAngleX; swirl.eulerAngleY = eulerAngleY; swirl.eulerAngleZ = eulerAngleZ; swirl.animationReturnType = FlexibleReturnType.Before; swirl.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule; //swirl.timeDurationSubmodule.SetDuration(eulerAngleX, eulerAngleY, eulerAngleZ); return swirl; } protected override void UpdateAnimation(float songTime) { eulerAngleX.UpdateFlexibleFloat(songTime); eulerAngleY.UpdateFlexibleFloat(songTime); eulerAngleZ.UpdateFlexibleFloat(songTime); if ((eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleX.isSwitchingReturnType) || (eulerAngleY.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleY.isSwitchingReturnType) || (eulerAngleZ.returnType is FlexibleReturnType.MiddleExecuting || eulerAngleZ.isSwitchingReturnType)) { animationReturnType = FlexibleReturnType.MiddleExecuting; Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value); targetTransformSubmodule.eulerAnglesOffset += currentEulerAngles; targetTransformSubmodule.eulerAnglesDirtyMark = true; } else { animationReturnType = FlexibleReturnType.MiddleInterval; } } public override void ApplyTimeOffset(float offset) { base.ApplyTimeOffset(offset); eulerAngleX.animations.ForEach(anim => anim.ApplyTimeOffset(offset)); eulerAngleY.animations.ForEach(anim => anim.ApplyTimeOffset(offset)); eulerAngleZ.animations.ForEach(anim => anim.ApplyTimeOffset(offset)); } } public partial class Swirl { public override void SaveBM() { matchedBM = new Swirl_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM, eulerAngleX.ConvertToBM(), eulerAngleY.ConvertToBM(), eulerAngleZ.ConvertToBM()); } } namespace Beatmap { public class Swirl_BM : AnimationBase_BM { public FlexibleFloat_BM eulerAngleX, eulerAngleY, eulerAngleZ; public Swirl_BM() { } public Swirl_BM(string elementName, Guid elementGuid, List tags, GameElement_BM attachedElement, FlexibleFloat_BM eulerAngleX, FlexibleFloat_BM eulerAngleY, FlexibleFloat_BM eulerAngleZ) : base(elementName, elementGuid, tags, attachedElement) { this.eulerAngleX = eulerAngleX; this.eulerAngleY = eulerAngleY; this.eulerAngleZ = eulerAngleZ; } public override void ExecuteBM() { matchedElement = Swirl.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid), eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType()); } public override GameElement DuplicateBM(GameElement parent) { return Swirl.GenerateElement(elementName, Guid.NewGuid(), tags, false, parent, eulerAngleX.ConvertToGameType(), eulerAngleY.ConvertToGameType(), eulerAngleZ.ConvertToGameType()); } } } }