Пример #1
1
 void setLabel(Label label, boolean undo) {
   Tile oldTile = new Tile(this);
   this.label = label;
   if (undo) {
     map.addUndo(this, oldTile);
   }
 }
Пример #2
1
 void setCaveLabel(Label caveLabel, boolean undo) {
   Tile oldTile = new Tile(this);
   this.caveLabel = caveLabel;
   if (undo) {
     map.addUndo(this, oldTile);
   }
 }
Пример #3
1
  void setTileContent(TileEntity entity, int level, boolean undo) {
    if (!isFlat()) {
      return;
    }

    if (entity instanceof Roof) {
      for (TileEntity e : entities.values()) {
        if (e instanceof Roof) {
          return;
        }
      }
    }

    final EntityData entityData = new EntityData(level, EntityType.FLOORROOF);
    if (entity != entities.get(entityData)) {
      Tile oldTile = new Tile(this);

      if (entity != null) {
        entities.put(entityData, entity);
      } else {
        entities.remove(entityData);
      }

      if (undo) {
        map.addUndo(this, oldTile);
      }
    }
  }
Пример #4
1
  void setVerticalWall(WallData wall, int level, boolean undo) {
    if (wall != null && wall.houseWall) {
      if (!(isFlat() || map.getTile(this, -1, 0).isFlat())) {
        return;
      }
    }

    final EntityData entityData;
    if (wall != null && wall.houseWall) {
      entityData = new EntityData(level, EntityType.VWALL);
    } else if (wall != null) {
      entityData = new EntityData(level, EntityType.VFENCE);
    } else {
      entityData = null;
    }

    final EntityData wallEntity = new EntityData(level, EntityType.VWALL);
    final EntityData fenceEntity = new EntityData(level, EntityType.VFENCE);
    final Wall currentWall = (Wall) entities.get(wallEntity);
    final Wall currentFence = (Wall) entities.get(fenceEntity);

    boolean reversed;
    if (wall != null && wall.houseWall) {
      if (Globals.autoReverseWall) {
        reversed =
            getTileContent(level) == null && map.getTile(this, -1, 0).getTileContent(level) != null;
        if (reversed == false) {
          reversed = Globals.reverseWall;
        }
      } else {
        reversed = Globals.reverseWall;
      }
    } else {
      reversed = false;
    }

    if (!(new Wall(wall, reversed).equals(entities.get(entityData)))) {
      Tile oldTile = new Tile(this);
      if (wall != null) {
        entities.put(entityData, new Wall(wall, reversed));
        if (wall.houseWall
            && !(wall.arch && currentFence != null && currentFence.data.archBuildable)) {
          entities.remove(fenceEntity);
        } else if (!wall.houseWall
            && !(wall.archBuildable && currentWall != null && currentWall.data.arch)) {
          entities.remove(wallEntity);
        }
      } else {
        entities.remove(wallEntity);
        entities.remove(fenceEntity);
      }

      if (undo) {
        map.addUndo(this, oldTile);
      }
    }
  }
Пример #5
1
 void setCaveEntity(CaveData entity, boolean undo) {
   if (this.cave != entity) {
     Tile oldTile = new Tile(this);
     this.cave = entity;
     if (undo) {
       map.addUndo(this, oldTile);
     }
   }
 }
Пример #6
1
 void setCaveHeight(int height, boolean undo) {
   if (this.caveHeight != height) {
     Tile oldTile = new Tile(this);
     this.caveHeight = height;
     map.recalculateHeight();
     if (undo) {
       map.addUndo(this, oldTile);
     }
   }
 }
Пример #7
1
 void setGameObject(GameObjectData data, ObjectLocation location, int floor, boolean undo) {
   Tile oldTile = new Tile(this);
   if (data != null) {
     entities.put(new ObjectEntityData(floor, location), new GameObject(data));
   } else {
     entities.remove(new ObjectEntityData(floor, location));
   }
   if (undo) {
     map.addUndo(this, oldTile);
   }
 }
Пример #8
1
 void setCaveSize(int size, boolean undo) {
   if (size < 30 || size > 300) {
     return;
   }
   if (this.caveSize != size) {
     Tile oldTile = new Tile(this);
     this.caveSize = size;
     map.recalculateHeight();
     if (undo) {
       map.addUndo(this, oldTile);
     }
   }
 }
Пример #9
1
  void setGround(GroundData data, RoadDirection dir, boolean undo) {
    if (!new Ground(data).equals(ground)) {
      Tile oldTile = new Tile(this);
      if (!data.diagonal) {
        dir = RoadDirection.CENTER;
      }
      ground = new Ground(data, dir);

      if (undo) {
        map.addUndo(this, oldTile);
      }
    }
  }
Пример #10
1
  void setVerticalBorder(BorderData border, boolean undo) {
    final EntityData entityData = new EntityData(0, EntityType.VBORDER);
    if (border != entities.get(entityData)) {
      Tile oldTile = new Tile(this);

      if (border != null) {
        entities.put(entityData, border);
      } else {
        entities.remove(entityData);
      }

      if (undo) {
        map.addUndo(this, oldTile);
      }
    }
  }