mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
优化框架轮询逻辑 ,用脏数据构建Execute数组。
优化框架轮询逻辑 ,用脏数据构建Execute数组。
This commit is contained in:
@@ -19,6 +19,7 @@ namespace TEngine
|
|||||||
private static readonly GameFrameworkLinkedList<ModuleImp> _modules = new GameFrameworkLinkedList<ModuleImp>();
|
private static readonly GameFrameworkLinkedList<ModuleImp> _modules = new GameFrameworkLinkedList<ModuleImp>();
|
||||||
private static readonly GameFrameworkLinkedList<ModuleImp> _updateModules = new GameFrameworkLinkedList<ModuleImp>();
|
private static readonly GameFrameworkLinkedList<ModuleImp> _updateModules = new GameFrameworkLinkedList<ModuleImp>();
|
||||||
private static readonly List<ModuleImp> _updateExecuteList = new List<ModuleImp>(DesignModuleCount);
|
private static readonly List<ModuleImp> _updateExecuteList = new List<ModuleImp>(DesignModuleCount);
|
||||||
|
private static bool _isExecuteListDirty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所有游戏框架模块轮询。
|
/// 所有游戏框架模块轮询。
|
||||||
@@ -27,6 +28,12 @@ namespace TEngine
|
|||||||
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
/// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param>
|
||||||
public static void Update(float elapseSeconds, float realElapseSeconds)
|
public static void Update(float elapseSeconds, float realElapseSeconds)
|
||||||
{
|
{
|
||||||
|
if (_isExecuteListDirty)
|
||||||
|
{
|
||||||
|
_isExecuteListDirty = false;
|
||||||
|
BuildExecuteList();
|
||||||
|
}
|
||||||
|
|
||||||
int executeCount = _updateExecuteList.Count;
|
int executeCount = _updateExecuteList.Count;
|
||||||
for (int i = 0; i < executeCount; i++)
|
for (int i = 0; i < executeCount; i++)
|
||||||
{
|
{
|
||||||
@@ -150,11 +157,19 @@ namespace TEngine
|
|||||||
_updateModules.AddLast(moduleImp);
|
_updateModules.AddLast(moduleImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateExecuteList.Clear();
|
_isExecuteListDirty = true;
|
||||||
_updateExecuteList.AddRange(_updateModules);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleImp;
|
return moduleImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构造执行队列。
|
||||||
|
/// </summary>
|
||||||
|
private static void BuildExecuteList()
|
||||||
|
{
|
||||||
|
_updateExecuteList.Clear();
|
||||||
|
_updateExecuteList.AddRange(_updateModules);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user