File: AAIUnitTable.h

package info (click to toggle)
spring 104.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 47,512 kB
  • sloc: cpp: 391,093; ansic: 79,943; python: 12,356; java: 12,201; awk: 5,889; sh: 1,826; xml: 655; makefile: 486; perl: 405; php: 211; objc: 194; sed: 2
file content (122 lines) | stat: -rw-r--r-- 3,274 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// -------------------------------------------------------------------------
// AAI
//
// A skirmish AI for the Spring engine.
// Copyright Alexander Seizinger
//
// Released under GPL license: see LICENSE.html for more information.
// -------------------------------------------------------------------------

#ifndef AAI_UNITTABLE_H
#define AAI_UNITTABLE_H

#include <set>

using std::set;

#include "aidef.h"

class AAI;
class AAIBuildTable;
class AAIExecute;
class AAIConstructor;

class AAIUnitTable
{
public:
	AAIUnitTable(AAI *ai);
	~AAIUnitTable(void);

	bool AddUnit(int unit_id, int def_id, AAIGroup *group = 0, AAIConstructor *cons = 0);
	void RemoveUnit(int unit_id);

	void AddScout(int unit_id);
	void RemoveScout(int unit_id);

	void AddConstructor(int unit_id, int def_id);
	void RemoveConstructor(int unit_id, int def_id);

	void AddCommander(int unit_id, int def_id);
	void RemoveCommander(int unit_id, int def_id);

	void AddExtractor(int unit_id);
	void RemoveExtractor(int unit_id);

	void AddPowerPlant(int unit_id, int def_id);
	void RemovePowerPlant(int unit_id);

	void AddMetalMaker(int unit_id, int def_id);
	void RemoveMetalMaker(int unit_id);

	void AddJammer(int unit_id, int def_id);
	void RemoveJammer(int unit_id);

	void AddRecon(int unit_id, int def_id);
	void RemoveRecon(int unit_id);

	void AddStationaryArty(int unit_id, int def_id);
	void RemoveStationaryArty(int unit_id);

	AAIConstructor* FindBuilder(int building, bool commander);

	// finds closest builder and stores its distance to pos in min_dist
	AAIConstructor* FindClosestBuilder(int building, float3 *pos, bool commander, float *min_dist);

	AAIConstructor* FindClosestAssistant(float3 pos, int importance, bool commander);

	void EnemyKilled(int unit);

	void SetUnitStatus(int unit, UnitTask status);

	void AssignGroupToEnemy(int unit, AAIGroup *group);

	// determine whether unit with specified def/unit id is commander/constrcutor
	bool IsDefCommander(int def_id);
	bool IsBuilder(int unit_id);

	// called when unit of specified catgeory has been created (= construction started)
	void UnitCreated(UnitCategory category);

	// called when construction of unit has been finished
	void UnitFinished(UnitCategory category);

	// called when unit request failed (e.g. builder has been killed on the way to the crash site)
	void UnitRequestFailed(UnitCategory category);

	void UnitRequested(UnitCategory category, int number = 1);

	// get/set methods
	//int GetActiveScouts();
	//int GetActiveBuilders();
	//int GetActiveFactories();
	void ActiveUnitKilled(UnitCategory category);
	void FutureUnitKilled(UnitCategory category);

	// units[i].unitId = -1 -> not used , -2 -> enemy unit
	vector<AAIUnit> units;

	// id of commander
	int cmdr;
	set<int> constructors;
	set<int> metal_makers;
	set<int> jammers;
	set<int> recon;

	// number of active/under construction units of all different types
	int activeUnits[(int)MOBILE_CONSTRUCTOR+1];
	int futureUnits[(int)MOBILE_CONSTRUCTOR+1];
	int requestedUnits[(int)MOBILE_CONSTRUCTOR+1];
	int activeBuilders, futureBuilders;
	int activeFactories, futureFactories;
private:
	bool IsUnitCommander(int unit_id);
	set<int> scouts;
	set<int> extractors;
	set<int> power_plants;
	set<int> stationary_arty;
	AAI *ai;

};

#endif