本文整理汇总了C++中StarSystem::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ StarSystem::getPosition方法的具体用法?C++ StarSystem::getPosition怎么用?C++ StarSystem::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StarSystem
的用法示例。
在下文中一共展示了StarSystem::getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rebuildRegion
//Recurrsively rebuilds regions given a system.
//If the system already has a region or is not occupied or
//colonized, then this function returns. Otherwise it
//sets the region based on its neighbors.
void TaeTurn::rebuildRegion(uint32_t system) {
Game* game = Game::getGame();
ObjectManager* obm = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
set<uint32_t>::iterator itcurr;
IGObject::Ptr sys = obm->getObject(system);
StarSystem* sysData = (StarSystem*) sys->getObjectBehaviour();
//Check to make sure the system doesnt already have a region
if(sysData->getRegion() != 0) {
return;
}
//Check to make sure it is colonized or occupied
set<uint32_t> children = sys->getContainedObjects();
for(itcurr = children.begin(); itcurr != children.end(); itcurr++) {
IGObject::Ptr ob = obm->getObject(*itcurr);
bool resource = true;
bool occupied = false;
if(ob->getType() == obtm->getObjectTypeByName("Planet")) {
Planet* p = (Planet*) ob->getObjectBehaviour();
if(p->getResource(4) == 0 && p->getResource(5) == 0 && p->getResource(6) == 0 && p->getResource(7) == 0) {
resource = false;
}
} else if(ob->getType() == obtm->getObjectTypeByName("Fleet")) {
if(!Move::isBorderingScienceColony(sysData)) {
sendHome(*itcurr);
occupied = false;
} else {
occupied = true;
}
}
if(!(resource || occupied)) {
return;
}
}
//Check to make sure this isnt a home system
if(sys->getName().find("'s System") != string::npos) {
return;
}
//Get neighbors
set<uint32_t> regions;
set<uint32_t> emptyNeighbors;
Vector3d pos = sysData->getPosition();
//east-west neighbors
for(int i = -1; i < 2; i+=2) {
set<uint32_t> ids = obm->getObjectsByPos(pos+Vector3d(80000*i,0,0), 1);
for(set<uint32_t>::iterator j=ids.begin(); j != ids.end(); j++) {
IGObject::Ptr tempObj = obm->getObject(*j);
if(tempObj->getType() == obtm->getObjectTypeByName("Star System")) {
uint32_t r = ((StarSystem*)(tempObj->getObjectBehaviour()))->getRegion();
if(r == 0) {
emptyNeighbors.insert(*j);
} else if (regions.count(r) == 0) {
regions.insert(r);
}
}
}
}
//north-south neighbors
for(int i = -1; i < 2; i+=2) {
set<uint32_t> ids = obm->getObjectsByPos(pos+Vector3d(0,80000*i,0), 1);
for(set<uint32_t>::iterator j=ids.begin(); j != ids.end(); j++) {
IGObject::Ptr tempObj = obm->getObject(*j);
if(tempObj->getType() == obtm->getObjectTypeByName("Star System")) {
uint32_t r = ((StarSystem*)(tempObj->getObjectBehaviour()))->getRegion();
if(r == 0) {
emptyNeighbors.insert(*j);
} else if (regions.count(r) == 0) {
regions.insert(r);
}
}
}
}
//Set Region
if(regions.size() == 0) {
//If neighbors have no region, then create a new region
sysData->setRegion(sys->getID());
stringstream out;
out << sysData->getRegion();
Logger::getLogger()->debug(string("System " + sys->getName() + " added to region " + out.str()).c_str());
} else if(regions.size() == 1) {
//If it neighbors 1 region, then set as that region
sysData->setRegion(*(regions.begin()));
stringstream out;
out << sysData->getRegion();
Logger::getLogger()->debug(string("System " + sys->getName() + " added to region " + out.str()).c_str());
} else {
//It should never border more than one region. If it reaches this point, then there is an error somewhere
Logger::getLogger()->debug(string("** Unable to rebuild region! System, " + sys->getName() + " is bordering more than one region! ***").c_str());
}
//.........这里部分代码省略.........
示例2: initCombat
//Setup the next turn to be ready for combat
void TaeTurn::initCombat() {
std::set<uint32_t>::iterator itcurr;
Game* game = Game::getGame();
ObjectManager* objectmanager = game->getObjectManager();
PlayerManager::Ptr playermanager = game->getPlayerManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
DesignStore::Ptr ds = game->getDesignStore();
//Pop the combat queue and set the combatants
pair<bool, map<uint32_t, uint32_t> > temp;
temp = combatQueue.front();
combatQueue.pop();
isInternal = temp.first;
combatants = temp.second;
strength.clear();
for(map<uint32_t, uint32_t>::iterator i = combatants.begin(); i != combatants.end(); ++i) {
IGObject::Ptr ob = Game::getGame()->getObjectManager()->getObject(i->first);
Fleet* f = (Fleet*) ob->getObjectBehaviour();
strength[f->getOwner()] = 0;
}
set<uint32_t> owners;
set<uint32_t> regions;
string shipType;
for(map<uint32_t, uint32_t>::iterator i = combatants.begin(); i != combatants.end(); ++i) {
IGObject::Ptr ob = objectmanager->getObject(i->first);
Fleet* leader = (Fleet*) (ob)->getObjectBehaviour();
//look for the shiptype which this combat is associated with
if(shipType.empty()) {
if(isInternal) {
shipType = "ScientistShip";
} else {
//Set shiptype to the type corresponding to the leader
uint32_t ship = leader->getShips().begin()->first;
shipType = ds->getDesign(ship)->getName();
size_t pos = shipType.find("Leader");
if(pos != shipType.npos) {
shipType.erase(pos, 6);
}
}
}
owners.insert(leader->getOwner());
//Set which regions are involved in combat
if(regions.count(i->second) <= 0) {
regions.insert(i->second);
}
//Set initial internal combat strength
if(isInternal) {
IGObject::Ptr starSys = objectmanager->getObject(ob->getParent());
StarSystem* starSysData = (StarSystem*)(starSys->getObjectBehaviour());
Vector3d pos = starSysData->getPosition();
//Search for bordering science colonies
//east-west neighbors
for(int i = -1; i < 2; i+=2) {
set<uint32_t> ids = objectmanager->getObjectsByPos(pos+Vector3d(80000*i,0,0), 1);
for(set<uint32_t>::iterator j=ids.begin(); j != ids.end(); j++) {
IGObject::Ptr tempObj = objectmanager->getObject(*j);
if(tempObj->getType() == obtm->getObjectTypeByName("Planet")) {
Planet* p = (Planet*)(tempObj->getObjectBehaviour());
if(p->getResource(5) > 0) {
addReinforcement(leader->getOwner());
}
}
}
}
//north-south neighbors
for(int i = -1; i < 2; i+=2) {
set<uint32_t> ids = objectmanager->getObjectsByPos(pos+Vector3d(0,80000*i,0), 1);
for(set<uint32_t>::iterator j=ids.begin(); j != ids.end(); j++) {
IGObject::Ptr tempObj = objectmanager->getObject(*j);
if(tempObj->getType() == obtm->getObjectTypeByName("Planet")) {
Planet* p = (Planet*)(tempObj->getObjectBehaviour());
if(p->getResource(5) > 0) {
addReinforcement(leader->getOwner());
}
}
}
}
}
}
//Set which resource will be awarded
int resourceType;
if(shipType.compare("MerchantShip") == 0) {
resourceType = 4;
} else if(shipType.compare("ScientistShip") == 0) {
resourceType = 5;
} else if(shipType.compare("SettlerShip") == 0) {
resourceType = 6;
} else {
resourceType = 7;
}
//Set all fleets to combat mode. Flag the fleets whose owners are
//directly involved in combat.
std::set<uint32_t> views;
//.........这里部分代码省略.........