Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Cell.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#ifndef SKYFIRE_CELL_H
7
#define SKYFIRE_CELL_H
8
9
#include <cmath>
10
11
#include "
TypeContainer.h
"
12
#include "
TypeContainerVisitor.h
"
13
14
#include "
GridDefines.h
"
15
16
class
Map
;
17
class
WorldObject
;
18
19
struct
CellArea
20
{
21
CellArea
() { }
22
CellArea
(
CellCoord
low,
CellCoord
high) :
low_bound
(low),
high_bound
(high) { }
23
24
bool
operator!
()
const
{
return
low_bound
==
high_bound
; }
25
26
void
ResizeBorders
(
CellCoord
& begin_cell,
CellCoord
& end_cell)
const
27
{
28
begin_cell =
low_bound
;
29
end_cell =
high_bound
;
30
}
31
32
CellCoord
low_bound
;
33
CellCoord
high_bound
;
34
};
35
36
struct
Cell
37
{
38
Cell
() {
data
.All = 0; }
39
Cell
(
Cell
const
& cell) {
data
.All = cell.
data
.
All
; }
40
explicit
Cell
(
CellCoord
const
& p);
41
explicit
Cell
(
float
x,
float
y);
42
43
void
Compute
(
uint32
& x,
uint32
& y)
const
44
{
45
x =
data
.Part.grid_x *
MAX_NUMBER_OF_CELLS
+
data
.Part.cell_x;
46
y =
data
.Part.grid_y *
MAX_NUMBER_OF_CELLS
+
data
.Part.cell_y;
47
}
48
49
bool
DiffCell
(
const
Cell
& cell)
const
50
{
51
return
(
data
.Part.cell_x != cell.
data
.
Part
.
cell_x
||
52
data
.Part.cell_y != cell.
data
.
Part
.
cell_y
);
53
}
54
55
bool
DiffGrid
(
const
Cell
& cell)
const
56
{
57
return
(
data
.Part.grid_x != cell.
data
.
Part
.
grid_x
||
58
data
.Part.grid_y != cell.
data
.
Part
.
grid_y
);
59
}
60
61
uint32
CellX
()
const
{
return
data
.Part.cell_x; }
62
uint32
CellY
()
const
{
return
data
.Part.cell_y; }
63
uint32
GridX
()
const
{
return
data
.Part.grid_x; }
64
uint32
GridY
()
const
{
return
data
.Part.grid_y; }
65
bool
NoCreate
()
const
{
return
data
.Part.nocreate; }
66
void
SetNoCreate
() {
data
.Part.nocreate = 1; }
67
68
CellCoord
GetCellCoord
()
const
69
{
70
return
CellCoord
(
71
data
.Part.grid_x *
MAX_NUMBER_OF_CELLS
+
data
.Part.cell_x,
72
data
.Part.grid_y *
MAX_NUMBER_OF_CELLS
+
data
.Part.cell_y);
73
}
74
75
Cell
&
operator=
(
Cell
const
& cell)
76
{
77
this->
data
.All = cell.
data
.
All
;
78
return
*
this
;
79
}
80
81
bool
operator ==
(
Cell
const
& cell)
const
{
return
(
data
.All == cell.
data
.
All
); }
82
bool
operator !=
(
Cell
const
& cell)
const
{
return
!
operator ==
(cell); }
83
union
84
{
85
struct
86
{
87
unsigned
grid_x
: 6;
88
unsigned
grid_y
: 6;
89
unsigned
cell_x
: 6;
90
unsigned
cell_y
: 6;
91
unsigned
nocreate
: 1;
92
unsigned
reserved
: 7;
93
}
Part
;
94
uint32
All
;
95
}
data
;
96
97
template
<
class
T,
class
CONTAINER>
void
Visit
(
CellCoord
const
&,
TypeContainerVisitor<T, CONTAINER>
& visitor,
Map
&,
WorldObject
const
&,
float
)
const
;
98
template
<
class
T,
class
CONTAINER>
void
Visit
(
CellCoord
const
&,
TypeContainerVisitor<T, CONTAINER>
& visitor,
Map
&,
float
,
float
,
float
)
const
;
99
100
static
CellArea
CalculateCellArea
(
float
x,
float
y,
float
radius);
101
102
private
:
103
template
<
class
T,
class
CONTAINER>
void
VisitCircle
(
TypeContainerVisitor<T, CONTAINER>
&,
Map
&,
CellCoord
const
&,
CellCoord
const
&)
const
;
104
};
105
106
#endif
uint32
std::uint32_t uint32
Definition
Define.h:77
GridDefines.h
MAX_NUMBER_OF_CELLS
#define MAX_NUMBER_OF_CELLS
Definition
GridDefines.h:22
CellCoord
CoordPair< TOTAL_NUMBER_OF_CELLS_PER_MAP > CellCoord
Definition
GridDefines.h:158
TypeContainer.h
TypeContainerVisitor.h
Map
Definition
Map.h:238
TypeContainerVisitor
Definition
TypeContainerVisitor.h:80
WorldObject
Definition
Object.h:610
CellArea
Definition
Cell.h:20
CellArea::high_bound
CellCoord high_bound
Definition
Cell.h:33
CellArea::low_bound
CellCoord low_bound
Definition
Cell.h:32
CellArea::operator!
bool operator!() const
Definition
Cell.h:24
CellArea::CellArea
CellArea(CellCoord low, CellCoord high)
Definition
Cell.h:22
CellArea::CellArea
CellArea()
Definition
Cell.h:21
CellArea::ResizeBorders
void ResizeBorders(CellCoord &begin_cell, CellCoord &end_cell) const
Definition
Cell.h:26
Cell::Cell
Cell(Cell const &cell)
Definition
Cell.h:39
Cell::GetCellCoord
CellCoord GetCellCoord() const
Definition
Cell.h:68
Cell::GridX
uint32 GridX() const
Definition
Cell.h:63
Cell::nocreate
unsigned nocreate
Definition
Cell.h:91
Cell::SetNoCreate
void SetNoCreate()
Definition
Cell.h:66
Cell::Cell
Cell()
Definition
Cell.h:38
Cell::grid_y
unsigned grid_y
Definition
Cell.h:88
Cell::reserved
unsigned reserved
Definition
Cell.h:92
Cell::Part
struct Cell::@253100141177133252213152253303204033205331220256::@054333305236276154171230343071320200077322155341 Part
Cell::NoCreate
bool NoCreate() const
Definition
Cell.h:65
Cell::Compute
void Compute(uint32 &x, uint32 &y) const
Definition
Cell.h:43
Cell::operator=
Cell & operator=(Cell const &cell)
Definition
Cell.h:75
Cell::GridY
uint32 GridY() const
Definition
Cell.h:64
Cell::Visit
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition
CellImpl.h:109
Cell::cell_y
unsigned cell_y
Definition
Cell.h:90
Cell::operator==
bool operator==(Cell const &cell) const
Definition
Cell.h:81
Cell::cell_x
unsigned cell_x
Definition
Cell.h:89
Cell::VisitCircle
void VisitCircle(TypeContainerVisitor< T, CONTAINER > &, Map &, CellCoord const &, CellCoord const &) const
Definition
CellImpl.h:117
Cell::operator!=
bool operator!=(Cell const &cell) const
Definition
Cell.h:82
Cell::DiffGrid
bool DiffGrid(const Cell &cell) const
Definition
Cell.h:55
Cell::grid_x
unsigned grid_x
Definition
Cell.h:87
Cell::CellX
uint32 CellX() const
Definition
Cell.h:61
Cell::CellY
uint32 CellY() const
Definition
Cell.h:62
Cell::DiffCell
bool DiffCell(const Cell &cell) const
Definition
Cell.h:49
Cell::data
union Cell::@253100141177133252213152253303204033205331220256 data
Cell::CalculateCellArea
static CellArea CalculateCellArea(float x, float y, float radius)
Definition
CellImpl.h:36
Cell::All
uint32 All
Definition
Cell.h:94
src
server
game
Grids
Cells
Cell.h
Generated on
for Project SkyFire Core by
1.17.0