mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
EntitySystem
EntitySystem
This commit is contained in:
@@ -52,8 +52,7 @@ namespace TEngine.EntityModule
|
||||
internal List<ILateUpdate> LateUpdates = new List<ILateUpdate>();
|
||||
internal bool InActive;
|
||||
internal bool CanUpdate;
|
||||
internal bool CanFixedUpdate;
|
||||
internal bool CanLateUpdate;
|
||||
|
||||
public int Index { get; set; } = -1;
|
||||
public Entity()
|
||||
{
|
||||
|
@@ -18,8 +18,6 @@ namespace TEngine.EntityModule
|
||||
|
||||
CanUpdate = Updates.Count > 0;
|
||||
|
||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
||||
|
||||
Destroy(component);
|
||||
}
|
||||
|
||||
@@ -39,7 +37,7 @@ namespace TEngine.EntityModule
|
||||
FixedUpdates.Add(fixedUpdate);
|
||||
}
|
||||
CanUpdate = Updates.Count > 0;
|
||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
@@ -58,7 +56,6 @@ namespace TEngine.EntityModule
|
||||
FixedUpdates.Add(fixedUpdate);
|
||||
}
|
||||
CanUpdate = Updates.Count > 0;
|
||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
||||
return component;
|
||||
}
|
||||
|
||||
|
@@ -132,47 +132,6 @@ namespace TEngine.EntityModule
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新Entity物理系统
|
||||
/// </summary>
|
||||
/// <param name="worker">线程池是否并行</param>
|
||||
public void FixedUpdate(bool worker = false)
|
||||
{
|
||||
int count = Entities.Count;
|
||||
if (!worker)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (!Entities.Buckets[i])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Entities[i].CanFixedUpdate)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Entities[i].FixedUpdate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Parallel.For(0, count, i =>
|
||||
{
|
||||
if (!Entities.Buckets[i])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Entities[i].CanFixedUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Entities[i].FixedUpdate();
|
||||
});
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
|
Reference in New Issue
Block a user