本文整理汇总了C++中Ship::GetFlightDeck方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::GetFlightDeck方法的具体用法?C++ Ship::GetFlightDeck怎么用?C++ Ship::GetFlightDeck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::GetFlightDeck方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
void
NetGameClient::DoElemCreate(NetMsg* msg)
{
if (!msg) return;
NetElemCreate elem_create;
elem_create.Unpack(msg->Data());
const char* elem_name = elem_create.GetName().data();
::Print("NetGameClient::DoElemCreate name: %s iff: %d type %s\n",
elem_name,
elem_create.GetIFF(),
Mission::RoleName(elem_create.GetType()));
Sim* sim = Sim::GetSim();
Element* elem = sim->FindElement(elem_name);
if (elem) {
::Print(" element '%' already exists - ignored\n", elem_name);
return;
}
elem = sim->CreateElement(elem_name,
elem_create.GetIFF(),
elem_create.GetType());
int* load = elem_create.GetLoadout();
int* slots = elem_create.GetSlots();
int squadron = elem_create.GetSquadron();
int code = elem_create.GetObjCode();
Text target = elem_create.GetObjective();
bool alert = elem_create.GetAlert();
bool active = elem_create.GetInFlight();
elem->SetIntelLevel(elem_create.GetIntel());
elem->SetLoadout(load);
if (code > Instruction::RTB || target.length() > 0) {
Instruction* obj = new(__FILE__,__LINE__) Instruction(code, target);
elem->AddObjective(obj);
}
Ship* carrier = sim->FindShip(elem_create.GetCarrier());
if (carrier) {
elem->SetCarrier(carrier);
Hangar* hangar = carrier->GetHangar();
if (hangar) {
Text squadron_name = hangar->SquadronName(squadron);
elem->SetSquadron(squadron_name);
if (active) {
for (int i = 0; i < 4; i++) {
int slot = slots[i];
if (slot > -1) {
hangar->GotoActiveFlight(squadron, slot, elem, load);
}
}
}
else {
FlightDeck* deck = 0;
int queue = 1000;
for (int i = 0; i < carrier->NumFlightDecks(); i++) {
FlightDeck* d = carrier->GetFlightDeck(i);
if (d && d->IsLaunchDeck()) {
int dq = hangar->PreflightQueue(d);
if (dq < queue) {
queue = dq;
deck = d;
}
}
}
for (int i = 0; i < 4; i++) {
int slot = slots[i];
if (slot > -1) {
hangar->GotoAlert(squadron, slot, deck, elem, load, !alert);
}
}
}
}
}
}
示例2: if
void
NetGameClient::DoObjKill(NetMsg* msg)
{
if (!msg) return;
NetObjKill obj_kill;
obj_kill.Unpack(msg->Data());
Ship* ship = FindShipByObjID(obj_kill.GetObjID());
if (ship) {
Ship* killer = FindShipByObjID(obj_kill.GetKillerID());
Text killer_name = Game::GetText("NetGameClient.unknown");
if (killer)
killer_name = killer->Name();
// log the kill:
switch (obj_kill.GetKillType()) {
default:
case NetObjKill::KILL_MISC:
Print("Ship '%s' destroyed (misc) (%s)\n", ship->Name(), FormatGameTime());
break;
case NetObjKill::KILL_PRIMARY:
case NetObjKill::KILL_SECONDARY:
Print("Ship '%s' killed by '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
break;
case NetObjKill::KILL_COLLISION:
Print("Ship '%s' killed in collision with '%s' (%s)\n", ship->Name(), killer_name.data(), FormatGameTime());
break;
case NetObjKill::KILL_CRASH:
Print("Ship '%s' destroyed (crash) (%s)\n", ship->Name(), FormatGameTime());
case NetObjKill::KILL_DOCK:
Print("Ship '%s' docked (%s)\n", ship->Name(), FormatGameTime());
}
// record the kill in the stats:
if (killer && obj_kill.GetKillType() != NetObjKill::KILL_DOCK) {
ShipStats* kstats = ShipStats::Find(killer->Name());
if (kstats) {
if (obj_kill.GetKillType() == NetObjKill::KILL_PRIMARY)
kstats->AddEvent(SimEvent::GUNS_KILL, ship->Name());
else if (obj_kill.GetKillType() == NetObjKill::KILL_SECONDARY)
kstats->AddEvent(SimEvent::MISSILE_KILL, ship->Name());
}
if (killer && killer->GetIFF() != ship->GetIFF()) {
if (ship->GetIFF() > 0 || killer->GetIFF() > 1)
kstats->AddPoints(ship->Value());
}
}
ShipStats* killee = ShipStats::Find(ship->Name());
if (killee) {
if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK)
killee->AddEvent(SimEvent::DOCK, killer_name);
else
killee->AddEvent(SimEvent::DESTROYED, killer_name);
}
if (obj_kill.GetKillType() == NetObjKill::KILL_DOCK) {
FlightDeck* deck = killer->GetFlightDeck(obj_kill.GetFlightDeck());
sim->NetDockShip(ship, killer, deck);
}
else {
ship->InflictNetDamage(ship->Integrity());
ship->DeathSpiral();
if (!obj_kill.GetRespawn())
ship->SetRespawnCount(0);
else
ship->SetRespawnLoc(obj_kill.GetRespawnLoc());
}
}
// this shouldn't happen in practice,
// but if it does, this is what should be done:
else {
Shot* shot = FindShotByObjID(obj_kill.GetObjID());
if (shot) {
::Print("NetGameClient::DoObjKill destroying shot '%s'\n", shot->Name());
shot->Destroy();
}
}
}