Example #1
0
        private ulong GetTileMappingIndex(Map map, CellTypeMap cellTypeMap, Vector2Int tileXY)
        {
            ulong x = (ulong)tileXY.x;
            ulong y = (ulong)tileXY.y;

            // Get default mapping index
            ulong mappingIndex = map.GetTileMappingIndex(x, y);

            // If no cell type map, return the map index. This will happen if there isn't any .opm mission file.
            if (cellTypeMap == null)
            {
                return(mappingIndex);
            }

            // Get TerrainType for mapping index, if available
            TerrainType terrainType;

            if (!GetTerrainTypeForMappingIndex(map, mappingIndex, out terrainType))
            {
                return(mappingIndex);
            }

            // Predict starting CellType and remap to terrain type
            int wallTubeIndex;

            switch (TileMapData.GetWallTubeIndexForTile(cellTypeMap, tileXY, out wallTubeIndex))
            {
            case CellType.DozedArea:                mappingIndex = terrainType.bulldozedTileMappingIndex;                                           break;

            case CellType.NormalWall:               mappingIndex = terrainType.wallTileMappingIndexes[2 * 16 + wallTubeIndex];          break;

            case CellType.LavaWall:                 mappingIndex = terrainType.wallTileMappingIndexes[wallTubeIndex];                       break;

            case CellType.MicrobeWall:              mappingIndex = terrainType.wallTileMappingIndexes[1 * 16 + wallTubeIndex];          break;

            case CellType.Tube0:
            case CellType.Tube1:
            case CellType.Tube2:
            case CellType.Tube3:
            case CellType.Tube4:
            case CellType.Tube5:
                mappingIndex = terrainType.tubeTileMappingIndexes[wallTubeIndex];
                break;
            }

            return(mappingIndex);
        }
Example #2
0
        private int GetTileMappingIndex(CellTypeMap cellTypeMap, Vector2Int tileXY)
        {
            int x = tileXY.x;
            int y = tileXY.y;

            // Get default mapping index
            int mappingIndex = UserData.current.map.GetTileMappingIndex(x, y);

            // Get TerrainType for mapping index, if available
            OP2UtilityDotNet.OP2Map.TerrainType terrainType;
            if (!GetTerrainTypeForMappingIndex(mappingIndex, out terrainType))
            {
                return(mappingIndex);
            }

            // Predict starting CellType and remap to terrain type
            int wallTubeIndex;

            switch (TileMapData.GetWallTubeIndexForTile(cellTypeMap, tileXY, out wallTubeIndex))
            {
            case OP2UtilityDotNet.OP2Map.CellType.DozedArea:                        mappingIndex = terrainType.bulldozedTileMappingIndex;                                           break;

            case OP2UtilityDotNet.OP2Map.CellType.NormalWall:                       mappingIndex = terrainType.wallTileMappingIndexes[2, wallTubeIndex];            break;

            case OP2UtilityDotNet.OP2Map.CellType.LavaWall:                         mappingIndex = terrainType.wallTileMappingIndexes[0, wallTubeIndex];            break;

            case OP2UtilityDotNet.OP2Map.CellType.MicrobeWall:                      mappingIndex = terrainType.wallTileMappingIndexes[1, wallTubeIndex];            break;

            case OP2UtilityDotNet.OP2Map.CellType.Tube0:
            case OP2UtilityDotNet.OP2Map.CellType.Tube1:
            case OP2UtilityDotNet.OP2Map.CellType.Tube2:
            case OP2UtilityDotNet.OP2Map.CellType.Tube3:
            case OP2UtilityDotNet.OP2Map.CellType.Tube4:
            case OP2UtilityDotNet.OP2Map.CellType.Tube5:
                mappingIndex = terrainType.tubeTileMappingIndexes[wallTubeIndex];
                break;
            }

            return(mappingIndex);
        }