本文整理汇总了C++中Contact::ActLock方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::ActLock方法的具体用法?C++ Contact::ActLock怎么用?C++ Contact::ActLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::ActLock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
CameraDirector::SetViewObjectGroup(ListIter<Ship> group, bool quick)
{
if (!ship) return;
Starshatter* stars = Starshatter::GetInstance();
if (!stars->InCutscene()) {
// only view solid contacts:
while (++group) {
Ship* s = group.value();
if (s->GetIFF() != ship->GetIFF()) {
Contact* c = ship->FindContact(s);
if (!c || !c->ActLock())
return;
}
if (s->Life() == 0 || s->IsDying() || s->IsDead())
return;
}
}
group.reset();
if (external_group.size() > 1 &&
external_group.size() == group.size()) {
bool same = true;
for (int i = 0; same && i < external_group.size(); i++) {
if (external_group[i] != group.container()[i])
same = false;
}
if (same) {
SetMode(MODE_ZOOM);
return;
}
}
ClearGroup();
if (quick) {
mode = MODE_ORBIT;
transition = 0;
}
else {
SetMode(MODE_TRANSLATE);
}
external_group.append(group.container());
ListIter<Ship> iter = external_group;
while (++iter) {
Ship* s = iter.value();
region = s->GetRegion();
Observe(s);
}
}
示例2: if
void
CameraDirector::CycleViewObject()
{
if (!ship) return;
Ship* current = external_ship;
external_ship = 0;
ListIter<Contact> iter = ship->ContactList();
while (++iter && !external_ship) {
Contact* c = iter.value();
Ship* c_ship = c->GetShip();
if (c_ship && !current) {
external_ship = c_ship;
}
else if (current && c_ship == current) {
while (++iter && !external_ship) {
c = iter.value();
if (c->ActLock())
external_ship = c->GetShip();
}
}
}
if (external_ship != current) {
if (external_ship) {
if (external_ship->Life() == 0 || external_ship->IsDying() || external_ship->IsDead()) {
external_point = external_ship->Location();
external_ship = 0;
}
else {
Observe(external_ship);
}
}
if (mode == MODE_ORBIT) {
SetMode(MODE_TRANSLATE);
ExternalRange(1);
}
}
}
示例3: if
void
StarshipAI::FireControl()
{
// identify unknown contacts:
if (identify) {
if (fabs(ship->GetHelmHeading() - ship->CompassHeading()) < 10*DEGREES) {
Contact* contact = ship->FindContact(target);
if (contact && !contact->ActLock()) {
if (!ship->GetProbe()) {
ship->LaunchProbe();
}
}
}
return;
}
// investigate last known location of enemy ship:
if (rumor && !target && ship->GetProbeLauncher() && !ship->GetProbe()) {
// is rumor in basket?
Point rmr = Transform(rumor->Location());
rmr.Normalize();
double dx = fabs(rmr.x);
double dy = fabs(rmr.y);
if (dx < 10*DEGREES && dy < 10*DEGREES && rmr.z > 0) {
ship->LaunchProbe();
}
}
// Corvettes and Frigates are anti-air platforms. They need to
// target missile threats even when the threat is aimed at another
// friendly ship. Forward facing weapons must be on auto fire,
// while lateral and aft facing weapons are set to point defense.
if (ship->Class() == Ship::CORVETTE || ship->Class() == Ship::FRIGATE) {
ListIter<WeaponGroup> iter = ship->Weapons();
while (++iter) {
WeaponGroup* group = iter.value();
ListIter<Weapon> w_iter = group->GetWeapons();
while (++w_iter) {
Weapon* weapon = w_iter.value();
double az = weapon->GetAzimuth();
if (fabs(az) < 45*DEGREES) {
weapon->SetFiringOrders(Weapon::AUTO);
weapon->SetTarget(target, 0);
}
else {
weapon->SetFiringOrders(Weapon::POINT_DEFENSE);
}
}
}
}
// All other starships are free to engage ship targets. Weapon
// fire control is managed by the type of weapon.
else {
System* subtgt = SelectSubtarget();
ListIter<WeaponGroup> iter = ship->Weapons();
while (++iter) {
WeaponGroup* weapon = iter.value();
if (weapon->GetDesign()->target_type & Ship::DROPSHIPS) { // anti-air weapon?
weapon->SetFiringOrders(Weapon::POINT_DEFENSE);
}
else if (weapon->IsDrone()) { // torpedoes
weapon->SetFiringOrders(Weapon::MANUAL);
weapon->SetTarget(target, 0);
if (target && target->GetRegion() == ship->GetRegion()) {
Point delta = target->Location() - ship->Location();
double range = delta.length();
if (range < weapon->GetDesign()->max_range * 0.9 &&
!AssessTargetPointDefense())
weapon->SetFiringOrders(Weapon::AUTO);
else if (range < weapon->GetDesign()->max_range * 0.5)
weapon->SetFiringOrders(Weapon::AUTO);
}
}
else { // anti-ship weapon
weapon->SetFiringOrders(Weapon::AUTO);
weapon->SetTarget(target, subtgt);
weapon->SetSweep(subtgt ? Weapon::SWEEP_NONE : Weapon::SWEEP_TIGHT);
}
}
}
}