using System; using System.Collections; using System.Collections.Generic; using Ichni.RhythmGame.Beatmap; using Lean.Pool; using UnityEngine; namespace Ichni.RhythmGame { public partial class TrackTotalTimeChange : AnimationBase { public FlexibleFloat totalTime; public TrackTimeSubmoduleStatic targetTrackTimeSubmoduleStatic; public static TrackTotalTimeChange GenerateElement(string elementName, Guid id, List tags, Track targetTrack, FlexibleFloat totalTime) { TrackTotalTimeChange trackTotalTimeChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject) .AddComponent(); trackTotalTimeChange.Initialize(elementName, id, tags); trackTotalTimeChange.targetObject = targetTrack; if (targetTrack.trackTimeSubmodule is TrackTimeSubmoduleStatic submoduleStatic) { trackTotalTimeChange.targetTrackTimeSubmoduleStatic = submoduleStatic; } else { throw new System.Exception("Target object does not have a TrackTimeSubmoduleStatic"); } trackTotalTimeChange.totalTime = totalTime; trackTotalTimeChange.animationReturnType = FlexibleReturnType.Before; trackTotalTimeChange.timeDurationSubmodule.SetDuration(totalTime); trackTotalTimeChange.SetParent(targetTrack); return trackTotalTimeChange; } protected override void UpdateAnimation(float songTime) { totalTime.UpdateFlexibleFloat(songTime); if (totalTime.returnType == FlexibleReturnType.MiddleExecuting) { targetTrackTimeSubmoduleStatic.trackTotalTime = totalTime.value; } } } public partial class TrackTotalTimeChange { public override void SaveBM() { matchedBM = new TrackTotalTimeChange_BM(elementName, elementGuid, tags, targetObject.matchedBM as Track_BM, totalTime.ConvertToBM()); } } namespace Beatmap { public class TrackTotalTimeChange_BM : BaseElement_BM { public FlexibleFloat_BM totalTime; public TrackTotalTimeChange_BM() { } public TrackTotalTimeChange_BM(string elementName, Guid elementGuid, List tags, BaseElement_BM attachedElement, FlexibleFloat_BM totalTime) : base(elementName, elementGuid, tags, attachedElement) { this.totalTime = totalTime; } public override void ExecuteBM() { TrackTotalTimeChange.GenerateElement(elementName, elementGuid, tags, GetElement(attachedElementGuid) as Track, totalTime.ConvertToGameType()); } public override BaseElement DuplicateBM(BaseElement parent) { return TrackTotalTimeChange.GenerateElement(elementName, elementGuid, tags, parent as Track, totalTime.ConvertToGameType()); } } } }