FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
AAI/AAIBuildTask.cpp at master · spring/AAI · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
spring
/
AAI
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
3
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
AAI
/
AAIBuildTask.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
101 lines (80 loc) · 2.4 KB
Breadcrumbs
AAI
/
AAIBuildTask.cpp
Copy path
File metadata and controls
101 lines (80 loc) · 2.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
-------------------------------------------------------------------------
//
AAI
//
//
A skirmish AI for the Spring engine.
//
Copyright Alexander Seizinger
//
//
Released under GPL license: see LICENSE.html for more information.
//
-------------------------------------------------------------------------
#
include
<
set
>
using
namespace
std
;
#
include
"
AAIBuildTask.h
"
#
include
"
AAI.h
"
#
include
"
AAIConstructor.h
"
#
include
"
AAIBuildTable.h
"
#
include
"
AAIExecute.h
"
#
include
"
AAISector.h
"
AAIBuildTask::AAIBuildTask
(UnitId unitId, UnitDefId unitDefId,
const
float3& buildsite, UnitId constructor) :
m_unitId(unitId),
m_defId(unitDefId),
m_buildsite(buildsite),
m_constructor(constructor)
{
}
AAIBuildTask::~AAIBuildTask
(
void
)
{
}
void
AAIBuildTask::BuilderDestroyed
(AAIMap* map, AAIUnitTable* unitTable)
{
m_constructor.
Invalidate
();
//
com only allowed if buildpos is inside the base
bool
commander =
false
;
AAISector* sector = map->
GetSectorOfPos
(m_buildsite);
if
(sector && (sector->
GetDistanceToBase
() ==
0
) )
commander =
true
;
//
look for new builder
AAIConstructor* nextBuilder = unitTable->
FindClosestAssistant
(m_buildsite,
10
, commander);
if
(nextBuilder)
{
nextBuilder->
TakeOverConstruction
(
this
);
m_constructor = nextBuilder->
m_myUnitId
;
}
}
bool
AAIBuildTask::CheckIfConstructionFailed
(
AAI
* ai, UnitId unitId)
{
if
(m_unitId == unitId)
{
//
cleanup buildmap etc.
if
(ai->
s_buildTree
.
GetMovementType
(m_defId).
IsStatic
())
ai->
Execute
()->
ConstructionFailed
(m_buildsite, m_defId);
AAIConstructor* constructor =
GetConstructor
(ai->
UnitTable
());
if
(constructor)
constructor->
ConstructionFinished
();
return
true
;
}
else
return
false
;
}
bool
AAIBuildTask::CheckIfConstructionFinished
(AAIUnitTable* unitTable, UnitId unitId)
{
if
(m_unitId == unitId)
{
AAIConstructor* constructor =
GetConstructor
(unitTable);
if
(constructor)
constructor->
ConstructionFinished
();
return
true
;
}
else
return
false
;
}
bool
AAIBuildTask::IsExpensiveUnitOfCategoryInSector
(
AAI
* ai,
const
AAIUnitCategory& category,
const
AAISector* sector)
const
{
if
( (ai->
s_buildTree
.
GetUnitCategory
(m_defId) == category)
&& sector->
PosInSector
(m_buildsite) )
{
const
StatisticalData& costStatistics = ai->
s_buildTree
.
GetUnitStatistics
(ai->
GetSide
()).
GetUnitCostStatistics
(category);
if
( ai->
s_buildTree
.
GetTotalCost
(m_defId) >
0
.
7f
* costStatistics.
GetAvgValue
() )
return
true
;
}
return
false
;
}
Back
|
FazBrowse Home
|
New Git URL