mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
fix
This commit is contained in:
parent
f565499138
commit
b73101d18c
@ -88,7 +88,7 @@ namespace DCFApixels.DragonECS
|
||||
_subjects = new EcsSubject[128];
|
||||
_executors = new EcsQueryExecutor[128];
|
||||
|
||||
_components = new object[0];
|
||||
_components = new object[2];
|
||||
}
|
||||
public void Destroy()
|
||||
{
|
||||
@ -103,19 +103,6 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WorldComponent
|
||||
public T Get<T>() where T : class, new()
|
||||
{
|
||||
var result = _components[WorldMetaStorage.GetWorldComponentId<T>(_worldTypeID)];
|
||||
if(result == null)
|
||||
{
|
||||
result = new T();
|
||||
_components[WorldMetaStorage.GetWorldComponentId<T>(_worldTypeID)] = result;
|
||||
}
|
||||
return (T)result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ComponentInfo
|
||||
public int GetComponentID<T>() => WorldMetaStorage.GetComponentId<T>(_worldTypeID);
|
||||
public Type GetComponentType(int componentID) => WorldMetaStorage.GetComponentType(_worldTypeID, componentID);
|
||||
@ -155,16 +142,30 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public TExecutor GetExecutor<TExecutor>() where TExecutor : EcsQueryExecutor, new()
|
||||
{
|
||||
int id = WorldMetaStorage.GetExecutorId<TExecutor>(_worldTypeID);
|
||||
if (id >= _executors.Length)
|
||||
int index = WorldMetaStorage.GetExecutorId<TExecutor>(_worldTypeID);
|
||||
if (index >= _executors.Length)
|
||||
Array.Resize(ref _executors, _executors.Length << 1);
|
||||
if (_executors[id] == null)
|
||||
if (_executors[index] == null)
|
||||
{
|
||||
var executor = new TExecutor();
|
||||
executor.Initialize(this);
|
||||
_executors[id] = executor;
|
||||
_executors[index] = executor;
|
||||
}
|
||||
return (TExecutor)_executors[id];
|
||||
return (TExecutor)_executors[index];
|
||||
}
|
||||
public T Get<T>() where T : class, new()
|
||||
{
|
||||
int index = WorldMetaStorage.GetWorldComponentId<T>(_worldTypeID);
|
||||
if (index >= _components.Length)
|
||||
Array.Resize(ref _executors, _executors.Length << 1);
|
||||
|
||||
var result = _components[index];
|
||||
if (result == null)
|
||||
{
|
||||
result = new T();
|
||||
_components[index] = result;
|
||||
}
|
||||
return (T)result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user