@@ -4,6 +4,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using Ichni.RhythmGame.ThemeBundles.DepartureToMultiverse;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -662,5 +665,108 @@ namespace Ichni.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void SplitHoldToTrack(int PathnodesCount)
|
||||
{
|
||||
if (inspector.connectedGameElement == null || inspector.connectedGameElement.GetType() != typeof(Hold))
|
||||
{
|
||||
LogWindow.Log("Please select a Hold first!");
|
||||
return;
|
||||
}
|
||||
Hold hold = (Hold)inspector.connectedGameElement;
|
||||
Track parentTrack = hold.parentElement as Track;
|
||||
if (parentTrack == null || parentTrack.trackTimeSubmodule is not TrackTimeSubmoduleMovable)
|
||||
{
|
||||
LogWindow.Log("Track Illegal (Only Movable)", Color.red);
|
||||
return;
|
||||
}
|
||||
TrackTimeSubmoduleMovable trackTimeSubmoduleMovable = hold.track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
|
||||
|
||||
if (PathnodesCount < 2)
|
||||
{
|
||||
LogWindow.Log("PathnodesCount must be greater than 1!", Color.red);
|
||||
return;
|
||||
}
|
||||
float startTime = hold.exactJudgeTime;
|
||||
float endTime = hold.holdEndTime;
|
||||
float interval = 1f / (PathnodesCount - 1);
|
||||
|
||||
hold.UpdateNoteInMovableTrack();
|
||||
Vector3 HoldStartPos = default;
|
||||
Vector3 HoldEndPos = default;
|
||||
if (hold.noteVisual is DTMNoteVisualHold dTMNoteVisualHold)
|
||||
{
|
||||
dTMNoteVisualHold.headPoint.SetPercent(trackTimeSubmoduleMovable.GetTrackPercent(hold.exactJudgeTime));
|
||||
dTMNoteVisualHold.tailPoint.SetPercent(trackTimeSubmoduleMovable.GetTrackPercent(hold.holdEndTime));
|
||||
HoldStartPos = dTMNoteVisualHold.headPoint.transform.position;
|
||||
HoldEndPos = dTMNoteVisualHold.tailPoint.transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWindow.Log("The selected Hold's NoteVisual is not DTMNoteVisualHold!", Color.red);
|
||||
return;
|
||||
}
|
||||
if (hold.track.trackPathSubmodule.pathNodeList.Count > 2)
|
||||
{
|
||||
LogWindow.Log("the Hold may not be split currently", Color.yellow);
|
||||
return;
|
||||
}
|
||||
hold.UpdateNoteInMovableTrack();
|
||||
Track NewTrack = Track.GenerateElement(hold.elementName + "_SplitTrack", Guid.NewGuid(), new List<string>(), true, parentTrack);
|
||||
new TrackTimeSubmoduleMovable(NewTrack, startTime, endTime, 1, AnimationCurveType.Linear);
|
||||
for (int i = 0; i < PathnodesCount; i++)
|
||||
{
|
||||
PathNode j = PathNode.GenerateElement("PathNode" + i.ToString(), Guid.NewGuid(), new List<string>(), true, NewTrack, true);
|
||||
j.transform.position = Vector3.Lerp(HoldStartPos, HoldEndPos, i * interval);
|
||||
j.transformSubmodule.originalPosition = j.transform.localPosition;
|
||||
}
|
||||
EditorManager.instance.operationManager.CopyPasteDeleteModule.CopyElement(hold);
|
||||
EditorManager.instance.operationManager.CopyPasteDeleteModule.PasteElement(NewTrack);
|
||||
|
||||
EditorManager.instance.operationManager.CopyPasteDeleteModule.DeleteElement(hold);
|
||||
Hold newHold = NewTrack.childElementList.OfType<Hold>().First();
|
||||
newHold.noteVisual.transformSubmodule.originalPosition = Vector3.zero;
|
||||
NewTrack.Refresh();
|
||||
Observable.Timer(TimeSpan.FromSeconds(0.3f)).Subscribe(_ =>
|
||||
{
|
||||
NewTrack?.trackPathSubmodule.path.Rebuild(true);
|
||||
DTMNoteVisualHold dTMNoteVisualHold = newHold.noteVisual as DTMNoteVisualHold;
|
||||
dTMNoteVisualHold.meshGenerator.Rebuild();
|
||||
});
|
||||
|
||||
}
|
||||
public static void SplitAllHoldToTrack(int PathnodesCount)
|
||||
{
|
||||
if (inspector.connectedGameElement == null || inspector.connectedGameElement.GetType() != typeof(Track))
|
||||
{
|
||||
LogWindow.Log("Please select a Track first!");
|
||||
return;
|
||||
}
|
||||
Track track = (Track)inspector.connectedGameElement;
|
||||
var holds = track.childElementList.OfType<Hold>().ToList();
|
||||
if (track.trackPathSubmodule.pathNodeList.Count > 2)
|
||||
{
|
||||
LogWindow.Log("the Hold may not be split currently", Color.yellow);
|
||||
return;
|
||||
}
|
||||
foreach (var hold in holds)
|
||||
{
|
||||
inspector.connectedGameElement = hold;
|
||||
SplitHoldToTrack(PathnodesCount);
|
||||
}
|
||||
}
|
||||
public static void Rebuild()
|
||||
{
|
||||
foreach (GameElement element in EditorManager.instance.beatmapContainer.gameElementList)
|
||||
{
|
||||
foreach (GameElement e in element.GetAllGameElementsFromThis())
|
||||
{
|
||||
e.Refresh();
|
||||
}
|
||||
foreach (Track track in element.GetAllGameElementsFromThis().OfType<Track>())
|
||||
{
|
||||
track?.trackPathSubmodule.path.Rebuild(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user