summary refs log tree commit diff stats
path: root/src/components/ponderable.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-04-28 09:22:44 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-04-28 09:22:44 -0400
commit8016a7146fec3f6f43ca05723441750e5aae3d4d (patch)
tree0d527c1af80cf9ac34a027f9ee6f1acbb95db9f4 /src/components/ponderable.h
parentf782b81ba10c9b7a1e221b16de0aaa7b6c521729 (diff)
downloadtherapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.gz
therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.bz2
therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.zip
Restructured the way the world is loaded
The World class was removed and replaced by the RealizingSystem and RealizableComponent. The realizable entity is intended to be a singleton and to represent the world. The Map class was also removed and integrated into the MappableComponent.

These changes are to facilitate implementation of map objects without needing special intermediary objects (including the Map class). Now, map entities are created as soon as the world is created, and map object entities will be as well. They will simply be deactivated while the map is not active. Multiple players are now slightly better supported, which will be important in the future.

This will likely become inefficient as the world becomes bigger, and some sort of sector-loading process will have to be designed. This also reduces the usefulness of EntityManager's entity-searching capabilities (which are not the most efficiently implemented currently anyway), and will likely in the future require some added functionality to better search subsets of entities.

A lot of the components were also rewritten to use bare member variables instead of accessor methods, as they never had special functionality and just took up space. These components were also documented.
Diffstat (limited to 'src/components/ponderable.h')
-rw-r--r--src/components/ponderable.h151
1 files changed, 62 insertions, 89 deletions
diff --git a/src/components/ponderable.h b/src/components/ponderable.h index 78af25f..fd7e775 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h
@@ -6,100 +6,73 @@
6class PonderableComponent : public Component { 6class PonderableComponent : public Component {
7public: 7public:
8 8
9 /**
10 * List of different types of physical bodies.
11 *
12 * vacuumed - Default.
13 * freefalling - The body will be treated as if there were a downward force
14 * of gravity being exerted onto it. The body will also exhibit
15 * terminal velocity (that is, its downward velocity will be
16 * capped at a constant value).
17 */
9 enum class Type { 18 enum class Type {
10 vacuumed, 19 vacuumed,
11 freefalling 20 freefalling
12 }; 21 };
13 22
14 PonderableComponent(Type type) : type_(type) 23 /**
15 { 24 * Constructor for initializing the body type, which is a constant.
16 } 25 */
17 26 PonderableComponent(Type type) : type(type)
18 inline Type getType() const 27 {
19 { 28 }
20 return type_; 29
21 } 30 /**
22 31 * The velocity of the body.
23 inline double getVelocityX() const 32 */
24 { 33 double velX = 0.0;
25 return velX_; 34 double velY = 0.0;
26 } 35
27 36 /**
28 inline void setVelocityX(double v) 37 * The acceleration of the body.
29 { 38 */
30 velX_ = v; 39 double accelX = 0.0;
31 } 40 double accelY = 0.0;
32 41
33 inline double getVelocityY() const 42 /**
34 { 43 * The type of physical body that the entity is meant to assume. The body will
35 return velY_; 44 * be acted upon differently based on this. See the enumeration above for more
36 } 45 * details.
37 46 *
38 inline void setVelocityY(double v) 47 * @managed_by PonderingSystem
39 { 48 */
40 velY_ = v; 49 const Type type;
41 } 50
42 51 /**
43 inline double getAccelX() const 52 * Whether or not a freefalling body is in contact with the ground.
44 { 53 *
45 return accelX_; 54 * @managed_by PonderingSystem
46 } 55 */
47 56 bool grounded = false;
48 inline void setAccelX(double v) 57
49 { 58 /**
50 accelX_ = v; 59 * If enabled, this will prevent the body from moving.
51 } 60 */
52 61 bool frozen = false;
53 inline double getAccelY() const 62
54 { 63 /**
55 return accelY_; 64 * If disabled, collision detection for this body will not be performed and
56 } 65 * other bodies will ignore it.
57 66 */
58 inline void setAccelY(double v) 67 bool collidable = true;
59 { 68
60 accelY_ = v; 69 /**
61 } 70 * If this flag is disabled, the entity will be ignored by the pondering
62 71 * system.
63 inline bool isGrounded() const 72 *
64 { 73 * @managed_by RealizingSystem
65 return grounded_; 74 */
66 } 75 bool active = false;
67
68 inline void setGrounded(bool v)
69 {
70 grounded_ = v;
71 }
72
73 inline bool isFrozen() const
74 {
75 return frozen_;
76 }
77
78 inline void setFrozen(bool v)
79 {
80 frozen_ = v;
81 }
82
83 inline bool isCollidable() const
84 {
85 return collidable_;
86 }
87
88 inline void setCollidable(bool v)
89 {
90 collidable_ = v;
91 }
92
93private:
94
95 double velX_ = 0.0;
96 double velY_ = 0.0;
97 double accelX_ = 0.0;
98 double accelY_ = 0.0;
99 Type type_ = Type::vacuumed;
100 bool grounded_ = false;
101 bool frozen_ = false;
102 bool collidable_ = true;
103}; 76};
104 77
105#endif /* end of include guard: TANGIBLE_H_746DB3EE */ 78#endif /* end of include guard: TANGIBLE_H_746DB3EE */