Files
ichni_Creator_Studio/Assets/Scripts/Animations/Track/TrackTotalTimeChange.cs

92 lines
3.2 KiB
C#
Raw Normal View History

2025-02-02 08:34:54 -05:00
using System;
using System.Collections;
using System.Collections.Generic;
2025-02-02 21:59:43 -05:00
using Ichni.RhythmGame.Beatmap;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
2025-02-02 21:59:43 -05:00
public partial class TrackTotalTimeChange : AnimationBase
{
public FlexibleFloat totalTime;
public TrackTimeSubmoduleStatic targetTrackTimeSubmoduleStatic;
2025-02-02 21:59:43 -05:00
public static TrackTotalTimeChange GenerateElement(string elementName, Guid id,
2025-02-02 08:34:54 -05:00
List<string> tags, Track targetTrack, FlexibleFloat totalTime)
{
2025-02-02 21:59:43 -05:00
TrackTotalTimeChange trackTotalTimeChange = Instantiate(EditorManager.instance.basePrefabs.emptyObject)
.AddComponent<TrackTotalTimeChange>();
2025-02-02 08:34:54 -05:00
trackTotalTimeChange.Initialize(elementName, id, tags);
2025-02-02 21:59:43 -05:00
2025-02-02 08:34:54 -05:00
trackTotalTimeChange.targetObject = targetTrack;
2025-02-02 21:59:43 -05:00
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;
2025-02-02 08:34:54 -05:00
trackTotalTimeChange.timeDurationSubmodule.SetDuration(totalTime);
2025-02-02 21:59:43 -05:00
2025-02-02 08:34:54 -05:00
trackTotalTimeChange.SetParent(targetTrack);
return trackTotalTimeChange;
}
protected override void UpdateAnimation(float songTime)
{
totalTime.UpdateFlexibleFloat(songTime);
2025-02-02 21:59:43 -05:00
if (totalTime.returnType == FlexibleReturnType.MiddleExecuting)
{
targetTrackTimeSubmoduleStatic.trackTotalTime = totalTime.value;
}
}
}
2025-02-02 21:59:43 -05:00
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<string> 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());
}
}
}
}