// 3D
    protected void ConvertCeiling(VirtualMap map, VirtualCell conversion_cell)
    {
        // Checking if we need to add a ceiling
        VirtualCell.CellType cell_type = conversion_cell.Type;
        //Debug.Log(conversion_cell);
        if (conversion_cell.IsFloor())
        {
            VirtualCell.CellType ceiling_type = VirtualCell.CellType.None;

            if (VirtualCell.IsRoomFloor(cell_type))
            {
                if (behaviour.addCeilingToRooms)
                {
                    ceiling_type = VirtualCell.CellType.RoomCeiling;
                }
            }
            else
            {
                if (behaviour.addCeilingToCorridors)
                {
                    ceiling_type = VirtualCell.CellType.CorridorCeiling;
                }
            }

            if (ceiling_type != VirtualCell.CellType.None)
            {
                conversion_cell.AddCellInstance(ceiling_type, conversion_cell.Orientation);
            }
        }
    }
Exemple #2
0
    public static VirtualCell Copy(VirtualCell input_cell)
    {
        VirtualCell copied_cell = new VirtualCell(input_cell.location);

        foreach (CellInstance c in input_cell.instances)
        {
            copied_cell.AddCellInstance(CellInstance.Copy(c));
        }
        copied_cell.connectedCells     = input_cell.connectedCells; // They have the same connected cells TODO: maybe instead copy them alltogether?
        copied_cell.distance_from_root = input_cell.distance_from_root;
        return(copied_cell);
    }
    protected void ConvertFloor(VirtualMap map, VirtualCell conversion_cell, bool mayBeDirectional = true)
    {
        CellLocation loc = conversion_cell.location;

        if (generator.mapDimensionsType == MapDimensionsType.THREE_DEE)
        {
            // 3D case
            if (GeneratorValues.multiStorey)
            {
                // Add ladders and avoid placing floors or ceilings for multi-storey
                if (map.start == loc && map.storey_number > 0)
                {
                    // No floor, just a ceiling
                    ConvertCeiling(map, conversion_cell);
                    conversion_cell.Type = VirtualCell.CellType.None;
                }
                else if (map.end == loc && map.storey_number < GeneratorValues.numberOfStoreys - 1)
                {
                    // Ladder up on top of a floor, no ceiling
                    ConvertDirectionalFloor(map, conversion_cell, mayBeDirectional);
                    conversion_cell.AddCellInstance(VirtualCell.CellType.Ladder, conversion_cell.Orientation);
                }
                else
                {
                    ConvertDirectionalFloor(map, conversion_cell, mayBeDirectional);
                    ConvertCeiling(map, conversion_cell);
                }
            }
            else
            {
                ConvertDirectionalFloor(map, conversion_cell, mayBeDirectional);
                ConvertCeiling(map, conversion_cell);
            }
        }
        else
        {
            // 2D case

            // We just check for directionality, if needed
            ConvertDirectionalFloor(map, conversion_cell, mayBeDirectional);
        }
    }
    protected void AddFillingFloors(VirtualMap map, VirtualCell conversion_cell)
    {
        if (conversion_cell.Type == VirtualCell.CellType.None)
        {
            return;
        }

        // Fill with floors
        VirtualCell.CellType     initial_type = conversion_cell.Type;
        VirtualMap.DirectionType initial_dir  = conversion_cell.Orientation;
        bool addedFloor = false;

        if (behaviour.fillWithFloors)
        {
            bool mayBeDirectional = false;
            if (CheckRoom(map, conversion_cell.location))
            {
                if (conversion_cell.IsDoor() || conversion_cell.IsEmpty())
                {
                    AddToCorrectRoom(map, conversion_cell.location);
                    conversion_cell.Type = VirtualCell.CellType.RoomFloor;
                    ConvertDirectionalRoomFloor(map, conversion_cell);
                    mayBeDirectional = true;
                }
                else
                {
                    conversion_cell.Type = VirtualCell.CellType.RoomFloor;
                }
            }
            else
            {
                if (conversion_cell.IsDoor() || conversion_cell.IsEmpty())
                {
                    conversion_cell.Type = VirtualCell.CellType.CorridorFloor;
                    ConvertDirectionalCorridorFloor(map, conversion_cell);
                    mayBeDirectional = true;
                }
                else
                {
                    conversion_cell.Type = VirtualCell.CellType.CorridorFloor;
                }
            }
            ConvertFloor(map, conversion_cell, mayBeDirectional);
            addedFloor = true;
        }
        else
        {
            // Special case: when not filling with floors AND we do not draw doors, we still need to place a floor underneath the empty passage representing the doors!
            if (conversion_cell.IsEmpty())                      // Decomment this if you want floors underneath doors ALWAYS: // || input_cell.IsDoor()){
            {
                conversion_cell.Type = VirtualCell.CellType.CorridorFloor;
                ConvertDirectionalCorridorFloor(map, conversion_cell);
                ConvertFloor(map, conversion_cell);
                addedFloor = true;
            }
        }

        if (addedFloor)
        {
            // The initial type is switched in, the floor becomes a subtype
            VirtualCell.CellType     new_subtype = conversion_cell.Type;
            VirtualMap.DirectionType new_dir     = conversion_cell.Orientation;
            conversion_cell.Type        = initial_type;
            conversion_cell.Orientation = initial_dir;
            conversion_cell.AddCellInstance(new_subtype, new_dir);
        }
    }