调整服务器逻辑

1、调整Entity.AddComponent方法添加的组件Id为父组件的Id。
2、增加了ISupportedSingleCollection和ISingleCollectionRoot接口.
3、增加了SingleCollection、用于把子组件保存到单独的数据库表的功能,配合ISupportedSingleCollection和ISingleCollectionRoot。
This commit is contained in:
ALEXTANG
2023-07-24 16:49:23 +08:00
parent 846dc4d4bc
commit f8056aef32
11 changed files with 224 additions and 29 deletions

View File

@@ -321,7 +321,7 @@ namespace TEngine
public T AddComponent<T>() where T : Entity, new()
{
var entity = Create<T>(Scene.RouteId, false);
var entity = Create<T>(Id, Scene.RouteId, false);
AddComponent(entity);
EntitiesSystem.Instance.Awake(entity);
EntitiesSystem.Instance.StartUpdate(entity);
@@ -367,6 +367,12 @@ namespace TEngine
}
else
{
#if TENGINE_NET
if (component is ISupportedSingleCollection && component.Id != Id)
{
Log.Error($"component type :{component.GetType().FullName} for implementing ISupportedSingleCollection, it is required that the Id must be the same as the parent");
}
#endif
if (_tree == null)
{
_tree = DictionaryPool<Type, Entity>.Create();
@@ -404,6 +410,8 @@ namespace TEngine
#endregion
#region GetComponent
public DictionaryPool<Type, Entity> GetTree => _tree;
public T GetComponent<T>() where T : Entity, new()
{