Esempio n. 1
0
        public float calc_water_depth(uint blockCellID, Vector3 point)
        {
            var  cellID = blockCellID & 0xFFFF;
            var  cellOffset = cellID - 1;
            uint cellX = 0, cellY = cellID;

            if (LandDefs.inbound_valid_cellid(cellID) && cellID < 0x100)
            {
                cellX = cellOffset / 8;
                cellY = cellOffset & 7;
            }
            uint terrainIdx;
            uint surfOffset = 0;

            // missing fpu instructions
            if (point.X <= point.Y)
            {
                terrainIdx = (cellY + 8 * cellX + cellX + 1);
                if (point.X == point.Y)
                {
                    terrainIdx--;
                }
            }
            else if (point.X >= point.Y)
            {
                terrainIdx = cellY + 8 * (cellX + 1) + cellX + 1;
            }
            else  // ?
            {
                terrainIdx = 8 * cellX + 10;
                surfOffset = (cellX + cellY) * 2;
            }
            var column   = Terrain[(int)terrainIdx & 0xFF];
            var hasWater = SurfChar[column + (int)surfOffset & 0x7F];

            if (hasWater != 0)
            {
                if (hasWater == 1)
                {
                    return(0.44999999f);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0.1f);
            }
        }