コード例 #1
0
ファイル: ThreatMap.cpp プロジェクト: cleanrock/CircuitAI
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
ファイル: PathFinder.cpp プロジェクト: cleanrock/CircuitAI
void CPathFinder::SetMapData(CCircuitUnit* unit, CThreatMap* threatMap, int frame)
{
	CCircuitDef* cdef = unit->GetCircuitDef();
	STerrainMapMobileType::Id mobileTypeId = cdef->GetMobileId();
	bool* moveArray = (mobileTypeId < 0) ? airMoveArray : moveArrays[mobileTypeId];
	float* costArray;
	if ((unit->GetPos(frame).y < .0f) && !cdef->IsSonarStealth()) {
		costArray = threatMap->GetAmphThreatArray();  // cloak doesn't work under water
	} else if (unit->GetUnit()->IsCloaked()) {
		costArray = threatMap->GetCloakThreatArray();
	} else if (cdef->IsAbleToFly()) {
		costArray = threatMap->GetAirThreatArray();
	} else if (cdef->IsAmphibious()) {
		costArray = threatMap->GetAmphThreatArray();
	} else {
		costArray = threatMap->GetSurfThreatArray();
	}
	micropather->SetMapData(moveArray, costArray);
}