ColliderSet2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ColliderSet2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Collection of 2-D colliders.
6 > Created Time: 2017/05/09
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_COLLIDER_SET2_H
10 #define CUBBYFLOW_COLLIDER_SET2_H
11 
13 
14 #include <vector>
15 
16 namespace CubbyFlow
17 {
19  class ColliderSet2 final : public Collider2
20  {
21  public:
22  class Builder;
23 
25  ColliderSet2();
26 
28  explicit ColliderSet2(const std::vector<Collider2Ptr>& others);
29 
31  Vector2D VelocityAt(const Vector2D& point) const override;
32 
34  void AddCollider(const Collider2Ptr& collider);
35 
37  size_t NumberOfColliders() const;
38 
40  Collider2Ptr Collider(size_t i) const;
41 
43  static Builder GetBuilder();
44 
45  private:
46  std::vector<Collider2Ptr> m_colliders;
47  };
48 
50  typedef std::shared_ptr<ColliderSet2> ColliderSet2Ptr;
51 
56  {
57  public:
59  Builder& WithColliders(const std::vector<Collider2Ptr>& others);
60 
62  ColliderSet2 Build() const;
63 
66 
67  private:
68  std::vector<Collider2Ptr> m_colliders;
69  };
70 }
71 
72 #endif
Front-end to create ColliderSet2 objects step by step.
Definition: ColliderSet2.h:55
static Builder GetBuilder()
Returns builder fox ColliderSet2.
size_t NumberOfColliders() const
Returns number of colliders.
std::shared_ptr< Collider2 > Collider2Ptr
Shared pointer type for the Collider2.
Definition: Collider2.h:112
Vector2D VelocityAt(const Vector2D &point) const override
Returns the velocity of the collider at given point.
ColliderSet2()
Default constructor.
Definition: pybind11Utils.h:24
Builder & WithColliders(const std::vector< Collider2Ptr > &others)
Returns builder with other colliders.
ColliderSet2 Build() const
Builds ColliderSet2.
void AddCollider(const Collider2Ptr &collider)
Adds a collider to the set.
2-D vector class.
Definition: Vector2.h:26
ColliderSet2Ptr MakeShared() const
Builds shared pointer of ColliderSet2 instance.
Abstract base class for generic collider object.
Definition: Collider2.h:27
Collection of 2-D colliders.
Definition: ColliderSet2.h:19
Collider2Ptr Collider(size_t i) const
Returns collider at index i.
std::shared_ptr< ColliderSet2 > ColliderSet2Ptr
Shared pointer for the ColliderSet2 type.
Definition: ColliderSet2.h:50