-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.hpp
executable file
·76 lines (63 loc) · 1.86 KB
/
command.hpp
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
#ifndef COMMAND_HPP
#define COMMAND_HPP
#include "types.hpp"
#include "util.hpp"
#include <vector>
#include <deque>
class Packet;
class Command
{
public:
typedef enum CommandFormat {
targetsUnit,
targetsTile,
targetsUnitType,
targetsQueue,
targetsRally,
} CommandFormat;
typedef enum CommandType {
none = 0,
// Commands for units with no targetting
stop,
unload,
retreat,
// Commands for units targetting ground
move,
attackMove,
// Commands for units targetting units
attack,
follow,
unloadSingle,
// Commands for scrapyards
buildUnit,
cancelBuild,
setRally,
// Unimplemented commands
patrol,
holdPosition,
} CommandType;
Command() {}
Command(CommandType type, const std::vector<unitID> &units, int x, int y);
Command(CommandType type, const std::vector<unitID> &units, unitID unit);
Command(CommandType type, int scrapyardId, std::string unitType);
Command(CommandType type, int scrapyardId, int index);
Command(CommandType type, int scrapyardId, int x, int y);
void writeToPacket(Packet *packet) const;
void readFromPacket(Packet *packet);
CommandFormat format; // What this command targets
CommandType type; // The type of command this is
std::vector<unitID> units; // Which units the command was given to
unitID targetUnit() const { return x; }
ICoord targetTile() const { return ICoord(x,y); }
int targetScrapyard() const { return scrapyard; }
std::string targetUnitType() const { return unitType; }
int targetIndex() const { return x; }
protected:
// The command's target. For commands which target neither a unit nor a
// tile, x=y=0. For commands which target a unit, x=target unitID, y=0.
int x, y, scrapyard;
// For build commands
std::string unitType;
};
typedef std::deque<Command> CommandQueue;
#endif