Exemplo n.º 1
0
 protected override void OnDestroy()
 {
     m_RpcData.Dispose();
     m_RpcTypeHashToIndex.Dispose();
     m_RpcErrors.Dispose();
 }
Exemplo n.º 2
0
        public static void SwapCellAndUpdateBoard(ActionKey action, StateData state, Cell cell1, Cell cell2)
        {
            // Swap cell types
            (cell1.Type, cell2.Type) = (cell2.Type, cell1.Type);

            state.SetTraitOnObjectAtIndex(cell1, action[Cell1Index]);
            state.SetTraitOnObjectAtIndex(cell2, action[Cell2Index]);

            int newScore       = 0;
            var cellsToDestroy = new NativeList <int>(1, Allocator.Temp);

            // Check match3 and destroy used Gem (set to Type = None)
            CheckMatchOnGem(state, cell1, action[Cell1Index], ref cellsToDestroy);
            CheckMatchOnGem(state, cell2, action[Cell2Index], ref cellsToDestroy);

            if (cellsToDestroy.Length > 0)
            {
                // Unset all destroyed cells
                var cellQueue   = new NativeQueue <int>(Allocator.Temp);
                var cellsQueued = new NativeHashMap <int, byte>(3, Allocator.Temp);
                var cellChanged = new NativeHashMap <int, byte>(3, Allocator.Temp);

                while (cellsToDestroy.Length > 0)
                {
                    foreach (var cellIndex in cellsToDestroy)
                    {
                        if (cellsQueued.ContainsKey(cellIndex))
                        {
                            continue;
                        }

                        var cellTrait = state.GetTraitOnObjectAtIndex <Cell>(cellIndex);
                        newScore += GetScore(cellTrait.Type);

                        cellTrait.Type = CellType.None;
                        state.SetTraitOnObjectAtIndex(cellTrait, cellIndex);

                        cellQueue.Enqueue(cellIndex);
                        cellsQueued.TryAdd(cellIndex, default);
                    }
                    cellsToDestroy.Clear();

                    // Stitch Unset Gems with Top Gem
                    while (cellQueue.Count > 0)
                    {
                        var cellIndex = cellQueue.Dequeue();
                        cellsQueued.Remove(cellIndex);
                        var cell = state.GetTraitOnObjectAtIndex <Cell>(cellIndex);

                        if (cell.Top.Id == ObjectId.None)
                        {
                            continue;
                        }

                        if (cell.Type == CellType.None)
                        {
                            var cellTopObject = state.GetTraitBasedObject(cell.Top);
                            var cellTop       = state.GetTraitOnObject <Cell>(cellTopObject);

                            // Find first cell with a known type on top
                            while (cellTop.Type == CellType.None)
                            {
                                if (cellTop.Top.Id == ObjectId.None)
                                {
                                    break;
                                }

                                cellTopObject = state.GetTraitBasedObject(cellTop.Top);
                                cellTop       = state.GetTraitOnObject <Cell>(cellTopObject);
                            }

                            if (cellTop.Type != CellType.None)
                            {
                                cell.Type = cellTop.Type;
                                state.SetTraitOnObjectAtIndex(cell, cellIndex);

                                var newCellTop = cellTop;
                                newCellTop.Type = CellType.None;
                                state.SetTraitOnObject(newCellTop, ref cellTopObject);

                                var index = state.GetTraitBasedObjectIndex(cellTopObject);
                                cellQueue.Enqueue(index);
                                cellsQueued.TryAdd(index, default);

                                // Queue all vertical cells for checking
                                var cellTopIndex = state.GetTraitBasedObjectIndex(cell.Top);
                                while (cellTop.Type != CellType.None)
                                {
                                    cellChanged.TryAdd(cellTopIndex, default);

                                    if (cellTop.Top == TraitBasedObjectId.None)
                                    {
                                        break;
                                    }

                                    cellTopIndex = state.GetTraitBasedObjectIndex(cellTop.Top);
                                    cellTop      = state.GetTraitOnObjectAtIndex <Cell>(cellTopIndex);
                                }
                            }
                        }
                    }

                    // Check cells affected by stitching for chained-explosion
                    using (var changedKeys = cellChanged.GetKeyArray(Allocator.Temp))
                    {
                        for (int i = 0; i < changedKeys.Length; i++)
                        {
                            var cellIndex = changedKeys[i];
                            var cell      = state.GetTraitOnObjectAtIndex <Cell>(cellIndex);
                            CheckMatchOnGem(state, cell, cellIndex, ref cellsToDestroy);
                        }
                    }
                    cellChanged.Clear();
                }

                cellQueue.Dispose();
                cellsQueued.Dispose();
                cellChanged.Dispose();
            }

            // Store information in Game state
            var gameId    = state.GetTraitBasedObjectId(action[GameIndex]);
            var game      = state.GetTraitBasedObject(gameId);
            var gameTrait = state.GetTraitOnObject <Game>(game);

            // Score is stored in the Game Object and apply later in the reward function
            gameTrait.Score = newScore;
            state.SetTraitOnObject(gameTrait, ref game);

            cellsToDestroy.Dispose();
        }
