本文整理汇总了C++中StarSystem::AddUnit方法的典型用法代码示例。如果您正苦于以下问题:C++ StarSystem::AddUnit方法的具体用法?C++ StarSystem::AddUnit怎么用?C++ StarSystem::AddUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StarSystem
的用法示例。
在下文中一共展示了StarSystem::AddUnit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
//.........这里部分代码省略.........
if (active_missions.size() > 1) {
for (int i = active_missions.size()-1; i > 0; --i) //don't terminate zeroth mission
if (active_missions[i]->player_num == k)
active_missions[i]->terminateMission();
}
unsigned int whichcp = k;
string newsystem;
QVector pos;
bool setplayerXloc;
savegame->SetStarSystem( "" );
QVector tmpoldpos = savegame->GetPlayerLocation();
savegame->SetPlayerLocation( QVector( FLT_MAX, FLT_MAX, FLT_MAX ) );
vector< string > packedInfo;
savegame->ParseSaveGame( savegamefile,
newsystem,
newsystem,
pos,
setplayerXloc,
this->credits,
packedInfo,
k );
UnpackUnitInfo(packedInfo);
if (pos.i == FLT_MAX && pos.j == FLT_MAX && pos.k == FLT_MAX)
pos = tmpoldpos;
savegame->SetPlayerLocation( pos );
CopySavedShips( savegame->GetCallsign(), whichcp, packedInfo, true );
bool actually_have_save = false;
static bool persistent_on_load =
XMLSupport::parse_bool( vs_config->getVariable( "physics", "persistent_on_load", "true" ) );
if (savegame->GetStarSystem() != "") {
actually_have_save = true;
newsystem = savegame->GetStarSystem()+".system";
} else {
newsystem = _Universe->activeStarSystem()->getFileName();
if (newsystem.find( ".system" ) == string::npos)
newsystem += ".system";
}
Background::BackgroundClone savedtextures = {
{NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
if (persistent_on_load) {
_Universe->getActiveStarSystem( 0 )->SwapOut();
} else {
Background *tmp = _Universe->activeStarSystem()->getBackground();
savedtextures = tmp->Cache();
_Universe->clearAllSystems();
}
StarSystem *ss = _Universe->GenerateStarSystem( newsystem.c_str(), "", Vector( 0, 0, 0 ) );
if (!persistent_on_load)
savedtextures.FreeClone();
this->activeStarSystem = ss;
_Universe->pushActiveStarSystem( ss );
vector< StarSystem* >saved;
while ( _Universe->getNumActiveStarSystem() ) {
saved.push_back( _Universe->activeStarSystem() );
_Universe->popActiveStarSystem();
}
if ( !saved.empty() )
saved.back() = ss;
unsigned int mysize = saved.size();
for (unsigned int i = 0; i < mysize; i++) {
_Universe->pushActiveStarSystem( saved.back() );
saved.pop_back();
}
ss->SwapIn();
int fgsnumber = 0;
if (fg) {
fgsnumber = fg->flightgroup_nr++;
fg->nr_ships++;
fg->nr_ships_left++;
}
Unit *un = UnitFactory::createUnit(
GetUnitFileName().c_str(), false, this->unitfaction, unitmodname, fg, fgsnumber );
un->SetCurPosition( UniverseUtil::SafeEntrancePoint( savegame->GetPlayerLocation() ) );
ss->AddUnit( un );
this->SetParent( un, GetUnitFileName().c_str(), unitmodname.c_str(), savegame->GetPlayerLocation() );
SwitchUnits( NULL, un );
this->credits = savegame->GetSavedCredits();
DoCockpitKeys();
_Universe->popActiveStarSystem();
_Universe->pushActiveStarSystem( ss );
savegame->ReloadPickledData();
savegame->LoadSavedMissions();
if (actually_have_save && !SERVER && Network == NULL) {
QVector vec;
DockToSavedBases( whichcp, vec );
}
UniverseUtil::hideSplashScreen();
_Universe->popActiveStarSystem();
if (!persistent_on_load)
_Universe->pushActiveStarSystem( ss );
return true;
}
}
}
}
return false;
}