Ejemplo n.º 1
0
        /// <summary>
        /// Get the BlockType struct of a block type
        /// </summary>
        /// <param name="Number">Number of the block</param>
        /// <param name="Result">BlockType struct of the block</param>
        /// <returns>Return code signifying success (0: OK, -1: No block with this name)</returns>
        public static int GetBlockType(int Number, out BlockType Result)
        {
            if (!NumToBlockDict.ContainsKey(Number))
            {
                Result = new BlockType();
                return -1;
            }

            NumToBlockDict.TryGetValue(Number, out Result);

            return 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the BlockType struct of a block type
        /// </summary>
        /// <param name="Name">Name of the block</param>
        /// <param name="Result">BlockType struct of the block</param>
        /// <returns>Return code signifying success (0: OK, -1: No block with this name)</returns>
        public static int GetBlockType(string Name, out BlockType Result)
        {
            if (!NameToNumDict.ContainsKey(Name))
            {
                Result = new BlockType();
                return -1;
            }

            int blockNumber;

            NameToNumDict.TryGetValue(Name, out blockNumber);
            NumToBlockDict.TryGetValue(blockNumber, out Result);

            return 0;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add a new block type to the dictionary
 /// </summary>
 /// <param name="Name">Name of the new block</param>
 /// <param name="Attributes">BlockType struct for the new block</param>
 /// <returns>Block number of the new block</returns>
 public static int RegisterNewBlock(string Name, BlockType Attributes)
 {
     NameToNumDict.Add(Name, NameToNumDict.Count + 1);
     NumToBlockDict.Add(NameToNumDict.Count, Attributes);
     return NameToNumDict.Count;
 }