Files
ichni_Official/Assets/Scripts/Game/Base/ProjectFiles/BeatmapContainer.cs
SoulliesOfficial 9fd5f098ab 设置扩展
2026-07-19 16:44:58 -04:00

88 lines
2.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
using UnityEngine.Events;
namespace Ichni.RhythmGame
{
public class BeatmapContainer : IBaseElement
{
public List<GameElement> gameElementList;
[NonSerialized]
public List<UnityAction> lowPriorityActions;
public BaseElement_BM matchedBM { get; set; }
public BeatmapContainer()
{
gameElementList = new List<GameElement>();
lowPriorityActions = new List<UnityAction>();
// UniRx Observable.EveryUpdate 已移除:低优先级操作由 ElementUpdateScheduler Phase 8 在 TickLate 中驱动
}
public void ExecuteLowPriorityActions()
{
if (lowPriorityActions.Count > 0)
{
lowPriorityActions.ForEach(low => low.Invoke());
lowPriorityActions.Clear();
}
}
/// <summary>
/// Rebuilds the list of elements whose active state is driven by a finite time duration.
/// This preserves the existing runtime filter, while avoiding a LINQ allocation during
/// every project load.
/// </summary>
public void RebuildRuntimeTimeDurations()
{
List<TimeDurationSubmodule> runtimeTimeDurations = GameManager.Instance.timeDurations;
runtimeTimeDurations.Clear();
float songLength = GameManager.Instance.songInformation.songLength;
for (int i = 0; i < gameElementList.Count; i++)
{
if (gameElementList[i] is not IHaveTimeDurationSubmodule timeDurationHost)
{
continue;
}
TimeDurationSubmodule timeDuration = timeDurationHost.timeDurationSubmodule;
if (timeDuration != null &&
(timeDuration.startTime > 0f || timeDuration.endTime < songLength))
{
runtimeTimeDurations.Add(timeDuration);
}
}
}
/// <summary>
/// Immediately applies the active state for the registered time-duration elements.
/// Used at loading-state boundaries so the first rendered frame already matches the
/// current song timeline.
/// </summary>
public void SyncRuntimeTimeDurationStates(float songTime)
{
List<TimeDurationSubmodule> runtimeTimeDurations = GameManager.Instance.timeDurations;
for (int i = 0; i < runtimeTimeDurations.Count; i++)
{
runtimeTimeDurations[i]?.DetectAndSwitchActiveState(songTime);
}
}
public void SetUpInspector()
{
throw new System.NotImplementedException();
}
public void Refresh()
{
throw new System.NotImplementedException();
}
}
}