Пример #1
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);
      }
    }
  }
Пример #2
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);
      }
    }
  }
Пример #3
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);
   }
 }
Пример #4
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);
      }
    }
  }
Пример #5
0
 public void clearVerticalWalls(int level) {
   entities.remove(new EntityData(level, EntityType.VWALL));
   entities.remove(new EntityData(level, EntityType.VFENCE));
 }
Пример #6
0
 public void clearHorizontalWalls(int level) {
   entities.remove(new EntityData(level, EntityType.HWALL));
   entities.remove(new EntityData(level, EntityType.HFENCE));
 }