-
Notifications
You must be signed in to change notification settings - Fork 0
/
CameraModule.h
81 lines (69 loc) · 2.38 KB
/
CameraModule.h
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
#pragma once
#include "sc2api/sc2_api.h"
class CameraModule
{
protected:
//Sometimes getObservation fails when starting a game.
bool m_initialized;
sc2::Client * m_client;
std::vector<int> m_playerIDs;
std::map<int, sc2::Point2D> m_startLocations;
int cameraMoveTime;
int cameraMoveTimeMin;
uint32_t watchScoutWorkerUntil;
int lastMoved;
int lastMovedPriority;
sc2::Point2D lastMovedPosition;
sc2::Point2D currentCameraPosition;
sc2::Point2D cameraFocusPosition;
const sc2::Unit * cameraFocusUnit;
bool followUnit;
void moveCamera(const sc2::Point2D pos, const int priority);
void moveCamera(const sc2::Unit * unit, int priority);
void moveCameraIsAttacking();
void moveCameraIsUnderAttack();
void moveCameraScoutWorker();
void moveCameraFallingNuke();
void moveCameraNukeDetect();
void moveCameraDrop();
void moveCameraArmy();
void updateCameraPosition();
bool shouldMoveCamera(const int priority) const;
bool isNearOpponentStartLocation(const sc2::Point2D pos, const int player) const;
bool isNearOwnStartLocation(const sc2::Point2D pos, int player) const;
bool isArmyUnitType(const sc2::UNIT_TYPEID type) const;
bool isBuilding(const sc2::UNIT_TYPEID type) const;
bool isValidPos(const sc2::Point2D pos) const;
bool isUnderAttack(const sc2::Unit * unit) const;
bool isAttacking(const sc2::Unit * unit) const;
bool IsWorkerType(const sc2::UNIT_TYPEID type) const;
float Dist(const sc2::Unit * A, const sc2::Unit * B) const;
float Dist(const sc2::Point2D A, const sc2::Point2D B) const;
void setPlayerStartLocations();
void setPlayerIds();
int getOpponent(const int player) const;
const sc2::Point2D getInvertedPos(const sc2::Point2D) const;
//Depending on whether we have an agent or an observer we need to use different functions to move the camera
virtual void updateCameraPositionExcecute() = 0;
public:
CameraModule(sc2::Client * const bot);
void onStart();
void onFrame();
void moveCameraUnitCreated(const sc2::Unit * unit);
~CameraModule();
};
class CameraModuleObserver : public CameraModule
{
private:
sc2::ReplayObserver * const m_observer;
void updateCameraPositionExcecute() override;
public:
CameraModuleObserver(sc2::ReplayObserver * const observer);
void onStart();
};
class CameraModuleAgent : public CameraModule
{
void updateCameraPositionExcecute() override;
public:
CameraModuleAgent(sc2::Agent * const observer);
};