MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / hasLineToPosition

Method hasLineToPosition

game/state/battle/battleunit.cpp:1003–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001}
1002
1003bool BattleUnit::hasLineToPosition(Vec3<float> targetPosition, bool useLOS) const
1004{
1005 auto muzzleLocation = getMuzzleLocation();
1006 // Map part that prevents Line to target
1007 auto cMap = tileObject->map.findCollision(muzzleLocation, targetPosition, mapPartSet,
1008 tileObject, useLOS);
1009 // Unit that prevents Line to target
1010 auto cUnitObj =
1011 useLOS ? Collision()
1012 : tileObject->map.findCollision(muzzleLocation, targetPosition, unitSet, tileObject);
1013 auto cUnit = cUnitObj ? std::static_pointer_cast<TileObjectBattleUnit>(cUnitObj.obj)->getUnit()
1014 : nullptr;
1015 // Condition:
1016 // No map part blocks Line
1017 return !cMap
1018 // No unit blocks Line
1019 && (!cUnit ||
1020 owner->isRelatedTo(cUnit->owner) == Organisation::Relation::Hostile
1021 // If our head blocks brainsucker on it - no problem, hit will go versus brainsucker
1022 // anyway
1023 || cUnit->brainSucker);
1024}
1025
1026int BattleUnit::getPsiChanceForEquipment(StateRef<BattleUnit> target, PsiStatus status,
1027 StateRef<AEquipmentType> item)

Callers

nothing calls this directly

Calls 4

findCollisionMethod · 0.80
getUnitMethod · 0.80
isRelatedToMethod · 0.80
CollisionClass · 0.70

Tested by

no test coverage detected