File: Builder.h

package info (click to toggle)
spring 105.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,860 kB
  • sloc: cpp: 467,785; ansic: 302,607; python: 12,925; java: 12,201; awk: 5,889; sh: 2,371; xml: 655; perl: 405; php: 276; objc: 194; makefile: 75; sed: 2
file content (98 lines) | stat: -rw-r--r-- 2,787 bytes parent folder | download | duplicates (3)
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
93
94
95
96
97
98
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef _BUILDER_H
#define _BUILDER_H

#include <string>

#include "Sim/Misc/NanoPieceCache.h"
#include "Sim/Units/Unit.h"
#include "System/float3.h"

struct UnitDef;
struct BuildInfo;
struct Command;
class CFeature;
class CSolidObject;

class CBuilder : public CUnit
{
private:
	void PreInit(const UnitLoadParams& params) override;

public:
	inline float f3Dist(const float3& a, const float3& b) const { return (f3Len(a - b)); }
	inline float f3SqDist(const float3& a, const float3& b) const { return (f3SqLen(a - b)); }
	inline float f3Len(const float3& a) const { return (range3D ? a.Length() : a.Length2D()); }
	inline float f3SqLen(const float3& a) const { return (range3D ? a.SqLength() : a.SqLength2D()); }

public:
	CR_DECLARE_DERIVED(CBuilder)

	CBuilder();

	void Update() override;
	void SlowUpdate() override;
	void DependentDied(CObject* o) override;

	bool UpdateTerraform(const Command& fCommand);
	bool AssistTerraform(const Command& fCommand);
	bool UpdateBuild(const Command& fCommand);
	bool UpdateReclaim(const Command& fCommand);
	bool UpdateResurrect(const Command& fCommand);
	bool UpdateCapture(const Command& fCommand);

	bool StartBuild(BuildInfo& buildInfo, CFeature*& feature, bool& inWaitStance, bool& limitReached);
	float CalculateBuildTerraformCost(BuildInfo& buildInfo);
	void StopBuild(bool callScript = true);
	void SetRepairTarget(CUnit* target);
	void SetReclaimTarget(CSolidObject* object);
	void StartRestore(float3 centerPos, float radius);
	bool ScriptStartBuilding(float3 pos, bool silent);

	void HelpTerraform(CBuilder* unit);
	void CreateNanoParticle(const float3& goal, float radius, bool inverse, bool highPriority = false);
	void SetResurrectTarget(CFeature* feature);
	void SetCaptureTarget(CUnit* unit);

	bool CanAssistUnit(const CUnit* u, const UnitDef* def = nullptr) const;
	bool CanRepairUnit(const CUnit* u) const;

	const NanoPieceCache& GetNanoPieceCache() const { return nanoPieceCache; }
	      NanoPieceCache& GetNanoPieceCache()       { return nanoPieceCache; }

public:
	bool range3D; ///< spheres instead of infinite cylinders for range tests

	float buildDistance;
	float buildSpeed;
	float repairSpeed;
	float reclaimSpeed;
	float resurrectSpeed;
	float captureSpeed;
	float terraformSpeed;

	CFeature* curResurrect;
	int lastResurrected;
	CUnit* curBuild;
	CUnit* curCapture;
	CSolidObject* curReclaim;
	bool reclaimingUnit;
	CBuilder* helpTerraform;

	bool terraforming;
	float terraformHelp;
	float myTerraformLeft;
	enum TerraformType {
		Terraform_Building,
		Terraform_Restore
	} terraformType;
	int tx1,tx2,tz1,tz2;
	float3 terraformCenter;
	float terraformRadius;

private:
	NanoPieceCache nanoPieceCache;
};

#endif // _BUILDER_H