示例#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;
		}
	}
}
示例#2
0
void CThreatMap::SetEnemyUnitRange(CEnemyUnit* e) const
{
	CCircuitDef* cdef = e->GetCircuitDef();
	assert(cdef != nullptr);

	const int slack = DEFAULT_SLACK * (cdef->IsMobile() ? 4 : 2);
	int range;
	int maxRange;

	range = cdef->HasAntiAir() ? ((int)cdef->GetMaxRange(CCircuitDef::RangeType::AIR) + slack) / squareSize : 0;
	e->SetRange(CEnemyUnit::RangeType::AIR, range);
	maxRange = range;

	range = cdef->HasAntiLand() ? ((int)cdef->GetMaxRange(CCircuitDef::RangeType::LAND) + slack) / squareSize : 0;
	e->SetRange(CEnemyUnit::RangeType::LAND, range);
	maxRange = std::max(maxRange, range);

	range = cdef->HasAntiWater() ? ((int)cdef->GetMaxRange(CCircuitDef::RangeType::WATER) + slack) / squareSize : 0;
	e->SetRange(CEnemyUnit::RangeType::WATER, range);
	maxRange = std::max(maxRange, range);

	e->SetRange(CEnemyUnit::RangeType::MAX, maxRange);
	e->SetRange(CEnemyUnit::RangeType::CLOAK, GetCloakRange(e));
}