This commit is contained in:
SoulliesOfficial
2026-06-05 04:45:57 -04:00
parent 3a63641a2c
commit 7c60c40d6b
377 changed files with 10970 additions and 843 deletions

View File

@@ -5,7 +5,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public abstract partial class AnimationBase : GameElement, IHaveTimeDurationSubmodule
public abstract partial class AnimationBase : GameElement, IHaveTimeDurationSubmodule, IScheduledElement
{
#region [] Attributes & Related Objects
public GameElement animatedObject;
@@ -27,8 +27,7 @@ namespace Ichni.RhythmGame
{
base.AfterInitialize();
// 【新增】受管家管控
GameManager.Instance.animationManager.RegisterAnimation(this);
CoreServices.UpdateScheduler.Register(UpdatePhase.Animation, this);
float delay = GameManager.Instance.songInformation.delay;
if (timeDurationSubmodule.CheckTimeInDuration(-delay))
{
@@ -36,6 +35,12 @@ namespace Ichni.RhythmGame
}
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Animation, this);
}
/// <summary>
/// 更新动画
/// </summary>
@@ -51,10 +56,19 @@ namespace Ichni.RhythmGame
if (timeDurationSubmodule.CheckAfterEndTime(currentSongTime))
{
GameManager.Instance.animationManager.UnregisterAnimation(this);
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Animation, this);
}
}
#region [IScheduledElement] Scheduler Interface
public virtual void ScheduledUpdate(UpdatePhase phase, float songTime)
{
ManualUpdate(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
/// <summary>
/// 施加时间偏移即移动所有Flexible参数的时间
/// </summary>

View File

@@ -44,7 +44,7 @@ namespace Ichni.RhythmGame
if (forceUpdate || fieldOfView.returnType == FlexibleReturnType.MiddleExecuting)
{
targetGameCamera.perspectiveAngle = fieldOfView.value;
targetGameCamera.cam.fieldOfView = fieldOfView.value;
targetGameCamera.RefreshFOV();
}
}

View File

@@ -1,7 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UnityEngine;
namespace Ichni.RhythmGame
@@ -89,32 +87,4 @@ namespace Ichni.RhythmGame
#endregion
}
}
namespace Ichni.RhythmGame.Beatmap
{
public class TrackGlobalColorChange_BM : AnimationBase_BM
{
public FlexibleFloat_BM colorR, colorG, colorB, colorA;
public TrackGlobalColorChange_BM()
{
}
public TrackGlobalColorChange_BM(string elementName, Guid elementGuid, List<string> tags,
GameElement_BM attachedElement, FlexibleFloat_BM colorR, FlexibleFloat_BM colorG, FlexibleFloat_BM colorB, FlexibleFloat_BM colorA)
: base(elementName, elementGuid, tags, attachedElement)
{
this.colorR = colorR;
this.colorG = colorG;
this.colorB = colorB;
this.colorA = colorA;
}
public override void ExecuteBM()
{
matchedElement = TrackGlobalColorChange.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
colorR.ConvertToGameType(), colorG.ConvertToGameType(), colorB.ConvertToGameType(), colorA.ConvertToGameType());
}
}
}

View File

@@ -45,16 +45,44 @@ namespace Ichni.RhythmGame
public override void AfterInitialize()
{
base.AfterInitialize();
// 注册 Phase 7Effect确保在 Track/TrackFollowerPhase 4/5和 NotePhase 6
// 全部更新完毕后再计算旋转覆盖,避免因位置尚未就绪导致的旋转抖动
CoreServices.UpdateScheduler.Register(UpdatePhase.Effect, this);
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
}
public override void ManualUpdate(float songTime, bool forceUpdate = false)
{
base.ManualUpdate(songTime, forceUpdate);
// 动画结束时同步注销 Phase 7
if (timeDurationSubmodule.CheckAfterEndTime(songTime))
{
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
}
}
#endregion
#region [] Core Animation Logic
void LateUpdate()
public override void ScheduledUpdate(UpdatePhase phase, float songTime)
{
if (enabling.value)
switch (phase)
{
(animatedObject as IHaveTransformSubmodule)?.UpdateLookAt(this);
case UpdatePhase.Animation:
base.ScheduledUpdate(phase, songTime);
break;
case UpdatePhase.Effect:
// 在所有 Track/TrackFollower/Note 位置更新完毕后覆盖旋转
if (enabling.value)
{
(animatedObject as IHaveTransformSubmodule)?.UpdateLookAt(this);
}
break;
}
}

