示例#1
0
void CThreatMap::AddEnemyMetal(const CEnemyUnit* e, const float scale)
{
	CCircuitDef* cdef = e->GetCircuitDef();
	assert(cdef != nullptr);

	const float cost = cdef->GetCost() * scale;
	if (cdef->IsAbleToFly()) {
		airMetal += cost;
	} else if (cdef->IsMobile()) {
		STerrainMapMobileType* mt = circuit->GetTerrainManager()->GetMobileTypeById(cdef->GetMobileId());
		if (mt->maxElevation > SQUARE_SIZE * 5) {
			landMetal += cost;
		}
		if (mt->minElevation < -SQUARE_SIZE * 5) {
			waterMetal += cost;
		}
	} else {
		STerrainMapImmobileType* it = circuit->GetTerrainManager()->GetImmobileTypeById(cdef->GetImmobileId());
		if (it->maxElevation > SQUARE_SIZE * 5) {
			landMetal += cost;
		}
		if (it->minElevation < -SQUARE_SIZE * 5) {
			waterMetal += cost;
		}
		if (cdef->HasAntiLand()) {
			staticMetal += cost;
		}
	}
}