CvUnit::canCreateGreatWork(const CvPlot *, bool) const
- Defined in
- CvUnit.cpp, line 7144
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_canCreateGreatWork
Hooks
static bool BeforeCvUnit_canCreateGreatWork(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static void AfterCvUnit_canCreateGreatWork(const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility, bool& result);static bool ReplaceCvUnit_canCreateGreatWork(bool (*original)(const CvUnit*, const CvPlot*, bool), const CvUnit* self, const CvPlot* pPlot, bool bOnlyTestVisibility);CivRegisterBefore<CivHooks::CvUnit_canCreateGreatWork>(host, &BeforeCvUnit_canCreateGreatWork);CivRegisterAfter<CivHooks::CvUnit_canCreateGreatWork>(host, &AfterCvUnit_canCreateGreatWork);CivRegisterReplace<CivHooks::CvUnit_canCreateGreatWork>(host, &ReplaceCvUnit_canCreateGreatWork);
Code
7144bool CvUnit::canCreateGreatWork(const CvPlot* pPlot, bool bOnlyTestVisibility) const7145{7146 // Unit class has this flag?7147 if(GetGreatWork() == NO_GREAT_WORK)7148 {7149 return false;7150 }71517152 const TeamTypes eTeam = getTeam();7153 if(GET_TEAM(eTeam).isMinorCiv())7154 {7155 return false;7156 }71577158 if(isDelayedDeath())7159 {7160 return false;7161 }71627163 //If we're only testing whether this unit has the capabilty to ever perform the action, return true.7164 if (bOnlyTestVisibility)7165 {7166 return true;7167 }71687169 // In or adjacent to a city?7170 CvCity* pCity;7171 if (pPlot == NULL)7172 {7173 return false;7174 }7175 pCity = pPlot->getPlotCity();7176 if (pCity == NULL)7177 {7178 pCity = pPlot->GetAdjacentCity();7179 if (pCity == NULL)7180 {7181 return false;7182 }7183 }71847185 // ... is this a friendly city?7186 if (eTeam != pCity->getTeam())7187 {7188 return false;7189 }71907191 // Is there a slot of the right type somewhere in the empire?7192 GreatWorkSlotType eGreatWorkSlot = CultureHelpers::GetGreatWorkSlot(GetGreatWork());7193 CvPlayer &kPlayer = GET_PLAYER(getOwner());7194 if (kPlayer.GetCulture()->GetNumAvailableGreatWorkSlots(eGreatWorkSlot) > 0)7195 {7196 return true;7197 }7198 else7199 {7200 return false;7201 }7202}
Calls
- CultureHelpers::GetGreatWorkSlot(GreatWorkType)
- CvCity::getTeam() const
- CvPlayer::GetCulture() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerCulture::GetNumAvailableGreatWorkSlots(GreatWorkSlotType) const
- CvPlot::GetAdjacentCity(bool) const
- CvPlot::getPlotCity() const
- CvTeam::getTeam(TeamTypes)
- CvTeam::isMinorCiv() const
- CvUnit::GetGreatWork() const
- CvUnit::getOwner() const
- CvUnit::getTeam() const
- CvUnit::isDelayedDeath() const