mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
EntitySystem
EntitySystem
This commit is contained in:
@@ -52,8 +52,7 @@ namespace TEngine.EntityModule
|
|||||||
internal List<ILateUpdate> LateUpdates = new List<ILateUpdate>();
|
internal List<ILateUpdate> LateUpdates = new List<ILateUpdate>();
|
||||||
internal bool InActive;
|
internal bool InActive;
|
||||||
internal bool CanUpdate;
|
internal bool CanUpdate;
|
||||||
internal bool CanFixedUpdate;
|
|
||||||
internal bool CanLateUpdate;
|
|
||||||
public int Index { get; set; } = -1;
|
public int Index { get; set; } = -1;
|
||||||
public Entity()
|
public Entity()
|
||||||
{
|
{
|
||||||
|
@@ -18,8 +18,6 @@ namespace TEngine.EntityModule
|
|||||||
|
|
||||||
CanUpdate = Updates.Count > 0;
|
CanUpdate = Updates.Count > 0;
|
||||||
|
|
||||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
|
||||||
|
|
||||||
Destroy(component);
|
Destroy(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +37,7 @@ namespace TEngine.EntityModule
|
|||||||
FixedUpdates.Add(fixedUpdate);
|
FixedUpdates.Add(fixedUpdate);
|
||||||
}
|
}
|
||||||
CanUpdate = Updates.Count > 0;
|
CanUpdate = Updates.Count > 0;
|
||||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +56,6 @@ namespace TEngine.EntityModule
|
|||||||
FixedUpdates.Add(fixedUpdate);
|
FixedUpdates.Add(fixedUpdate);
|
||||||
}
|
}
|
||||||
CanUpdate = Updates.Count > 0;
|
CanUpdate = Updates.Count > 0;
|
||||||
CanFixedUpdate = FixedUpdates.Count > 0;
|
|
||||||
return component;
|
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
|
#endregion
|
||||||
|
|
||||||
#region Dispose
|
#region Dispose
|
||||||
|
Reference in New Issue
Block a user