CvUnit::canLoad(const CvPlot &) const
- Defined in
- CvUnit.cpp, line 4375
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canLoad- Lua events
GameEvents.CanLoadAt
Hooks
static bool BeforeCvUnit_canLoad(const CvUnit* self, const CvPlot& targetPlot, bool& result);static void AfterCvUnit_canLoad(const CvUnit* self, const CvPlot& targetPlot, bool& result);static bool ReplaceCvUnit_canLoad(bool (*original)(const CvUnit*, const CvPlot&), const CvUnit* self, const CvPlot& targetPlot);CivRegisterBefore<CivHooks::CvUnit_canLoad>(host, &BeforeCvUnit_canLoad);CivRegisterAfter<CivHooks::CvUnit_canLoad>(host, &AfterCvUnit_canLoad);CivRegisterReplace<CivHooks::CvUnit_canLoad>(host, &ReplaceCvUnit_canLoad);
Code
4375bool CvUnit::canLoad(const CvPlot& targetPlot) const4376{4377 VALIDATE_OBJECT4378 if(NO_SPECIALUNIT != getSpecialUnitType())4379 {4380 CvSpecialUnitInfo* pkSpecialUnitInfo = GC.getSpecialUnitInfo(getSpecialUnitType());4381 if(pkSpecialUnitInfo)4382 {4383 if(pkSpecialUnitInfo->isCityLoad())4384 {4385 if(targetPlot.isCity())4386 {4387 return true;4388 }43894390#if defined(MOD_GLOBAL_RELOCATION)4391 // Is there a friendly improvement that AllowsRebaseTo4392 ImprovementTypes eImprovement = targetPlot.getImprovementType();4393 if (eImprovement != NO_IMPROVEMENT)4394 {4395 CvImprovementEntry *pkEntry = GC.getImprovementInfo(eImprovement);4396 if (pkEntry && pkEntry->IsAllowsRebaseTo() && !targetPlot.IsImprovementPillaged() && targetPlot.IsFriendlyTerritory(getOwner()) && !targetPlot.isVisibleEnemyUnit(getOwner()))4397 {4398 return true;4399 }4400 }4401#endif44024403#if defined(MOD_EVENTS_REBASE)4404 if (MOD_EVENTS_REBASE) {4405 if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_CanLoadAt, getOwner(), GetID(), targetPlot.getX(), targetPlot.getY()) == GAMEEVENTRETURN_TRUE) {4406 return true;4407 }4408 } else {4409#endif4410 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();4411 if (pkScriptSystem)4412 {4413 CvLuaArgsHandle args;4414 args->Push(getOwner());4415 args->Push(GetID());4416 args->Push(targetPlot.getX());4417 args->Push(targetPlot.getY());44184419 // Attempt to execute the game events.4420 // Will return false if there are no registered listeners.4421 bool bResult = false;4422 if (LuaSupport::CallTestAny(pkScriptSystem, "CanLoadAt", args.get(), bResult))4423 {4424 // Check the result.4425 if (bResult == true) {4426 return true;4427 }4428 }4429 }4430#if defined(MOD_EVENTS_REBASE)4431 }4432#endif4433 }4434 }4435 }44364437 const IDInfo* pUnitNode = targetPlot.headUnitNode();4438 while(pUnitNode != NULL)4439 {4440 const CvUnit* pLoopUnit = ::getUnit(*pUnitNode);4441 pUnitNode = targetPlot.nextUnitNode(pUnitNode);44424443 if(pLoopUnit && canLoadUnit(*pLoopUnit, targetPlot))4444 {4445 return true;4446 }4447 }44484449 return false;4450}
Calls
- CustomMods::eventTestAny(const char *, const char *, ...)
- CustomMods::isEVENTS_REBASE()
- CvGlobals::getDLLIFace()
- CvGlobals::getImprovementInfo(ImprovementTypes)
- CvGlobals::getSpecialUnitInfo(SpecialUnitTypes)
- CvImprovementEntry::IsAllowsRebaseTo() const
- CvLuaArgsHandle::CvLuaArgsHandle()
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvPlot::getImprovementType() const
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::headUnitNode() const
- CvPlot::isCity() const
- CvPlot::IsFriendlyTerritory(PlayerTypes) const
- CvPlot::IsImprovementPillaged() const
- CvPlot::isVisibleEnemyUnit(PlayerTypes) const
- CvPlot::nextUnitNode(const IDInfo *) const
- CvSpecialUnitInfo::isCityLoad() const
- CvUnit::canLoadUnit(const CvUnit &, const CvPlot &) const
- CvUnit::GetID() const
- CvUnit::getOwner() const
- CvUnit::getSpecialUnitType() const
- getUnit(const IDInfo &)
ICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystem- LuaSupport::CallTestAny(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)