Files
ichni_Creator_Studio/Assets/Scripts/GameElements/Track/TrackSubmodules/TrackPathSubmodule.cs
SoulliesOfficial 8d0abec75f 基础内容
必要插件安装
缓动曲线和动画基础
ElementFolder,Track与其次级模块,PathNode重构
2025-01-26 21:10:16 -05:00

74 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
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;
public void NewInitialize(Track track, bool isClosed, Track.TrackSpaceType trackSpaceType,
Track.TrackSamplingType trackSamplingType)
{
this.track = track;
this.path = track.AddComponent<SplineComputer>();
track.trackPathSubmodule = this;
this.pathNodeList = new List<PathNode>();
this.trackSpaceType = trackSpaceType;
this.trackSamplingType = trackSamplingType;
this.isClosed = isClosed;
SetUpSplineComputer(trackSpaceType, trackSamplingType);
}
}
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 AddPathNode(PathNode point)
{
path.SetPoint(pathNodeList.Count, point.node, SplineComputer.Space.Local);
pathNodeList.Add(point);
}
public void SetPathNode(PathNode point)
{
path.SetPoint(point.index, point.node, SplineComputer.Space.Local);
}
}
}