File: AAIBuildTask.h

package info (click to toggle)
spring 106.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 55,260 kB
  • sloc: cpp: 543,946; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (59 lines) | stat: -rw-r--r-- 1,932 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
// -------------------------------------------------------------------------
// AAI
//
// A skirmish AI for the Spring engine.
// Copyright Alexander Seizinger
//
// Released under GPL license: see LICENSE.html for more information.
// -------------------------------------------------------------------------

#ifndef AAI_BUILDTASK_H
#define AAI_BUILDTASK_H

#include "System/float3.h"
#include "aidef.h"
#include "AAIMap.h"
#include "AAIUnitTable.h"

class AAI;

class AAIBuildTask
{
	friend AAIConstructor;

public:
	AAIBuildTask(UnitId unitId, UnitDefId unitDefId, const float3& buildsite, UnitId constructor);

	~AAIBuildTask(void);

	//! @brief Indicates that the responsible construction unit has been killed
	void BuilderDestroyed(AAIMap* map, AAIUnitTable* unitTable);

	//! @brief Checks if task belongs to killed unit (and has thus failed); if yes, cleans up the buildmap and notifies the construction unit
	bool CheckIfConstructionFailed(AAI* ai, UnitId unitId);

	//! @brief Checks if task belongs to finished unit; if yes, notifies the construction unit
	bool CheckIfConstructionFinished(AAIUnitTable* unitTable, UnitId unitId);

	//! @brief Returns true if buildtask belongs to expensive (> 0.7+avg cost) unit/building of given category
	bool IsExpensiveUnitOfCategoryInSector(AAI* ai, const AAIUnitCategory& category, const AAISector* sector) const;

	//! @brief Returns the corresponding constructor (or nullptr if none)
	AAIConstructor* GetConstructor(AAIUnitTable* unitTable) const { return m_constructor.IsValid() ? unitTable->units[m_constructor.id].cons : nullptr; }

private:
	//! The unit id of the unit/building that is being constructed
	UnitId m_unitId;

	//! The unit definition of the unit/building that is being constructed
	UnitDefId m_defId;

	//! The id of the construction unit
	UnitId m_constructor;

	//! The location where the building/unit is being constructed
	float3 m_buildsite;
};

#endif