CvUnit::CanAutomate(AutomateTypes, bool) const
- Defined in
- CvUnit.cpp, line 3864
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_CanAutomate
Hooks
static bool BeforeCvUnit_CanAutomate(const CvUnit* self, AutomateTypes eAutomate, bool bTestVisibility, bool& result);static void AfterCvUnit_CanAutomate(const CvUnit* self, AutomateTypes eAutomate, bool bTestVisibility, bool& result);static bool ReplaceCvUnit_CanAutomate(bool (*original)(const CvUnit*, AutomateTypes, bool), const CvUnit* self, AutomateTypes eAutomate, bool bTestVisibility);CivRegisterBefore<CivHooks::CvUnit_CanAutomate>(host, &BeforeCvUnit_CanAutomate);CivRegisterAfter<CivHooks::CvUnit_CanAutomate>(host, &AfterCvUnit_CanAutomate);CivRegisterReplace<CivHooks::CvUnit_CanAutomate>(host, &ReplaceCvUnit_CanAutomate);
Code
3864bool CvUnit::CanAutomate(AutomateTypes eAutomate, bool bTestVisibility) const3865{3866 VALIDATE_OBJECT3867 if(eAutomate == NO_AUTOMATE)3868 {3869 return false;3870 }38713872 switch(eAutomate)3873 {3874 case AUTOMATE_BUILD:3875 if((AI_getUnitAIType() != UNITAI_WORKER) && (AI_getUnitAIType() != UNITAI_WORKER_SEA))3876 {3877 return false;3878 }38793880 if(!bTestVisibility)3881 {3882 if(GC.getUNIT_WORKER_AUTOMATION_DISABLED() == 1)3883 {3884 return false;3885 }3886 }38873888 break;38893890 case AUTOMATE_EXPLORE:3891 if((GetBaseCombatStrength(true) == 0) || (getDomainType() == DOMAIN_AIR) || (getDomainType() == DOMAIN_IMMOBILE))3892 {3893 return false;3894 }38953896 if(!bTestVisibility)3897 {3898#if defined(MOD_BUGFIX_USE_GETTERS)3899 if (!GET_MY_PLAYER().GetHomelandAI()->IsAnyValidExploreMoves(this))3900#else3901 if (!GET_PLAYER(m_eOwner).GetHomelandAI()->IsAnyValidExploreMoves(this))3902#endif3903 {3904 return false;3905 }3906 }39073908 if (GC.getUNIT_AUTO_EXPLORE_FULL_DISABLED() == 1)3909 {3910 return false;3911 }39123913 if(!bTestVisibility)3914 {3915 if(GC.getUNIT_AUTO_EXPLORE_DISABLED() == 1)3916 {3917 return false;3918 }3919 }3920 break;39213922 default:3923 CvAssert(false);3924 break;3925 }39263927 return true;3928}
Calls
- CvGlobals::getUNIT_AUTO_EXPLORE_DISABLED()
- CvGlobals::getUNIT_AUTO_EXPLORE_FULL_DISABLED()
- CvGlobals::getUNIT_WORKER_AUTOMATION_DISABLED()
- CvHomelandAI::IsAnyValidExploreMoves(const CvUnit *) const
- CvPlayer::GetHomelandAI() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvUnit::AI_getUnitAIType() const
- CvUnit::GetBaseCombatStrength(bool) const
- CvUnit::getDomainType() const
- CvUnit::getOwner() const