CvUnit::SetAutomateType(AutomateTypes)
- Defined in
- CvUnit.cpp, line 22364
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_SetAutomateType
Hooks
static bool BeforeCvUnit_SetAutomateType(CvUnit* self, AutomateTypes eNewValue);static void AfterCvUnit_SetAutomateType(CvUnit* self, AutomateTypes eNewValue);static void ReplaceCvUnit_SetAutomateType(void (*original)(CvUnit*, AutomateTypes), CvUnit* self, AutomateTypes eNewValue);CivRegisterBefore<CivHooks::CvUnit_SetAutomateType>(host, &BeforeCvUnit_SetAutomateType);CivRegisterAfter<CivHooks::CvUnit_SetAutomateType>(host, &AfterCvUnit_SetAutomateType);CivRegisterReplace<CivHooks::CvUnit_SetAutomateType>(host, &ReplaceCvUnit_SetAutomateType);
Code
22364void CvUnit::SetAutomateType(AutomateTypes eNewValue)22365{22366 VALIDATE_OBJECT22367 CvAssert(getOwner() != NO_PLAYER);2236822369 if(GetAutomateType() != eNewValue)22370 {22371 AutomateTypes eOldAutomateType = GetAutomateType();22372 m_eAutomateType = eNewValue;2237322374 ClearMissionQueue();22375 SetActivityType(ACTIVITY_AWAKE);22376 if(eOldAutomateType == AUTOMATE_EXPLORE)22377 {22378 GET_PLAYER(getOwner()).GetEconomicAI()->m_bExplorationPlotsDirty = true; // these need to be rebuilt22379 }2238022381 // if canceling automation, cancel on cargo as well22382 if(eNewValue == NO_AUTOMATE)22383 {22384 CvPlot* pPlot = plot();22385 if(pPlot != NULL)22386 {22387 IDInfo* pUnitNode = pPlot->headUnitNode();22388 while(pUnitNode != NULL)22389 {22390 CvUnit* pCargoUnit = ::getUnit(*pUnitNode);22391 pUnitNode = pPlot->nextUnitNode(pUnitNode);2239222393 CvUnit* pTransportUnit = pCargoUnit->getTransportUnit();22394 if(pTransportUnit != NULL && pTransportUnit == this)22395 {22396 pCargoUnit->SetAutomateType(NO_AUTOMATE);22397 pCargoUnit->SetActivityType(ACTIVITY_AWAKE);22398 }22399 }22400 }22401 }22402 else if(m_eAutomateType == AUTOMATE_EXPLORE)22403 {22404 GET_PLAYER(getOwner()).GetEconomicAI()->m_bExplorationPlotsDirty = true; // these need to be rebuilt22405 }22406 }22407}
Calls
- CvPlayer::GetEconomicAI() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::headUnitNode()
- CvPlot::nextUnitNode(IDInfo *)
- CvUnit::ClearMissionQueue(int)
- CvUnit::GetAutomateType() const
- CvUnit::getOwner() const
- CvUnit::getTransportUnit()
- CvUnit::plot() const
- CvUnit::SetActivityType(ActivityTypes, bool)
FAutoVariable::operator const AutomateTypes &FAutoVariable::operator=- getUnit(const IDInfo &)
Called by
- CvHomelandAI::ExecuteExplorerMoves()
- CvHomelandAI::MoveCivilianToSafety(CvUnit *, bool, bool)
- CvGameTrade::CreateVis(int)
- CvUnit::Automate(AutomateTypes)
- CvUnit::doCommand(CommandTypes, int, int)
- CvUnit::setPromotionReady(bool)
- CvUnitCombat::ApplyNuclearExplosionDamage(const CvCombatMemberEntry *, int, CvUnit *, CvPlot *, int)
- CvUnitCombat::Attack(CvUnit &, CvPlot &, ATTACK_OPTION)
- CvUnitCombat::AttackAir(CvUnit &, CvPlot &, ATTACK_OPTION)
- CvUnitCombat::AttackAirSweep(CvUnit &, CvPlot &, ATTACK_OPTION)
- CvUnitCombat::AttackCity(CvUnit &, CvPlot &, CvUnitCombat::ATTACK_OPTION)
- CvUnitCombat::AttackRanged(CvUnit &, int, int, CvUnitCombat::ATTACK_OPTION)
- CvUnitCombat::ResolveNuclearCombat(const CvCombatInfo &, uint)
- CvUnitMission::PushMission(UnitHandle, MissionTypes, int, int, int, bool, bool, MissionAITypes, CvPlot *, CvUnit *)