Search in sources :

Example 1 with BuildHelper

use of eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper in project Eidolons by IDemiurge.

the class LocationBuilder method buildDungeonPlan.

// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
    if (helper == null) {
        helper = new BuildHelper(location, params);
        helper.setPlan(plan);
    }
    if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
        {
            if (!location.isUnderground()) {
            // return;
            }
            plan = new DungeonPlan(testTemplate, location);
            int x1 = 0;
            int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
            if (x2 <= 0) {
                x2 = location.getCellsX();
            } else {
                location.setParam(PARAMS.BF_WIDTH, x2);
            }
            int y1 = 0;
            int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
            if (y2 <= 0) {
                y2 = location.getCellsY();
            } else {
                location.setParam(PARAMS.BF_HEIGHT, y2);
            }
            MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
            List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
            new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
            plan.getZones().add(zone);
            return plan;
        }
    }
    if (TestDungeonInitializer.PRESET_PLAN != null) {
        File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
        if (file.isFile()) {
            String data = FileManager.readFile(file);
            DungeonPlan plan = null;
            try {
                plan = loadDungeonMap(data);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
            return plan;
        }
    }
    // preset in location-mission, based
    // on Level?
    // yes, any dungeon could have any template more or less,
    template = location.getTemplate();
    if (testMode) {
        template = testTemplate;
    }
    if (template == null) {
        template = DUNGEON_TEMPLATES.CLASSIC;
    }
    List<MapBlock> blocks = null;
    Map<ObjType, Coordinates> objMap = null;
    plan = new DungeonPlan(template, location);
    location.setPlan(plan);
    plan.setBlocks(blocks);
    plan.setObjMap(objMap);
    plan.setZones(createMapZones());
    // Entrance exit = dungeon.getMainExit();
    // Entrance entrance = dungeon.getMainEntrance();
    // plan.setBaseAnchor(
    // entrance.getCoordinates()
    // );
    // plan.setEndAnchor(exit.getCoordinates());
    // if (!dungeon.isIgnoreRotate())
    plan.setRotated(location.isRotated());
    plan.setFlippedX(location.isFlippedX());
    plan.setFlippedY(location.isFlippedY());
    placeMainRooms();
    if (!location.isSurface()) {
        placeCulDeSacs();
    }
    if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
        placeAdditionalRooms();
    }
    if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
        linkWithCorridors();
    }
    return plan;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) ObjType(main.entity.type.ObjType) DungeonPlan(eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan) Coordinates(main.game.bf.Coordinates) BuildHelper(eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) File(java.io.File)

Example 2 with BuildHelper

use of eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper in project Eidolons by IDemiurge.

the class LE_MapMaster method initBuildParams.

public static BuildParameters initBuildParams(boolean empty, Location location) {
    BuildParameters params = new BuildHelper(location).new BuildParameters(empty);
    params.setValue(BUILD_PARAMS.WIDTH, "" + location.getCellsX());
    params.setValue(BUILD_PARAMS.HEIGHT, "" + location.getCellsY());
    if (location.getPlan() != null) {
        params.setValue(BUILD_PARAMS.WIDTH_MOD, "" + location.getPlan().getWidthMod());
        params.setValue(BUILD_PARAMS.HEIGHT_MOD, "" + location.getPlan().getHeightMod());
        params.setValue(BUILD_PARAMS.SIZE_MOD, "" + location.getPlan().getSizeMod());
    }
    String data = params.getDataMapFormat();
    data = TextEditor.inputTextLargeField("Alter build parameters...", data);
    if (data != null) {
        params = new BuildHelper(location).new BuildParameters(data);
        location.setParam(PARAMS.BF_WIDTH, params.getIntValue(BUILD_PARAMS.WIDTH));
        location.setParam(PARAMS.BF_HEIGHT, params.getIntValue(BUILD_PARAMS.HEIGHT));
        location.setProperty(PROPS.FILLER_TYPE, params.getValue(BUILD_PARAMS.FILLER_TYPE));
        location.getType().setParam(PARAMS.BF_WIDTH, params.getIntValue(BUILD_PARAMS.WIDTH));
        location.getType().setParam(PARAMS.BF_HEIGHT, params.getIntValue(BUILD_PARAMS.HEIGHT));
        location.getType().setProperty(PROPS.FILLER_TYPE, params.getValue(BUILD_PARAMS.FILLER_TYPE));
        location.setBuildParams(params);
    }
    GuiManager.setCurrentLevelCellsX(location.getCellsX());
    GuiManager.setCurrentLevelCellsY(location.getCellsY());
    return params;
}
Also used : BuildParameters(eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper.BuildParameters) BuildHelper(eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper)

Aggregations

BuildHelper (eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper)2 BuildParameters (eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper.BuildParameters)1 DungeonPlan (eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan)1 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)1 MapZone (eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)1 File (java.io.File)1 ObjType (main.entity.type.ObjType)1 Coordinates (main.game.bf.Coordinates)1