This commit is contained in:
CortexCore
2023-08-18 11:03:06 +08:00
parent 0cee02523b
commit 003fff50fa
16 changed files with 36 additions and 22 deletions

View File

@@ -22,7 +22,6 @@ public partial class BITAppForGodot : Node
BIT4Log.OnWarning += GD.PushWarning;
BIT4Log.OnNextLine += () => GD.Print();
BIT4Log.OnException += x=>GD.PrintErr(x.ToString());
BIT4Log.UseLogTime();
//启动BITApp
BITApp.Start(ProjectSettings.GetSetting("application/config/name").AsString());

View File

@@ -17,7 +17,7 @@ public partial class Exec : Node
}
else
{
BIT4Log.Warnning<Exec>($"未加载:{path}");
BIT4Log.Warning<Exec>($"未加载:{path}");
}
}
}

View File

@@ -18,6 +18,8 @@ public partial class GodotEntitiesService : Node,IEntitiesService
}
private readonly Dictionary<ulong,IEntity> _entities=new ();
private CancellationTokenSource _cancellationTokenSource;
public event Action<IEntity> OnAdd;
public event Action<IEntity> OnRemove;
public IEntity[] Entities => _entities.Values.ToArray();
public bool Register(IEntity entity)
{
@@ -40,11 +42,28 @@ public partial class GodotEntitiesService : Node,IEntitiesService
public CancellationToken CancellationToken => _cancellationTokenSource.Token;
public IEntity Get(ulong id)
{
throw new NotImplementedException();
}
public IEntity[] Query<T>() where T : IEntityComponent
{
return _entities.Values.Where(x => x.TryGetComponent<T>(out _)).ToArray();
}
T[] IEntitiesService.QueryComponents<T>()
{
return _entities.Values
.Where(x => x.TryGetComponent<T>(out _))
.Select(x =>
{
var component = x.Components.Single(x => x is T);
return (T)component;
})
.ToArray();
}
public ValueTuple<T>[] QueryComponents<T>() where T : IEntityComponent
{
return _entities.Values
@@ -59,16 +78,6 @@ public partial class GodotEntitiesService : Node,IEntitiesService
}
public (T, T1)[] QueryComponents<T, T1>() where T : IEntityComponent where T1 : IEntityComponent
{
// return _entities.Values
// .Where(x => x.TryGetComponent<T>(out _) && x.TryGetComponent<T1>(out _))
// .Select(x =>
// {
// var component = (T)x.Components.Single(x => x is T);
// var component1 = (T1)x.Components.Single(x => x is T1);
// (T, T1) value = new(component, component1);
// return value;
// })
// .ToArray();
var entities = _entities.Values.Where(x => x.TryGetComponent<T>(out _) && x.TryGetComponent<T1>(out _));
var result = new List<(T, T1)>();
foreach (var entity in entities)

View File

@@ -23,7 +23,7 @@ public static class LabelExtensions
}
catch (Exception)
{
BIT4Log.Warnning(path);
BIT4Log.Warning(path);
throw;
}

View File

@@ -71,7 +71,7 @@ public partial class HttpGet : Node,IActivable
}
catch (InvalidOperationException)
{
BIT4Log.Warnning(url);
BIT4Log.Warning(url);
//返回并发数量
limitConcurrent.Release();
}