@@ -61,11 +61,13 @@ namespace Ichni.RhythmGame
|
||||
if (this is IHaveTransformSubmodule transformSource && !GameManager.Instance.activeTransformSubmodules.Contains(transformSource))
|
||||
{
|
||||
GameManager.Instance.activeTransformSubmodules.Add(transformSource);
|
||||
CoreServices.UpdateScheduler?.RegisterDirtyTransform(transformSource);
|
||||
}
|
||||
|
||||
if (this is IHaveColorSubmodule colorSource && !GameManager.Instance.activeColorSubmodules.Contains(colorSource))
|
||||
{
|
||||
GameManager.Instance.activeColorSubmodules.Add(colorSource);
|
||||
CoreServices.UpdateScheduler?.RegisterDirtyColor(colorSource);
|
||||
}
|
||||
|
||||
if (this is IHaveDirtyMarkSubmodule dirtySource && !GameManager.Instance.activeDirtyMarkSubmodules.Contains(dirtySource))
|
||||
@@ -177,10 +179,12 @@ namespace Ichni.RhythmGame
|
||||
if (this is IHaveTransformSubmodule transformSource)
|
||||
{
|
||||
GameManager.Instance.activeTransformSubmodules.Remove(transformSource);
|
||||
CoreServices.UpdateScheduler?.UnregisterDirtyTransform(transformSource);
|
||||
}
|
||||
if (this is IHaveColorSubmodule colorSource)
|
||||
{
|
||||
GameManager.Instance.activeColorSubmodules.Remove(colorSource);
|
||||
CoreServices.UpdateScheduler?.UnregisterDirtyColor(colorSource);
|
||||
}
|
||||
if (this is IHaveDirtyMarkSubmodule dirtySource)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IScheduledElement
|
||||
public partial class Track : GameElement, IHaveTransformSubmodule, IHaveTimeDurationSubmodule, IScheduledElement, IHaveDirtyMarkSubmodule
|
||||
{
|
||||
#region [暴露属性字段] Essential Configs
|
||||
public GameObject trackRenderer;
|
||||
@@ -22,6 +22,8 @@ namespace Ichni.RhythmGame
|
||||
public TrackPathSubmodule trackPathSubmodule { get; set; }
|
||||
public TrackTimeSubmodule trackTimeSubmodule { get; set; }
|
||||
public TrackRendererSubmodule trackRendererSubmodule { get; set; }
|
||||
public DirtyMarkSubmodule dirtyMarkSubmodule { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region [生命周期] Lifecycle & Factory
|
||||
@@ -36,34 +38,37 @@ namespace Ichni.RhythmGame
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
|
||||
public override void SetDefaultSubmodules()
|
||||
{
|
||||
transformSubmodule = new TransformSubmodule(this);
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||||
trackPathSubmodule = new TrackPathSubmodule(this, TrackSpaceType.CatmullRom, TrackSamplingType.TimeDistributed, false, false);
|
||||
dirtyMarkSubmodule = new DirtyMarkSubmodule(this);
|
||||
trackTimeSubmodule = null;
|
||||
trackRendererSubmodule = null;
|
||||
}
|
||||
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
base.AfterInitialize();
|
||||
|
||||
|
||||
// 保留 TrackManager 注册以维持 ManualLateUpdate 的 refreshedThisFrame 清除逻辑
|
||||
GameManager.Instance.trackManager.RegisterTrack(this);
|
||||
// 注册调度器 Phase 4(TrackCore)驱动 ManualUpdate
|
||||
CoreServices.UpdateScheduler.Register(UpdatePhase.TrackCore, this);
|
||||
CoreServices.UpdateScheduler.RegisterTrackSpline(this);
|
||||
|
||||
if (trackPathSubmodule != null && trackPathSubmodule.pathNodeList.Count > 3)
|
||||
|
||||
if (trackPathSubmodule != null)
|
||||
{
|
||||
trackPathSubmodule.ClosePath();
|
||||
if (trackPathSubmodule.pathNodeList.Count > 3) trackPathSubmodule.ClosePath();
|
||||
|
||||
}
|
||||
|
||||
if(trackRendererSubmodule != null)
|
||||
if (trackRendererSubmodule != null)
|
||||
{
|
||||
trackRendererSubmodule.meshGenerator.autoUpdate = true;
|
||||
trackRendererSubmodule.meshGenerator.autoUpdate =
|
||||
GameManager.Instance.trackManager.EnableTrackAutoUpdate;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -79,7 +84,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public void ManualLateUpdate()
|
||||
{
|
||||
if(trackPathSubmodule != null) trackPathSubmodule.refreshedThisFrame = false;
|
||||
if (trackPathSubmodule != null) trackPathSubmodule.refreshedThisFrame = false;
|
||||
}
|
||||
|
||||
#region [IScheduledElement] Scheduler Interface
|
||||
@@ -88,7 +93,8 @@ namespace Ichni.RhythmGame
|
||||
ManualUpdate(songTime);
|
||||
}
|
||||
|
||||
public bool IsScheduledActive => isActiveAndEnabled;
|
||||
public override bool IsScheduledActive => isActiveAndEnabled;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
@@ -108,6 +114,11 @@ namespace Ichni.RhythmGame
|
||||
CoreServices.UpdateScheduler.UnregisterTrackSpline(this);
|
||||
if (parentElement is ElementFolder folder) folder.trackList.Remove(this);
|
||||
}
|
||||
|
||||
public void OnDirtyRefresh(Dictionary<string, bool> flags)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
this.path.sampleRate = 8;
|
||||
this.path.updateMode = SplineComputer.UpdateMode.LateUpdate;
|
||||
this.path.enabled = false;
|
||||
SetUpSplineComputer(this.trackSpaceType, this.trackSamplingType);
|
||||
//闭合路径在PathNode生成时执行,在初始化的情况下,PathNode数量为0,不会执行闭合操作
|
||||
|
||||
@@ -109,4 +110,4 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ namespace Ichni.RhythmGame
|
||||
this.materialThemeBundleName = materialThemeBundleName;
|
||||
this.materialName = materialName;
|
||||
Material mat = ThemeBundleManager.instance.GetObject<Material>(materialThemeBundleName, materialName);
|
||||
if(mat != null)
|
||||
if (mat != null)
|
||||
{
|
||||
renderMaterial = mat;
|
||||
meshRenderer.material = renderMaterial;
|
||||
}
|
||||
|
||||
|
||||
meshRenderer.InitializeShader();
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
track.dirtyMarkSubmodule?.MarkDirty();
|
||||
/*if (forceImmediateRebuild)
|
||||
{
|
||||
meshGenerator.RebuildImmediate();
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace Ichni.RhythmGame
|
||||
this.uvMode = MeshGenerator.UVMode.UniformClip;
|
||||
|
||||
SetMesh();
|
||||
this.splineRenderer.enabled = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace Ichni.RhythmGame
|
||||
this.uvMode = MeshGenerator.UVMode.UniformClip;
|
||||
|
||||
SetMesh();
|
||||
this.pathGenerator.enabled = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Ichni.RhythmGame
|
||||
this.surface.uvMode = MeshGenerator.UVMode.UniformClip;
|
||||
|
||||
SetMesh();
|
||||
this.surface.enabled = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Ichni.RhythmGame
|
||||
this.tubeGenerator.uvMode = MeshGenerator.UVMode.UniformClip;
|
||||
|
||||
SetMesh();
|
||||
this.tubeGenerator.enabled = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Ichni.RhythmGame
|
||||
return Mathf.Clamp01(per);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region [行为重写] Behavior Overrides
|
||||
public override void Refresh()
|
||||
{
|
||||
@@ -149,7 +149,7 @@ namespace Ichni.RhythmGame
|
||||
//timeDurationSubmodule 根据下辖Note的时间来设置
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region [行为重写] Behavior Overrides
|
||||
public override void Refresh()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user