Exemplo n.º 3
0
    private void Update()
    {
        List <Transform> children = new List <Transform>();

        foreach (var child in transform)
        {
            children.Add(child as Transform);
        }

        var sdf = GetComponent <SDFBehaviour>().GetNode().Compile();

        var pairArrays = new NativeArray <KeyValuePair <int3, float3> > [Chunks * Chunks];

        for (int i = 0; i < pairArrays.Length; i++)
        {
            pairArrays[i] = new NativeArray <KeyValuePair <int3, float3> >(Resolution * Resolution * Resolution, Allocator.TempJob);
        }

        NativeArray <JobHandle> handles = new NativeArray <JobHandle>(Chunks * Chunks, Allocator.TempJob);

        var counts  = new NativeArray <int>(Chunks * Chunks, Allocator.TempJob);
        var offsets = new NativeArray <int>(Chunks * Chunks, Allocator.TempJob);

        float size = (Resolution - 1) * GridSize;

        //STEP 1
        {
            int pairIndex = 0;
            for (int dx = 0; dx < Chunks; dx++)
            {
                for (int dz = 0; dz < Chunks; dz++)
                {
                    handles[pairIndex] = new BuildVertices()
                    {
                        Resolution    = Resolution,
                        GridSize      = GridSize,
                        GridCorner    = transform.position + new Vector3(dx, 0, dz) * size,
                        SDF           = sdf,
                        Vertices      = pairArrays[pairIndex],
                        Counts        = counts,
                        CountIndex    = pairIndex,
                        CellOffset    = new int3(dx * (Resolution - 1), 0, dz * (Resolution - 1)),
                        UseVoxelStyle = UseVoxelStyle
                    }.Schedule();

                    pairIndex++;
                }
            }

            JobHandle.CompleteAll(handles);
        }

        //STEP 2
        {
            new CalculateOffsets()
            {
                Counts  = counts,
                Offsets = offsets
            }.Run();
        }

        int totalVerts = 0;

        for (int i = 0; i < counts.Length; i++)
        {
            totalVerts += counts[i];
        }

        var verts = new NativeArray <Vector3>(totalVerts, Allocator.TempJob);
        var map   = new NativeHashMap <int3, int>(totalVerts, Allocator.TempJob);

        //STEP 3
        {
            int pairIndex = 0;
            for (int dx = 0; dx < Chunks; dx++)
            {
                for (int dz = 0; dz < Chunks; dz++)
                {
                    new BuildVertexArrayAndMap()
                    {
                        InVertices = pairArrays[pairIndex],
                        Counts     = counts,
                        Offsets    = offsets,
                        CountIndex = pairIndex,
                        Vertices   = verts,
                        VertexMap  = map.AsParallelWriter()
                    }.Schedule().Complete();

                    pairIndex++;
                }
            }
        }

        var triQueue = new NativeQueue <int3>(Allocator.TempJob);

        //STEP 4
        {
            int pairIndex = 0;
            for (int dx = 0; dx < Chunks; dx++)
            {
                for (int dz = 0; dz < Chunks; dz++)
                {
                    new BuildTriQueue()
                    {
                        InVertices = pairArrays[pairIndex],
                        Counts     = counts,
                        CountIndex = pairIndex,
                        TriQueue   = triQueue.AsParallelWriter(),
                        VertexMap  = map,

                        SDF        = sdf,
                        GridCorner = transform.position,
                        GridSize   = GridSize
                    }.Schedule().Complete();

                    pairIndex++;
                }
            }
        }

        var triArray = new NativeArray <int>(triQueue.Count * 3, Allocator.TempJob);

        //STEP 5
        new BuildTriArray()
        {
            TriQueue  = triQueue,
            Triangles = triArray
        }.Schedule().Complete();

        _mesh.Clear();
        _mesh.vertices  = verts.ToArray();
        _mesh.triangles = triArray.ToArray();
        _mesh.RecalculateNormals();
        Graphics.DrawMesh(_mesh, Matrix4x4.identity, previewMat, 0);

        foreach (var pairArray in pairArrays)
        {
            pairArray.Dispose();
        }
        counts.Dispose();
        offsets.Dispose();
        sdf.Dispose();
        verts.Dispose();
        map.Dispose();
        triQueue.Dispose();
        triArray.Dispose();
        handles.Dispose();
    }
 protected override void OnDestroyManager()
 {
     m_ShipArrivedQueue.Dispose();
     base.OnDestroyManager();
 }
