mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
调整服务器逻辑
1、调整Entity.AddComponent方法添加的组件Id为父组件的Id。 2、增加了ISupportedSingleCollection和ISingleCollectionRoot接口. 3、增加了SingleCollection、用于把子组件保存到单独的数据库表的功能,配合ISupportedSingleCollection和ISingleCollectionRoot。
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
Reference in New Issue
Block a user