本文整理汇总了C++中Ship::Class方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::Class方法的具体用法?C++ Ship::Class怎么用?C++ Ship::Class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::Class方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
TacticalAI::FindSupport()
{
if (!ship_ai->GetThreat()) {
ship_ai->SetSupport(0);
return;
}
// pick the biggest friendly contact in the sector:
Ship* support = 0;
double support_dist = 1e9;
ListIter<Contact> contact = ship->ContactList();
while (++contact) {
if (contact->GetShip() && contact->GetIFF(ship) == ship->GetIFF()) {
Ship* c_ship = contact->GetShip();
if (c_ship != ship && c_ship->Class() >= ship->Class() && !c_ship->InTransition()) {
if (!support || c_ship->Class() > support->Class())
support = c_ship;
}
}
}
ship_ai->SetSupport(support);
}
示例2:
bool
FighterTacticalAI::IsStrikeComplete(Instruction* instr)
{
// wingmen can not call a halt to a strike:
if (!ship || element_index > 1)
return false;
// if there's nothing to shoot at, we must be done:
if (!instr || !instr->GetTarget() || instr->GetTarget()->Life() == 0 ||
instr->GetTarget()->Type() != SimObject::SIM_SHIP)
return true;
// break off strike only when ALL weapons are expended:
// (remember to check all relevant wingmen)
Element* element = ship->GetElement();
Ship* target = (Ship*) instr->GetTarget();
if (!element)
return true;
for (int i = 0; i < element->NumShips(); i++) {
Ship* s = element->GetShip(i+1);
if (!s || s->Integrity() < 25) // || (s->Location() - target->Location()).length() > 250e3)
continue;
ListIter<WeaponGroup> g_iter = s->Weapons();
while (++g_iter) {
WeaponGroup* w = g_iter.value();
if (w->Ammo() && w->CanTarget(target->Class())) {
ListIter<Weapon> w_iter = w->GetWeapons();
while (++w_iter) {
Weapon* weapon = w_iter.value();
if (weapon->Status() > System::CRITICAL)
return false;
}
}
}
}
// still here? we must be done!
return true;
}
示例3: if
void
TacticalAI::FindThreat()
{
// pick the closest contact on Threat Warning System:
Ship* threat = 0;
Shot* threat_missile = 0;
Ship* rumor = 0;
double threat_dist = 1e9;
const DWORD THREAT_REACTION_TIME = 1000; // 1 second
ListIter<Contact> iter = ship->ContactList();
while (++iter) {
Contact* contact = iter.value();
if (contact->Threat(ship) &&
(Game::GameTime() - contact->AcquisitionTime()) > THREAT_REACTION_TIME) {
if (contact->GetShot()) {
threat_missile = contact->GetShot();
rumor = (Ship*) threat_missile->Owner();
}
else {
double rng = contact->Range(ship);
Ship* c_ship = contact->GetShip();
if (c_ship && !c_ship->InTransition() &&
c_ship->Class() != Ship::FREIGHTER &&
c_ship->Class() != Ship::FARCASTER) {
if (c_ship->GetTarget() == ship) {
if (!threat || c_ship->Class() > threat->Class()) {
threat = c_ship;
threat_dist = 0;
}
}
else if (rng < threat_dist) {
threat = c_ship;
threat_dist = rng;
}
}
}
}
}
if (rumor && !rumor->InTransition()) {
iter.reset();
while (++iter) {
if (iter->GetShip() == rumor) {
rumor = 0;
ship_ai->ClearRumor();
break;
}
}
}
else {
rumor = 0;
ship_ai->ClearRumor();
}
ship_ai->SetRumor(rumor);
ship_ai->SetThreat(threat);
ship_ai->SetThreatMissile(threat_missile);
}