void Start::parsePlayer(YAML::Node n, std::ostream& lerr) { player->setName(readYAMLStr(n, "Name", "anonymous")); player->setUnitProto(Unit::getMob(readYAMLStr(n, "Unit", "player"))->proto); player->setArea(world->getArea(readYAMLStr(n, "Area", "no area specified"))); Zone* zone = world->getZone(readYAMLStr(n, "Zone", "no zone specified")); player->setZone(zone); player->getUnit()->pos = readYAMLCoord(n, "Loc", ORIGIN); zone->getLocationAt(player->getUnit()->pos)->unit = player->getUnit(); }
void Start::findAreaUnits() { areaUnits.clear(); Area* area = player->getArea(); for (unsigned int i = 0; i < area->getNumZones(); i++) { Zone* zone = area->getZone(i); if (zone->isFilled()) { for (int k = 0; k < zone->getHeight(); k++) { for (int j = 0; j < zone->getWidth(); j++) { Location* loc = zone->getLocationAt(Coord(j, k)); if (loc->hasUnit()) { areaUnits.insert(std::pair<Unit*, Zone*>(loc->unit, zone)); } } } } } }