mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-11-15 10:35:55 +08:00
remove ent
This commit is contained in:
parent
d1abb9d647
commit
514cf706e5
@ -269,7 +269,7 @@ namespace DCFApixels.DragonECS
|
|||||||
if(_count > 0)
|
if(_count > 0)
|
||||||
Clear();
|
Clear();
|
||||||
foreach (var item in group)
|
foreach (var item in group)
|
||||||
AggressiveAdd(item.id);
|
AggressiveAdd(item);
|
||||||
}
|
}
|
||||||
public EcsGroup Clone()
|
public EcsGroup Clone()
|
||||||
{
|
{
|
||||||
@ -290,8 +290,8 @@ namespace DCFApixels.DragonECS
|
|||||||
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
||||||
#endif
|
#endif
|
||||||
foreach (var item in group)
|
foreach (var item in group)
|
||||||
if (!Contains(item.id))
|
if (!Contains(item))
|
||||||
AggressiveAdd(item.id);
|
AggressiveAdd(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>as Except sets</summary>
|
/// <summary>as Except sets</summary>
|
||||||
@ -304,8 +304,8 @@ namespace DCFApixels.DragonECS
|
|||||||
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
||||||
#endif
|
#endif
|
||||||
foreach (var item in this)
|
foreach (var item in this)
|
||||||
if (group.Contains(item.id))
|
if (group.Contains(item))
|
||||||
AggressiveRemove(item.id);
|
AggressiveRemove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>as Intersect sets</summary>
|
/// <summary>as Intersect sets</summary>
|
||||||
@ -318,8 +318,8 @@ namespace DCFApixels.DragonECS
|
|||||||
if (World != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
if (World != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
||||||
#endif
|
#endif
|
||||||
foreach (var item in this)
|
foreach (var item in this)
|
||||||
if (!group.Contains(item.id))
|
if (!group.Contains(item))
|
||||||
AggressiveRemove(item.id);
|
AggressiveRemove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>as Symmetric Except sets</summary>
|
/// <summary>as Symmetric Except sets</summary>
|
||||||
@ -332,10 +332,10 @@ namespace DCFApixels.DragonECS
|
|||||||
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
if (_source != group.World) throw new ArgumentException("WorldIndex != groupFilter.WorldIndex");
|
||||||
#endif
|
#endif
|
||||||
foreach (var item in group)
|
foreach (var item in group)
|
||||||
if (Contains(item.id))
|
if (Contains(item))
|
||||||
AggressiveRemove(item.id);
|
AggressiveRemove(item);
|
||||||
else
|
else
|
||||||
AggressiveAdd(item.id);
|
AggressiveAdd(item);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -349,8 +349,8 @@ namespace DCFApixels.DragonECS
|
|||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetGroupFromPool();
|
EcsGroup result = a._source.GetGroupFromPool();
|
||||||
foreach (var item in a)
|
foreach (var item in a)
|
||||||
if (!b.Contains(item.id))
|
if (!b.Contains(item))
|
||||||
result.AggressiveAdd(item.id);
|
result.AggressiveAdd(item);
|
||||||
a._source.ReleaseGroup(a);
|
a._source.ReleaseGroup(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -363,8 +363,8 @@ namespace DCFApixels.DragonECS
|
|||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetGroupFromPool();
|
EcsGroup result = a._source.GetGroupFromPool();
|
||||||
foreach (var item in a)
|
foreach (var item in a)
|
||||||
if (b.Contains(item.id))
|
if (b.Contains(item))
|
||||||
result.AggressiveAdd(item.id);
|
result.AggressiveAdd(item);
|
||||||
a._source.ReleaseGroup(a);
|
a._source.ReleaseGroup(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -377,9 +377,9 @@ namespace DCFApixels.DragonECS
|
|||||||
#endif
|
#endif
|
||||||
EcsGroup result = a._source.GetGroupFromPool();
|
EcsGroup result = a._source.GetGroupFromPool();
|
||||||
foreach (var item in a)
|
foreach (var item in a)
|
||||||
result.AggressiveAdd(item.id);
|
result.AggressiveAdd(item);
|
||||||
foreach (var item in a)
|
foreach (var item in a)
|
||||||
result.Add(item.id);
|
result.Add(item);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -432,10 +432,10 @@ namespace DCFApixels.DragonECS
|
|||||||
_count = group.Count;
|
_count = group.Count;
|
||||||
_index = 0;
|
_index = 0;
|
||||||
}
|
}
|
||||||
public ent Current
|
public int Current
|
||||||
{
|
{
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
get => new ent(_dense[_index]);
|
get => _dense[_index];
|
||||||
}
|
}
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public bool MoveNext() => ++_index <= _count && _count<_dense.Length; // <= потму что отсчет начинается с индекса 1 //_count < _dense.Length дает среде понять что проверки на выход за границы не нужны
|
public bool MoveNext() => ++_index <= _count && _count<_dense.Length; // <= потму что отсчет начинается с индекса 1 //_count < _dense.Length дает среде понять что проверки на выход за границы не нужны
|
||||||
@ -456,7 +456,7 @@ namespace DCFApixels.DragonECS
|
|||||||
if (other.Count != Count)
|
if (other.Count != Count)
|
||||||
return false;
|
return false;
|
||||||
foreach (var item in other)
|
foreach (var item in other)
|
||||||
if (!Contains(item.id))
|
if (!Contains(item))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -464,7 +464,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
foreach (var item in this)
|
foreach (var item in this)
|
||||||
hash ^= 1 << (item.id % 32); //реализация от балды, так как не нужен, но фишка в том что хеш не учитывает порядок сущьностей, что явлется правильным поведением.
|
hash ^= 1 << (item % 32); //реализация от балды, так как не нужен, но фишка в том что хеш не учитывает порядок сущьностей, что явлется правильным поведением.
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,13 +1,4 @@
|
|||||||
using Mono.CompilerServices.SymbolWriter;
|
using Unity.Profiling;
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Unity.Profiling;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Jobs;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
@ -28,13 +19,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
private int[] _mapping;
|
private int[] _mapping;
|
||||||
private int[] _counts;
|
private int[] _counts;
|
||||||
//private int[] _entites;
|
|
||||||
private EntityLinkedList _linkedBasket;
|
private EntityLinkedList _linkedBasket;
|
||||||
|
|
||||||
private bool _isJoinExecuted = false;
|
private bool _isJoinExecuted = false;
|
||||||
public bool IsJoinExecuted => _isJoinExecuted;
|
public bool IsJoinExecuted => _isJoinExecuted;
|
||||||
//private LinkedList<int>
|
|
||||||
|
|
||||||
|
|
||||||
private bool _isInitTargetWorlds = false;
|
private bool _isInitTargetWorlds = false;
|
||||||
|
|
||||||
@ -61,9 +49,9 @@ namespace DCFApixels.DragonECS
|
|||||||
//Подготовка массивов
|
//Подготовка массивов
|
||||||
if (_targetWorldCapacity < _targetWorld.Capacity)
|
if (_targetWorldCapacity < _targetWorld.Capacity)
|
||||||
{
|
{
|
||||||
|
_targetWorldCapacity = _targetWorld.Capacity;
|
||||||
_mapping = new int[_targetWorldCapacity];
|
_mapping = new int[_targetWorldCapacity];
|
||||||
_counts = new int[_targetWorldCapacity];
|
_counts = new int[_targetWorldCapacity];
|
||||||
_targetWorldCapacity = _targetWorld.Capacity;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -72,16 +60,15 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
if (_targetPoolCapacity < _targetPool.Capacity)
|
if (_targetPoolCapacity < _targetPool.Capacity)
|
||||||
{
|
{
|
||||||
_linkedBasket.Resize(_targetPoolCapacity);
|
|
||||||
_targetPoolCapacity = _targetPool.Capacity;
|
_targetPoolCapacity = _targetPool.Capacity;
|
||||||
|
_linkedBasket.Resize(_targetPoolCapacity);
|
||||||
}
|
}
|
||||||
_linkedBasket.Clear();
|
_linkedBasket.Clear();
|
||||||
//Конец подготовки массивов
|
//Конец подготовки массивов
|
||||||
|
|
||||||
ExecuteWhere();
|
ExecuteWhere();
|
||||||
foreach (var e in groupFilter)
|
foreach (var attachID in groupFilter)
|
||||||
{
|
{
|
||||||
int attachID = e.id;
|
|
||||||
EcsEntity attachTarget = _targetPool.Read(attachID).Target;
|
EcsEntity attachTarget = _targetPool.Read(attachID).Target;
|
||||||
// if (!attachTarget.IsAlive)//TODO пофиксить IsAlive
|
// if (!attachTarget.IsAlive)//TODO пофиксить IsAlive
|
||||||
//{
|
//{
|
||||||
@ -177,39 +164,5 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
return groupFilter.GetEnumerator();
|
return groupFilter.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodesEnumrable GetNodes(int entityID)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly ref struct NodesEnumrable
|
|
||||||
{
|
|
||||||
private readonly int[] _nodes;
|
|
||||||
private readonly int _start;
|
|
||||||
private readonly int _count;
|
|
||||||
public NodesEnumrable(int[] nodes, int start, int count)
|
|
||||||
{
|
|
||||||
_nodes = nodes;
|
|
||||||
_start = start;
|
|
||||||
_count = count;
|
|
||||||
}
|
|
||||||
public NodesEnumerator GetEnumerator() => new NodesEnumerator(_nodes, _start, _count);
|
|
||||||
}
|
|
||||||
public ref struct NodesEnumerator
|
|
||||||
{
|
|
||||||
private readonly int[] _nodes;
|
|
||||||
private readonly int _end;
|
|
||||||
private int _index;
|
|
||||||
public NodesEnumerator(int[] nodes, int start, int count)
|
|
||||||
{
|
|
||||||
_nodes = nodes;
|
|
||||||
int end = start + count;
|
|
||||||
_end = end < _nodes.Length ? end : _nodes.Length;
|
|
||||||
_index = start;
|
|
||||||
}
|
|
||||||
public ent Current => new ent(_nodes[_index]);
|
|
||||||
public bool MoveNext() => ++_index <= _end;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,18 +85,17 @@ namespace DCFApixels.DragonECS
|
|||||||
result.Clear();
|
result.Clear();
|
||||||
foreach (var e in group)
|
foreach (var e in group)
|
||||||
{
|
{
|
||||||
int entityID = e.id;
|
|
||||||
for (int i = 0, iMax = mask.Inc.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask.Inc.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
if (!pools[mask.Inc[i]].Has(entityID))
|
if (!pools[mask.Inc[i]].Has(e))
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
for (int i = 0, iMax = mask.Exc.Length; i < iMax; i++)
|
for (int i = 0, iMax = mask.Exc.Length; i < iMax; i++)
|
||||||
{
|
{
|
||||||
if (pools[mask.Exc[i]].Has(entityID))
|
if (pools[mask.Exc[i]].Has(e))
|
||||||
goto next;
|
goto next;
|
||||||
}
|
}
|
||||||
result.AggressiveAdd(entityID);
|
result.AggressiveAdd(e);
|
||||||
next: continue;
|
next: continue;
|
||||||
}
|
}
|
||||||
result.Sort();
|
result.Sort();
|
||||||
|
|||||||
@ -21,9 +21,8 @@ namespace DCFApixels.DragonECS
|
|||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public readonly short world;
|
public readonly short world;
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
//public ent ToEnt() => EcsWorld.Worlds[world].EntityIsAlive(id, gen) ? new ent(id) : default;
|
//public ent ToEnt() => EcsWorld.Worlds[world].EntityIsAlive(id, gen) ? new ent(id) : default;
|
||||||
public ent ToEnt() => new ent(id);
|
|
||||||
|
|
||||||
public bool IsAlive => EcsWorld.Worlds[world].EntityIsAlive(id, gen);
|
public bool IsAlive => EcsWorld.Worlds[world].EntityIsAlive(id, gen);
|
||||||
|
|
||||||
@ -65,8 +64,8 @@ namespace DCFApixels.DragonECS
|
|||||||
public static bool operator !=(in EcsEntity a, in EcsEntity b) => a.full != b.full;
|
public static bool operator !=(in EcsEntity a, in EcsEntity b) => a.full != b.full;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static explicit operator long(in EcsEntity a) => a.full;
|
public static explicit operator long(in EcsEntity a) => a.full;
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static explicit operator ent(in EcsEntity a) => a.ToEnt();
|
//public static explicit operator ent(in EcsEntity a) => a.ToEnt();
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static explicit operator EcsEntity(in long a) => new EcsEntity(a);
|
public static explicit operator EcsEntity(in long a) => new EcsEntity(a);
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
#pragma warning disable CS0660, CS0661, IDE1006
|
|
||||||
/// <summary>Weak identifier/Single frame entity identifier</summary>
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 4)]
|
|
||||||
public readonly ref struct ent
|
|
||||||
{
|
|
||||||
[MarshalAs(UnmanagedType.I4)]
|
|
||||||
internal readonly int id;
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
internal ent(int id) => this.id = id;
|
|
||||||
|
|
||||||
public static implicit operator int(ent entityID) => entityID.id;
|
|
||||||
|
|
||||||
public static bool operator ==(ent a, ent b) => a.id == b.id;
|
|
||||||
public static bool operator !=(ent a, ent b) => a.id != b.id;
|
|
||||||
|
|
||||||
public static bool operator ==(ent a, Null? _) => a.id == 0;
|
|
||||||
public static bool operator ==(Null? _, ent b) => b.id == 0;
|
|
||||||
public static bool operator !=(ent a, Null? _) => a.id != 0;
|
|
||||||
public static bool operator !=(Null? _, ent b) => b.id != 0;
|
|
||||||
|
|
||||||
public struct Null { }
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public EcsEntity ToStrongID(EcsWorld world) => world.GetEcsEntity(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user