Cytopia
0.3
A city building simulation game
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
Functions
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
z
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
a
c
d
e
g
i
m
n
p
r
s
t
u
v
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Functions
b
c
d
f
g
i
m
o
p
r
s
t
w
Variables
a
c
d
g
h
i
l
m
n
r
s
t
Typedefs
a
c
d
e
f
g
i
j
l
m
n
r
s
t
v
Enumerations
Enumerator
a
b
d
e
f
g
l
m
n
p
r
s
t
u
w
z
Macros
_
c
e
i
l
n
r
s
t
v
Examples
▼
Cytopia
Todo List
►
Namespaces
►
Classes
▼
Files
▼
File List
▼
src
►
engine
▼
game
►
ui
GamePlay.cxx
►
GamePlay.hxx
►
PowerGrid.cxx
►
PowerGrid.hxx
PowerManager.cxx
►
PowerManager.hxx
►
ZoneArea.cxx
►
ZoneArea.hxx
ZoneManager.cxx
►
ZoneManager.hxx
►
scripting
►
services
►
util
►
windows
Game.cxx
►
Game.hxx
►
main.cxx
►
MainMenu.cxx
►
MainMenu.hxx
phc.hxx
►
File Members
►
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
PowerGrid.cxx
Go to the documentation of this file.
1
#include "
PowerGrid.hxx
"
2
#include <
MapFunctions.hxx
>
3
#include "
LOG.hxx
"
4
5
PowerGrid::PowerGrid
(
PowerNode
powerNode) :
MapGrid
(powerNode) {}
6
7
void
mergePowerGrids
(
PowerGrid
&mainGrid,
PowerGrid
&toBeMerged)
8
{
9
mainGrid.
m_gridNodes
.insert(mainGrid.
end
(), toBeMerged.
begin
(), toBeMerged.
end
());
10
}
11
12
void
PowerGrid::updatePowerLevel
()
13
{
14
// reset the power level of this grid before recalculating
15
m_powerLevel
= 0;
16
for
(
const
auto
&node :
m_gridNodes
)
17
{
18
if
(
MapFunctions::instance
().getMapNode(node.coordinate).getTileData(
Layer::BUILDINGS
) && node.powerProduction == 0)
19
{
// each occupied node consumes one power unit
20
m_powerLevel
--;
21
}
22
23
// For multi-tile buildings, each tile has the same tiledata (including power level).
24
// so make sure we only add it once (if it's the origin node)
25
if
(
MapFunctions::instance
().getMapNode(node.coordinate).isOriginNode())
26
{
27
m_powerLevel
+= node.powerProduction;
28
}
29
}
30
}
PowerGrid::PowerGrid
PowerGrid(PowerNode powerNode)
Definition:
PowerGrid.cxx:5
MapGrid::begin
auto begin()
Definition:
MapGrid.hxx:46
PowerGrid
Definition:
PowerGrid.hxx:17
LOG.hxx
MapFunctions.hxx
MapGrid::end
auto end()
Definition:
MapGrid.hxx:47
PowerGrid::updatePowerLevel
void updatePowerLevel()
Recalculate the power level of this power grid.
Definition:
PowerGrid.cxx:12
PowerGrid.hxx
BUILDINGS
@ BUILDINGS
8- Buildings, Streets and everything that goes on the terrain
Definition:
enums.hxx:19
mergePowerGrids
void mergePowerGrids(PowerGrid &mainGrid, PowerGrid &toBeMerged)
Definition:
PowerGrid.cxx:7
PowerNode
Definition:
PowerGrid.hxx:8
MapGrid::m_gridNodes
std::vector< T > m_gridNodes
Definition:
MapGrid.hxx:50
Singleton< MapFunctions >::instance
static MapFunctions & instance(void)
Get an instance of the singleton.
Definition:
Singleton.hxx:15
PowerGrid::m_powerLevel
int m_powerLevel
Definition:
PowerGrid.hxx:38
MapGrid
Definition:
MapGrid.hxx:7
src
game
PowerGrid.cxx
Generated on Sun Nov 27 2022 09:50:52 for Cytopia by
1.8.17