Exemplo n.º 5
0
        protected override void OnUpdate()
        {
            var mapSettings = GetSingleton <MapSettings>();
            var edgeSize    = mapSettings.MapEdgeSize;

            var ores = GetComponentDataFromEntity <ResourceOre>(true);

            var tiles          = mapSettings.Tiles;
            var neighborsLocal = _neighbors;

            var setTargetCMDBuffer = _cmdBufferSystem.CreateCommandBuffer().ToConcurrent();

            // TODO: Enable burst (native queue allocation problem)
            Entities
            .WithReadOnly(ores)
            .WithReadOnly(neighborsLocal)
            .WithReadOnly(tiles)
            .WithNativeDisableContainerSafetyRestriction(tiles)
            .WithoutBurst()
            .WithAll <UnitTag, SeekingOresTag>()
            .WithNone <Waypoint, PathRequest>()
            .ForEach((Entity e, int entityInQueryIndex, in MapIndex mapIndex) =>
            {
                #region Found ores
                int2 oreIndex = new int2();

                bool founded  = false;
                var tilesSize = tiles.Length;

                NativeQueue <int> toSearch     = new NativeQueue <int>(Allocator.Temp);
                NativeArray <Boolean> searched = new NativeArray <Boolean>(tiles.Length, Allocator.Temp, NativeArrayOptions.ClearMemory);
                toSearch.Enqueue(mapIndex.Index1D);

                while (founded == false && toSearch.Count > 0)
                {
                    var currentIndex = toSearch.Dequeue();
                    for (int i = 0; i < neighborsLocal.Length; i++)
                    {
                        var neighborIndex = neighborsLocal[i].Of(currentIndex, tilesSize);
                        if (neighborIndex != -1 && searched[neighborIndex] == false)
                        {
                            toSearch.Enqueue(neighborIndex);
                        }
                    }

                    var currentEntity      = tiles[currentIndex];
                    searched[currentIndex] = true;

                    if (ores.HasComponent(currentEntity) && ores[currentEntity].IsValid)
                    {
                        oreIndex = IndexUtils.Index2D(currentIndex, tilesSize);
                        founded  = true;
                    }
                }

                toSearch.Dispose();
                searched.Dispose();
                #endregion Found ores

                setTargetCMDBuffer.AddComponent <PathRequest>(entityInQueryIndex, e, new PathRequest(mapIndex.Index2D, oreIndex));
            }).ScheduleParallel();

            _cmdBufferSystem.AddJobHandleForProducer(Dependency);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Process all queued events.
        /// </summary>
        public void ProcessEvents()
        {
            // Early bail to avoid setting up job stuff unnecessarily
            if (_queuedEvents.Length == 0)
            {
                return;
            }

            NativeQueue <UnityEventJob> eventsToProcessQueue = new NativeQueue <UnityEventJob>(Allocator.TempJob);

            BuildEventQueueJob job = new BuildEventQueueJob();

            job.queuedEvents    = _queuedEvents;
            job.subscribers     = _subscribers;
            job.eventsToProcess = eventsToProcessQueue.ToConcurrent();

            job.Schedule(_queuedEvents.Length, 32).Complete();

            int eventCount = eventsToProcessQueue.Count;

            NativeArray <UnityEventJob> eventsToProcess = new NativeArray <UnityEventJob>(eventCount, Allocator.TempJob);

            EventQueueToEventArrayJob setJob = new EventQueueToEventArrayJob();

            setJob.eventsInQueue = eventsToProcessQueue;
            setJob.events        = eventsToProcess;

            JobHandle setArrayHandle = setJob.Schedule();

            NativeArray <T_Job> jobsArray = new NativeArray <T_Job>(eventCount, Allocator.TempJob);

            CreateJobsArrayJob createJobArrayJob = new CreateJobsArrayJob();

            createJobArrayJob.events      = eventsToProcess;
            createJobArrayJob.subscribers = _subscribers;
            createJobArrayJob.jobs        = jobsArray;

            JobHandle createJobArrayHandle = createJobArrayJob.Schedule(
                eventCount,
                _batchCount,
                setArrayHandle);

            ExecuteEventJobsJob executeJob = new ExecuteEventJobsJob();

            executeJob.jobsResult = jobsArray;
            executeJob.evs        = eventsToProcess;

            JobHandle executeHandle = executeJob.Schedule(
                eventCount,
                _batchCount,
                createJobArrayHandle);

            WriteBackToSubscribersJob writeBackJob = new WriteBackToSubscribersJob();

            writeBackJob.subscribers = _subscribers;
            writeBackJob.evs         = eventsToProcess;
            writeBackJob.jobsResult  = jobsArray;

            JobHandle writeBackHandle = writeBackJob.Schedule(
                eventCount,
                _batchCount,
                executeHandle);

            writeBackHandle.Complete();

            int count = eventsToProcess.Length;

            for (int i = 0; i < count; i++)
            {
                UnityEventJob ev  = eventsToProcess[i];
                Subscription  sub = _subscribers[ev.subscriberIndex];

                try
                {
                    _subscriberCallbacks[ev.subscriberIndex](sub.job);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            eventsToProcessQueue.Dispose();
            eventsToProcess.Dispose();
            jobsArray.Dispose();

            _queuedEvents.Clear();

#if !DISABLE_EVENT_SAFETY_CHKS
            _cachedCurEvents.Clear();
#endif
        }
Exemplo n.º 7
0
 public void Shutdown()
 {
     m_DragHistory.Dispose();
 }
Exemplo n.º 8
0
    void RunTest()
    {
        var em = World.All[0].EntityManager;

        if (!em.HasComponent <Navmesh>(Navmesh.Entity))
        {
            return;
        }
        _runTest = true;

        BurstCompiler.Options.EnableBurstCompilation = BurstInsert;
        var r = new Random((uint)Seed);
        var l = new NativeList <float2>(Allocator.Persistent);
        var a = new NativeList <int>(Allocator.Persistent);

        _entities = new NativeList <Entity>(Amount, Allocator.Persistent);

        if (Select && P)
        {
            P.position = ((float2)SelectPos).ToXxY();
        }

        for (int i = 0; i < Amount; i++)
        {
            var p     = Prefabs[r.NextInt(Prefabs.Length)];
            var scale = (1 - ScaleOffset + r.NextFloat() * 2 * ScaleOffset);
            var rot   = r.NextFloat(2 * math.PI);

            var vertices = p.Vertices.Select(f => Math.Rotate((float2)(scale * f), rot)).ToList();
            if (p.Closed)
            {
                vertices.Add(vertices[0]);
            }

            var min = new float2(float.MaxValue);
            var max = new float2(float.MinValue);

            foreach (var f in vertices)
            {
                min = math.min(f, min);
                max = math.max(f, max);
            }

            var size   = max - min;
            var range  = Size - size;
            var offset = r.NextFloat2(range);

            if (Select)
            {
                var add = false;
                for (int j = 0; j < vertices.Count - 1; j++)
                {
                    if (i < 10 || IntersectSegCircle(vertices[j] - min + offset, vertices[j + 1] - min + offset, SelectPos, SelectRadius) > 0)
                    {
                        add = true;
                        break;
                    }
                }

                if (!add)
                {
                    DestroyImmediate(p.gameObject);
                    continue;
                }
            }

            foreach (var f in vertices)
            {
                l.Add(f - min + offset);
            }
            a.Add(vertices.Count);
        }

        _points = l.Length;

        Warmup();


        for (int i = 0; i < Amount; i++)
        {
            _entities.Add(em.CreateEntity());
        }

        var navmeshes = new NativeArray <Navmesh>(1, Allocator.TempJob);

        navmeshes[0] = em.GetComponentData <Navmesh>(Navmesh.Entity);
        var toRemove = new NativeQueue <Entity>(Allocator.TempJob);

        new InsertValidateJob
        {
            Navmesh          = navmeshes,
            Destroyed        = em.GetBuffer <DestroyedTriangleElement>(Navmesh.Entity),
            Points           = l,
            Amounts          = a,
            ObstacleEntities = _entities,
            Validation       = Validation,
            ToRemove         = toRemove
        }
        .RunTimed($"Insert and refine {_points} points");

        em.SetComponentData(Navmesh.Entity, navmeshes[0]);

        if (Remove)
        {
            RunRemove();
        }

        navmeshes.Dispose();
        l.Dispose();
        a.Dispose();
        toRemove.Dispose();
    }
Exemplo n.º 9
0
 protected override void OnDestroy()
 {
     m_Connections.Dispose();
 }
Exemplo n.º 10
0
 protected override void OnDestroy()
 {
     base.OnDestroy();
     triggeredProjectiles.Dispose();
 }
Exemplo n.º 11
0
    protected override void OnUpdate()
    {
        //Debug.Log(sheet0NativeQueue.Count);
        bool useQuadrantSystem = Testing.Instance.useQuadrantSystem;
        bool sortSprite        = Testing.Instance.sortSprite;

        if (useQuadrantSystem)
        {
            #region useQuadrantSystem
            NativeQueue <SpriteSheetAnimationComponent> node0NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node1NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node2NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node3NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node4NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node5NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node6NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node7NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            NativeQueue <SpriteSheetAnimationComponent> node8NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);

            CopySpriteMultiGroupJob copyTileMultiJob = new CopySpriteMultiGroupJob {
                sheet0NativeQueue = node0NativeQueue.AsParallelWriter(),
                sheet1NativeQueue = node1NativeQueue.AsParallelWriter(),
                sheet2NativeQueue = node2NativeQueue.AsParallelWriter(),
                sheet3NativeQueue = node3NativeQueue.AsParallelWriter(),
                sheet4NativeQueue = node4NativeQueue.AsParallelWriter(),
                sheet5NativeQueue = node5NativeQueue.AsParallelWriter(),
                sheet6NativeQueue = node6NativeQueue.AsParallelWriter(),
                sheet7NativeQueue = node7NativeQueue.AsParallelWriter(),
                sheet8NativeQueue = node8NativeQueue.AsParallelWriter()
            };
            JobHandle jobHandle = copyTileMultiJob.Schedule(this);
            jobHandle.Complete();

            NativeArray <SpriteSheetAnimationComponent> node0NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node0NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node1NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node1NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node2NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node2NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node3NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node3NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node4NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node4NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node5NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node5NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node6NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node6NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node7NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node7NativeQueue.Count, Allocator.TempJob);
            NativeArray <SpriteSheetAnimationComponent> node8NativeArray = new NativeArray <SpriteSheetAnimationComponent>(node8NativeQueue.Count, Allocator.TempJob);

            NativeArray <JobHandle> jobHandleArray = new NativeArray <JobHandle>(9, Allocator.TempJob);

            NativeQueueToArrayJob node0NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node0NativeQueue,
                nativeArray = node0NativeArray,
            };
            jobHandleArray[0] = node0NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node1NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node1NativeQueue,
                nativeArray = node1NativeArray,
            };
            jobHandleArray[1] = node1NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node2NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node2NativeQueue,
                nativeArray = node2NativeArray,
            };
            jobHandleArray[2] = node2NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node3NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node3NativeQueue,
                nativeArray = node3NativeArray,
            };
            jobHandleArray[3] = node3NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node4NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node4NativeQueue,
                nativeArray = node4NativeArray,
            };
            jobHandleArray[4] = node4NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node5NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node5NativeQueue,
                nativeArray = node5NativeArray,
            };
            jobHandleArray[5] = node5NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node6NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node6NativeQueue,
                nativeArray = node6NativeArray,
            };
            jobHandleArray[6] = node6NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node7NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node7NativeQueue,
                nativeArray = node7NativeArray,
            };
            jobHandleArray[7] = node7NativeQueueToArrayJob.Schedule();

            NativeQueueToArrayJob node8NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = node8NativeQueue,
                nativeArray = node8NativeArray,
            };
            jobHandleArray[8] = node8NativeQueueToArrayJob.Schedule();

            JobHandle.CompleteAll(jobHandleArray);

            node0NativeQueue.Dispose();
            node1NativeQueue.Dispose();
            node2NativeQueue.Dispose();
            node3NativeQueue.Dispose();
            node4NativeQueue.Dispose();
            node5NativeQueue.Dispose();
            node6NativeQueue.Dispose();
            node7NativeQueue.Dispose();
            node8NativeQueue.Dispose();

            if (sortSprite)
            {
                SortLayerJob sortLayer0Job = new SortLayerJob {
                    sortArray = node0NativeArray
                };
                jobHandleArray[0] = sortLayer0Job.Schedule();

                SortLayerJob sortLayer1Job = new SortLayerJob {
                    sortArray = node1NativeArray
                };
                jobHandleArray[1] = sortLayer1Job.Schedule();

                SortLayerJob sortLayer2Job = new SortLayerJob {
                    sortArray = node2NativeArray
                };
                jobHandleArray[2] = sortLayer2Job.Schedule();

                SortLayerJob sortLayer3Job = new SortLayerJob {
                    sortArray = node3NativeArray
                };
                jobHandleArray[3] = sortLayer3Job.Schedule();

                SortLayerJob sortLayer4Job = new SortLayerJob {
                    sortArray = node4NativeArray
                };
                jobHandleArray[4] = sortLayer4Job.Schedule();

                SortLayerJob sortLayer5Job = new SortLayerJob {
                    sortArray = node5NativeArray
                };
                jobHandleArray[5] = sortLayer5Job.Schedule();

                SortLayerJob sortLayer6Job = new SortLayerJob {
                    sortArray = node6NativeArray
                };
                jobHandleArray[6] = sortLayer6Job.Schedule();

                SortLayerJob sortLayer7Job = new SortLayerJob {
                    sortArray = node7NativeArray
                };
                jobHandleArray[7] = sortLayer7Job.Schedule();

                SortLayerJob sortLayer8Job = new SortLayerJob {
                    sortArray = node8NativeArray
                };
                jobHandleArray[8] = sortLayer8Job.Schedule();

                JobHandle.CompleteAll(jobHandleArray);
            }
            int visibleTileTotal = node0NativeArray.Length +
                                   node1NativeArray.Length +
                                   node2NativeArray.Length +
                                   node3NativeArray.Length +
                                   node4NativeArray.Length +
                                   node5NativeArray.Length +
                                   node6NativeArray.Length +
                                   node7NativeArray.Length +
                                   node8NativeArray.Length
            ;

            NativeArray <Matrix4x4> matrixArray = new NativeArray <Matrix4x4>(visibleTileTotal, Allocator.TempJob);
            NativeArray <Vector4>   uvArray     = new NativeArray <Vector4>(visibleTileTotal, Allocator.TempJob);
            NativeArray <int>       matIdArray  = new NativeArray <int>(visibleTileTotal, Allocator.TempJob);

            int startingIndex = 0;
            FillArrayForParalleJob fillArrayForParalleJob_0 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node0NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[0] = fillArrayForParalleJob_0.Schedule(node0NativeArray.Length, 10);
            startingIndex    += node0NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_1 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node1NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[1] = fillArrayForParalleJob_1.Schedule(node1NativeArray.Length, 10);
            startingIndex    += node1NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_2 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node2NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[2] = fillArrayForParalleJob_2.Schedule(node2NativeArray.Length, 10);
            startingIndex    += node2NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_3 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node3NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[3] = fillArrayForParalleJob_3.Schedule(node3NativeArray.Length, 10);
            startingIndex    += node3NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_4 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node4NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[4] = fillArrayForParalleJob_4.Schedule(node4NativeArray.Length, 10);
            startingIndex    += node4NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_5 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node5NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[5] = fillArrayForParalleJob_5.Schedule(node5NativeArray.Length, 10);
            startingIndex    += node5NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_6 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node6NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[6] = fillArrayForParalleJob_6.Schedule(node6NativeArray.Length, 10);
            startingIndex    += node6NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_7 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node7NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[7] = fillArrayForParalleJob_7.Schedule(node7NativeArray.Length, 10);
            startingIndex    += node7NativeArray.Length;

            FillArrayForParalleJob fillArrayForParalleJob_8 = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = node8NativeArray,
                startingIndex = startingIndex
            };
            jobHandleArray[8] = fillArrayForParalleJob_8.Schedule(node8NativeArray.Length, 10);
            startingIndex    += node8NativeArray.Length;

            JobHandle.CompleteAll(jobHandleArray);

            int sliceCount = matrixInstanceArray.Length;
            int off        = 0;
            while (off < visibleTileTotal)
            {
                int sheetId   = matIdArray[off];
                int sliceSize = 0;
                while (off + sliceSize < visibleTileTotal && sliceSize < sliceCount)
                {
                    if (matIdArray[off + sliceSize] != sheetId)
                    {
                        break;
                    }
                    sliceSize++;
                }

                NativeArray <Matrix4x4> .Copy(matrixArray, off, matrixInstanceArray, 0, sliceSize);

                NativeArray <Vector4> .Copy(uvArray, off, uvInstanceArray, 0, sliceSize);

                materialPropertyBlock.SetVectorArray(sharedPropertyId, uvInstanceArray);

                Graphics.DrawMeshInstanced(
                    Testing.Instance.mesh,
                    0,
                    GetMaterial(sheetId),
                    matrixInstanceArray,
                    sliceSize,
                    materialPropertyBlock
                    );

                off += sliceSize;
            }

            matrixArray.Dispose();
            uvArray.Dispose();
            matIdArray.Dispose();

            node0NativeArray.Dispose();
            node1NativeArray.Dispose();
            node2NativeArray.Dispose();
            node3NativeArray.Dispose();
            node4NativeArray.Dispose();
            node5NativeArray.Dispose();
            node6NativeArray.Dispose();
            node7NativeArray.Dispose();
            node8NativeArray.Dispose();
            jobHandleArray.Dispose();
            #endregion
        }
        else
        {
            NativeQueue <SpriteSheetAnimationComponent> sheet0NativeQueue = new NativeQueue <SpriteSheetAnimationComponent>(Allocator.TempJob);
            CopySpriteJob copyTileJob = new CopySpriteJob {
                sheet0NativeQueue = sheet0NativeQueue.AsParallelWriter()
            };
            JobHandle jobHandle = copyTileJob.Schedule(this);
            jobHandle.Complete();

            NativeArray <SpriteSheetAnimationComponent> sheet0NativeArray = new NativeArray <SpriteSheetAnimationComponent>(sheet0NativeQueue.Count, Allocator.TempJob);

            NativeQueueToArrayJob sheet0NativeQueueToArrayJob = new NativeQueueToArrayJob {
                nativeQueue = sheet0NativeQueue,
                nativeArray = sheet0NativeArray,
            };
            jobHandle = sheet0NativeQueueToArrayJob.Schedule();
            jobHandle.Complete();

            sheet0NativeQueue.Dispose();

            if (sortSprite)
            {
                SortLayerJob sortLayerJob = new SortLayerJob {
                    sortArray = sheet0NativeArray
                };
                jobHandle = sortLayerJob.Schedule();
                jobHandle.Complete();
            }

            int visibleTileTotal = sheet0NativeArray.Length;

            NativeArray <Matrix4x4> matrixArray            = new NativeArray <Matrix4x4>(visibleTileTotal, Allocator.TempJob);
            NativeArray <Vector4>   uvArray                = new NativeArray <Vector4>(visibleTileTotal, Allocator.TempJob);
            NativeArray <int>       matIdArray             = new NativeArray <int>(visibleTileTotal, Allocator.TempJob);
            FillArrayForParalleJob  fillArrayForParalleJob = new FillArrayForParalleJob {
                matrixArray   = matrixArray,
                uvArray       = uvArray,
                matIdArray    = matIdArray,
                nativeArray   = sheet0NativeArray,
                startingIndex = 0
            };
            jobHandle = fillArrayForParalleJob.Schedule(sheet0NativeArray.Length, 10);
            jobHandle.Complete();


            int sliceCount = matrixInstanceArray.Length;
            int off        = 0;
            while (off < visibleTileTotal)
            {
                int sheetId   = matIdArray[off];
                int sliceSize = 0;
                while (off + sliceSize < visibleTileTotal && sliceSize < sliceCount)
                {
                    if (matIdArray[off + sliceSize] != sheetId)
                    {
                        break;
                    }
                    sliceSize++;
                }
                NativeArray <Matrix4x4> .Copy(matrixArray, off, matrixInstanceArray, 0, sliceSize);

                NativeArray <Vector4> .Copy(uvArray, off, uvInstanceArray, 0, sliceSize);

                materialPropertyBlock.SetVectorArray(sharedPropertyId, uvInstanceArray);

                Graphics.DrawMeshInstanced(
                    Testing.Instance.mesh,
                    0,
                    GetMaterial(sheetId),
                    matrixInstanceArray,
                    sliceSize,
                    materialPropertyBlock
                    );

                off += sliceSize;
            }

            matrixArray.Dispose();
            uvArray.Dispose();
            matIdArray.Dispose();

            sheet0NativeArray.Dispose();
        }
    }
