| 1179 | |
| 1180 | #include <Poseidon/Foundation/Containers/StaticArray.hpp> |
| 1181 | void 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 | { |
no test coverage detected