/// <summary> /// Returns the number of transactions sent from an address. /// </summary> /// <param name="address">address</param> /// <param name="blockTag">Block Param</param> /// <param name="blockNumber">integer block number,</param> /// <returns>integer of the number of transactions send from this address.</returns> public long GetTransactionCount(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionCount); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToString()); } var rpcResult = new RpcConnector().MakeRequest(rpcRequest); var balance = Convert.ToInt64(rpcResult.Result, 16); return(balance); }
/// <summary> /// Adds a new block as child of another. Return the child. /// </summary> /// <remarks>Original: add_child</remarks> public static Block CreateChildBlock(Block parent, LineInfo line, BlockTag blockType, int startColumn) { // if 'parent' isn't the kind of block that can accept this child, // then back up til we hit a block that can. while (!CanContain(parent.Tag, blockType)) { Finalize(parent, line); parent = parent.Parent; } var startPosition = line.IsTrackingPositions ? line.CalculateOrigin(startColumn, true) : line.LineOffset; #pragma warning disable 0618 Block child = new Block(blockType, line.LineNumber, startColumn + 1, startPosition); #pragma warning restore 0618 child.Parent = parent; child.Top = parent.Top; var lastChild = parent.LastChild; if (lastChild != null) { lastChild.NextSibling = child; #pragma warning disable 0618 child.Previous = lastChild; #pragma warning restore 0618 } else { parent.FirstChild = child; } parent.LastChild = child; return(child); }
private static bool CanContain(BlockTag parent_type, BlockTag child_type) { return (parent_type == BlockTag.Document || parent_type == BlockTag.BlockQuote || parent_type == BlockTag.ListItem || (parent_type == BlockTag.List && child_type == BlockTag.ListItem)); }
public Filter(string fromBlock = null, string toBlock = null,BlockTag from = BlockTag.Earliest, BlockTag to = BlockTag.Pending, string address = null, string[] topics = null) { FromBlock = fromBlock ?? from.ToJsonMethodName(); ToBlock = toBlock ?? to.ToJsonMethodName(); Address = address; Topics = topics; }
private static bool AcceptsLines(BlockTag block_type) { return (block_type == BlockTag.Paragraph || block_type == BlockTag.AtxHeader || block_type == BlockTag.IndentedCode || block_type == BlockTag.FencedCode); }
public Filter(string fromBlock = null, string toBlock = null, BlockTag from = BlockTag.Earliest, BlockTag to = BlockTag.Pending, string address = null, string[] topics = null) { FromBlock = fromBlock ?? from.ToJsonMethodName(); ToBlock = toBlock ?? to.ToJsonMethodName(); Address = address; Topics = topics; }
private static bool CanContain(BlockTag parent_type, BlockTag child_type) { return(parent_type == BlockTag.Document || parent_type == BlockTag.BlockQuote || parent_type == BlockTag.ListItem || (parent_type == BlockTag.List && child_type == BlockTag.ListItem)); }
protected Block ToMarkdownDocumentBlock(BlockTag blockTag, FencedCodeData fencedCodeData) { var document = new Block(BlockTag.Document, 0); var block = new Block(blockTag, 0) { Parent = document, Top = document, FencedCodeData = fencedCodeData, StringContent = new StringContent() }; if (Buffer.Length > 0) { block.StringContent.Append(Buffer.Value, 0, Buffer.Length); if (Buffer.Value [Buffer.Length - 1] != '\n') { block.StringContent.Append("\n", 0, 1); } } document.FirstChild = block; return(document); }
private static bool AcceptsLines(BlockTag block_type) { return(block_type == BlockTag.Paragraph || block_type == BlockTag.AtxHeading || block_type == BlockTag.IndentedCode || block_type == BlockTag.FencedCode); }
public Block GetBlockByNumber(int blockNumber, BlockTag blockTag, bool returnFullObject) { var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByNumber); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToHexString()); } rpcRequest.AddParam(returnFullObject); var rpcResult = new RpcConnector().MakeRequest(rpcRequest); var json = JsonConvert.SerializeObject(rpcResult.Result); var block = JsonConvert.DeserializeObject <Block>(json); return(block); }
/// <summary> /// Returns the balance of the account of given address. /// </summary> /// <param name="address">address to check for balance.</param> /// <param name="blockTag"> integer block number</param> /// <param name="blockNumber">Block param</param> /// <returns></returns> public BigInteger GetBalance(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getBalance); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToString()); } var rpcResult = new RpcConnector().MakeRequest(rpcRequest); if (rpcResult.Result == null) { return(0); } string value = rpcResult.Result.ToString(); var balance = value.ToBigInteger(); return(balance); }
public Block(BlockTag tag, int startLine, int startColumn) { this.Tag = tag; this.StartLine = startLine; this.EndLine = startLine; this.StartColumn = startColumn; this.IsOpen = true; }
public Block(BlockTag tag, int startLine, int startColumn, int sourcePosition) { this.Tag = tag; this.StartLine = startLine; this.EndLine = startLine; this.StartColumn = startColumn; this.SourcePosition = sourcePosition; this.IsOpen = true; }
/// <summary> /// Returns the balance of the account of given address. /// </summary> /// <param name="address">20 Bytes - address to check for balance.</param> /// <param name="blockNumber">"latest", "earliest" or "pending"</param> /// <returns>integer of the current balance in wei</returns> public async Task <int> GetBalanceAsync(string address, BlockTag tag = BlockTag.Latest) { var response = await InvokeAsync <string>( "eth_getBalance", address, nameof(tag).ToLower()); return(response.Result.ToInt()); }
public Block(BlockTag tag, int startLine, int startColumn, int sourcePosition) { Tag = tag; StartLine = startLine; EndLine = startLine; StartColumn = startColumn; SourcePosition = sourcePosition; IsOpen = true; }
public BlockTag AddBlockTag(string id, params Block[] values) { BlockTag tag = new BlockTag(new ResourceLocation(this, id)); foreach (Block b in values) { tag.Add(b); } return(tag); }
/// <summary> /// Returns the value from a storage position at a given address. /// </summary> /// <param name="address">20 Bytes - address of the storage</param> /// <param name="position">integer of the position in the storage</param> /// <param name="block">"latest", "earliest" or "pending"</param> /// <returns>the value at this storage position</returns> public async Task <string> GetStorageAtAsync(string address, int position, BlockTag block = BlockTag.Latest) { var response = await InvokeAsync <string>( "eth_getStorageAt", address, position.ToString(), nameof(block).ToLower()); return(response.Result); }
public override bool Equals(BlockTag tag) { var t = tag as DamageTag; if (ReferenceEquals(t, null)) { return(false); } return(Strength == t.Strength && TotalStrength == t.TotalStrength); }
public override bool Equals(BlockTag tag) { var t = tag as LiquidTag; if (ReferenceEquals(t, null)) { return(false); } return(Pressure == t.Pressure && LiquidType == t.LiquidType && Sourced == t.Sourced); }
/// <summary> /// Writes specidfied value to current cursor position /// </summary> /// <param name="value"></param> /// <param name="tag"> </param> /// <param name="sourceDynamicId">Id of the entity that is responsible for that change</param> public void Write(byte value, BlockTag tag = null, uint sourceDynamicId = 0) { var handler = BeforeWrite; if (handler != null) { handler(this, new LandscapeCursorBeforeWriteEventArgs { GlobalPosition = GlobalPosition, Value = value, BlockTag = tag, SourceDynamicId = sourceDynamicId == 0 ? OwnerDynamicId : sourceDynamicId }); } _landscapeManager.ReplaceBlock(_bigArrayIndex, ref _globalPosition, value, false, tag); }
/// <summary> /// Returns code at a given address. /// </summary> /// <param name="address">address</param> /// <param name="blockTag"></param> /// <param name="blockNumber">integer block number,</param> /// <returns></returns> public string GetCode(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getCode); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToHexString()); }; var rpcResult = new RpcConnector().MakeRequest(rpcRequest); return(rpcResult.Result); }
public void ReplaceBlocks(Vector3I[] position, byte[] blockId, BlockTag[] tags, bool isNetworkChange) { //Single block to change ============================================= if (blockId.Length == 1) { ThreadsManager.RunAsync(() => ReplaceBlockThreaded(position[0], blockId[0], isNetworkChange, tags != null ? tags[0] : null), singleConcurrencyRun: true); return; } //Multiple blocks to change ============================================= Dictionary <VisualChunk, List <TerraCubePositionTag> > blockPerChunk = new Dictionary <VisualChunk, List <TerraCubePositionTag> >(); List <TerraCubePositionTag> blockList; //Multiple block to changes at once //Split the various blocks by chunks for (int i = 0; i < blockId.Length; i++) { BlockTag tag = tags != null ? tags[i] : null; VisualChunk impactedChunk; if (_worldChunks.GetSafeChunk(position[i].X, position[i].Z, out impactedChunk)) { if (!blockPerChunk.TryGetValue(impactedChunk, out blockList)) { blockList = new List <TerraCubePositionTag>(); blockPerChunk[impactedChunk] = blockList; } blockList.Add(new TerraCubePositionTag(position[i], blockId[i], tag)); } } //Create a thread for working on the update per chunk ! foreach (var blocks in blockPerChunk) { ThreadsManager.RunAsync(() => ReplaceChunkBlocksThreaded(blocks.Key, blocks.Value, isNetworkChange), singleConcurrencyRun: true); } }
/// <summary> /// Initializes a new instance of the <see cref="Block"/> class. /// </summary> /// <param name="tag">The type of the element this instance represents.</param> /// <param name="sourcePosition">The position of the first character of this block in the source text.</param> public Block(BlockTag tag, int sourcePosition) { this.Tag = tag; this.SourcePosition = sourcePosition; this.IsOpen = true; }
// Add a block as child of another. Return pointer to child. public static Syntax.Block add_child(Syntax.Block parent, BlockTag block_type, int start_line, int start_column) { // if 'parent' isn't the kind of block that can accept this child, // then back up til we hit a block that can. while (!can_contain(parent.Tag, block_type)) { finalize(parent, start_line); parent = parent.Parent; } if (parent == null) throw new ArgumentNullException("parent"); Syntax.Block child = new Syntax.Block(block_type, start_line, start_column); child.Parent = parent; child.Top = parent.Top; if (parent.LastChild != null) { parent.LastChild.Next = child; child.Previous = parent.LastChild; } else { parent.FirstChild = child; child.Previous = null; } parent.LastChild = child; return child; }
/// <summary> /// Initializes a new instance of the <see cref="Block"/> class. /// </summary> /// <param name="tag">The type of the element this instance represents.</param> /// <param name="sourcePosition">The position of the first character of this block in the source text.</param> public Block(BlockTag tag, int sourcePosition) { Tag = tag; SourcePosition = sourcePosition; IsOpen = true; }
public bool ReplaceBlock(int cubeArrayIndex, ref Vector3I cubeCoordinates, byte replacementCubeId, bool isNetworkChanged, BlockTag blockTag = null) { VisualChunk impactedChunk = _worldChunks.GetChunk(cubeCoordinates.X, cubeCoordinates.Z); if (impactedChunk.State != ChunkState.DisplayInSyncWithMeshes && isNetworkChanged) { return(false); } try { // Check if the cube is not already the same ? ! ? var existingCube = _cubesHolder.Cubes[cubeArrayIndex]; var inChunkPos = BlockHelper.GlobalToInternalChunkPosition(cubeCoordinates); if (existingCube.Id == replacementCubeId) { // tag change event // some tags changes requires chunk mesh rebuild (LiquidTag), some not (DamageTag) // we will update the mesh only if at least one tag (current or previous) requires mesh update var needChunkMeshUpdate = false; var oldTag = impactedChunk.BlockData.GetTag(inChunkPos); if (oldTag != null && oldTag.RequireChunkMeshUpdate) { needChunkMeshUpdate = true; } if (blockTag != null && blockTag.RequireChunkMeshUpdate) { needChunkMeshUpdate = true; } if (!needChunkMeshUpdate) { impactedChunk.BlockData.SetTag(blockTag, inChunkPos); return(true); } } // Change the cube in the big array impactedChunk.BlockData.SetBlock(inChunkPos, replacementCubeId, blockTag); // Start Chunk Visual Impact to decide what needs to be redraw, will be done in async mode, // quite heavy, will also restart light computations for the impacted chunk range. var cube = new TerraCubeWithPosition(cubeCoordinates, replacementCubeId, _visualWorldParameters.WorldParameters.Configuration.BlockProfiles[replacementCubeId]); #if PERFTEST if (Utopia.Worlds.Chunks.WorldChunks.perf.Actif == false) { Utopia.Worlds.Chunks.WorldChunks.perf.Actif = true; Utopia.Worlds.Chunks.WorldChunks.perf.CollectedData = new List <string>(); Utopia.Worlds.Chunks.WorldChunks.perf.AddData("Started New User Action"); Utopia.Worlds.Chunks.WorldChunks.perf.sw.Restart(); } #endif impactedChunk.UpdateOrder = !cube.BlockProfile.IsBlockingLight ? 1 : 2; //Compute the Range impacted by the cube change var cubeRange = new Range3I { Position = new Vector3I(cube.Position.X, 0, cube.Position.Z), Size = Vector3I.One }; ThreadsManager.RunAsync(() => CheckImpact(impactedChunk, cubeRange), ThreadsManager.ThreadTaskPriority.High); // Raise event for sound OnBlockReplaced(new LandscapeBlockReplacedEventArgs { IsLocalPLayerAction = !isNetworkChanged, Position = cubeCoordinates, NewBlockType = replacementCubeId, PreviousBlock = existingCube }); return(true); } finally { // Save the modified Chunk in local buffer DB SendChunkForBuffering(impactedChunk); } }
public bool ReplaceBlock(Vector3I cubeCoordinates, byte replacementCubeId, bool isNetworkChange, BlockTag blockTag = null) { return(ReplaceBlock(_cubesHolder.Index(ref cubeCoordinates), ref cubeCoordinates, replacementCubeId, isNetworkChange, blockTag)); }
/// <summary> /// Returns code at a given address. /// </summary> /// <param name="address">address</param> /// <param name="blockTag"></param> /// <param name="blockNumber">integer block number,</param> /// <returns></returns> public string GetCode(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getCode); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToHexString()); }; var rpcResult = new RpcConnector().MakeRequest(rpcRequest); return rpcResult.Result; }
/// <summary> /// Returns the number of transactions sent from an address. /// </summary> /// <param name="address">20 Bytes - address of the storage</param> /// <param name="block">"latest", "earliest" or "pending"</param> /// <returns>integer of the number of transactions send from this address</returns> public async Task <int> GetTransactionCountAsync(string address, BlockTag block) { var response = await InvokeAsync <string>("eth_getTransactionCount", address, nameof(block).ToLower()); return(response.Result.ToInt()); }
/// <summary> /// Returns the number of uncles in a block from a block matching the given block number. /// </summary> /// <param name="block">"latest", "earliest" and "pending"</param> /// <returns>integer of the number of uncles in this block</returns> public async Task <int> GetUncleCountByBlockNumberAsync(BlockTag block) { var response = await InvokeAsync <string>("eth_getUncleCountByBlockNumber", nameof(block).ToLower()); return(response.Result.ToInt()); }
public static string ToJsonMethodName(this BlockTag value) { return(GetEnumDescription(value)); }
/// <summary> /// Returns code at a given address. /// </summary> /// <param name="address">20 Bytes - address</param> /// <param name="block">"latest", "earliest" and "pending"</param> /// <returns>the code from the given address</returns> public async Task <string> GetCodeAsync(string address, BlockTag block) { var response = await InvokeAsync <string>("eth_getCode", address, nameof(block).ToLower()); return(response.Result); }
/// <summary> /// Adds a new block as child of another. Return the child. /// </summary> /// <remarks>Original: add_child</remarks> public static Block CreateChildBlock(Block parent, LineInfo line, BlockTag blockType, int startColumn) { // if 'parent' isn't the kind of block that can accept this child, // then back up til we hit a block that can. while (!CanContain(parent.Tag, blockType)) { Finalize(parent, line); parent = parent.Parent; } var startPosition = line.IsTrackingPositions ? line.CalculateOrigin(startColumn, true) : line.LineOffset; #pragma warning disable 0618 Block child = new Block(blockType, line.LineNumber, startColumn + 1, startPosition); #pragma warning restore 0618 child.Parent = parent; child.Top = parent.Top; var lastChild = parent.LastChild; if (lastChild != null) { lastChild.NextSibling = child; #pragma warning disable 0618 child.Previous = lastChild; #pragma warning restore 0618 } else { parent.FirstChild = child; } parent.LastChild = child; return child; }
public void GenCubeFace(ref TerraCube cube, CubeFaces cubeFace, ref Vector4B cubePosition, ref Vector3I cubePosiInWorld, VisualChunk chunk, ref TerraCube topCube, Dictionary <long, int> verticeDico) { int yBlockOffsetAsInt = 0; float yBlockOffset = 0; int verticeCubeOffset = chunk.Graphics.LiquidCubeVertices.Count; int indiceCubeOffset = chunk.Graphics.LiquidCubeIndices.Count; ByteColor newColor = cube.EmissiveColor; BlockTag tag = null; BlockProfile blockProfile = _wp.WorldParameters.Configuration.BlockProfiles[cube.Id]; //Get the Cube Tag Informations if (blockProfile.IsTaggable) { tag = chunk.BlockData.GetTag(new Vector3I(cubePosition.X, cubePosition.Y, cubePosition.Z)); } bool IsEmissiveColor = blockProfile.IsEmissiveColorLightSource; bool vertexInDico; //Les 4 vertex de ma face.... en fct de leur position dans le cube leur valeur en Z va changer ! (Face Top, Bottom, ... Vector4B topLeft; Vector4B topRight; Vector4B bottomLeft; Vector4B bottomRight; //GetBlock Offset if (blockProfile.IsTaggable && tag is ICubeYOffsetModifier) { yBlockOffset = ((ICubeYOffsetModifier)tag).YOffset; } else { //Add a naturel Offset to StillWater when touching water at the surface ! if (topCube.Id != cube.Id) { yBlockOffset = (float)blockProfile.YBlockOffset; } } yBlockOffsetAsInt = (int)(yBlockOffset * 255); ChunkColumnInfo chunkInfo = chunk.BlockData.GetColumnInfo(new Vector2I(cubePosition.X, cubePosition.Z)); Vector4B vertexInfo2 = new Vector4B(chunkInfo.Moisture, chunkInfo.Temperature, (byte)0, (byte)0); Vector4B vertexInfo1 = new Vector4B((byte)cubeFace, (byte)0, //Is "UP" vertex blockProfile.BiomeColorArrayTexture, (byte)0); long hashVertex; int generatedVertex = 0; int vertexOffset0, vertexOffset1, vertexOffset2, vertexOffset3; int[] ind = new int[9]; //Get the index of the current cube. int baseIndex = _cubesHolder.Index(ref cubePosiInWorld); switch (cubeFace) { case CubeFaces.Front: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Z, SingleArrayChunkContainer.IdxRelativeMove.Z_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Z, ind, true); ByteColor Back_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor BackLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor BackRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor BackTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor BackBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor BackLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor BackRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor BackLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor BackRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Front.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Front.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackTop_Cube, BackLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackTop_Cube, BackRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackLeft_Cube, BackBottom_Cube, BackLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Back_Cube, BackRight_Cube, BackBottom_Cube, BackRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Front.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); break; case CubeFaces.Back: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Z, SingleArrayChunkContainer.IdxRelativeMove.Z_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Z, ind, true); ByteColor Front_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor FrontLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor FrontRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor FrontTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor FrontBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor FrontLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor FrontRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor FrontLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor FrontRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Back.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Back.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontLeftTop_Cube, FrontLeft_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontTop_Cube, FrontRight_Cube, FrontRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontLeft_Cube, FrontLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Front_Cube, FrontBottom_Cube, FrontRight_Cube, FrontRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Back.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); break; case CubeFaces.Top: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Y, SingleArrayChunkContainer.IdxRelativeMove.Y_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Y, ind, true); ByteColor Bottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor BottomLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor BottomRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor BottomTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor BottomBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor BottomLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor BottomRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor BottomLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor BottomRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Top.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Top.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomLeft_Cube, BottomLeftTop_Cube, BottomTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomRight_Cube, BottomBottom_Cube, BottomRightBottom_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomBottom_Cube, BottomLeft_Cube, BottomLeftBottom_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Bottom_Cube, BottomTop_Cube, BottomRight_Cube, BottomRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Top.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); break; case CubeFaces.Bottom: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.Y, SingleArrayChunkContainer.IdxRelativeMove.Y_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.Y, ind, true); ByteColor Top_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor TopLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor TopRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor TopTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor TopBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor TopLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor TopRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor TopLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor TopRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Bottom.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Bottom.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopLeft_Cube, TopLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopLeft_Cube, TopLeftTop_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopBottom_Cube, TopRight_Cube, TopRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Top_Cube, TopTop_Cube, TopRight_Cube, TopRightTop_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Bottom.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); break; case CubeFaces.Left: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.X, SingleArrayChunkContainer.IdxRelativeMove.X_Minus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.X, ind, true); ByteColor Right_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor RightLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor RightRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor RightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor RightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor RightLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor RightRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor RightLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor RightRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(0, 1, 0, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(0, 0, 1, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(0, 0, 0, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(0, 1, 1, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Left.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Left.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightRight_Cube, RightRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightTop_Cube, RightLeft_Cube, RightLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightRight_Cube, RightRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Right_Cube, RightBottom_Cube, RightLeft_Cube, RightLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Left.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); break; case CubeFaces.Right: //Get the 9 Facing cubes to the face _cubesHolder.SurroundingAxisIndex(_cubesHolder.FastIndex(baseIndex, cubePosiInWorld.X, SingleArrayChunkContainer.IdxRelativeMove.X_Plus1), cubePosiInWorld.X, cubePosiInWorld.Y, cubePosiInWorld.Z, SingleArrayChunkContainer.Axis.X, ind, true); ByteColor Left_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.BaseIndex]].EmissiveColor; ByteColor LeftLeft_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.LeftIndex]].EmissiveColor; ByteColor LefttRight_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.RightIndex]].EmissiveColor; ByteColor LeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpIndex]].EmissiveColor; ByteColor LeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownIndex]].EmissiveColor; ByteColor LeftLeftTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpLeftIndex]].EmissiveColor; ByteColor LeftRightTop_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.UpRightIndex]].EmissiveColor; ByteColor LeftLeftBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownLeftIndex]].EmissiveColor; ByteColor LeftRightBottom_Cube = _cubesHolder.Cubes[ind[SingleArrayChunkContainer.DownRightIndex]].EmissiveColor; topLeft = cubePosition + new Vector4B(1, 1, 1, yBlockOffsetAsInt); topRight = cubePosition + new Vector4B(1, 1, 0, yBlockOffsetAsInt); bottomLeft = cubePosition + new Vector4B(1, 0, 1, yBlockOffsetAsInt); bottomRight = cubePosition + new Vector4B(1, 0, 0, yBlockOffsetAsInt); vertexInfo2.Z = blockProfile.Tex_Right.AnimationSpeed; vertexInfo2.W = blockProfile.Tex_Right.Texture.AnimationFrames; hashVertex = (long)cubeFace + ((long)topRight.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset0); if (vertexInDico == false) { vertexOffset0 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset0); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LefttRight_Cube, LeftRightTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)topLeft.GetHashCode() << 8) + ((long)cube.Id << 40) + ((long)yBlockOffsetAsInt << 48); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset1); if (vertexInDico == false) { vertexOffset1 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset1); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftTop_Cube, LeftLeft_Cube, LeftLeftTop_Cube); } vertexInfo1.Y = 1; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref topLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomLeft.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset2); if (vertexInDico == false) { vertexOffset2 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset2); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LeftLeft_Cube, LeftLeftBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomLeft, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } hashVertex = (long)cubeFace + ((long)bottomRight.GetHashCode() << 8) + ((long)cube.Id << 40); vertexInDico = verticeDico.TryGetValue(hashVertex, out vertexOffset3); if (vertexInDico == false) { vertexOffset3 = generatedVertex + verticeCubeOffset; verticeDico.Add(hashVertex, vertexOffset3); if (!IsEmissiveColor) { newColor = ByteColor.Average(Left_Cube, LeftBottom_Cube, LefttRight_Cube, LeftRightBottom_Cube); } vertexInfo1.Y = 0; chunk.Graphics.LiquidCubeVertices.Add(new VertexCubeLiquid(ref bottomRight, blockProfile.Tex_Right.TextureArrayId, ref newColor, ref vertexInfo2, ref vertexInfo1)); generatedVertex++; } //Create Vertices chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset3)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset1)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset2)); chunk.Graphics.LiquidCubeIndices.Add((ushort)(vertexOffset0)); break; } }
internal RuntimeTag(BlockTag blockTag) : base(blockTag.Attributes) { this._segment = blockTag; }
public TerraCubePositionTag(Vector3I pos, byte cubeId, BlockTag tag) { Position = pos; Cube = new TerraCube(cubeId); Tag = tag; }
/// <summary> /// Returns the number of transactions sent from an address. /// </summary> /// <param name="address">address</param> /// <param name="blockTag">Block Param</param> /// <param name="blockNumber">integer block number,</param> /// <returns>integer of the number of transactions send from this address.</returns> public long GetTransactionCount(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getTransactionCount); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToString()); } var rpcResult = new RpcConnector().MakeRequest(rpcRequest); var balance = Convert.ToInt64(rpcResult.Result, 16); return balance; }
//Single block replace logic public void ReplaceBlockThreaded(Vector3I cubeCoordinates, byte replacementCubeId, bool isNetworkChange, BlockTag blockTag = null) { while (!ReplaceBlock(cubeCoordinates, replacementCubeId, isNetworkChange, blockTag) && isNetworkChange) { System.Threading.Thread.Sleep(5); } }
/// <summary> /// Returns the balance of the account of given address. /// </summary> /// <param name="address">address to check for balance.</param> /// <param name="blockTag"> integer block number</param> /// <param name="blockNumber">Block param</param> /// <returns></returns> public BigInteger GetBalance(string address, BlockTag blockTag = BlockTag.Quantity, int blockNumber = -1) { var rpcRequest = new RpcRequest(RpcMethod.eth_getBalance); rpcRequest.AddParam(address); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToString()); } var rpcResult = new RpcConnector().MakeRequest(rpcRequest); if (rpcResult.Result == null) { return 0; } string value = rpcResult.Result.ToString(); var balance = value.ToBigInteger(); return balance; }
public Block GetBlockByNumber(int blockNumber, BlockTag blockTag, bool returnFullObject) { var rpcRequest = new RpcRequest(RpcMethod.eth_getBlockByNumber); if (blockTag != BlockTag.Quantity && blockNumber > -1) { throw new Exception("Balance tag and block number cannot both be provided, chose either"); } if (blockTag != BlockTag.Quantity) { rpcRequest.AddParam(blockTag.ToJsonMethodName()); } else { rpcRequest.AddParam(blockNumber.ToHexString()); } rpcRequest.AddParam(returnFullObject); var rpcResult = new RpcConnector().MakeRequest(rpcRequest); var json = JsonConvert.SerializeObject(rpcResult.Result); var block = JsonConvert.DeserializeObject<Block>(json); return block; }