CvPlot::canHaveFeature(FeatureTypes) const
- Defined in
- CvPlot.cpp, line 4341
- Class
- CvPlot
- Hook name
CivHooks::CvPlot_canHaveFeature
Hooks
static bool BeforeCvPlot_canHaveFeature(const CvPlot* self, FeatureTypes eFeature, bool& result);static void AfterCvPlot_canHaveFeature(const CvPlot* self, FeatureTypes eFeature, bool& result);static bool ReplaceCvPlot_canHaveFeature(bool (*original)(const CvPlot*, FeatureTypes), const CvPlot* self, FeatureTypes eFeature);CivRegisterBefore<CivHooks::CvPlot_canHaveFeature>(host, &BeforeCvPlot_canHaveFeature);CivRegisterAfter<CivHooks::CvPlot_canHaveFeature>(host, &AfterCvPlot_canHaveFeature);CivRegisterReplace<CivHooks::CvPlot_canHaveFeature>(host, &ReplaceCvPlot_canHaveFeature);
Code
4341bool CvPlot::canHaveFeature(FeatureTypes eFeature) const4342{4343 CvAssertMsg(getTerrainType() != NO_TERRAIN, "TerrainType is not assigned a valid value");43444345 if(eFeature == NO_FEATURE)4346 {4347 return true;4348 }43494350 if(getFeatureType() != NO_FEATURE)4351 {4352 return false;4353 }43544355 if(isMountain())4356 {4357 return false;4358 }43594360 if(isCity())4361 {4362 return false;4363 }43644365 CvFeatureInfo* pkFeature = GC.getFeatureInfo(eFeature);4366 if(pkFeature == NULL)4367 {4368 return false;4369 }43704371 if(!pkFeature->isTerrain(getTerrainType()))4372 {4373 return false;4374 }43754376 if(pkFeature->isNoCoast() && isCoastalLand())4377 {4378 return false;4379 }43804381 if(pkFeature->isNoRiver() && isRiver())4382 {4383 return false;4384 }43854386 if(pkFeature->isRequiresFlatlands() && isHills())4387 {4388 return false;4389 }43904391 if(pkFeature->isNoAdjacent())4392 {4393 for(int iI = 0; iI < NUM_DIRECTION_TYPES; ++iI)4394 {4395 CvPlot* pAdjacentPlot = plotDirection(getX(), getY(), ((DirectionTypes)iI));43964397 if(pAdjacentPlot != NULL)4398 {4399 if(pAdjacentPlot->getFeatureType() == eFeature)4400 {4401 return false;4402 }4403 }4404 }4405 }44064407 if(!isRiver() && pkFeature->isRequiresRiver())4408 {4409 return false;4410 }44114412 return true;4413}
Calls
- CvFeatureInfo::isNoAdjacent() const
- CvFeatureInfo::isNoCoast() const
- CvFeatureInfo::isNoRiver() const
- CvFeatureInfo::isRequiresFlatlands() const
- CvFeatureInfo::isRequiresRiver() const
- CvFeatureInfo::isTerrain(int) const
- CvGlobals::getFeatureInfo(FeatureTypes)
- CvPlot::getFeatureType() const
- CvPlot::getTerrainType() const
- CvPlot::getX() const
- CvPlot::getY() const
- CvPlot::isCity() const
- CvPlot::isCoastalLand(int) const
- CvPlot::isHills() const
- CvPlot::isMountain() const
- CvPlot::isRiver() const
- plotDirection(int, int, DirectionTypes)