MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / Disclose

Method Disclose

engine/Poseidon/World/Simulation/Collisions.cpp:1181–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1179
1180#include <Poseidon/Foundation/Containers/StaticArray.hpp>
1181void Landscape::Disclose(EntityAI* owner, Vector3Par pos, float maxDist, bool discloseSide, bool disclosePosition)
1182{
1183 AUTO_STATIC_ARRAY(Ref<AIGroup>, disclose, 32);
1184
1185 // tell all near enemy vehicles they are disclosed
1186 if (!owner)
1187 {
1188 LOG_DEBUG(Physics, "No owner");
1189 return;
1190 }
1191 AIUnit* ownerUnit = owner->CommanderUnit();
1192 if (!ownerUnit)
1193 {
1194 return;
1195 }
1196 AIGroup* ownerGroup = ownerUnit->GetGroup();
1197 if (!ownerGroup)
1198 {
1199 return;
1200 }
1201
1202 AICenter* myCenter = ownerGroup->GetCenter();
1203 int xMin, xMax, zMin, zMax;
1204 ObjRadiusRectangle(xMin, xMax, zMin, zMax, pos, pos, maxDist);
1205 for (int x = xMin; x <= xMax; x++)
1206 {
1207 for (int z = zMin; z <= zMax; z++)
1208 {
1209 const ObjectList& list = _objects(x, z);
1210 int n = list.Size();
1211 for (int i = 0; i < n; i++)
1212 {
1213 Object* obj = list[i];
1214 if (obj->GetType() != TypeVehicle)
1215 {
1216 continue;
1217 }
1218 EntityAI* veh = dyn_cast<EntityAI>(obj);
1219 if (!veh)
1220 {
1221 continue;
1222 }
1223 if (veh->Position().Distance2(pos) > Square(maxDist))
1224 {
1225 continue;
1226 }
1227 AIUnit* vehBrain = veh->CommanderUnit();
1228 if (vehBrain && vehBrain->GetLifeState() == AIUnit::LSAlive)
1229 {
1230 AIGroup* vehGroup = vehBrain->GetGroup();
1231 if (vehGroup && myCenter != vehGroup->GetCenter())
1232 {
1233 if (myCenter->IsEnemy(veh->GetTargetSide()))
1234 {
1235 disclose.Add(vehGroup);
1236 vehBrain->Disclose(false);
1237 if (veh->PilotUnit() && veh->PilotUnit() != vehBrain)
1238 {

Callers 2

TrackTargetsMethod · 0.45
ScreamMethod · 0.45

Calls 15

ObjRadiusRectangleFunction · 0.85
GetLifeStateMethod · 0.80
IsEnemyMethod · 0.80
GetTargetAssignedMethod · 0.80
AUTO_STATIC_ARRAYFunction · 0.70
SquareFunction · 0.50
CommanderUnitMethod · 0.45
GetGroupMethod · 0.45
GetCenterMethod · 0.45
SizeMethod · 0.45
GetTypeMethod · 0.45
Distance2Method · 0.45

Tested by

no test coverage detected