本文整理汇总了C++中Fleet::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Fleet::getPosition方法的具体用法?C++ Fleet::getPosition怎么用?C++ Fleet::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fleet
的用法示例。
在下文中一共展示了Fleet::getPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doOrder
bool UnloadArmament::doOrder(IGObject::Ptr ob){
Fleet* fleet = dynamic_cast<Fleet*>(ob->getObjectBehaviour());
ObjectManager* obman = Game::getGame()->getObjectManager();
ObjectTypeManager* otman = Game::getGame()->getObjectTypeManager();
ResourceManager::Ptr resman = Game::getGame()->getResourceManager();
std::set<uint32_t>objs = obman->getObjectsByPos(fleet->getPosition(), 10000);
IGObject::Ptr planetObj;
Planet* planet;
for (std::set<uint32_t>::const_iterator itcurr = objs.begin(); itcurr != objs.end(); ++itcurr) {
if (obman->getObject(*itcurr)->getType() == otman->getObjectTypeByName("Planet")) {
planetObj = obman->getObject(*itcurr);
planet = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
Logger::getLogger()->debug("UnloadArmaments::doOrder Found Planet %s for Unload Armaments Order", planetObj->getName().c_str());
const uint32_t factoryType = resman->getResourceDescription("Factories")->getResourceType();
IdMap weapontype = weaponlist->getList();
for(IdMap::iterator weaponit = weapontype.begin(); weaponit != weapontype.end(); ++weaponit) {
if (planet->removeResource(factoryType, 1)) {
if (fleet->removeResource(weaponit->first, weaponit->second)) {
Logger::getLogger()->debug("UnloadArmaments::doOrder success, adding to resource %d: #:%d", weaponit->first, weaponit->second);
planet->addResource(weaponit->first, weaponit->second);
planetObj->touchModTime();
return true;
}
} else {
turns = 1;
return true;
}
}
}
}
return false;
}
示例2:
std::map<uint32_t, std::pair<std::string, uint32_t> > LoadArmament::generateListOptions(){
Logger::getLogger()->debug("Entering LoadArmament::generateListOptions");
std::map<uint32_t, std::pair<std::string, uint32_t> > options;
Game* game = Game::getGame();
IGObject::Ptr selectedObj = game->getObjectManager()->getObject(
game->getOrderManager()->getOrderQueue(orderqueueid)->getObjectId());
Fleet* fleet = dynamic_cast<Fleet*>(selectedObj->getObjectBehaviour());
ObjectManager* obman = Game::getGame()->getObjectManager();
ObjectTypeManager* otman = Game::getGame()->getObjectTypeManager();
ResourceManager::Ptr resman = Game::getGame()->getResourceManager();
std::set<uint32_t>objs = obman->getObjectsByPos(fleet->getPosition(), 10000);
for (std::set<uint32_t>::iterator itcurr = objs.begin(); itcurr != objs.end(); ++itcurr) {
if (obman->getObject(*itcurr)->getType() == otman->getObjectTypeByName("Planet")) {
IGObject::Ptr planetObj = obman->getObject(*itcurr);
Planet* planet = dynamic_cast<Planet*>(planetObj->getObjectBehaviour());
Logger::getLogger()->debug("Found Planet %s for Load Armaments Order", planetObj->getName().c_str());
std::map<uint32_t, std::pair<uint32_t, uint32_t> > reslist = planet->getResources();
for (std::map<uint32_t, std::pair<uint32_t, uint32_t> >::iterator it = reslist.begin(); it != reslist.end(); ++it) {
if (resman->getResourceDescription(it->first)->getUnitSingular() == "weapon") {
options[it->first] = std::pair<std::string, uint32_t>(resman->getResourceDescription(it->first)->getNamePlural(),
planet->getResourceSurfaceValue(it->first));
}
}
}
}
Logger::getLogger()->debug("Exiting LoadArmament::generateListOptions");
return options;
}
示例3: getETA
int Move::getETA(IGObject *ob) const{
Fleet* fleet = ((Fleet*)(ob->getObjectBehaviour()));
unsigned long long distance = coords->getPosition().getDistance(fleet->getPosition());
unsigned long max_speed = 3000000;
if(distance == 0)
return 1;
return (int)((distance - 1) / max_speed) + 1;
}
示例4: doOrder
bool Move::doOrder(IGObject * ob){
Vector3d dest = coords->getPosition();
Fleet* fleet = ((Fleet*)(ob->getObjectBehaviour()));
unsigned long long distance = dest.getDistance(fleet->getPosition());
unsigned long long max_speed = 3000000;
Logger::getLogger()->debug("Moving %lld at %lld speed", distance, max_speed);
if(distance <= max_speed){
uint32_t parentid;
Logger::getLogger()->debug("Object(%d)->Move->doOrder(): Is arriving at [%lld, %lld, %lld] ",
ob->getID(), dest.getX(), dest.getY(), dest.getZ());
fleet->setVelocity(Vector3d(0,0,0));
parentid = ob->getParent();
// recontainerise if necessary
int containertype = Game::getGame()->getObjectManager()->getObject(parentid)->getContainerType();
Game::getGame()->getObjectManager()->doneWithObject(parentid);
if(fleet->getPosition() != dest && containertype >= 1){
//removeFromParent();
std::set<unsigned int> oblist = ((MTSecTurn*)(Game::getGame()->getTurnProcess()))->getContainerIds();
for(std::set<unsigned int>::reverse_iterator itcurr = oblist.rbegin(); itcurr != oblist.rend(); ++itcurr){
IGObject* testedobject = Game::getGame()->getObjectManager()->getObject(*itcurr);
Position3dObjectParam * pos = dynamic_cast<Position3dObjectParam*>(testedobject->getParameterByType(obpT_Position_3D));
SizeObjectParam * size = dynamic_cast<SizeObjectParam*>(testedobject->getParameterByType(obpT_Size));
if(pos == NULL || size == NULL){
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
continue;
}
Vector3d pos1 = pos->getPosition();
uint64_t size1 = size->getSize();
uint64_t diff = dest.getDistance(pos1);
if(diff <= fleet->getSize() / 2 + size1 / 2){
Logger::getLogger()->debug("Container object %d", *itcurr);
//if(Game::getGame()->getObject(*itcurr)->getType() <= 2){
//if(*itcurr != id){
if(size1 >= fleet->getSize()){
if(*itcurr != parentid){
ob->removeFromParent();
ob->addToParent(*itcurr);
}
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
parentid = *itcurr;
break;
}
}
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
//}
}
if(parentid == 0){
ob->removeFromParent();
ob->addToParent(0);
}
}
fleet->setPosition(dest);
Message * msg = new Message();
msg->setSubject("Move order complete");
msg->setBody("The fleet '" + ob->getName() + "' has reached it's destination.");
msg->addReference(rst_Action_Order, rsorav_Completion);
msg->addReference(rst_Object, ob->getID());
msg->addReference(rst_Object, parentid); /* It's parent */
Game::getGame()->getPlayerManager()->getPlayer(fleet->getOwner())->postToBoard(msg);
return true;
}else{
Vector3d velo = (dest - fleet->getPosition()).makeLength(max_speed);
Vector3d arriveat = fleet->getPosition()+velo;
Logger::getLogger()->debug("Move->doOrder(%d): Velocity is [%lld, %lld, %lld] (will arrive at [%lld, %lld, %lld])",
ob->getID(), velo.getX(), velo.getY(), velo.getZ(), arriveat.getX(), arriveat.getY(), arriveat.getZ());
fleet->setVelocity(velo);
uint32_t parentid = ob->getParent();
// recontainerise if necessary
uint32_t containertype = Game::getGame()->getObjectManager()->getObject(parentid)->getContainerType();
Game::getGame()->getObjectManager()->doneWithObject(parentid);
if(fleet->getPosition() != arriveat && containertype >= 1){
//removeFromParent();
std::set<uint32_t> oblist = ((MTSecTurn*)(Game::getGame()->getTurnProcess()))->getContainerIds();
for(std::set<uint32_t>::reverse_iterator itcurr = oblist.rbegin(); itcurr != oblist.rend(); ++itcurr){
IGObject* testedobject = Game::getGame()->getObjectManager()->getObject(*itcurr);
Position3dObjectParam * pos = dynamic_cast<Position3dObjectParam*>(testedobject->getParameterByType(obpT_Position_3D));
SizeObjectParam * size = dynamic_cast<SizeObjectParam*>(testedobject->getParameterByType(obpT_Size));
if(pos == NULL || size == NULL){
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
continue;
}
Vector3d pos1 = pos->getPosition();
//.........这里部分代码省略.........
示例5: doOrder
bool MergeFleet::doOrder(IGObject::Ptr ob){
IGObject::Ptr parent = Game::getGame()->getObjectManager()->getObject(ob->getParent());
Fleet *myfleet = (Fleet*)(ob->getObjectBehaviour());
//find fleet to merge with
uint32_t targetid = 0;
std::set<uint32_t> oblist = parent->getContainedObjects();
for(std::set<uint32_t>::iterator itcurr = oblist.begin(); itcurr != oblist.end(); ++itcurr){
if(*itcurr == ob->getID())
continue;
IGObject::Ptr ptarget = Game::getGame()->getObjectManager()->getObject(*itcurr);
if(ptarget->getType() == ob->getType()){
Fleet* pfleet = (Fleet*)(ptarget->getObjectBehaviour());
if(pfleet->getOwner() == myfleet->getOwner()){
if(pfleet->getSize() + myfleet->getSize() > pfleet->getPosition().getDistance(myfleet->getPosition())){
targetid = *itcurr;
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
break;
}
}
}
Game::getGame()->getObjectManager()->doneWithObject(*itcurr);
}
if(targetid == 0){
Message::Ptr msg( new Message() );
msg->setSubject("Merge Fleet order canceled");
msg->setBody("No target fleet at this location");
msg->addReference(rst_Action_Order, rsorav_Canceled);
msg->addReference(rst_Object, ob->getID());
Game::getGame()->getPlayerManager()->getPlayer(((Fleet*)(ob->getObjectBehaviour()))->getOwner())->postToBoard(msg);
}else{
IGObject::Ptr target = Game::getGame()->getObjectManager()->getObject(targetid);
Message::Ptr msg( new Message() );
msg->setSubject("Merge Fleet order complete");
msg->setBody("The two fleets have been merged");
msg->addReference(rst_Action_Order, rsorav_Completion);
msg->addReference(rst_Object, ob->getID());
msg->addReference(rst_Object, target->getID());
Fleet *tfleet = (Fleet*)(target->getObjectBehaviour());
IdMap ships = myfleet->getShips();
for(IdMap::iterator itcurr = ships.begin();
itcurr != ships.end(); ++itcurr){
tfleet->addShips(itcurr->first, itcurr->second);
}
//remove the fleet from the physical universe
ob->removeFromParent();
Game::getGame()->getObjectManager()->scheduleRemoveObject(ob->getID());
Game::getGame()->getPlayerManager()->getPlayer(myfleet->getOwner())->getPlayerView()->removeOwnedObject(ob->getID());
Game::getGame()->getObjectManager()->doneWithObject(target->getID());
Game::getGame()->getPlayerManager()->getPlayer(myfleet->getOwner())->postToBoard(msg);
}
return true;
}
示例6: doTurn
void MinisecTurn::doTurn(){
std::set<uint32_t>::iterator itcurr;
Game* game = Game::getGame();
OrderManager* ordermanager = game->getOrderManager();
ObjectManager* objectmanager = game->getObjectManager();
RSPCombat* combatstrategy = new RSPCombat();
PlayerManager::Ptr playermanager = game->getPlayerManager();
//sort by order type
std::set<uint32_t> movers;
std::set<uint32_t> otherorders;
std::set<uint32_t> interceptors;
containerids.clear();
std::set<uint32_t> possiblecombatants;
std::set<uint32_t> objects = objectmanager->getAllIds();
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject::Ptr ob = objectmanager->getObject(*itcurr);
if(ob->getType() == planettype || ob->getType() == fleettype){
possiblecombatants.insert(ob->getID());
OrderQueueObjectParam* oqop = dynamic_cast<OrderQueueObjectParam*>(ob->getParameterByType(obpT_Order_Queue));
if(oqop != NULL){
OrderQueue::Ptr orderqueue = ordermanager->getOrderQueue(oqop->getQueueId());
if(orderqueue != NULL){
Order * currOrder = orderqueue->getFirstOrder();
if(currOrder != NULL){
if(currOrder->getType() == ordermanager->getOrderTypeByName("Move")){
movers.insert(ob->getID());
} else if (currOrder->getType() == ordermanager->getOrderTypeByName("Intercept")){
interceptors.insert(ob->getID());
}else{
otherorders.insert(ob->getID());
}
}
}
}
}
if(ob->getContainerType() >= 1){
containerids.insert(ob->getID());
}
objectmanager->doneWithObject(ob->getID());
}
// do move
for(itcurr = movers.begin(); itcurr != movers.end(); ++itcurr) {
IGObject::Ptr ob = objectmanager->getObject(*itcurr);
OrderQueueObjectParam* oqop = dynamic_cast<OrderQueueObjectParam*>(ob->getParameterByType(obpT_Order_Queue));
OrderQueue::Ptr orderqueue = ordermanager->getOrderQueue(oqop->getQueueId());
Order * currOrder = orderqueue->getFirstOrder();
if(currOrder->doOrder(ob)){
orderqueue->removeFirstOrder();
}else{
orderqueue->updateFirstOrder();
}
objectmanager->doneWithObject(ob->getID());
}
// do interceptions
for(itcurr = interceptors.begin(); itcurr != interceptors.end(); ++itcurr) {
IGObject::Ptr ob = objectmanager->getObject(*itcurr);
OrderQueueObjectParam* oqop = dynamic_cast<OrderQueueObjectParam*>(ob->getParameterByType(obpT_Order_Queue));
OrderQueue::Ptr orderqueue = ordermanager->getOrderQueue(oqop->getQueueId());
Order * currOrder = orderqueue->getFirstOrder();
if(currOrder->doOrder(ob)){
orderqueue->removeFirstOrder();
}else{
orderqueue->updateFirstOrder();
}
objectmanager->doneWithObject(ob->getID());
}
// do combat
std::list<std::map<uint32_t, std::set<uint32_t> > > combats;
for(itcurr = possiblecombatants.begin(); itcurr != possiblecombatants.end(); ++itcurr) {
IGObject::Ptr ob = objectmanager->getObject(*itcurr);
uint32_t playerid1;
Vector3d pos1;
uint32_t size1;
if(ob->getType() == planettype){
Planet* planet = (Planet*)(ob->getObjectBehaviour());
playerid1 = planet->getOwner();
pos1 = planet->getPosition();
size1 = planet->getSize();
}else{
Fleet* fleet = (Fleet*)(ob->getObjectBehaviour());
playerid1 = fleet->getOwner();
pos1 = fleet->getPosition();
size1 = fleet->getSize();
}
if(playerid1 == 0){
//.........这里部分代码省略.........