Example #1
0
  public void updateAsScheduled(int numUpdates) {
    commerce.updateCommerce(numUpdates);
    paving.distribute(BuildConstants.ALL_PROVISIONS);
    dangerMap.updateVals();
    for (Mission mission : missions) mission.updateMission();
    //
    //  Once per day, iterate across all personnel to get a sense of citizen
    //  mood, and compute community spirit.  (This declines as your settlement
    //  gets bigger.)
    if (numUpdates % World.STANDARD_DAY_LENGTH == 0) {
      final Tile t = world.tileAt(0, 0);
      int numResidents = 0;
      averageMood = 0.5f;

      for (Object o : world.presences.matchesNear(this, t, -1)) {
        if (!(o instanceof Venue)) continue;
        final Venue v = (Venue) o;
        for (Actor resident : v.personnel.residents()) {
          numResidents++;
          averageMood += resident.health.moraleLevel();
        }
      }

      averageMood /= (numResidents + 1);
      communitySpirit = 1f / (1 + (numResidents / 100f));
      communitySpirit = (communitySpirit + averageMood) / 2f;
    }
  }