summary refs log tree commit diff stats
path: root/src/components/playable.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/playable.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/playable.h')
-rw-r--r--src/components/playable.h28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/components/playable.h b/src/components/playable.h index 86a7ee7..94d4326 100644 --- a/src/components/playable.h +++ b/src/components/playable.h
@@ -2,22 +2,30 @@
2#define PLAYABLE_H_DDC566C3 2#define PLAYABLE_H_DDC566C3
3 3
4#include "component.h" 4#include "component.h"
5#include <functional> 5#include "entity_manager.h"
6 6
7class PlayableComponent : public Component { 7class PlayableComponent : public Component {
8public: 8public:
9 9
10 using MapChangeCallback = std::function<void()>; 10 using id_type = EntityManager::id_type;
11 11
12 bool changingMap = false; 12 /**
13 int newMapId = -1; 13 * The entity ID of the map that the player is on.
14 double newMapX = 0; 14 *
15 double newMapY = 0; 15 * @managed_by PlayingSystem
16 MapChangeCallback newMapCallback; 16 */
17 id_type mapId;
17 18
18 int checkpointMapId = -1; 19 /**
19 double checkpointX = 0; 20 * The map ID and coordinates of the location that the player will spawn after
20 double checkpointY = 0; 21 * dying. Note that the map ID here is a world description map ID, not an
22 * entity ID.
23 *
24 * @managed_by PlayingSystem
25 */
26 size_t checkpointMapId;
27 double checkpointX;
28 double checkpointY;
21 29
22}; 30};
23 31