View File

@@ -1,25 +1,31 @@
namespace Ichni.RhythmGame
{
/// <summary>
/// 轻量级核心服务定位器,允许游戏编辑器分别注册自己的时间引擎
/// 轻量级核心服务定位器,允许游戏本体与谱面编辑器分别注册自己的时间引擎
/// </summary>
public static class CoreServices
{
public static ISongTimeProvider TimeProvider { get; set; }
/// <summary>
/// 集中式元素更新调度器。
/// 所有 GameElement 子类应通过此属性访问调度器进行 Register / Unregister
/// 而非直接引用 EditorManager 或 GameManager。
/// </summary>
public static ElementUpdateScheduler UpdateScheduler { get; set; }
}
/// <summary>
/// 全局时间供应器接口
/// 无论是在游戏本体还是在谱面编辑器,一切与时间强相关的运作(特效、生成、判定
/// 全局时间供应器接口
/// 无论是在游戏本体还是在谱面编辑器,一切与时间强相关的运作(特效、动画、生成)
/// 只能依赖此接口,严禁直接调用 GameManager
/// </summary>
public interface ISongTimeProvider
{
/// <summary>当前音频的播放进度时间 (秒)</summary>
/// <summary>当前音频的播放进度时间(秒),已扣除 offset</summary>
float SongTime { get; }
/// <summary>当前时间轴是否处于流转播放状态</summary>
bool IsPlaying { get; }
}
}
}

View File