Exemplo n.º 12
0
 protected override void OnDestroyManager()
 {
     numNetworkIds.Dispose();
     freeNetworkIds.Dispose();
     m_Driver.Dispose();
 }
Exemplo n.º 13
0
 static void NQDisposer <T>(NativeQueue <T> queue) where T : struct
 {
     queue.Dispose();
 }
Exemplo n.º 14
0
 protected override void OnDestroy()
 {
     weaponFired.Dispose();
 }
Exemplo n.º 15
0
    Mesh GenerateMesh(float[,,] voxels)
    {
        var grids       = new NativeList <Gridcell>(Allocator.TempJob);
        var gridOffsets = new NativeList <Vector3Int>(Allocator.TempJob);

        for (int x = 0; x < dimensions.x - 1; x++)
        {
            for (int y = 0; y < dimensions.y; y++)
            {
                for (int z = 0; z < dimensions.z - 1; z++)
                {
                    Gridcell gridcell;

                    try
                    {
                        gridcell = new Gridcell
                        {
                            val1 = voxels[x, y, z],
                            val2 = voxels[x, y, 1 + z],
                            val3 = voxels[1 + x, y, 1 + z],
                            val4 = voxels[1 + x, y, z],
                            val5 = voxels[x, 1 + y, z],
                            val6 = voxels[x, 1 + y, 1 + z],
                            val7 = voxels[1 + x, 1 + y, 1 + z],
                            val8 = voxels[1 + x, 1 + y, z],
                        };
                    }

                    catch
                    {
                        gridcell = new Gridcell
                        {
                            val1 = voxels[x, y, z],
                            val2 = voxels[x, y, 1 + z],
                            val3 = voxels[1 + x, y, 1 + z],
                            val4 = voxels[1 + x, y, z],
                            val5 = 0,
                            val6 = 0,
                            val7 = 0,
                            val8 = 0,
                        };
                    }

                    if (gridcell.Equals(Gridcell.one) || gridcell.Equals(Gridcell.zero))
                    {
                        continue;
                    }

                    int index = x + dimensions.y * (y + (dimensions.z - 1) * z);

                    grids.Add(gridcell);
                    gridOffsets.Add(new Vector3Int(x, y, z));
                }
            }
        }

        var trianglesMC = new NativeQueue <Triangle>(Allocator.Persistent);

        new PolygoniseJob()
        {
            grids       = grids,
            gridOffsets = gridOffsets,
            isolevel    = isolevel,

            trianglesMC = trianglesMC,
        }.Schedule(grids.Length, 64).Complete();

        grids.Dispose();
        gridOffsets.Dispose();

        Dictionary <Vector3, int> vertexDictionary = new Dictionary <Vector3, int>(Vec3EqComparer.c);
        NativeList <int>          triangles        = new NativeList <int>(Allocator.TempJob);

        while (trianglesMC.TryDequeue(out Triangle triangle))
        {
            foreach (Vector3 vertex in triangle.Verts)
            {
                if (!vertexDictionary.TryGetValue(vertex, out int vertexIndex))
                {
                    vertexIndex = vertexDictionary.Count;
                    vertexDictionary.Add(vertex, vertexIndex);
                }

                triangles.Add(vertexIndex);
            }
        }

        var vertices = new NativeArray <Vector3>(vertexDictionary.Keys.ToArray(), Allocator.TempJob);

        trianglesMC.Dispose();

        var uv = new NativeArray <Vector2>(vertices.Length, Allocator.TempJob);

        new GetUVJob()
        {
            verts      = vertices,
            uv         = uv,
            dimensions = dimensions,
        }.Schedule(uv.Length, 64).Complete();

        Mesh terrainMesh = new Mesh
        {
            name      = "Terrain" + System.DateTime.UtcNow.ToFileTime().ToString() + " Mesh",
            vertices  = vertices.ToArray(),
            triangles = triangles.ToArray(),
            uv        = uv.ToArray(),
        };

        vertices.Dispose();
        triangles.Dispose();
        uv.Dispose();

        terrainMesh.RecalculateBounds();
        terrainMesh.RecalculateTangents();
        terrainMesh.RecalculateNormals();

        AssetDatabase.CreateAsset(terrainMesh, "Assets/Terrain Data/" + terrainMesh.name + ".asset");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();

        return((Mesh)AssetDatabase.LoadAssetAtPath("Assets/Terrain Data/" + terrainMesh.name + ".asset", typeof(Mesh)));
    }
