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

Function CreateSensor

engine/Poseidon/AI/AICenterImpl.cpp:1242–1385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1240Vehicle* CreateSensor(const ArcadeSensorInfo& info, AIGroup* grp, bool multiplayer)
1241{
1242 Vector3 pos = info.position, normal = VUp;
1243 pos[1] = GLOB_LAND->RoadSurfaceYAboveWater(pos[0], pos[2]);
1244
1245 AICenter* center = nullptr;
1246 switch (info.type) // special cases - guarded by ...
1247 {
1248 case ASTEastGuarded:
1249 center = GWorld->GetEastCenter();
1250 goto Guarded;
1251 case ASTWestGuarded:
1252 center = GWorld->GetWestCenter();
1253 goto Guarded;
1254 case ASTGuerrilaGuarded:
1255 center = GWorld->GetGuerrilaCenter();
1256 goto Guarded;
1257 Guarded:
1258 if (!center)
1259 {
1260 return nullptr;
1261 }
1262 if (grp)
1263 {
1264 AI_ERROR(grp->Leader());
1265 if (grp->Leader())
1266 {
1267 pos = grp->Leader()->Position();
1268 }
1269 }
1270 else
1271 {
1272 if (info.idStatic >= 0)
1273 {
1274 Object* obj = GLandscape->FindObject(info.idStatic);
1275 if (obj)
1276 {
1277 pos = obj->Position();
1278 }
1279 }
1280 else
1281 {
1282 if (info.idVehicle >= 0 && info.idVehicle < vehiclesMap.Size())
1283 {
1284 Vehicle* veh = vehiclesMap[info.idVehicle];
1285 if (veh)
1286 {
1287 pos = veh->Position();
1288 }
1289 }
1290 }
1291 }
1292 {
1293 int index = center->_guardedPoints.Add();
1294 center->_guardedPoints[index].position = pos;
1295 }
1296 return nullptr;
1297 }
1298
1299 Ref<Vehicle> vehicle = NewNonAIVehicle(info.object);

Callers 2

InitNoCentersFunction · 0.85
BeginArcadeMethod · 0.85

Calls 15

NewNonAIVehicleFunction · 0.85
GameValueExtClass · 0.85
GetEastCenterMethod · 0.80
GetWestCenterMethod · 0.80
GetGuerrilaCenterMethod · 0.80
BoundingCenterMethod · 0.80
FromTemplateMethod · 0.80
AddBuildingMethod · 0.80
Vector3Class · 0.50
LeaderMethod · 0.45
PositionMethod · 0.45

Tested by

no test coverage detected