public ref EntityFilterCollection GetOrCreatePersistentFilter <T>(CombinedFilterID filterID, NativeRefWrapperType typeRef) where T : unmanaged, IEntityComponent { long combineFilterIDs = Internal_FilterHelper.CombineFilterIDs <T>(filterID); if (_persistentEntityFilters.TryFindIndex(combineFilterIDs, out var index) == true) { return(ref _persistentEntityFilters.GetDirectValueByRef(index)); } _persistentEntityFilters.Add(combineFilterIDs, new EntityFilterCollection(filterID)); var lastIndex = _persistentEntityFilters.count - 1; if (_indicesOfPersistentFiltersUsedByThisComponent.TryFindIndex(typeRef, out var getIndex) == false) { var newArray = new NativeDynamicArrayCast <int>(1, Allocator.Persistent); newArray.Add(lastIndex); _indicesOfPersistentFiltersUsedByThisComponent.Add(typeRef, newArray); } else { ref var array = ref _indicesOfPersistentFiltersUsedByThisComponent.GetDirectValueByRef(getIndex); array.Add(lastIndex); }
public EntityFilterCollectionsWithContextEnumerator(NativeDynamicArrayCast <int> getDirectValueByRef, SharedSveltoDictionaryNative <long, EntityFilterCollection> sharedSveltoDictionaryNative, FilterContextID filterContextId) : this() { _getDirectValueByRef = getDirectValueByRef; _sharedSveltoDictionaryNative = sharedSveltoDictionaryNative; _filterContextId = filterContextId; }
internal FilterGroup(ExclusiveGroupStruct exclusiveGroupStruct) { _denseListOfIndicesToEntityComponentArray = new NativeDynamicArrayCast <uint>(NativeDynamicArray.Alloc <uint>(Allocator.Persistent)); _reverseEGIDs = new NativeDynamicArrayCast <uint>(NativeDynamicArray.Alloc <uint>(Allocator.Persistent)); _EIDs = new SharedSveltoDictionaryNative <uint, uint>(0, Allocator.Persistent); _exclusiveGroupStruct = exclusiveGroupStruct; }
public void TestAllocationSize1() { NativeDynamicArrayCast <int> fasterList = new NativeDynamicArrayCast <int>(1, Allocator.Persistent); Assert.That(fasterList.capacity, Is.EqualTo(1)); Assert.That(fasterList.count, Is.EqualTo(0)); fasterList.Dispose(); }
internal FilterGroup(ExclusiveGroupStruct exclusiveGroupStruct, int ID) { _denseListOfIndicesToEntityComponentArray = new NativeDynamicArrayCast <uint>(NativeDynamicArray.Alloc <uint>(Allocator.Persistent)); //from the index, find the entityID _reverseEIDs = new NativeDynamicArrayCast <uint>(NativeDynamicArray.Alloc <uint>(Allocator.Persistent)); //from the entityID, find the index _indexOfEntityInDenseList = new SharedSveltoDictionaryNative <uint, uint>(0); _exclusiveGroupStruct = exclusiveGroupStruct; _ID = ID; }
public void TestResizeTo0() { NativeDynamicArrayCast <byte> fasterList = new NativeDynamicArrayCast <byte>(10, Allocator.Persistent); fasterList.Resize(0); Assert.That(fasterList.capacity, Is.EqualTo(0)); Assert.That(fasterList.count, Is.EqualTo(0)); fasterList.Dispose(); }
public void TesSetAt() { NativeDynamicArrayCast <int> fasterList = new NativeDynamicArrayCast <int>(0, Allocator.Persistent); fasterList.AddAt(10) = 10; Assert.That(fasterList[10], Is.EqualTo(10)); Assert.That(fasterList.capacity, Is.EqualTo(16)); Assert.That(fasterList.count, Is.EqualTo(11)); fasterList.Dispose(); }
public void TestAdd() { NativeDynamicArrayCast <int> fasterList = new NativeDynamicArrayCast <int>(0, Allocator.Persistent); for (int i = 0; i < 10; i++) { fasterList.Add(i); } for (int i = 0; i < 10; i++) { Assert.That(fasterList[i], Is.EqualTo(i)); } Assert.That(fasterList.capacity, Is.EqualTo(10)); Assert.That(fasterList.count, Is.EqualTo(10)); fasterList.Dispose(); }
public void TestUnorderedRemoveAt() { NativeDynamicArrayCast <int> fasterList = new NativeDynamicArrayCast <int>(0, Allocator.Persistent); for (int i = 0; i < 10; i++) { fasterList.Add(i); } fasterList.UnorderedRemoveAt(3); Assert.That(fasterList[3], Is.EqualTo(9)); fasterList.UnorderedRemoveAt(0); Assert.That(fasterList[0], Is.EqualTo(8)); fasterList.UnorderedRemoveAt(7); Assert.That(fasterList.capacity, Is.EqualTo(10)); Assert.That(fasterList.count, Is.EqualTo(7)); fasterList.Dispose(); }
public void TestRemoveAt() { NativeDynamicArrayCast <byte> fasterList = new NativeDynamicArrayCast <byte>(0, Allocator.Persistent); for (var i = 0; i < 10; i++) { fasterList.Add((byte)i); } fasterList.RemoveAt(3); Assert.That(fasterList[3], Is.EqualTo(4)); fasterList.RemoveAt(0); Assert.That(fasterList[0], Is.EqualTo(1)); fasterList.RemoveAt(7); Assert.That(fasterList.capacity, Is.EqualTo(10)); Assert.That(fasterList.count, Is.EqualTo(7)); fasterList.Dispose(); }
public FilteredIndices(NativeDynamicArrayCast <uint> denseListOfIndicesToEntityComponentArray) { _denseListOfIndicesToEntityComponentArray = denseListOfIndicesToEntityComponentArray; _count = _denseListOfIndicesToEntityComponentArray.count; }
public EntityFilterCollectionsEnumerator(NativeDynamicArrayCast <int> getDirectValueByRef, SharedSveltoDictionaryNative <long, EntityFilterCollection> sharedSveltoDictionaryNative) : this() { _getDirectValueByRef = getDirectValueByRef; _sharedSveltoDictionaryNative = sharedSveltoDictionaryNative; }