Exemplo n.º 16
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        NativeQueue <Entity> destroyedPlanetoidsQueue = new NativeQueue <Entity>(Allocator.TempJob);

        #region alternativeNoTWorking

        /*
         * NativeArray<int> keys = QuadrantSystem.quadrantMultiHashMap.GetKeyArray(Allocator.TempJob);
         * NativeArray<JobHandle> jobHandles = new NativeArray<JobHandle>(keys.Length, Allocator.TempJob);
         *
         * //make array of keys
         * //in a job make subarray of key, index of a key is number of array
         * //loop through array and add to queue
         * //place all the subarrays in array
         * //use
         *
         * for (int i = 0; i < keys.Length; i++)
         * {
         *  NativeArray<EntityWithProps> entityWithPropsArray = new NativeArray<EntityWithProps>(QuadrantSystem.GetEntityCountInQuadrant(QuadrantSystem.quadrantMultiHashMap, keys[i]), Allocator.TempJob);
         *  SortPositionsJob sortPositionsJob = new SortPositionsJob
         *  {
         *      quadrantMultiHashMap = QuadrantSystem.quadrantMultiHashMap,
         *      sortedPositionsArray = entityWithPropsArray,
         *      realTimeSinceStartUp = Time.realtimeSinceStartup,
         *      keys = keys,
         *      index = i
         *  };
         *
         *  jobHandles[i] = sortPositionsJob.Schedule();
         * }
         *
         * JobHandle.CompleteAll(jobHandles);
         * keys.Dispose();
         * jobHandles.Dispose();
         * destroyedPlanetoidsQueue.Dispose();
         */
        #endregion
        CollisionDetectionInQuadrantsJob collisionDetectionInQuadrantsJob = new CollisionDetectionInQuadrantsJob
        {
            quadrantMultiHashMap     = QuadrantSystem.quadrantMultiHashMap,
            destroyedPlanetoidsQueue = destroyedPlanetoidsQueue.ToConcurrent(),
            explosionCoordsQueue     = AnimationHandler.explosionCoordsQueue.ToConcurrent(),
            //entityCommandBuffer = endSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
            realTimeSinceStartUp = Time.realtimeSinceStartup,
        };
        JobHandle jobHandle = collisionDetectionInQuadrantsJob.Schedule(this, inputDeps);
        //endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle);

        AddDisabledComponentJob removeTranslationJob = new AddDisabledComponentJob
        {
            destroyedPlanetoidQueue = destroyedPlanetoidsQueue,
            entityCommandBuffer     = endSimulationEntityCommandBufferSystem.CreateCommandBuffer()
        };

        jobHandle = removeTranslationJob.Schedule(jobHandle);
        endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle); //executes only after job has been completed

        jobHandle.Complete();
        destroyedPlanetoidsQueue.Dispose();
        AddTranslationJob addTranslationJob = new AddTranslationJob
        {
            seed = UnityEngine.Random.Range(1, 1000000),
            realTimeSinceStartUp = Time.realtimeSinceStartup,
            entityCommandBuffer  = endPresentationSimulationEntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
            cameraMaxLeftDown    = Camera.main.ViewportToWorldPoint(new Vector3(0, 0)),
            cameraMaxRightUp     = Camera.main.ViewportToWorldPoint(new Vector3(1, 1))
        };
        jobHandle = addTranslationJob.Schedule(this, jobHandle);
        endPresentationSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle);



        return(jobHandle);
    }
 protected override void OnDestroy()
 {
     base.OnDestroy();
     _messageQueue.Dispose();
 }
