Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
Grid.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_GRID_H
7
#define SKYFIRE_GRID_H
8
9
/*
10
@class Grid
11
Grid is a logical segment of the game world represented inside SkyFire.
12
Grid is bind at compile time to a particular type of object which
13
we call it the object of interested. There are many types of loader,
14
specially, dynamic loader, static loader, or on-demand loader. There's
15
a subtle difference between dynamic loader and on-demand loader but
16
this is implementation specific to the loader class. From the
17
Grid's perspective, the loader meets its API requirement is suffice.
18
*/
19
20
#include "
Define.h
"
21
#include "
TypeContainer.h
"
22
#include "
TypeContainerVisitor.h
"
23
24
// forward declaration
25
template
<
class
A,
class
T,
class
O>
class
GridLoader
;
26
27
template
28
<
29
class
ACTIVE_OBJECT,
30
class
WORLD_OBJECT_TYPES,
31
class
GRID_OBJECT_TYPES
32
>
33
class
Grid
34
{
35
// allows the GridLoader to access its internals
36
template
<
class
A,
class
T,
class
O>
friend
class
GridLoader
;
37
public
:
41
~Grid
() { }
42
45
template
<
class
SPECIFIC_OBJECT>
void
AddWorldObject
(SPECIFIC_OBJECT* obj)
46
{
47
i_objects
.template insert<SPECIFIC_OBJECT>(obj);
48
ASSERT
(obj->IsInGrid());
49
}
50
53
//Actually an unlink is enough, no need to go through the container
54
//template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj)
55
//{
56
// ASSERT(obj->GetGridRef().isValid());
57
// i_objects.template remove<SPECIFIC_OBJECT>(obj);
58
// ASSERT(!obj->GetGridRef().isValid());
59
//}
60
63
//void RefreshGrid(void) { /* TBI */}
64
67
//void LockGrid(void) { /* TBI */ }
68
71
//void UnlockGrid(void) { /* TBI */ }
72
73
// Visit grid objects
74
template
<
class
T>
75
void
Visit
(
TypeContainerVisitor
<T,
TypeMapContainer<GRID_OBJECT_TYPES>
>& visitor)
76
{
77
visitor.Visit(
i_container
);
78
}
79
80
// Visit world objects
81
template
<
class
T>
82
void
Visit
(
TypeContainerVisitor
<T,
TypeMapContainer<WORLD_OBJECT_TYPES>
>& visitor)
83
{
84
visitor.Visit(
i_objects
);
85
}
86
89
//unsigned int ActiveObjectsInGrid(void) const { return i_objects.template Count<ACTIVE_OBJECT>(); }
90
template
<
class
T>
91
uint32
GetWorldObjectCountInGrid
()
const
92
{
93
return
i_objects
.template Count<T>();
94
}
95
98
template
<
class
SPECIFIC_OBJECT>
void
AddGridObject
(SPECIFIC_OBJECT* obj)
99
{
100
i_container
.template insert<SPECIFIC_OBJECT>(obj);
101
ASSERT
(obj->IsInGrid());
102
}
103
106
//template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj)
107
//{
108
// ASSERT(obj->GetGridRef().isValid());
109
// i_container.template remove<SPECIFIC_OBJECT>(obj);
110
// ASSERT(!obj->GetGridRef().isValid());
111
//}
112
113
/*bool NoWorldObjectInGrid() const
114
{
115
return i_objects.GetElements().isEmpty();
116
}
117
118
bool NoGridObjectInGrid() const
119
{
120
return i_container.GetElements().isEmpty();
121
}*/
122
123
private
:
124
TypeMapContainer<GRID_OBJECT_TYPES>
i_container
;
125
TypeMapContainer<WORLD_OBJECT_TYPES>
i_objects
;
126
//typedef std::set<void*> ActiveGridObjects;
127
//ActiveGridObjects m_activeGridObjects;
128
};
129
#endif
Define.h
uint32
std::uint32_t uint32
Definition
Define.h:77
ASSERT
#define ASSERT
Definition
Errors.h:29
TypeContainer.h
TypeContainerVisitor.h
Grid
Definition
Grid.h:34
Grid< Player, AllWorldObjectTypes, AllGridObjectTypes >::GridLoader
friend class GridLoader
Definition
Grid.h:36
Grid< Player, AllWorldObjectTypes, AllGridObjectTypes >::i_objects
TypeMapContainer< AllWorldObjectTypes > i_objects
Definition
Grid.h:125
Grid< Player, AllWorldObjectTypes, AllGridObjectTypes >::i_container
TypeMapContainer< AllGridObjectTypes > i_container
Definition
Grid.h:124
Grid::GetWorldObjectCountInGrid
uint32 GetWorldObjectCountInGrid() const
Definition
Grid.h:91
Grid::Visit
void Visit(TypeContainerVisitor< T, TypeMapContainer< GRID_OBJECT_TYPES > > &visitor)
Definition
Grid.h:75
Grid::AddWorldObject
void AddWorldObject(SPECIFIC_OBJECT *obj)
Definition
Grid.h:45
Grid::AddGridObject
void AddGridObject(SPECIFIC_OBJECT *obj)
Definition
Grid.h:98
Grid::~Grid
~Grid()
Definition
Grid.h:41
Grid::Visit
void Visit(TypeContainerVisitor< T, TypeMapContainer< WORLD_OBJECT_TYPES > > &visitor)
Definition
Grid.h:82
GridLoader
Definition
Grid.h:25
TypeContainerVisitor
Definition
TypeContainerVisitor.h:80
TypeMapContainer
Definition
TypeContainer.h:86
src
server
game
Grids
Grid.h
Generated on
for Project SkyFire Core by
1.17.0