本文整理汇总了C++中Sim::GetRegions方法的典型用法代码示例。如果您正苦于以下问题:C++ Sim::GetRegions方法的具体用法?C++ Sim::GetRegions怎么用?C++ Sim::GetRegions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sim
的用法示例。
在下文中一共展示了Sim::GetRegions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
MissionEvent::CheckTrigger()
{
Sim* sim = Sim::GetSim();
if (time > 0 && time > sim->MissionClock())
return false;
switch (trigger) {
case TRIGGER_TIME: {
if (time <= sim->MissionClock())
Activate();
}
break;
case TRIGGER_DAMAGE: {
Ship* ship = sim->FindShip(trigger_ship);
if (ship) {
double damage = 100.0 * (ship->Design()->integrity - ship->Integrity()) /
(ship->Design()->integrity);
if (damage >= trigger_param[0])
Activate();
}
}
break;
case TRIGGER_DETECT: {
Ship* ship = sim->FindShip(trigger_ship);
Ship* tgt = sim->FindShip(trigger_target);
if (ship && tgt) {
if (ship->FindContact(tgt))
Activate();
}
else {
Skip();
}
}
break;
case TRIGGER_RANGE: {
Ship* ship = sim->FindShip(trigger_ship);
Ship* tgt = sim->FindShip(trigger_target);
if (ship && tgt) {
double range = (ship->Location() - tgt->Location()).length();
double min_range = 0;
double max_range = 1e12;
if (trigger_param[0] > 0)
min_range = trigger_param[0];
else
max_range = -trigger_param[0];
if (range < min_range || range > max_range)
Activate();
}
else {
Skip();
}
}
break;
case TRIGGER_SHIPS_LEFT: {
int alive = 0;
int count = 0;
int iff = -1;
int nparams = NumTriggerParams();
if (nparams > 0) count = TriggerParam(0);
if (nparams > 1) iff = TriggerParam(1);
ListIter<SimRegion> iter = sim->GetRegions();
while (++iter) {
SimRegion* rgn = iter.value();
ListIter<Ship> s_iter = rgn->Ships();
while (++s_iter) {
Ship* ship = s_iter.value();
if (ship->Type() >= Ship::STATION)
continue;
if (ship->Life() == 0 && ship->RespawnCount() < 1)
continue;
if (iff < 0 || ship->GetIFF() == iff)
alive++;
}
}
if (alive <= count)
Activate();
}
break;
case TRIGGER_EVENT_ALL: {
bool all = true;
int nparams = NumTriggerParams();
//.........这里部分代码省略.........