Exemple #1
0
  @Override
  public void onDamage(
      int amount, World world, Player player, BlockCoord coord, BuildableDamageBlock hit) {

    ControlPoint cp = this.controlPoints.get(coord);
    Resident resident = CivGlobal.getResident(player);

    if (!resident.canDamageControlBlock()) {
      CivMessage.send(
          player,
          CivColor.Rose
              + "Cannot damage control blocks due to missing/invalid Town Hall or Capitol structure.");
      return;
    }

    if (cp != null) {
      if (!cp.isDestroyed()) {

        if (resident.isControlBlockInstantBreak()) {
          cp.damage(cp.getHitpoints());
        } else {
          cp.damage(amount);
        }

        if (cp.isDestroyed()) {
          onControlBlockDestroy(cp, world, player, (StructureBlock) hit);
        } else {
          onControlBlockHit(cp, world, player, (StructureBlock) hit);
        }
      } else {
        CivMessage.send(player, CivColor.Rose + "Control Block already destroyed.");
      }

    } else {
      CivMessage.send(
          player,
          CivColor.Rose
              + "Cannot Damage "
              + this.getDisplayName()
              + ", go after the control points!");
    }
  }