public void ShouldGetIndex() { //arrange var componentType = ComponentType <Position> .Type; using IAllocator allocator = new DynamicAllocator(_logFactory); using var data = new ComponentDataArray(_logFactory, allocator, componentType, 32); //act var span = data.AsSpan <Position>(); ref var p = ref span[0];
internal ComponentPackedArray(ILoggerFactory logFactory, IAllocator allocator, EntitySpec specification) { _logFactory = logFactory; _logger = _logFactory.CreateLogger <ComponentPackedArray>(); _allocator = allocator; Specification = specification; var _componentTypes = Specification.ComponentTypes; _componentData = new ComponentDataArray[_componentTypes.Length]; for (var i = 0; i < _componentTypes.Length; i++) { _componentData[i] = new ComponentDataArray(_logFactory, _allocator, _componentTypes[i], Entity.ENTITY_MAX); } }
internal static void CopyTo(ComponentDataArray srcArray, int srcIndex, ComponentDataArray dstArray, int dstIndex) { Assert.EqualTo(srcArray._componentType.ID, dstArray._componentType.ID); Assert.Range(srcIndex, 0, srcArray.Length); Assert.Range(dstIndex, 0, dstArray.Length); var srcAddr = (byte *)srcArray._memoryHandle.Address; var dstAddr = (byte *)dstArray._memoryHandle.Address; var src = srcAddr + srcIndex * srcArray.ElementSize; var dst = dstAddr + dstIndex * srcArray.ElementSize; srcArray._componentHelper.Copy(src, dst); #if DEBUG srcArray._componentHelper.Reset(src); #endif }
internal static void CopyTo(ComponentPackedArray srcArray, int srcComponentIndex, int srcIndex, ComponentPackedArray dstArray, int dstComponentIndex, int dstIndex) { ComponentDataArray.CopyTo(srcArray._componentData[srcComponentIndex], srcIndex, dstArray._componentData[dstComponentIndex], dstIndex); }