File: CThreatMap.h

package info (click to toggle)
spring 103.0%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 43,720 kB
  • ctags: 63,685
  • sloc: cpp: 368,283; ansic: 33,988; python: 12,417; java: 12,203; awk: 5,879; sh: 1,846; xml: 655; perl: 405; php: 211; objc: 194; makefile: 77; sed: 2
file content (59 lines) | stat: -rw-r--r-- 1,352 bytes parent folder | download | duplicates (4)
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
#ifndef THREATMAP_H
#define THREATMAP_H

#include "headers/Defines.h"
#include "headers/HEngine.h"

class AIClasses;
class CGroup;

// TODO: convert into flags?
enum ThreatMapType {
	TMT_NONE = 0,
	TMT_AIR,
	TMT_SURFACE,
	TMT_UNDERWATER,
	TMT_LAST
};

class CThreatMap {

public:
	CThreatMap(AIClasses* ai);
	~CThreatMap();

	void update(int frame);
	float getThreat(float3 center, float radius, ThreatMapType type = TMT_SURFACE);
	float getThreat(const float3& center, float radius, CGroup* group);
	const float* getMap(ThreatMapType);
	bool switchDebugMode();
	bool isInBounds(int x, int z) { return (x >= 0 && z >= 0 && x < X && z < Z); }
	void checkInBounds(int& x, int& z);

protected:
    AIClasses* ai;

private:
	int X, Z;
		// width & height of threat map (in pathgraph resolution)
	int lastUpdateFrame;
		// not very helpful for now; will be really used when threatmap
		// is shared between allied AIs
	ThreatMapType drawMap;
		// current threat map to visualize
	std::map<ThreatMapType, float> maxPower;
		// max threat per map
	std::map<ThreatMapType, float*> maps;
		// threatmap data
#if !defined(BUILDING_AI_FOR_SPRING_0_81_2)
	std::map<ThreatMapType, int> handles;
		// for visual debugging purposes
#endif
	float gauss(float x, float sigma, float mu);

	void reset();

	void visualizeMap(ThreatMapType type = TMT_SURFACE);
};

#endif