1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef BUILD_INFO_H
4 #define BUILD_INFO_H
5 
6 #include <string>
7 
8 #include "System/float3.h"
9 #include "Sim/Units/CommandAI/Command.h"
10 
11 struct UnitDef;
12 
13 /**
14  * Info about a build, which consists of additional properties
15  * of a unit that only exist during construction.
16  */
17 struct BuildInfo
18 {
19 	BuildInfo();
20 	BuildInfo(const UnitDef* def, const float3& pos, int buildFacing);
21 	BuildInfo(const std::string& name, const float3& pos, int facing);
BuildInfoBuildInfo22 	BuildInfo(const Command& c) { Parse(c); }
23 
24 	int GetXSize() const;
25 	int GetZSize() const;
26 	bool Parse(const Command& c);
27 
28 	int CreateCommandID() const;
29 	void AddCommandParams(Command& cmd) const;
30 	inline Command CreateCommand(unsigned char options = 0) const
31 	{
32 		// this is inlined to prevent copying of cmd on return
33 		Command cmd(CreateCommandID(), options);
34 		AddCommandParams(cmd);
35 		return cmd;
36 	}
37 
38 	const UnitDef* def;
39 	float3 pos;
40 	int buildFacing;
41 };
42 
43 #endif /* BUILD_INFO_H */
44