Exemplo n.º 18
0
 protected override void OnDestroy()
 {
     m_Queue.Dispose();
 }
Exemplo n.º 19
0
 protected override void OnDestroyManager()
 {
     playerClearQueue.Dispose();
 }
Exemplo n.º 20
0
    protected override void OnUpdate()
    {
        NativeQueue <RenderData> node0NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node1NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node2NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node3NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node4NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node5NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);
        NativeQueue <RenderData> node6NativeQueue = new NativeQueue <RenderData>(Allocator.TempJob);

        CopyTileJob copyTileJob = new CopyTileJob
        {
            node0NativeQueue = node0NativeQueue.ToConcurrent(),
            node1NativeQueue = node1NativeQueue.ToConcurrent(),
            node2NativeQueue = node2NativeQueue.ToConcurrent(),
            node3NativeQueue = node3NativeQueue.ToConcurrent(),
            node4NativeQueue = node4NativeQueue.ToConcurrent(),
            node5NativeQueue = node5NativeQueue.ToConcurrent(),
            node6NativeQueue = node6NativeQueue.ToConcurrent()
        };
        JobHandle jobHandle = copyTileJob.Schedule(this);

        jobHandle.Complete();

        NativeArray <RenderData> node0NativeArray = new NativeArray <RenderData>(node0NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node1NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node2NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node3NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node4NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node5NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);
        NativeArray <RenderData> node6NativeArray = new NativeArray <RenderData>(node1NativeQueue.Count, Allocator.TempJob);

        NativeArray <JobHandle> jobHandleArray = new NativeArray <JobHandle>(7, Allocator.TempJob);

        NativeQueueToArrayJob node0NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node0NativeQueue,
            nativeArray = node0NativeArray,
        };

        jobHandleArray[0] = node0NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node1NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node1NativeQueue,
            nativeArray = node1NativeArray,
        };

        jobHandleArray[1] = node1NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node2NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node2NativeQueue,
            nativeArray = node2NativeArray,
        };

        jobHandleArray[2] = node2NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node3NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node3NativeQueue,
            nativeArray = node3NativeArray,
        };

        jobHandleArray[3] = node3NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node4NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node4NativeQueue,
            nativeArray = node4NativeArray,
        };

        jobHandleArray[4] = node4NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node5NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node5NativeQueue,
            nativeArray = node5NativeArray,
        };

        jobHandleArray[5] = node5NativeQueueToArrayJob.Schedule();

        NativeQueueToArrayJob node6NativeQueueToArrayJob = new NativeQueueToArrayJob
        {
            nativeQueue = node6NativeQueue,
            nativeArray = node6NativeArray,
        };

        jobHandleArray[6] = node6NativeQueueToArrayJob.Schedule();

        JobHandle.CompleteAll(jobHandleArray);

        node0NativeQueue.Dispose();
        node1NativeQueue.Dispose();
        node2NativeQueue.Dispose();
        node3NativeQueue.Dispose();
        node4NativeQueue.Dispose();
        node5NativeQueue.Dispose();
        node6NativeQueue.Dispose();

        int visibleTileTotal = node0NativeArray.Length + node1NativeArray.Length;

        NativeArray <Matrix4x4> matrixArray = new NativeArray <Matrix4x4>(visibleTileTotal, Allocator.TempJob);

        int startingIndex = 0;
        FillArrayForParalleJob fillArrayForParalleJob_0 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node0NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[0] = fillArrayForParalleJob_0.Schedule(node0NativeArray.Length, 10);
        startingIndex    += node0NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_1 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node1NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[1] = fillArrayForParalleJob_1.Schedule(node1NativeArray.Length, 10);
        startingIndex    += node1NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_2 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node2NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[2] = fillArrayForParalleJob_2.Schedule(node1NativeArray.Length, 10);
        startingIndex    += node2NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_3 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node1NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[3] = fillArrayForParalleJob_3.Schedule(node3NativeArray.Length, 10);
        startingIndex    += node3NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_4 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node4NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[4] = fillArrayForParalleJob_4.Schedule(node4NativeArray.Length, 10);
        startingIndex    += node4NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_5 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node5NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[5] = fillArrayForParalleJob_5.Schedule(node5NativeArray.Length, 10);
        startingIndex    += node5NativeArray.Length;

        FillArrayForParalleJob fillArrayForParalleJob_6 = new FillArrayForParalleJob
        {
            matrixArray   = matrixArray,
            nativeArray   = node6NativeArray,
            startingIndex = startingIndex
        };

        jobHandleArray[6] = fillArrayForParalleJob_6.Schedule(node6NativeArray.Length, 10);
        startingIndex    += node6NativeArray.Length;

        JobHandle.CompleteAll(jobHandleArray);

        int sliceCount = 1023;

        Matrix4x4[] matrixInstanceArray = new Matrix4x4[1023];
        int         off = 0;

        //while (off < visibleTileTotal)
        //{
        //    int tilePick = off < node0NativeArray.Length ? 0 : 0.34f;
        //    int sliceSize = math.min(visibleTileTotal - off, sliceCount);
        //    if (off < node0NativeArray.Length && off + sliceSize >= node0NativeArray.Length)
        //    {
        //        sliceSize = node0NativeArray.Length - off;
        //    }
        //    NativeArray<Matrix4x4>.Copy(matrixArray, off, matrixInstanceArray, 0, sliceSize);

        //    Graphics.DrawMeshInstanced(
        //        Bootstrap.Defines.ResourceNodesPrefab[tilePick].mesh,
        //        0,
        //        Bootstrap.Defines.ResourceNodesPrefab[tilePick].material,
        //        matrixInstanceArray,
        //        sliceSize);

        //    off += sliceSize;
        //}

        matrixArray.Dispose();
        node0NativeArray.Dispose();
        node1NativeArray.Dispose();
        node2NativeArray.Dispose();
        node3NativeArray.Dispose();
        node4NativeArray.Dispose();
        node5NativeArray.Dispose();
        node6NativeArray.Dispose();
        jobHandleArray.Dispose();
    }
 protected override void OnDestroy()
 {
     _eventQueue.Dispose();
 }
 protected override void OnDestroy()
 {
     explosionCoordsQueue.Dispose();
     base.OnDestroy();
 }