Пример #1
0
void Generator::add_units(GameMain &m) const {
	for (auto &r : this->regions) {

		// Regions filled with resource objects
		// trees / mines
		if (r.object_id) {
			Player* p = m.get_player(r.owner);
			auto otype = p->get_type(r.object_id);
			if (!otype) {
				break;
			}
			for (auto &tile : r.get_tiles()) {
				m.placed_units.new_unit(*otype, *p, tile.to_phys3(*m.terrain));
			}
		}

		// A space for starting town center and villagers
		else if (r.owner) {
			Player* p = m.get_player(r.owner);
			auto tctype = p->get_type(109); // town center
			auto mvtype = p->get_type(83);  // male villager
			auto fvtype = p->get_type(293); // female villager
			auto sctype = p->get_type(448); // scout cavarly
			if (!tctype || !mvtype || !fvtype || !sctype) {
				break;
			}

			coord::tile tile = r.get_center();
			tile.ne -= 1;
			tile.se -= 1;

			// Place a completed town center
			auto ref = m.placed_units.new_unit(*tctype, *p, tile.to_phys3(*m.terrain));
			if (ref.is_valid()) {
				complete_building(*ref.get());
			}

			// Place three villagers
			tile.ne -= 1;
			m.placed_units.new_unit(*fvtype, *p, tile.to_phys3(*m.terrain));
			tile.se += 1;
			m.placed_units.new_unit(*mvtype, *p, tile.to_phys3(*m.terrain));
			tile.se += 1;
			m.placed_units.new_unit(*fvtype, *p, tile.to_phys3(*m.terrain));
			// TODO uncomment when the scout looks better
			//tile.se += 2;
			//m.placed_units.new_unit(*sctype, *p, tile.to_tile3().to_phys3());
		}
	}
}
Пример #2
0
void Generator::add_units(GameMain &m) const {
	for (auto &r : this->regions) {

		// Regions filled with resource objects
		// trees / mines
		if (r.object_id) {
			Player &p = m.players[r.owner];
			auto otype = p.get_type(r.object_id);
			if (!otype) {
				break;
			}
			for (auto &tile : r.get_tiles()) {
				m.placed_units.new_unit(*otype, p, tile.to_tile3().to_phys3());
			}
		}

		// A space for starting town center and villagers
		else if (r.owner) {
			Player &p = m.players[r.owner];
			auto tctype = p.get_type(109); // town center
			auto mvtype = p.get_type(83);  // male villager
			auto fvtype = p.get_type(293); // female villager
			if (!tctype || !mvtype || !fvtype) {
				break;
			}

			coord::tile tile = r.get_center();
			tile.ne -= 1;
			tile.se -= 1;

			// Place a completed town center
			auto ref = m.placed_units.new_unit(*tctype, p, tile.to_tile3().to_phys3());
			if (ref.is_valid()) {
				complete_building(*ref.get());
			}

			// Place three villagers
			tile.ne -= 1;
			m.placed_units.new_unit(*fvtype, p, tile.to_tile3().to_phys3());
			tile.se += 1;
			m.placed_units.new_unit(*mvtype, p, tile.to_tile3().to_phys3());
			tile.se += 1;
			m.placed_units.new_unit(*fvtype, p, tile.to_tile3().to_phys3());
		}
	}
}