CvUnit::canDisembark(const CvPlot *) const
- Defined in
- CvUnit.cpp, line 4901
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canDisembark
Hooks
static bool BeforeCvUnit_canDisembark(const CvUnit* self, const CvPlot* pPlot, bool& result);static void AfterCvUnit_canDisembark(const CvUnit* self, const CvPlot* pPlot, bool& result);static bool ReplaceCvUnit_canDisembark(bool (*original)(const CvUnit*, const CvPlot*), const CvUnit* self, const CvPlot* pPlot);CivRegisterBefore<CivHooks::CvUnit_canDisembark>(host, &BeforeCvUnit_canDisembark);CivRegisterAfter<CivHooks::CvUnit_canDisembark>(host, &AfterCvUnit_canDisembark);CivRegisterReplace<CivHooks::CvUnit_canDisembark>(host, &ReplaceCvUnit_canDisembark);
Code
4901bool CvUnit::canDisembark(const CvPlot* pPlot) const4902{4903 VALIDATE_OBJECT4904 if(getDomainType() != DOMAIN_LAND)4905 {4906 return false;4907 }49084909 if(!isEmbarked())4910 {4911 return false;4912 }49134914 if(movesLeft() <= 0)4915 {4916 return false;4917 }49184919 if(!pPlot->isWater())4920 {4921 return false;4922 }49234924#if defined(MOD_PATHFINDER_TERRAFIRMA)4925 // Can we disembark from our current plot?4926 // Only if we are adjacent to land (actual check for plot being land/ice is below)4927 bool bCanDisembark = plot()->isAdjacentToLand();4928#if defined(MOD_PATHFINDER_CROSS_ICE)4929 // ... or we cross ice and are adjacent to ice4930 bCanDisembark = bCanDisembark || (canCrossIce() && plot()->isAdjacentToIce());4931#endif4932#if defined(MOD_PATHFINDER_DEEP_WATER_EMBARKATION)4933 // ... or we hover and are adjacent to shallow water4934 bCanDisembark = bCanDisembark || (IsHoveringUnit() && plot()->isAdjacentToShallowWater());4935#endif4936 if(!bCanDisembark)4937#else4938 if(!pPlot->isAdjacentToLand())4939#endif4940 {4941 return false;4942 }49434944 // search the land plots around this plot to see if any can be moved into4945 int iRange = 1;4946 bool bOpenPlot = false;4947 for(int iX = -iRange; iX <= iRange; iX++)4948 {4949 for(int iY = -iRange; iY <= iRange; iY++)4950 {4951 CvPlot* pEvalPlot = plotXYWithRangeCheck(pPlot->getX(), pPlot->getY(), iX, iY, iRange);4952 if(!pEvalPlot)4953 {4954 continue;4955 }49564957 if(pEvalPlot->getX() == pPlot->getX() && pEvalPlot->getY() == pPlot->getY())4958 {4959 continue;4960 }49614962 if(canDisembarkOnto(*pEvalPlot))4963 {4964 bOpenPlot = true;49654966 // get out of the loop4967 iX = iRange + 1;4968 iY = iRange + 1;4969 }4970 }4971 }49724973 return bOpenPlot;4974}
Calls
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::isAdjacentToIce() const
- CvPlot::isAdjacentToLand() const
- CvPlot::isAdjacentToShallowWater() const
- CvPlot::isWater() const
- CvUnit::canCrossIce() const
- CvUnit::canDisembarkOnto(const CvPlot &, bool) const
- CvUnit::getDomainType() const
- CvUnit::isEmbarked() const
- CvUnit::IsHoveringUnit() const
- CvUnit::movesLeft() const
- CvUnit::plot() const
- plotXYWithRangeCheck(int, int, int, int, int)