MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getTargetDistance

Method getTargetDistance

Engine/source/T3D/aiPlayer.cpp:1474–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1472}
1473
1474F32 AIPlayer::getTargetDistance(GameBase* target, bool _checkEnabled)
1475{
1476 if (!isServerObject()) return false;
1477 if (!target)
1478 {
1479 target = mAimObject.getPointer();
1480 if (!target)
1481 return F32_MAX;
1482 }
1483
1484 if (_checkEnabled)
1485 {
1486 if (target->getTypeMask() & ShapeBaseObjectType)
1487 {
1488 ShapeBase *shapeBaseCheck = static_cast<ShapeBase *>(target);
1489 if (shapeBaseCheck)
1490 if (shapeBaseCheck->getDamageState() != Enabled) return false;
1491 }
1492 else
1493 return F32_MAX;
1494 }
1495
1496 return (getPosition() - target->getPosition()).len();
1497}
1498
1499DefineEngineMethod(AIPlayer, getTargetDistance, F32, (ShapeBase* obj, bool checkEnabled), (nullAsType<ShapeBase*>(), false),
1500 "@brief The distance to a given object.\n"

Callers 1

aiPlayer.cppFile · 0.80

Calls 6

getPositionFunction · 0.85
getTypeMaskMethod · 0.80
getPointerMethod · 0.45
getDamageStateMethod · 0.45
lenMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected