Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
2
Indexable
Never
  struct Location {
    int type, x, y;
    Location(int t, float c, vector<Location> &l) {
      this->type = t;
      int cBias = c > 0.0f ? (LEVEL_CENTER * c) : LEVEL_CENTER;
      for (;;) {
        this->x = LEVEL_CENTER + RANDOMI(-cBias, cBias);
        this->y = LEVEL_CENTER + RANDOMI(-cBias, cBias);
        bool valid = true;
        for (auto& loc : l) {
          if (&loc == this) continue;
          if (loc.x == this->x && loc.y == this->y) {
            valid = false;
            break;
          }
        }
        if (valid) {
          break;
        }
      }
    }
  };

  vector<Location> locations;
  locations.emplace_back(FEATURE_HOSPITAL, 0.9f, locations);
  locations.emplace_back(FEATURE_MALL, 0.7f, locations);
  locations.emplace_back(FEATURE_WAREHOUSE, 0.3f, locations);
  locations.emplace_back(FEATURE_ARMORY, 0.2f, locations);
  locations.emplace_back(FEATURE_MILLBASE, 0.1f, locations);

  locations.emplace_back(LOCATION_PARK, 0.0f, locations);
  locations.emplace_back(LOCATION_GAS_STATION, 0.0f, locations);
  locations.emplace_back(LOCATION_WAREHOUSE, 0.0f, locations);
  locations.emplace_back(LOCATION_POLICE_STATION, 0.0f, locations);
  locations.emplace_back(LOCATION_FIRE_STATION, 0.0f, locations);