예제 #1
0
파일: Base.java 프로젝트: Kagesh/Presidium
  public Base(Session s) throws Exception {
    s.cacheInstance(this);
    this.world = s.world();
    commerce.loadState(s);
    credits = s.loadFloat();

    ruler = (Actor) s.loadObject();
    s.loadObjects(missions);

    communitySpirit = s.loadFloat();
    alertLevel = s.loadFloat();
    crimeLevel = s.loadFloat();
    averageMood = s.loadFloat();
    for (int n = s.loadInt(); n-- > 0; ) {
      final Relation r = Relation.loadFrom(s);
      baseRelations.put(r.subject, r);
    }

    paving = new Paving(world);
    paving.loadState(s);

    dangerMap = new DangerMap(world, this);
    dangerMap.loadState(s);
    intelMap.loadState(s);
  }
예제 #2
0
파일: Base.java 프로젝트: Kagesh/Presidium
  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;
    }
  }
예제 #3
0
파일: Base.java 프로젝트: Kagesh/Presidium
  public void saveState(Session s) throws Exception {
    commerce.saveState(s);
    s.saveFloat(credits);

    s.saveObject(ruler);
    s.saveObjects(missions);

    s.saveFloat(communitySpirit);
    s.saveFloat(alertLevel);
    s.saveFloat(crimeLevel);
    s.saveFloat(averageMood);
    s.saveInt(baseRelations.size());
    for (Relation r : baseRelations.values()) Relation.saveTo(s, r);

    paving.saveState(s);

    dangerMap.saveState(s);
    intelMap.saveState(s);
  }