基础内容-2

Track Percent Point 和 Track Head Point 重构优化

Note基础

特效框架(Effect Submodule 和 Effect基础类),将用于“时间触发型特效容器”与“Note特效容器“
This commit is contained in:
SoulliesOfficial
2025-01-27 10:29:38 -05:00
parent 8d0abec75f
commit 8d887d5a7c
25 changed files with 449 additions and 102 deletions

View File

@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Ichni;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class PathNode : BaseElement
{
public ColorSubmodule colorSubmodule;
public Track track;
public int index;
public SplinePoint node;
public static PathNode GeneratePathNode(string elementName, Track track, int index, Vector3 nodePosition,
Vector3 nodeNormal, float nodeSize, Color nodeColor)
{
PathNode pathNode = LeanPool.Spawn(EditorManager.instance.basePrefabs.pathNode, track.transform).GetComponent<PathNode>();
pathNode.NewInitialize(elementName, track, index, nodePosition, nodeNormal, nodeSize, nodeColor);
track.trackPathSubmodule.pathNodeList.Add(pathNode);
pathNode.SetParent(track);
return pathNode;
}
public void NewInitialize(string elementName, Track track, int index, Vector3 nodePosition,
Vector3 nodeNormal, float nodeSize, Color nodeColor)
{
base.NewInitialize(elementName);
this.track = track;
this.index = index;
this.transformSubmodule = new TransformSubmodule(nodePosition, Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
this.colorSubmodule = new ColorSubmodule(nodeColor);
Refresh();
}
public override void AfterInitialize()
{
Refresh();
if (track.trackPathSubmodule.pathNodeList.Count > 3)
{
track.trackPathSubmodule.ClosePath(track.trackPathSubmodule.isClosed);
}
}
}
public partial class PathNode
{
public override void Refresh()
{
Vector3 position = transformSubmodule.currentPosition;
Vector3 normal = Quaternion.Euler(transformSubmodule.currentEulerAngles) * Vector3.up;
float size = transformSubmodule.currentScale.x;
Color color = colorSubmodule.currentBaseColor;
node = new SplinePoint(position, Vector3.up, normal, size, color);
track.trackPathSubmodule.SetPathNode(this);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 09efd164733b64d539127e1d09f6ef5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -40,8 +40,7 @@ namespace Ichni.RhythmGame
public override void AfterInitialize()
{
trackPathSubmodule.path.RebuildImmediate();
//Refresh();
}
private void Update()

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 50c407d9db7cf4ed096db0106bdc3c0c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Lean.Pool;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class TrackHeadPoint : BaseElement
{
public Track track;
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
public SplinePositioner trackPositioner;
public static TrackHeadPoint GenerateElement(string elementName, Track track)
{
TrackHeadPoint head = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
head.NewInitialize(elementName, track);
head.SetParent(track);
return head;
}
private void NewInitialize(string elementName, Track track)
{
base.NewInitialize(elementName);
this.track = track;
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
this.trackPositioner.spline = track.trackPathSubmodule.path;
this.trackTimeSubmoduleMovable = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
}
public void Update()
{
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
{
trackPositioner.SetPercent(trackTimeSubmoduleMovable.headPercent);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d5925af6db50645cdaf05d9fbb53f751
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using Dreamteck.Splines;
using Lean.Pool;
using UniRx;
using UnityEngine;
namespace Ichni.RhythmGame
{
/// <summary>
/// 在轨道上根据百分比进行运动的点
/// </summary>
public class TrackPercentPoint : BaseElement
{
public Track track;
public SplinePositioner trackPositioner;
public FlexibleFloat trackPercent;
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
{
TrackPercentPoint point = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
point.NewInitialize(elementName, track, trackPercent);
point.SetParent(track);
return point;
}
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
{
base.NewInitialize(elementName);
this.track = track;
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
this.trackPositioner.spline = track.trackPathSubmodule.path;
this.trackPercent = trackPercent;
}
public void Update()
{
if (trackPercent.animations.Count > 0)
{
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
{
trackPositioner.SetPercent(trackPercent.value);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6150424209395469db7104ccaa18bffd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -11,25 +11,29 @@ namespace Ichni.RhythmGame
public Track track;
public MeshGenerator meshGenerator;
public MeshRenderer meshRenderer;
public Material renderMaterial;
}
public class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule
{
public SplineRenderer splineRenderer;
public void NewInitialize(Track track)
public void NewInitialize(Track track, Material material = null)
{
this.track = track;
this.track.trackRendererSubmodule = this;
this.splineRenderer = track.AddComponent<SplineRenderer>();
this.meshRenderer = splineRenderer.GetComponent<MeshRenderer>();
this.meshGenerator = splineRenderer;
this.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrackMaterial : material;
this.splineRenderer.spline = track.trackPathSubmodule.path;
this.splineRenderer.clipFrom = 0;
this.splineRenderer.clipTo = 1;
this.meshRenderer.material = renderMaterial;
Debug.Log(splineRenderer.clipFrom + " " + splineRenderer.clipTo);
this.splineRenderer.color = Color.white;
}
public override void InitialRefresh()
{
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)

View File

@@ -37,9 +37,7 @@ namespace Ichni.RhythmGame
headPercent = GetTrackPercent(songTime);
tailPercent = GetTrackPercent(songTime - visibleTrackTimeLength);
Debug.Log("Head: " + headPercent + " Tail: " + tailPercent);
if (track.trackRendererSubmodule != null)
{
track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent;