55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
|
using System.Threading;
|
||
|
|
||
|
namespace BITKit.Core.Entites
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 基本实体
|
||
|
/// </summary>
|
||
|
public interface IEntity
|
||
|
{
|
||
|
ulong Id { get; }
|
||
|
#if UNITY
|
||
|
#else
|
||
|
bool TryGetComponent<T>(out T component) where T : IEntityComponent;
|
||
|
IEntityComponent[] Components { get; }
|
||
|
bool RegisterComponent<T>(T component) where T : IEntityComponent;
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 基本实体组件
|
||
|
/// </summary>
|
||
|
public interface IEntityComponent:IAwake,IStart
|
||
|
{
|
||
|
IEntity Entity { get; set; }
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 基本实体服务
|
||
|
/// </summary>
|
||
|
public interface IEntitiesService
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 所有Entity
|
||
|
/// </summary>
|
||
|
IEntity[] Entities { get; }
|
||
|
/// <summary>
|
||
|
/// 注册Entity
|
||
|
/// </summary>
|
||
|
/// <param name="entity"></param>
|
||
|
/// <returns></returns>
|
||
|
bool Register(IEntity entity);
|
||
|
/// <summary>
|
||
|
/// 注销Entity
|
||
|
/// </summary>
|
||
|
/// <param name="entity"></param>
|
||
|
/// <returns></returns>
|
||
|
bool UnRegister(IEntity entity);
|
||
|
CancellationToken CancellationToken { get; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 查询Entity,例如
|
||
|
/// </summary>
|
||
|
/// <para>var rotationEntities=EntitiesService.Query<RotationComponent></para>
|
||
|
IEntity[] Query<T>() where T : IEntityComponent;
|
||
|
}
|
||
|
}
|