YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
CollidableAreaCell.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Game/World/Map/Physics/CollidableAreaCell.hpp
"
2
#include "
YAPOG/Game/World/Map/WorldObject.hpp
"
3
#include "
YAPOG/Game/World/Map/DynamicWorldObject.hpp
"
4
#include "
YAPOG/Game/World/Map/MapEventQueue.hpp
"
5
#include "
YAPOG/Game/World/Map/MapEventContext.hpp
"
6
7
namespace
yap
8
{
9
CollidableAreaCell::CollidableAreaCell
()
10
: physicsCollidables_ ()
11
, eventCollidables_ ()
12
{
13
}
14
15
void
CollidableAreaCell::AddPhysicsCollidable
(
16
ICollidable
* collidable,
17
const
MapCollidableInfo::PtrType
& mapCollidableInfo)
18
{
19
physicsCollidables_
.
Add
(collidable, mapCollidableInfo);
20
}
21
22
void
CollidableAreaCell::RemovePhysicsCollidable
(
ICollidable
* collidable)
23
{
24
physicsCollidables_
.
Remove
(collidable);
25
}
26
27
void
CollidableAreaCell::AddEventCollidable
(
28
ICollidable
* collidable,
29
const
MapEventInfo::PtrType
& mapEventInfo)
30
{
31
eventCollidables_
.
Add
(collidable, mapEventInfo);
32
}
33
34
void
CollidableAreaCell::RemoveEventCollidable
(
ICollidable
* collidable)
35
{
36
eventCollidables_
.
Remove
(collidable);
37
}
38
39
bool
CollidableAreaCell::CollidesWith
(
40
const
ICollidable
& collidable,
41
const
Vector2
& offset,
42
const
WorldObject
& parent)
const
43
{
44
for
(
auto
& it :
physicsCollidables_
)
45
{
46
if
(&it.second->GetParent () == &parent)
47
continue
;
48
49
if
(collidable.
CollidesWith
(*it.first, offset))
50
return
true
;
51
}
52
53
return
false
;
54
}
55
56
void
CollidableAreaCell::GetEventsCollidingWith
(
57
const
ICollidable
& collidable,
58
MapEventQueue
& events,
59
DynamicWorldObject
& parent)
const
60
{
61
for
(
auto
& it :
eventCollidables_
)
62
{
63
if
(&it.second->GetParent () == &parent)
64
continue
;
65
66
if
(collidable.
CollidesWith
(*it.first))
67
events.
AddEvent
(
new
MapEventContext
(parent, collidable, *it.second));
68
}
69
}
70
71
void
CollidableAreaCell::Clear
()
72
{
73
physicsCollidables_
.
Clear
();
74
eventCollidables_
.
Clear
();
75
}
76
}
// namespace yap
YAPOG
src
YAPOG
Game
World
Map
Physics
CollidableAreaCell.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1