2025-01-26 21:10:16 -05:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Dreamteck.Splines;
|
2025-02-06 23:01:44 -05:00
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
2025-01-26 21:10:16 -05:00
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class TrackPathSubmodule : TrackSubmodule
|
|
|
|
|
|
{
|
|
|
|
|
|
public SplineComputer path;
|
|
|
|
|
|
public List<PathNode> pathNodeList;
|
|
|
|
|
|
|
|
|
|
|
|
public Track.TrackSpaceType trackSpaceType;
|
|
|
|
|
|
public Track.TrackSamplingType trackSamplingType;
|
|
|
|
|
|
public bool isClosed;
|
|
|
|
|
|
|
2025-01-30 22:45:33 -05:00
|
|
|
|
public TrackPathSubmodule(Track track, Track.TrackSpaceType trackSpaceType, Track.TrackSamplingType trackSamplingType, bool isClosed) : base(track)
|
2025-01-26 21:10:16 -05:00
|
|
|
|
{
|
|
|
|
|
|
this.path = track.AddComponent<SplineComputer>();
|
2025-02-08 23:09:50 -05:00
|
|
|
|
this.track.trackPathSubmodule = this;
|
2025-01-26 21:10:16 -05:00
|
|
|
|
this.pathNodeList = new List<PathNode>();
|
|
|
|
|
|
this.trackSpaceType = trackSpaceType;
|
|
|
|
|
|
this.trackSamplingType = trackSamplingType;
|
|
|
|
|
|
this.isClosed = isClosed;
|
|
|
|
|
|
|
2025-01-30 22:45:33 -05:00
|
|
|
|
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
|
|
|
|
|
|
//闭合路径在PathNode生成时执行,在初始化的情况下,PathNode数量为0,不会执行闭合操作
|
2025-01-26 21:10:16 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class TrackPathSubmodule
|
|
|
|
|
|
{
|
|
|
|
|
|
private void SetUpSplineComputer(Track.TrackSpaceType trackSpaceType, Track.TrackSamplingType trackSamplingType)
|
|
|
|
|
|
{
|
|
|
|
|
|
path.type = (Spline.Type)(int)trackSpaceType;
|
|
|
|
|
|
path.sampleMode = (SplineComputer.SampleMode)(int)trackSamplingType;
|
|
|
|
|
|
path.space = SplineComputer.Space.Local;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ClosePath(bool close)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (close)
|
|
|
|
|
|
{
|
|
|
|
|
|
path.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
path.Break();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
isClosed = close;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetTrackSpaceType(int spaceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
trackSpaceType = (Track.TrackSpaceType)spaceType;
|
|
|
|
|
|
path.type = (Spline.Type)spaceType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetPathNode(PathNode point)
|
|
|
|
|
|
{
|
|
|
|
|
|
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-06 23:01:44 -05:00
|
|
|
|
|
|
|
|
|
|
public partial class TrackPathSubmodule
|
|
|
|
|
|
{
|
2025-02-13 02:04:41 -05:00
|
|
|
|
public override void SaveBM()
|
2025-02-06 23:01:44 -05:00
|
|
|
|
{
|
2025-02-08 02:31:39 -05:00
|
|
|
|
matchedBM = new TrackPathSubmodule_BM(attachedGameElement, this);
|
2025-02-06 23:01:44 -05:00
|
|
|
|
}
|
2025-02-13 02:04:41 -05:00
|
|
|
|
|
|
|
|
|
|
public override void SetUpInspector()
|
|
|
|
|
|
{
|
|
|
|
|
|
var container = inspector.GenerateContainer("Track Path");
|
|
|
|
|
|
var trackSpaceDropdown =
|
|
|
|
|
|
inspector.GenerateDropdown(this, container, "Space Type", typeof(Track.TrackSpaceType), nameof(trackSpaceType));
|
|
|
|
|
|
var trackSamplingDropdown =
|
|
|
|
|
|
inspector.GenerateDropdown(this, container, "Sampling Type", typeof(Track.TrackSamplingType), nameof(trackSamplingType));
|
|
|
|
|
|
}
|
2025-02-06 23:01:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace Beatmap
|
|
|
|
|
|
{
|
|
|
|
|
|
public class TrackPathSubmodule_BM : Submodule_BM
|
|
|
|
|
|
{
|
|
|
|
|
|
public Track.TrackSpaceType trackSpaceType;
|
|
|
|
|
|
public Track.TrackSamplingType trackSamplingType;
|
|
|
|
|
|
public bool isClosed;
|
|
|
|
|
|
|
|
|
|
|
|
public TrackPathSubmodule_BM()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-08 02:31:39 -05:00
|
|
|
|
public TrackPathSubmodule_BM(GameElement attachedElement, TrackPathSubmodule trackPathSubmodule) : base(
|
2025-02-06 23:01:44 -05:00
|
|
|
|
attachedElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.trackSpaceType = trackPathSubmodule.trackSpaceType;
|
|
|
|
|
|
this.trackSamplingType = trackPathSubmodule.trackSamplingType;
|
|
|
|
|
|
this.isClosed = trackPathSubmodule.isClosed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExecuteBM()
|
|
|
|
|
|
{
|
2025-02-08 02:31:39 -05:00
|
|
|
|
attachedElement = GameElement_BM.GetElement(attachedElementGuid);
|
|
|
|
|
|
Track track = attachedElement as Track;
|
|
|
|
|
|
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
|
2025-02-08 23:09:50 -05:00
|
|
|
|
track.submoduleList.Add(track.trackPathSubmodule);
|
2025-02-06 23:01:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-08 02:31:39 -05:00
|
|
|
|
public override void DuplicateBM(GameElement attached)
|
2025-02-06 23:01:44 -05:00
|
|
|
|
{
|
2025-02-08 02:31:39 -05:00
|
|
|
|
Track track = attachedElement as Track;
|
|
|
|
|
|
track.trackPathSubmodule = new TrackPathSubmodule(track, trackSpaceType, trackSamplingType, isClosed);
|
2025-02-08 23:09:50 -05:00
|
|
|
|
track.submoduleList.Add(track.trackPathSubmodule);
|
2025-02-06 23:01:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-01-26 21:10:16 -05:00
|
|
|
|
}
|