1 // -------------------------------------------------------------------------
2 // AAI
3 //
4 // A skirmish AI for the Spring engine.
5 // Copyright Alexander Seizinger
6 //
7 // Released under GPL license: see LICENSE.html for more information.
8 // -------------------------------------------------------------------------
9 
10 #ifndef AAI_AIRFORCEMANAGER_H
11 #define AAI_AIRFORCEMANAGER_H
12 
13 #include <vector>
14 #include "System/float3.h"
15 #include "aidef.h"
16 
17 namespace springLegacyAI {
18 	struct UnitDef;
19 }
20 using namespace springLegacyAI;
21 using namespace std;
22 
23 class AAI;
24 class AAIBuildTable;
25 
26 struct AAIAirTarget
27 {
28 	float3 pos;
29 	int def_id;
30 	int unit_id;
31 	float cost;
32 	float health;
33 	UnitCategory category;
34 };
35 
36 class AAIAirForceManager
37 {
38 public:
39 	AAIAirForceManager(AAI *ai);
40 	~AAIAirForceManager(void);
41 
42 	// checks if a certain unit is worth attacking it and tries to order air units to do it (units, stationary defences)
43 	void CheckTarget(int unit, const UnitDef *def);
44 
45 	// removes target from bombing target list
46 	void RemoveTarget(int unit_id);
47 
48 	// attacks the most promising target
49 	void BombBestUnit(float cost, float danger);
50 
51 
52 	// list of possible bombing targets
53 	vector<AAIAirTarget> targets;
54 
55 private:
56 	AAIGroup* GetAirGroup(float importance, UnitType group_type);
57 
58 	// returns true if uni already in target list
59 	bool IsTarget(int unit_id);
60 	// tries to attack units of a certain category
61 	void BombUnitsOfCategory(UnitCategory category);
62 	// checks if target is possible bombing target and adds to list of bomb targets (used for buildings e.g. stationary arty, nuke launchers..)
63 	void CheckBombTarget(int unit_id, int def_id);
64 	// adds new target to bombing targets (if free space in list)
65 	void AddTarget(int unit_id, int def_id);
66 
67 	list<AAIGroup*> *air_groups;
68 	AAI *ai;
69 	int my_team;
70 	int num_of_targets;
71 };
72 
73 #endif
74