添加了授权

This commit is contained in:
CortexCore
2023-09-21 03:49:27 +08:00
parent c59d513cca
commit c65fe87a6c
10 changed files with 317 additions and 20 deletions

View File

@@ -51,6 +51,7 @@ public partial class Entity : Node,IEntity
public override void _ExitTree()
{
_cancellationTokenSource.Cancel();
_entitiesService.UnRegister(this);
}
/// <summary>
@@ -95,6 +96,8 @@ public partial class Entity : Node,IEntity
this._components = entityComponents.ToArray();
SetMeta("Components",Variant.From(_components.Select(x=>x.GetType().Name).ToArray()));
}
public bool TryGetComponent<T>(out T component)
{
if (TypeComponents.TryGetValue(typeof(T), out var iComponent) && iComponent is T _component)
@@ -105,14 +108,6 @@ public partial class Entity : Node,IEntity
component = default;
return false;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_entitiesService.UnRegister(this);
}
}
public bool RegisterComponent<T>(T component)
{