public void Execute() { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < 16; y++) { if (chunkData.Blocks[BlockExtensions.GetBlockIndex(new int3(x, y, z))].IsEmpty()) { continue; } for (int i = 0; i < 6; i++) { var direction = (Direction)i; if (Check(BlockExtensions.GetPositionInDirection(direction, x, y, z))) { CreateFace(direction, new int3(x, y, z)); } } } } } }
public async Task <TxReceipt[][]> BuildReceiptsResponse(BlockHeader[] headers, BlockBody[] bodies, Response flags = Response.AllCorrect) { if (headers.Length != bodies.Length + 1) { throw new InvalidDataException("Headers and bodies response length should be the same for receipt tests"); } TxReceipt[][] receipts = new TxReceipt[headers.Length - 1][]; for (int i = 1; i < headers.Length; i++) { receipts[i - 1] = bodies[i - 1].Transactions .Select(t => Build.A.Receipt .WithStatusCode(StatusCode.Success) .WithGasUsed(10) .WithBloom(Bloom.Empty) .WithLogs(Build.A.LogEntry.WithAddress(t.SenderAddress).WithTopics(TestItem.KeccakA).TestObject) .TestObject) .ToArray(); headers[i].ReceiptsRoot = flags.HasFlag(Response.IncorrectReceiptRoot) ? Keccak.EmptyTreeHash : BlockExtensions.CalculateReceiptRoot(headers[i].Number, MainNetSpecProvider.Instance, receipts[i - 1]); } ReceiptsMessage message = new ReceiptsMessage(receipts); byte[] messageSerialized = _receiptsSerializer.Serialize(message); return(await Task.FromResult(_receiptsSerializer.Deserialize(messageSerialized).TxReceipts)); }
private bool Check(int3 position) { if (position.x >= 16 || position.z >= 16 || position.x <= -1 || position.z <= -1 || position.y <= -1) { return(true); } if (position.y >= 16) { return(false); } return(chunkData.Blocks[BlockExtensions.GetBlockIndex(position)].IsEmpty()); }
private void CreateFace(Direction direction, int3 pos) { var _vertices = BlockExtensions.GetFaceVertices(direction, 1, pos); meshData.Vertices.AddRange(_vertices); _vertices.Dispose(); var vCount = meshData.Vertices.Length - 4; meshData.Triangles.Add(vCount); meshData.Triangles.Add(vCount + 1); meshData.Triangles.Add(vCount + 2); meshData.Triangles.Add(vCount); meshData.Triangles.Add(vCount + 2); meshData.Triangles.Add(vCount + 3); }
private string CalculateMidPoint(string sourceBlockName, string destinationBlockName) { string @default = "[0, 0]"; Block srcBlock = this.model.System.Block.FirstOrDefault(b => b.BlockName == sourceBlockName); if (srcBlock != null) { Block destBlock = this.model.System.Block.FirstOrDefault(b => b.BlockName == destinationBlockName); if (destBlock != null) { int distance = BlockExtensions.GetHorizontalDistance(srcBlock, destBlock) / 2; @default = $"[{distance}, 0]"; } } return(@default); }
internal Parameter CalculateBranchPoint(string sourceBlockName, string destinationBlockName, Action <IPathDirection> action = null) { Parameter @default = new Parameter() { Name = "Points", Text = "[0, 0]" }; action?.Invoke(this); if (Path.Type != LinePath.DirectionType.Straight) { Block srcBlock = this.model.System.Block.FirstOrDefault(b => b.BlockName == sourceBlockName); if (srcBlock != null) { Block destBlock = this.model.System.Block.FirstOrDefault(b => b.BlockName == destinationBlockName); if (destBlock != null) { int horizontalDiff = BlockExtensions.GetHorizontalDistance(srcBlock, destBlock); int verticalDiff = BlockExtensions.GetVerticalDistance(srcBlock, destBlock); switch (Path.Type) { case LinePath.DirectionType.Up: { @default = new Parameter() { Name = "Points", Text = $"[0, {-1 * (verticalDiff + Path.AppendedDistance)}]" }; } break; case LinePath.DirectionType.Down: { @default = new Parameter() { Name = "Points", Text = $"[0, {verticalDiff + Path.AppendedDistance}]" }; } break; case LinePath.DirectionType.Left: { @default = new Parameter() { Name = "Points", Text = $"[{-1 * (horizontalDiff + Path.AppendedDistance)}, 0]" }; } break; case LinePath.DirectionType.Right: { @default = new Parameter() { Name = "Points", Text = $"[{horizontalDiff + Path.AppendedDistance}, 0]" }; } break; } } } } return(@default); }