fix changes

This commit is contained in:
Mikhail 2023-04-08 19:54:47 +08:00
parent b5f134845d
commit 7ccf23e137
3 changed files with 38 additions and 7 deletions

View File

@ -246,7 +246,7 @@ namespace DCFApixels.DragonECS
#endregion
#region Enumerator
public struct Enumerator : IDisposable
public ref struct Enumerator
{
private readonly EcsGroup _source;
private readonly int[] _dense;

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
@ -11,8 +12,9 @@ namespace DCFApixels.DragonECS
private IEcsPool[] _pools;
private EcsNullPool _nullPool;
private int[] _denseEntities;
private int[] _sparceEntities;
private short[] _gens;
private short[] _componentCounts;
private int _entitiesCount;
private List<EcsQueryBase>[] _filtersByIncludedComponents;
@ -22,12 +24,42 @@ namespace DCFApixels.DragonECS
private List<EcsGroup> _groups;
#region Internal Properties
#region Properties
public int Count => _entitiesCount;
public int Capacity => _denseEntities.Length;
public int Capacity => _gens.Length;
public ReadOnlySpan<IEcsPool> GetAllPools() => new ReadOnlySpan<IEcsPool>(_pools);
#endregion
#region internal Add/Has/Remove
internal void Add(int entityID)
{
int entity;
if (_entitiesCount >= _gens.Length)
{
Array.Resize(ref _gens, _gens.Length << 1);
Array.Resize(ref _componentCounts, _componentCounts.Length << 1);
}
_gens[_entitiesCount++]++;
_componentCounts[_entitiesCount++] = 0;
// if (_gens.Length <= entityID)
// {
// //TODO есть проблема что если передать слишком большой id такой алогоритм не сработает
// }
}
internal void Has(int entityID)
{
}
internal void Remove(int entityID)
{
}
#endregion
public ReadOnlySpan<IEcsPool> GetAllPools() => new ReadOnlySpan<IEcsPool>(_pools);
//public int GetComponentID<T>() => ;
}

View File

@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Transactions;
namespace DCFApixels.DragonECS
{