Files
TEngine/Assets/TEngine/Runtime/Entity/EntityComponent.cs
ALEXTANG 464d1b230c EntitySystem
EntitySystem
2022-08-08 17:01:52 +08:00

22 lines
792 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace TEngine.EntityModule
{
/// <summary>
/// Entity构架可以将此组件从Entity上移除这个组件并丢入对象池给其他此刻需要此组件的Entity使用
/// 因此可以节省大量的内存反复创建和释放, 这也是Entity的特性可以大量重复使用组件
/// </summary>
public class EntityComponent : EcsObject
{
public Entity Entity { get; set; }
#region Static
public static T Create<T>() where T : EntityComponent, new()
{
var entity = EntitySystem.Instance.CreateComponent<T>();
#if UNITY_EDITOR
TLogger.LogInfoSuccessd($"Create ID {entity.InstanceId} EntityComponent{ entity.ToString()}");
#endif
return entity;
}
#endregion
}
}