扁平化优化更新
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Demo.Game
|
||||
public class RootObject : ScriptableObject
|
||||
{
|
||||
protected override bool IsSelfEnableUpdate => false;
|
||||
[Content] public List<ScriptableObject> UpdateChilds = new();
|
||||
[Content] public Dictionary<Type, List<ScriptableObject>> UpdateChilds = new();
|
||||
[Resources] public BasicAudioSystem audioSystem;
|
||||
|
||||
[Content] public GameController RootGameController;
|
||||
@@ -85,24 +85,30 @@ namespace Demo.Game
|
||||
{
|
||||
if (RootGameController.IsMain)
|
||||
{
|
||||
if (RootGameController.IsAutoPlay)
|
||||
return;
|
||||
if (RootGameController.MainAudio.IsPlaying() == false)
|
||||
return;
|
||||
// 更新缓存时间
|
||||
CurrentUpdateTickTimePoint = currentTime;
|
||||
// 将距离当前更近的输入调整到更靠前的位置
|
||||
InputCatch.Sort((x, y) => Mathf.Abs(x.TimePoint - currentTime).CompareTo(y.TimePoint - currentTime));
|
||||
if (InputCatch.Count > 50)
|
||||
InputCatch = InputCatch.GetRange(0, 50);
|
||||
if (tickType == TickType.Start)
|
||||
void foo()
|
||||
{
|
||||
InputCatch.Clear();
|
||||
if (RootGameController.IsAutoPlay)
|
||||
return;
|
||||
if (RootGameController.MainAudio.IsPlaying() == false)
|
||||
return;
|
||||
// 更新缓存时间
|
||||
CurrentUpdateTickTimePoint = currentTime;
|
||||
// 将距离当前更近的输入调整到更靠前的位置
|
||||
InputCatch.Sort((x, y) => Mathf.Abs(x.TimePoint - currentTime).CompareTo(y.TimePoint - currentTime));
|
||||
if (InputCatch.Count > 50)
|
||||
InputCatch = InputCatch.GetRange(0, 50);
|
||||
if (tickType == TickType.Start)
|
||||
{
|
||||
InputCatch.Clear();
|
||||
}
|
||||
}
|
||||
foo();
|
||||
}
|
||||
foreach (var item in UpdateChilds)
|
||||
foreach (var (type, items) in UpdateChilds)
|
||||
{
|
||||
item.ScriptUpdate(currentTime, deltaTime, tickType);
|
||||
using (Profiler.BeginZone($"{type.Name}.ScriptUpdate"))
|
||||
foreach (var item in items)
|
||||
item.ScriptUpdate(currentTime, deltaTime, tickType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user