MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / CanDeployIntoBuilding

Method CanDeployIntoBuilding

src/Ext/Techno/Body.cpp:426–448  ·  view source on GitHub ↗

Checks if vehicle can deploy into a building at its current location. If unit has no DeploysInto set returns noDeploysIntoDefaultValue (def = false) instead.

Source from the content-addressed store, hash-verified

424
425// Checks if vehicle can deploy into a building at its current location. If unit has no DeploysInto set returns noDeploysIntoDefaultValue (def = false) instead.
426bool TechnoExt::CanDeployIntoBuilding(UnitClass* pThis, bool noDeploysIntoDefaultValue)
427{
428 if (!pThis)
429 return false;
430
431 auto const pDeployType = pThis->Type->DeploysInto;
432
433 if (!pDeployType)
434 return noDeploysIntoDefaultValue;
435
436 auto mapCoords = CellClass::Coord2Cell(pThis->GetCoords());
437
438 if (pDeployType->GetFoundationWidth() > 2 || pDeployType->GetFoundationHeight(false) > 2)
439 mapCoords += CellStruct { -1, -1 };
440
441 // The vanilla game used an inappropriate approach here, resulting in potential risk of desync.
442 // Now, through additional checks, we can directly exclude the unit who want to deploy.
443 TechnoExt::Deployer = pThis;
444 const bool canDeploy = pDeployType->CanCreateHere(mapCoords, pThis->Owner);
445 TechnoExt::Deployer = nullptr;
446
447 return canDeploy;
448}
449
450bool TechnoExt::IsTypeImmune(TechnoClass* pThis, TechnoClass* pSource)
451{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected