YAPOG  0.0.1
Yet Another Pokemon Online Game
CollidableAreaCell.cpp
Go to the documentation of this file.
6 
7 namespace yap
8 {
10  : physicsCollidables_ ()
11  , eventCollidables_ ()
12  {
13  }
14 
16  ICollidable* collidable,
17  const MapCollidableInfo::PtrType& mapCollidableInfo)
18  {
19  physicsCollidables_.Add (collidable, mapCollidableInfo);
20  }
21 
23  {
24  physicsCollidables_.Remove (collidable);
25  }
26 
28  ICollidable* collidable,
29  const MapEventInfo::PtrType& mapEventInfo)
30  {
31  eventCollidables_.Add (collidable, mapEventInfo);
32  }
33 
35  {
36  eventCollidables_.Remove (collidable);
37  }
38 
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 
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 
72  {
75  }
76 } // namespace yap