File: AAIConstructor.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (105 lines) | stat: -rw-r--r-- 2,458 bytes parent folder | download
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
99
100
101
102
103
104
105
// -------------------------------------------------------------------------
// AAI
//
// A skirmish AI for the TA Spring engine.
// Copyright Alexander Seizinger
//
// Released under GPL license: see LICENSE.html for more information.
// -------------------------------------------------------------------------

#pragma once

#include "aidef.h"

class AAI;
class AAIBuildTable;
class AAIBuildTask;

class AAIConstructor
{
public:
	AAIConstructor(AAI *ai, int unit_id, int def_id, bool factory, bool builder, bool assistant);
	~AAIConstructor(void);

	void Update();

	bool IsBusy();

	void Idle();

	// checks if assisting builders needed
	void CheckAssistance();

	// gets the total buildtime of all units in the buildque of the factory
	double GetMyQueBuildtime();

	// stops all assisters from assisting this unit
	void ReleaseAllAssistants();

	// stops this unit from assisting another builder/factory
	void StopAssisting();

	// removes an assisting con unit
	void RemoveAssitant(int unit_id);

	void ConstructionFinished();

	void ConstructionFailed();

	void GiveConstructionOrder(int id_building, float3 pos, bool water);

	void AssistConstruction(int constructor, int target_unit = -1);

	// continue with construction after original builder has been killed
	void TakeOverConstruction(AAIBuildTask *build_task);

	void GiveReclaimOrder(int unit_id);

	void Killed();

	// moves mobile constructors to safe sectors
	void Retreat(UnitCategory attacked_by);


	AAI *ai;
	AAIBuildTable *bt;
	IAICallback *cb;

	// specify type of construction units (several values may be true, e.g. builders that may build certain combat units as well)
	bool factory;		// can build units
	bool builder;		// can build buildings
	bool assistant;		// can assists construction (nanotowers, fark, etc.)
	bool resurrect;		// can resurrect

	// ids of the construction unit
	int unit_id;
	int def_id;
	int buildspeed;

	// ids of the currently constructed unit/building (-1 if none)
	int construction_def_id;
	int construction_unit_id;
	UnitCategory construction_category;

	// current task (idle, building, assisting)
	UnitTask task;

	// zero vector if none
	float3 build_pos;

	// id of the unit, the builder currently assists (-1 if none)
	int assistance;

	// assistant builders
	set<int> assistants;

	// engine tick the build order had been given
	int order_tick;

	// buildque
	list<int> *buildque;

	// pointer to possible buildtask
	AAIBuildTask *build_task;

};