Bazaar developer reference

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

Called by