2026-03-14 02:30:26 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Ichni.RhythmGame;
|
|
|
|
|
|
using SLSUtilities.General;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编辑器 TrackManager:集中管理场上所有轨道相关组件的逐帧更新。
|
|
|
|
|
|
/// 替代各组件自身持有的 Update() 调用,消除大量零散的 MonoBehaviour 帧回调开销。
|
|
|
|
|
|
/// 通过 ManualTick() 由 EditorManager 统一调度,确保时序可控。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class TrackManager : Singleton<TrackManager>
|
|
|
|
|
|
{
|
|
|
|
|
|
#region [单例别名] Singleton Alias
|
|
|
|
|
|
public new static TrackManager instance => Instance;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region [活跃组件列表] Active Component Lists
|
|
|
|
|
|
private readonly List<Track> _activeTracks = new List<Track>(50);
|
|
|
|
|
|
private readonly List<CrossTrackPoint> _activeCrossPoints = new List<CrossTrackPoint>(50);
|
|
|
|
|
|
private readonly List<ObjectTracker> _activeObjectTrackers = new List<ObjectTracker>(50);
|
|
|
|
|
|
private readonly List<ParticleTracker> _activeParticleTrackers = new List<ParticleTracker>(50);
|
2026-04-05 03:14:24 -04:00
|
|
|
|
private readonly List<TrackHeadPoint> _activeHeadPoints = new List<TrackHeadPoint>(50);
|
|
|
|
|
|
private readonly List<TrackPercentPoint> _activePercentPoints = new List<TrackPercentPoint>(50);
|
2026-03-14 02:30:26 -04:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region [注册与注销] Registration
|
|
|
|
|
|
public void RegisterTrack(Track track)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activeTracks.Contains(track)) _activeTracks.Add(track);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterTrack(Track track) => _activeTracks.Remove(track);
|
|
|
|
|
|
|
|
|
|
|
|
public void RegisterCrossPoint(CrossTrackPoint point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activeCrossPoints.Contains(point)) _activeCrossPoints.Add(point);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterCrossPoint(CrossTrackPoint point) => _activeCrossPoints.Remove(point);
|
|
|
|
|
|
|
|
|
|
|
|
public void RegisterObjectTracker(ObjectTracker tracker)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activeObjectTrackers.Contains(tracker)) _activeObjectTrackers.Add(tracker);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterObjectTracker(ObjectTracker tracker) => _activeObjectTrackers.Remove(tracker);
|
|
|
|
|
|
|
|
|
|
|
|
public void RegisterParticleTracker(ParticleTracker tracker)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activeParticleTrackers.Contains(tracker)) _activeParticleTrackers.Add(tracker);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterParticleTracker(ParticleTracker tracker) => _activeParticleTrackers.Remove(tracker);
|
2026-04-05 03:14:24 -04:00
|
|
|
|
|
|
|
|
|
|
public void RegisterHeadPoint(TrackHeadPoint point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activeHeadPoints.Contains(point)) _activeHeadPoints.Add(point);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterHeadPoint(TrackHeadPoint point) => _activeHeadPoints.Remove(point);
|
|
|
|
|
|
|
|
|
|
|
|
public void RegisterPercentPoint(TrackPercentPoint point)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_activePercentPoints.Contains(point)) _activePercentPoints.Add(point);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void UnregisterPercentPoint(TrackPercentPoint point) => _activePercentPoints.Remove(point);
|
2026-03-14 02:30:26 -04:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region [中央集权主循环] Manager-Driven Tick
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 由 EditorManager.Update 统一调度。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void ManualTick(float songTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 1. Track:更新轨道时间子模块
|
|
|
|
|
|
for (int i = 0; i < _activeTracks.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var track = _activeTracks[i];
|
|
|
|
|
|
if (!track.isActiveAndEnabled) continue;
|
|
|
|
|
|
if (track.timeDurationSubmodule.CheckTimeInDuration(songTime))
|
|
|
|
|
|
{
|
|
|
|
|
|
(track.trackTimeSubmodule as TrackTimeSubmoduleMovable)?.UpdateTrackPart(songTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2. CrossTrackPoint:更新跨轨切分点
|
|
|
|
|
|
for (int i = 0; i < _activeCrossPoints.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var point = _activeCrossPoints[i];
|
|
|
|
|
|
if (!point.isActiveAndEnabled) continue;
|
|
|
|
|
|
point.ManualTick(songTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3. ObjectTracker:更新轨道物体跟踪器
|
|
|
|
|
|
for (int i = 0; i < _activeObjectTrackers.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tracker = _activeObjectTrackers[i];
|
|
|
|
|
|
if (!tracker.isActiveAndEnabled) continue;
|
|
|
|
|
|
tracker.ManualTick(songTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 4. ParticleTracker:更新轨道粒子跟踪器
|
|
|
|
|
|
for (int i = 0; i < _activeParticleTrackers.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tracker = _activeParticleTrackers[i];
|
|
|
|
|
|
if (!tracker.isActiveAndEnabled) continue;
|
|
|
|
|
|
tracker.ManualTick(songTime);
|
|
|
|
|
|
}
|
2026-04-05 03:14:24 -04:00
|
|
|
|
|
|
|
|
|
|
// 5. TrackHeadPoint:更新轨道头节点
|
|
|
|
|
|
for (int i = 0; i < _activeHeadPoints.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var point = _activeHeadPoints[i];
|
|
|
|
|
|
if (!point.isActiveAndEnabled) continue;
|
|
|
|
|
|
point.ManualTick(songTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 6. TrackPercentPoint:更新轨道百分比节点
|
|
|
|
|
|
for (int i = 0; i < _activePercentPoints.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var point = _activePercentPoints[i];
|
|
|
|
|
|
if (!point.isActiveAndEnabled) continue;
|
|
|
|
|
|
point.ManualTick(songTime);
|
|
|
|
|
|
}
|
2026-03-14 02:30:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|