Search in sources :

Example 1 with LE_MapViewComp

use of main.game.logic.dungeon.editor.gui.LE_MapViewComp in project Eidolons by IDemiurge.

the class Level method removeObj.

public void removeObj(DC_Obj obj) {
    Chronos.mark("removing " + obj);
    Unit unit = null;
    if (obj instanceof Unit) {
        unit = (Unit) obj;
    }
    if (obj instanceof Entrance) {
        if (location.getMainEntrance() != null) {
            location.setMainEntrance(null);
            location.getPlan().setEntranceLayout(null);
        } else if (location.getMainExit() == null) {
            location.setMainExit(null);
            location.getPlan().setExitLayout(null);
        }
        location.getEntrances().remove(obj);
    }
    // TODO getOrCreate Top object!
    // ++ ZOrder...
    Coordinates coordinates = obj.getCoordinates();
    LevelEditor.getSimulation().remove(obj);
    // TODO ???
    // obj = dungeon.getMinimap().getGrid().getTopObj(coordinates);
    // if (obj != null)
    // if (!unit.isOverlaying())TODO
    MapBlock b = LevelEditor.getMapMaster().getBlock();
    if (b == null) {
        b = getBlockForCoordinate(coordinates, false);
    }
    if (b != null) {
        boolean result = !b.removeObject(obj, coordinates);
        if (result) {
            if (unit.isLandscape()) {
                b.addCoordinate(obj.getCoordinates());
            }
        }
    } else {
        b = LevelEditor.getMainPanel().getPlanPanel().getSelectedBlock();
        if (b == null) {
            b = getBlockForCoordinate(coordinates, true);
        } else if (!CoordinatesMaster.isAdjacent(b.getCoordinates(), coordinates)) {
            b = getBlockForCoordinate(coordinates, true);
        }
        if (b != null) {
            if (!unit.isOverlaying()) {
                b.addCoordinate(obj.getCoordinates());
            }
        }
    }
    if (unit != null) {
        if (!unit.isOverlaying()) // if (LevelEditor.isMinimapMode())
        {
            if (LE_MapViewComp.isMinimapMode()) {
                LevelEditor.getMainPanel().getMiniGrid().refreshComp(null, obj.getCoordinates());
            } else {
                LE_MapViewComp comp = LevelEditor.getMainPanel().getMapViewComp();
                comp.getGrid().getCompForObject(obj).refresh();
                comp.getGrid().refresh();
                comp.getGrid().getCompForObject(obj).refresh();
                comp.getGrid().getPanel().repaint();
            }
        }
    }
    // TODO ADD COORDINATE!
    Chronos.logTimeElapsedForMark("removing " + obj);
}
Also used : Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Coordinates(main.game.bf.Coordinates) LE_MapViewComp(main.game.logic.dungeon.editor.gui.LE_MapViewComp) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)1 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)1 Entrance (eidolons.game.module.dungeoncrawl.dungeon.Entrance)1 Coordinates (main.game.bf.Coordinates)1 LE_MapViewComp (main.game.logic.dungeon.editor.gui.LE_MapViewComp)1