Exemplo n.º 1
0
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                NativeArray <Entity>            entities       = chunk.GetNativeArray(this.entityType);
                NativeArray <BlockDissolveData> blockDissolves = chunk.GetNativeArray(this.blockDissolveType);
                NativeArray <BlockGridNodeData> blockGridNodes = chunk.GetNativeArray(this.blockGridNodeType);

                for (int ci = 0, cn = chunk.Count; ci < cn; ci++)
                {
                    // Update block dissolve

                    BlockDissolveData blockDissolve = blockDissolves[ci];
                    BlockGridNodeData blockGridNode = blockGridNodes[ci];

                    // Update while block is dissolving
                    if (blockDissolve.isDissolving)
                    {
                        this.outDissolvedNodeIndices[this.outNumDissolvedNodes[0]++] = (blockGridNode.Index);

                        // TEMP: Immediately disable on dissolve
                        EntityUtils.DisableEntityHierarchy(ref this.ecb, chunkIndex, entities[ci], in this.childrenBuffer);
                    }

                    // Apply changes
                    blockDissolves[ci] = blockDissolve;
                }
            }
            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                NativeArray <BlockPlayerCollisionData> blockCollisions = chunk.GetNativeArray(this.blockPlayerCollisionType);
                NativeArray <BlockTraversalData>       blockTraversals = chunk.GetNativeArray(this.blockTraversalType);
                NativeArray <BlockDissolveData>        blockDissolves  = chunk.GetNativeArray(this.blockDissolveType);

                for (int ci = 0, cn = chunk.Count; ci < cn; ci++)
                {
                    // Update common block traversal logic

                    BlockPlayerCollisionData blockCollision = blockCollisions[ci];
                    BlockTraversalData       blockTraversal = blockTraversals[ci];
                    BlockDissolveData        blockDissolve  = blockDissolves[ci];

                    // Add to traversal count when exiting block
                    if (blockCollision.triggerState == PhysicsTriggerState.Exit)
                    {
                        bool maxTraversalReached = blockTraversal.IncrementTraversalCount();

                        // Mark block for dissolve if max traversal reached
                        if (maxTraversalReached)
                        {
                            blockDissolve.isDissolving = maxTraversalReached;
                        }
                    }

                    // Apply changes
                    blockTraversals[ci] = blockTraversal;
                    blockDissolves[ci]  = blockDissolve;
                }
            }