This commit is contained in:
Mikhail 2023-12-31 21:02:53 +08:00
parent b5300f7b43
commit 0b6c1e8d26
2 changed files with 13 additions and 5 deletions

View File

@ -107,7 +107,7 @@ namespace DCFApixels.DragonECS
public bool IsSubsetOf(EcsGroup group) => _source.IsSubsetOf(group);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool IsSupersetOf(EcsReadonlyGroup group) => _source.Overlaps(group._source);
public bool IsSupersetOf(EcsReadonlyGroup group) => _source.IsSupersetOf(group._source);
public bool IsSupersetOf(EcsGroup group) => _source.IsSupersetOf(group);
#endregion
@ -648,7 +648,7 @@ namespace DCFApixels.DragonECS
public Enumerator(EcsGroup group)
{
_dense = group._dense;
_index = (uint)(group._count > _dense.Length ? _dense.Length : group._count);
_index = (uint)(group._count > _dense.Length ? _dense.Length : group._count) + 1;
}
public int Current
{
@ -689,7 +689,7 @@ namespace DCFApixels.DragonECS
{
world = group.World;
_dense = group._dense;
_index = (uint)(group._count > _dense.Length ? _dense.Length : group._count);
_index = (uint)(group._count > _dense.Length ? _dense.Length : group._count) + 1;
}
public entlong Current
{
@ -698,7 +698,7 @@ namespace DCFApixels.DragonECS
}
object IEnumerator.Current => Current;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool MoveNext() => ++_index > 0; // <= потму что отсчет начинается с индекса 1 //_count < _dense.Length дает среде понять что проверки на выход за границы не нужны
public bool MoveNext() => --_index > 0; // <= потму что отсчет начинается с индекса 1 //_count < _dense.Length дает среде понять что проверки на выход за границы не нужны
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose() { }
[MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@ -64,7 +64,8 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetForWorld(int worldID)
{
return ref _items[GetItemIndex(worldID)];
int index = GetItemIndex(worldID);
return ref _items[index];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ref T GetForWorldUnchecked(int worldID)
@ -78,8 +79,11 @@ namespace DCFApixels.DragonECS
public static int GetItemIndex(int worldID)
{
if (_mapping.Length < Worlds.Length)
{
Array.Resize(ref _mapping, Worlds.Length);
}
ref short itemIndex = ref _mapping[worldID];
if (itemIndex <= 0)
{
@ -92,6 +96,10 @@ namespace DCFApixels.DragonECS
{
itemIndex = ++_count;
}
if(_items.Length <= itemIndex)
{
Array.Resize(ref _items, _items.Length << 1);
}
_interface.Init(ref _items[itemIndex], Worlds[worldID]);
_dataReleaseres.Add(new Releaser());
}