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; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <BlockPlayerCollisionData> blockCollisions = chunk.GetNativeArray(this.blockPlayerCollisionType); NativeArray <Entity> entities = chunk.GetNativeArray(this.entityType); for (int ci = 0, cn = chunk.Count; ci < cn; ci++) { // Update trigger event type for block collision Entity entity = entities[ci]; BlockPlayerCollisionData blockCollision = blockCollisions[ci]; // Check if this block entity currently is colliding (is in passed triggerEntities dic) if (this.triggerEntities.ContainsKey(entity)) { // If colliding, update none/exit to enter, enter to stay switch (blockCollision.triggerState) { case PhysicsTriggerState.None: case PhysicsTriggerState.Exit: blockCollision.triggerState = PhysicsTriggerState.Enter; break; case PhysicsTriggerState.Enter: case PhysicsTriggerState.Stay: blockCollision.triggerState = PhysicsTriggerState.Stay; break; } } else { // If not colliding, update enter/stay to exit, and exit to none switch (blockCollision.triggerState) { case PhysicsTriggerState.Enter: case PhysicsTriggerState.Stay: blockCollision.triggerState = PhysicsTriggerState.Exit; break; case PhysicsTriggerState.Exit: case PhysicsTriggerState.None: blockCollision.triggerState = PhysicsTriggerState.None; break; } } // Apply changes blockCollisions[ci] = blockCollision; } }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { NativeArray <BlockPlayerCollisionData> blockCollisions = chunk.GetNativeArray(this.blockPlayerCollisionType); NativeArray <BlockSwitchData> blockSwitches = chunk.GetNativeArray(this.blockSwitchType); for (int ci = 0, cn = chunk.Count; ci < cn; ci++) { // Activate switch if entered block BlockPlayerCollisionData blockCollision = blockCollisions[ci]; BlockSwitchData blockSwitch = blockSwitches[ci]; if (blockCollision.triggerState == PhysicsTriggerState.Enter) { blockSwitch.Activate(); } // Apply changes blockSwitches[ci] = blockSwitch; } }