1
This commit is contained in:
@@ -28,6 +28,12 @@ public partial class Entity : Node,IEntity
|
||||
/// 所有EntityComponent
|
||||
/// </summary>
|
||||
IEntityComponent[] IEntity.Components => Components.OfType<IEntityComponent>().ToArray();
|
||||
|
||||
public void WaitForInitializationComplete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IEntity.Id实现
|
||||
/// </summary>
|
||||
|
@@ -48,6 +48,22 @@ public partial class GodotEntitiesService : Node,IEntitiesService
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetEntity(ulong id, out IEntity entity)
|
||||
{
|
||||
return _entities.TryGetValue(id, out entity);
|
||||
}
|
||||
|
||||
public IEntity GetOrAdd(ulong id, Func<ulong, IEntity> factory)
|
||||
{
|
||||
if (_entities.TryGetValue(id, out var entity))
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
entity = factory(id);
|
||||
Register(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public IEntity[] Query<T>()
|
||||
{
|
||||
return _entities.Values.Where(x => x.TryGetComponent<T>(out _)).ToArray();
|
||||
|
Reference in New Issue
Block a user