fCraft.Map.Index C# (CSharp) Method

Index() public method

Converts given coordinates to a block array index.
public Index ( Vector3I coords ) : int
coords Vector3I Coordinate vector (X,Y,Z).
return int
        public int Index( Vector3I coords )
        {
            return ( coords.Z * Length + coords.Y ) * Width + coords.X;
        }

Same methods

Map::Index ( int x, int y, int z ) : int

Usage Example

Example #1
0
 private static void SealLiquids(Map map, byte sealantType)
 {
     for (int x = 1; x < map.Width - 1; x++)
     {
         for (int z = 1; z < map.Height; z++)
         {
             for (int y = 1; y < map.Length - 1; y++)
             {
                 int index = map.Index(x, y, z);
                 if ((map.Blocks[index] == 10 || map.Blocks[index] == 11 || map.Blocks[index] == 8 || map.Blocks[index] == 9) &&
                     (map.GetBlock(x - 1, y, z) == Block.Air || map.GetBlock(x + 1, y, z) == Block.Air ||
                      map.GetBlock(x, y - 1, z) == Block.Air || map.GetBlock(x, y + 1, z) == Block.Air ||
                      map.GetBlock(x, y, z - 1) == Block.Air))
                 {
                     map.Blocks[index] = sealantType;
                 }
             }
         }
     }
 }
All Usage Examples Of fCraft.Map::Index