更新
This commit is contained in:
@@ -114,9 +114,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public void SetColorObserver()
|
||||
{
|
||||
colorSubmodule.observer = Observable.EveryUpdate()
|
||||
.Subscribe(_ => UpdateColor())
|
||||
.AddTo(colorSubmodule.attachedGameElement);
|
||||
// 旧版的 UniRx 各自监听已淘汰,现由 GameManager 中枢在 LateUpdate 统一下发 UpdateColor()
|
||||
}
|
||||
|
||||
public void UpdateColor(bool refreshAll = true)
|
||||
|
||||
63
Assets/Scripts/Game/Components/DirtyMarkSubmodule.cs
Normal file
63
Assets/Scripts/Game/Components/DirtyMarkSubmodule.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class DirtyMarkSubmodule : SubmoduleBase
|
||||
{
|
||||
public bool isAnyDirty { get; private set; }
|
||||
public Dictionary<string, bool> dirtyFlags;
|
||||
|
||||
public DirtyMarkSubmodule(GameElement attachedGameElement) : base(attachedGameElement)
|
||||
{
|
||||
isAnyDirty = false;
|
||||
dirtyFlags = new Dictionary<string, bool>();
|
||||
|
||||
if (!HaveSameSubmodule && attachedGameElement is IHaveDirtyMarkSubmodule host)
|
||||
{
|
||||
host.dirtyMarkSubmodule = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkDirty(string flagKey = "All")
|
||||
{
|
||||
isAnyDirty = true;
|
||||
if (!string.IsNullOrEmpty(flagKey))
|
||||
{
|
||||
dirtyFlags[flagKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteDeferredRefresh()
|
||||
{
|
||||
if (isAnyDirty && attachedGameElement is IHaveDirtyMarkSubmodule host)
|
||||
{
|
||||
host.OnDirtyRefresh(dirtyFlags);
|
||||
ClearDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearDirty()
|
||||
{
|
||||
isAnyDirty = false;
|
||||
dirtyFlags.Clear();
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
MarkDirty("All");
|
||||
}
|
||||
|
||||
public override void CheckAndRemoveObservers() { }
|
||||
}
|
||||
|
||||
public interface IHaveDirtyMarkSubmodule
|
||||
{
|
||||
DirtyMarkSubmodule dirtyMarkSubmodule { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当有一帧收到来自于动画或者其它管理器的脏标记篡改时,在此方法中处理推送至具体表现层的工作。
|
||||
/// </summary>
|
||||
void OnDirtyRefresh(Dictionary<string, bool> flags);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5748988e564e7241ba2eaac6f9ad09d
|
||||
@@ -125,10 +125,8 @@ namespace Ichni.RhythmGame
|
||||
/// </summary>
|
||||
public void SetTransformObserver()
|
||||
{
|
||||
transformSubmodule.observer = Observable.EveryUpdate()
|
||||
.Where(_ => GameManager.Instance.songPlayer.isUpdating)
|
||||
.Subscribe(_ => UpdateTransform())
|
||||
.AddTo(transformSubmodule.attachedGameElement);
|
||||
// 旧版的 UniRx 各自监听已淘汰,现由 GameManager 中枢在 LateUpdate 统一下发 UpdateTransform()
|
||||
// 如果有一些特殊物体需要极其特殊时序,可覆盖此方法或手动管理
|
||||
}
|
||||
|
||||
public void UpdateTransform(bool refreshAll = true)
|
||||
|
||||
Reference in New Issue
Block a user