YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PhysicsBoundingBoxCollection.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Game/World/Map/Physics/PhysicsBoundingBoxCollection.hpp
"
2
#include "
YAPOG/Game/World/Map/Physics/MapCollidableInfo.hpp
"
3
#include "
YAPOG/Game/World/Map/Physics/CollidableArea.hpp
"
4
#include "
YAPOG/Game/World/Map/Physics/BoundingBox.hpp
"
5
#include "
YAPOG/Game/World/Map/WorldObject.hpp
"
6
7
namespace
yap
8
{
9
PhysicsBoundingBoxCollection::PhysicsBoundingBoxCollection
()
10
:
BoundingBoxCollection
()
11
, parent_ (nullptr)
12
{
13
}
14
15
PhysicsBoundingBoxCollection::~PhysicsBoundingBoxCollection
()
16
{
17
}
18
19
PhysicsBoundingBoxCollection::PhysicsBoundingBoxCollection
(
20
const
PhysicsBoundingBoxCollection
& copy)
21
:
BoundingBoxCollection
(copy)
22
, parent_ (nullptr)
23
{
24
for
(
BoundingBox
* boundingBox : copy.
GetBoundingBoxes
())
25
AddPhysicsBoundingBox
(
new
BoundingBox
(*boundingBox));
26
}
27
28
void
PhysicsBoundingBoxCollection::AddPhysicsBoundingBox
(
29
BoundingBox
* boundingBox)
30
{
31
AddBoundingBox
(boundingBox);
32
}
33
34
void
PhysicsBoundingBoxCollection::RemovePhysicsBoundingBox
(
35
BoundingBox
* boundingBox)
36
{
37
RemoveBoundingBox
(boundingBox);
38
}
39
40
void
PhysicsBoundingBoxCollection::SetCollidableArea
(
41
const
WorldObject
& parent,
42
CollidableArea
* collidableArea)
43
{
44
parent_
= &parent;
45
46
BoundingBoxCollection::SetCollidableArea
(collidableArea);
47
}
48
49
bool
PhysicsBoundingBoxCollection::CollidesWithArea
(
50
const
CollidableArea
& collidableArea,
51
const
Vector2
& offset)
const
52
{
53
for
(
BoundingBox
* boundingBox :
GetBoundingBoxes
())
54
if
(collidableArea.
CollidesWith
(*boundingBox, offset, *
parent_
))
55
return
true
;
56
57
return
false
;
58
}
59
60
void
PhysicsBoundingBoxCollection::HandleAddBoundingBoxToCollidableArea
(
61
BoundingBox
* boundingBox)
62
{
63
GetCollidableArea
().
AddPhysicsCollidable
(
64
boundingBox,
65
MapCollidableInfo::PtrType
(
66
new
MapCollidableInfo
(
67
*boundingBox,
68
*
parent_
)));
69
}
70
71
void
72
PhysicsBoundingBoxCollection::HandleRemoveBoundingBoxFromCollidableArea
(
73
BoundingBox
* boundingBox)
74
{
75
GetCollidableArea
().
RemovePhysicsCollidable
(boundingBox);
76
}
77
}
// namespace yap
YAPOG
src
YAPOG
Game
World
Map
Physics
PhysicsBoundingBoxCollection.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1