-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyUnitGroup.h
92 lines (72 loc) · 2.37 KB
/
MyUnitGroup.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
82
83
84
85
86
87
88
89
90
91
92
#pragma once
#define VALFHDR [=](Move& move, const World& world)
#include <functional>
#include "model/World.h"
#include "model/Move.h"
#include <queue>
#include <memory>
#include "MyGlobalInfoStorer.h"
using namespace std;
using namespace model;
enum class CondQueueCondition
{
AllUnitStopped,
NoCondition
};
class MyUnitGroup
{
public:
bool act(Move& move, const World& world);
void pushToConditionalQueue(CondQueueCondition cnd, function<void(Move&, const World&, MyUnitGroup&)> func, bool recursive = false);
void lockInterrupts();
void unlockInterrupts();
bool mayBeInterrupted();
void removeDestroyed();
void buildMoveMap();
bool smartMoveTo(dxypoint point, Move& move, const World& world);
void move(dxypoint vector, bool saveFormation, Move& move, const World& world);
void scale(dxypoint point, double factor, Move& move, const World& world);
void forcedSelect(Move& move);
void setTag(const string& tag);
void setGroupAngle(double angle);
void setVehicleType(VehicleType type);
double getDef() const;
pair<xypoint, xypoint> getGridedAabb() const;
xypoint getMovingVector() const;
VehicleType getVehicleType() const;
double getGroupAngle() const;
int getGroupActsCount() const;
int getGroupId() const;
const string& getTag() const;
const set<int>& getGroupIdList() const;
bool moving() const;
xypoint getCenterOfGroup() const;
xypoint getClosestEnemy() const;
double getGroupRadius() const;
static void dropSelection();
MyUnitGroup(Move& move, const World& world, const MyGlobalInfoStorer& globaler, double groupAngle);
private:
struct ConditionalQueueItem
{
CondQueueCondition mCond;
function<void(Move&, const World&, MyUnitGroup&)> mFunc;
bool mRecursive;
};
bool pointIsInBounds(xypoint point, int width, int height);
bool groupAtPointDoesntIntersect(xypoint point, int width, int height, xypoint ltcorner, xypoint rbcorner);
static int sCurrentlySelectedGroup, sGroupsCount;
double getMaxSpeedOnVector(dxypoint vector, const World& world);
int mGroupNumber;
bool mDoNotInterruptPlease;
deque<ConditionalQueueItem> mConditionalQueue;
deque<function<void(Move&, const World&, MyUnitGroup&)>> mCurrentExecutionQueue;
set<int> mIngroupIds;
const MyGlobalInfoStorer& mGlobaler;
string mTag;
VehicleType mVehicleType;
int mGroupActs;
double mGroupAngle;
xypoint mMovingVector;
vector<vector<xypoint>> mMoveParent;
double mGroupDefValue = 1;
};