EntitySystem

EntitySystem
This commit is contained in:
ALEXTANG
2022-08-08 16:06:36 +08:00
parent 0c51d17278
commit 1fd7e21981
3 changed files with 2 additions and 47 deletions

View File

@@ -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()
{

View File

@@ -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;
}

View File

@@ -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