@@ -0,0 +1,22 @@
namespace Ichni.RhythmGame
{
/// <summary>
/// 所有参与集中更新调度的元素需实现的接口。
/// 同一元素可注册到多个 <see cref="UpdatePhase"/>
/// 通过 <paramref name="phase"/> 参数区分当前所处阶段并执行对应逻辑。
/// </summary>
public interface IScheduledElement
{
/// <summary>
/// 由 <see cref="ElementUpdateScheduler"/> 在对应阶段调用。
/// </summary>
/// <param name="phase">当前执行的更新阶段</param>
/// <param name="songTime">当前音频播放时间(秒)</param>
void ScheduledUpdate(UpdatePhase phase, float songTime);
/// <summary>
/// 元素是否处于活跃状态。调度器跳过非活跃元素以节省开销。
/// </summary>
bool IsScheduledActive { get; }
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8b0489cd9b9f44b4f9a7c73cf2b07de2

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using Ichni.RhythmGame.Beatmap;
using UniRx;
using UnityEngine;
using UnityEngine.Events;
@@ -21,7 +20,7 @@ namespace Ichni.RhythmGame
{
gameElementList = new List<GameElement>();
lowPriorityActions = new List<UnityAction>();
Observable.EveryUpdate().Subscribe(_ => ExecuteLowPriorityActions());
// UniRx Observable.EveryUpdate 已移除:低优先级操作由 ElementUpdateScheduler Phase 8 在 TickLate 中驱动
}
public void ExecuteLowPriorityActions()

View File

@@ -0,0 +1,38 @@
namespace Ichni.RhythmGame
{
/// <summary>
/// 集中式更新调度器的阶段定义。
/// 每帧按数值升序执行,保证严格的依赖顺序:
/// 动画先于变换应用 → 变换先于 Spline 重建 → 轨道先于音符。
/// 数值留有间隔,便于未来插入新阶段。
/// </summary>
public enum UpdatePhase
{
/// <summary>判定元素激活/隐藏状态</summary>
TimeDuration = 0,
/// <summary>更新动画值,设置脏标记</summary>
Animation = 10,
/// <summary>执行 DirtyRefresh + Transform + Color</summary>
Apply = 20,
/// <summary>手动重建 Dreamteck SplineComputer同时执行 LookAt 等 Transform 后处理覆盖</summary>
SplineRebuild = 30,
/// <summary>更新轨道时间、裁剪区间</summary>
TrackCore = 40,
/// <summary>更新轨道跟踪器CrossTrackPoint / HeadPoint / PercentPoint 等)</summary>
TrackFollower = 50,
/// <summary>音符可见性、轨道位置、判定、特效</summary>
Note = 60,
/// <summary>ParticleEmitter / TimeEffectsCollection / ParticleTracker 等特效</summary>
Effect = 70,
/// <summary>SkyboxSubsetter / LowPriorityActions 等杂项</summary>
Misc = 80
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5b8c1372937779c4ab43eeddbce7cf29

View File

@@ -1,18 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dodger : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -6,7 +6,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class SkyboxSubsetter : GameElement
public partial class SkyboxSubsetter : GameElement, IScheduledElement
{
#region [] Core Components & Skybox Lists
public SkyboxBlender skyboxBlender;
@@ -46,6 +46,18 @@ namespace Ichni.RhythmGame
skyboxSubsetter.selectedSkybox = String.Empty;
return skyboxSubsetter;
}
public override void AfterInitialize()
{
base.AfterInitialize();
CoreServices.UpdateScheduler.Register(UpdatePhase.Misc, this);
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Misc, this);
}
#endregion
#region [] Internal Configs & Utils
@@ -81,28 +93,31 @@ namespace Ichni.RhythmGame
#endregion
#region [] Main Update
private void Update()
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
if (skyBoxThemeBundleList.Count > 1)
{
float songTime = CoreServices.TimeProvider.SongTime;
float delay = GameManager.Instance.songInformation.delay;
float finalTime = 32767; // 曲目长度
const float finalTime = 32767f; // 曲目长度上限
for (var index = 0; index < blendTimeList.Count + 1; index++)
{
float startTime = index == 0 ? -delay : blendTimeList[index - 1];
float endTime = index >= blendTimeList.Count ? finalTime : blendTimeList[index];
if(songTime >= startTime && songTime < endTime && currentSkyboxIndex != index)
if (songTime >= startTime && songTime < endTime && currentSkyboxIndex != index)
{
currentSkyboxIndex = index;
if(currentSkyboxIndex != 0) skyboxBlender.blendSpeed = blendSpeedList[currentSkyboxIndex - 1];
if (currentSkyboxIndex != 0) skyboxBlender.blendSpeed = blendSpeedList[currentSkyboxIndex - 1];
skyboxBlender.Blend(currentSkyboxIndex, false);
DynamicGI.UpdateEnvironment();
}
}
}
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
#endregion
}

View File

@@ -25,6 +25,12 @@ namespace Ichni.RhythmGame
public float orthographicSize;
public float perspectiveOffset;
public float zoomOffset; // 用于效果如CameraZoomEffect的临时视野偏移
public void RefreshFOV()
{
cam.fieldOfView = perspectiveAngle + perspectiveOffset + zoomOffset;
}
#endregion
#region [] Submodules & References
@@ -54,14 +60,14 @@ namespace Ichni.RhythmGame
float ratioDifference = UIManager.GetScreenRatio() - UIManager.StandardRatio;
if (ratioDifference > 0)
{
gameCamera.perspectiveOffset = -22f * ratioDifference;
//gameCamera.perspectiveOffset = 12.5f * ratioDifference;
}
else
{
//gameCamera.perspectiveOffset = 11f * ratioDifference;
gameCamera.perspectiveOffset = -25f * ratioDifference;
}
gameCamera.cam.fieldOfView = perspectiveAngle + gameCamera.perspectiveOffset;
gameCamera.RefreshFOV();
return gameCamera;
}

View File

@@ -7,7 +7,7 @@ using Object = UnityEngine.Object;
namespace Ichni.RhythmGame
{
public partial class ParticleEmitter : GameElement, IHaveParticles, IHaveTimeDurationSubmodule, IHaveTransformSubmodule, IHaveColorSubmodule
public partial class ParticleEmitter : GameElement, IHaveParticles, IHaveTimeDurationSubmodule, IHaveTransformSubmodule, IHaveColorSubmodule, IScheduledElement
{
#region [] Essential Configs
public string themeBundleName;
@@ -85,15 +85,26 @@ namespace Ichni.RhythmGame
transformSubmodule = new TransformSubmodule(this);
colorSubmodule = new ColorSubmodule(this, Color.white, true, Color.white, 0);
}
public override void AfterInitialize()
{
base.AfterInitialize();
CoreServices.UpdateScheduler.Register(UpdatePhase.Effect, this);
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
}
#endregion
}
#region [] Main Update & Behavior Overrides
public partial class ParticleEmitter
{
private void Update()
private void UpdateParticlePlayState(float songTime)
{
float songTime = CoreServices.TimeProvider.SongTime;
if (playTime > songTime || stopTime < songTime)
{
particle.Stop();
@@ -107,6 +118,15 @@ namespace Ichni.RhythmGame
}
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
UpdateParticlePlayState(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
public override void Refresh()
{
base.Refresh();

View File

@@ -8,12 +8,18 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TimeEffectsCollection : GameElement, IHaveTransformSubmodule, IHaveEffectSubmodule
public partial class TimeEffectsCollection : GameElement, IHaveTransformSubmodule, IHaveEffectSubmodule, IScheduledElement
{
#region [] Essential Configs
public float time; //触发效果的时间
#endregion
#region [] Cached Effect Lists
private List<EffectBase> _priorEffects;
private List<EffectBase> _defaultEffects;
private List<EffectBase> _lateEffects;
#endregion
#region [] Submodules
public TransformSubmodule transformSubmodule { get; set; }
public EffectSubmodule effectSubmodule { get; set; }
@@ -34,31 +40,55 @@ namespace Ichni.RhythmGame
transformSubmodule = new TransformSubmodule(this);
effectSubmodule = new EffectSubmodule(this);
}
public override void AfterInitialize()
{
base.AfterInitialize();
CacheEffectLists();
CoreServices.UpdateScheduler.Register(UpdatePhase.Effect, this);
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
}
/// <summary>
/// 缓存 effectCollection 中的 Prior/Default/Late 列表引用,
/// 避免 ScheduledUpdate 中每帧执行 Dictionary string key 查找。
/// </summary>
private void CacheEffectLists()
{
if (effectSubmodule?.effectCollection == null) return;
effectSubmodule.effectCollection.TryGetValue("Prior", out _priorEffects);
effectSubmodule.effectCollection.TryGetValue("Default", out _defaultEffects);
effectSubmodule.effectCollection.TryGetValue("Late", out _lateEffects);
}
#endregion
#region [] Main Update
private void Update()
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
if (!GameManager.Instance.songPlayer.isUpdating || effectSubmodule == null)
{
return;
}
if (effectSubmodule == null) return;
foreach (EffectBase effect in effectSubmodule.effectCollection["Prior"])
{
effect.UpdateEffect(time);
}
UpdateEffectList(_priorEffects, time);
UpdateEffectList(_defaultEffects, time);
UpdateEffectList(_lateEffects, time);
}
foreach (EffectBase effect in effectSubmodule.effectCollection["Default"])
private static void UpdateEffectList(List<EffectBase> effects, float effectTime)
{
if (effects == null) return;
for (int i = 0; i < effects.Count; i++)
{
effect.UpdateEffect(time);
}
foreach (EffectBase effect in effectSubmodule.effectCollection["Late"])
{
effect.UpdateEffect(time);
effects[i].UpdateEffect(effectTime);
}
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
#endregion
}

View File

@@ -42,7 +42,7 @@ namespace Ichni.RhythmGame
public override bool CheckJudgeAvailability(InputUnit inputUnit)
{
Vector2 inputScreenPosition = inputUnit.inputPosition;
Vector2 noteScreenPosition = note.GetScreenPosition();
Vector2 noteScreenPosition = note.noteScreenPosition != Vector2.zero ? note.noteScreenPosition : note.GetScreenPosition();
float scaledBaseRadius = areaRadius * CurrentScreenRatio;
float dx = Mathf.Abs(inputScreenPosition.x - noteScreenPosition.x) / ellipseXMultiplier;

View File

@@ -295,6 +295,7 @@ namespace Ichni.RhythmGame
protected virtual void ExecuteJudge(NoteJudgeType judgeType, float triggerTime)
{
isDuringJudging = false;
isFirstJudged = true;
judgedTriggerTime = triggerTime;
judgedType = judgeType;

View File

@@ -10,7 +10,7 @@ using UnityEngine.Serialization;
namespace Ichni.RhythmGame
{
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IScheduledElement
{
#region [] Essential Configs
public GameObject trackRenderer;
@@ -50,7 +50,11 @@ namespace Ichni.RhythmGame
{
base.AfterInitialize();
GameManager.Instance.trackManager.RegisterTrack(this);
// 保留 TrackManager 注册以维持 ManualLateUpdate 的 refreshedThisFrame 清除逻辑
GameManager.Instance.trackManager.RegisterTrack(this);
// 注册调度器 Phase 4TrackCore驱动 ManualUpdate
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackCore, this);
CoreServices.UpdateScheduler.RegisterTrackSpline(this);
if (trackPathSubmodule != null && trackPathSubmodule.pathNodeList.Count > 3)
{
@@ -77,6 +81,15 @@ namespace Ichni.RhythmGame
{
if(trackPathSubmodule != null) trackPathSubmodule.refreshedThisFrame = false;
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
ManualUpdate(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
#endregion
#region [] Behavior Overrides
@@ -91,6 +104,8 @@ namespace Ichni.RhythmGame
public override void OnDelete()
{
GameManager.Instance.trackManager.UnregisterTrack(this);
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackCore, this);
CoreServices.UpdateScheduler.UnregisterTrackSpline(this);
if (parentElement is ElementFolder folder) folder.trackList.Remove(this);
}
#endregion

View File

@@ -9,7 +9,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class CrossTrackPoint : GameElement, IHaveTimeDurationSubmodule
public partial class CrossTrackPoint : GameElement, IHaveTimeDurationSubmodule, IScheduledElement
{
#region [] Essential Configs
public ElementFolder trackListFolder;
@@ -45,10 +45,16 @@ namespace Ichni.RhythmGame
public override void AfterInitialize()
{
GameManager.Instance.trackManager.RegisterCrossPoint(this);
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackFollower, this);
base.AfterInitialize();
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
public override void SetDefaultSubmodules()
{
timeDurationSubmodule = new TimeDurationSubmodule(this);
@@ -68,11 +74,20 @@ namespace Ichni.RhythmGame
trackPercent.returnType == FlexibleReturnType.After)
{
trackPositioner.SetPercent(1);
GameManager.Instance.trackManager.UnregisterCrossPoint(this);
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
}
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
ManualUpdate(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
private void SetPoint()
{
if (nowAttachedTrackIndex != trackSwitch.value &&
@@ -82,6 +97,7 @@ namespace Ichni.RhythmGame
nowAttachedTrack = trackListFolder.trackList[trackSwitch.value];
nowAttachedTrackIndex = trackSwitch.value;
trackPositioner.spline = trackListFolder.trackList[trackSwitch.value].trackPathSubmodule.path;
trackPositioner.RebuildImmediate();
}
trackPositioner.SetPercent(trackPercent.value);

View File

@@ -8,7 +8,7 @@ using UnityEngine;
namespace Ichni.RhythmGame
{
public partial class TrackHeadPoint : GameElement, IHaveTimeDurationSubmodule
public partial class TrackHeadPoint : GameElement, IHaveTimeDurationSubmodule, IScheduledElement
{
#region [] Essential Configs
public Track track;
@@ -53,9 +53,15 @@ namespace Ichni.RhythmGame
public override void AfterInitialize()
{
GameManager.Instance.trackManager.RegisterHeadPoint(this);
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackFollower, this);
base.AfterInitialize();
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
#endregion
#region [] Main Update
@@ -68,9 +74,18 @@ namespace Ichni.RhythmGame
if(track.timeDurationSubmodule.CheckAfterEndTime(currentSongTime))
{
GameManager.Instance.trackManager.UnregisterHeadPoint(this);
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
ManualUpdate(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
#endregion
}

View File

@@ -13,7 +13,7 @@ namespace Ichni.RhythmGame
/// <summary>
/// 在轨道上根据百分比进行运动的点
/// </summary>
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule
public partial class TrackPercentPoint : GameElement, IHaveTimeDurationSubmodule, IScheduledElement
{
#region [] Essential Configs
public Track track;
@@ -52,9 +52,15 @@ namespace Ichni.RhythmGame
public override void AfterInitialize()
{
GameManager.Instance.trackManager.RegisterPercentPoint(this);
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackFollower, this);
base.AfterInitialize();
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
#endregion
#region [] Main Update
@@ -73,10 +79,19 @@ namespace Ichni.RhythmGame
if (trackPercent.returnType == FlexibleReturnType.After)
{
trackPositioner.SetPercent(1);
GameManager.Instance.trackManager.UnregisterPercentPoint(this);
CoreServices.UpdateScheduler.Unregister(UpdatePhase.TrackFollower, this);
}
}
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
ManualUpdate(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
#endregion
}

View File

@@ -65,14 +65,17 @@ namespace Ichni.RhythmGame
path.type = Spline.Type.Linear;
path.sampleRate = 1;
}
if (isClosed)
if (pathNodeList.Count >= 3)
{
path.Close();
}
else
{
path.Break();
if (isClosed)
{
path.Close();
}
else
{
path.Break();
}
}
}

View File

@@ -14,6 +14,11 @@ namespace Ichni.RhythmGame
public string materialThemeBundleName;
public string materialName;
public string customTextureThemeBundleName = "None";
public string customTextureName = "None";
public MeshGenerator.UVMode uvMode = MeshGenerator.UVMode.UniformClip;
public float uvRotation = 0f;
public float size = 1f;
public bool enableEmission;
public float emissionIntensity;
public bool zWrite;
@@ -86,6 +91,9 @@ namespace Ichni.RhythmGame
{
meshGenerator.uvScale = uvScale;
meshGenerator.uvOffset = uvOffset;
meshGenerator.uvRotation = uvRotation;
meshGenerator.uvMode = uvMode;
meshGenerator.size = size;
}
}
#endregion

View File

@@ -32,8 +32,8 @@ namespace Ichni.RhythmGame
this.splineRenderer.updateMethod = SplineUser.UpdateMethod.Update;
this.meshRenderer.material = renderMaterial;
this.splineRenderer.color = Color.white;
this.splineRenderer.uvRotation = 90;
this.splineRenderer.uvMode = MeshGenerator.UVMode.UniformClip;
this.uvRotation = 0f;
this.uvMode = MeshGenerator.UVMode.UniformClip;
SetMesh();
}

View File

@@ -31,8 +31,8 @@ namespace Ichni.RhythmGame
this.pathGenerator.updateMethod = SplineUser.UpdateMethod.Update;
this.meshRenderer.material = renderMaterial;
this.pathGenerator.color = Color.white;
this.pathGenerator.uvRotation = 90;
this.pathGenerator.uvMode = MeshGenerator.UVMode.UniformClip;
this.uvRotation = 90f;
this.uvMode = MeshGenerator.UVMode.UniformClip;
SetMesh();
}

View File

@@ -56,7 +56,10 @@ namespace Ichni.RhythmGame
{
track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent;
track.trackRendererSubmodule.meshGenerator.clipTo = headPercent;
track.trackRendererSubmodule.meshGenerator.RebuildImmediate();
}
//track.trackPathSubmodule.path.Rebuild(true);
}
public float GetTrackPercent(float songTimeInTime)

View File

@@ -1,18 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectTracker : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -8,7 +8,7 @@ using UnityEngine.Serialization;
namespace Ichni.RhythmGame
{
public partial class ParticleTracker : GameElement, IHaveParticles, IHaveColorSubmodule
public partial class ParticleTracker : GameElement, IHaveParticles, IHaveColorSubmodule, IScheduledElement
{
#region [] Essential Configs
public Track track;
@@ -66,6 +66,18 @@ namespace Ichni.RhythmGame
{
colorSubmodule = new ColorSubmodule(this, Color.white, true, Color.white, 0);
}
public override void AfterInitialize()
{
base.AfterInitialize();
CoreServices.UpdateScheduler.Register(UpdatePhase.Effect, this);
}
public override void OnDelete()
{
base.OnDelete();
CoreServices.UpdateScheduler.Unregister(UpdatePhase.Effect, this);
}
#endregion
#region [] Runtime Settings
@@ -91,9 +103,8 @@ namespace Ichni.RhythmGame
#region [] Main Update
public partial class ParticleTracker
{
private void Update()
private void UpdateParticlePlayState(float songTime)
{
float songTime = CoreServices.TimeProvider.SongTime;
if (playTime > songTime || stopTime < songTime)
{
particle.Stop();
@@ -106,6 +117,15 @@ namespace Ichni.RhythmGame
}
}
}
#region [IScheduledElement] Scheduler Interface
public void ScheduledUpdate(UpdatePhase phase, float songTime)
{
UpdateParticlePlayState(songTime);
}
public bool IsScheduledActive => isActiveAndEnabled;
#endregion
}
#endregion