Room system now uses CharacterData instead of Entity
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#config
|
||||
INCLUDES+=. ../entities ../monsters ../server_utilities ../waypoints ../../common/map ../../common/utilities
|
||||
INCLUDES+=. ../characters ../entities ../monsters ../server_utilities ../waypoints ../../common/gameplay ../../common/map ../../common/utilities
|
||||
LIBS+=
|
||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||
|
||||
|
||||
@@ -49,6 +49,6 @@ WaypointManager* RoomData::GetWaypointMgr() {
|
||||
return &waypointMgr;
|
||||
}
|
||||
|
||||
std::list<Entity*>* RoomData::GetEntityList() {
|
||||
return &entityList;
|
||||
std::list<CharacterData*>* RoomData::GetCharacterList() {
|
||||
return &characterList;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef ROOMDATA_HPP_
|
||||
#define ROOMDATA_HPP_
|
||||
|
||||
#include "entity.hpp"
|
||||
#include "character_data.hpp"
|
||||
#include "monster_manager.hpp"
|
||||
#include "region_pager_lua.hpp"
|
||||
#include "waypoint_manager.hpp"
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
RegionPagerLua* GetPager();
|
||||
MonsterManager* GetMonsterMgr();
|
||||
WaypointManager* GetWaypointMgr();
|
||||
std::list<Entity*>* GetEntityList();
|
||||
std::list<CharacterData*>* GetCharacterList();
|
||||
|
||||
//TODO: triggers for unload, save, per-second, player enter, player exit, etc.
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
RegionPagerLua pager;
|
||||
MonsterManager monsterMgr;
|
||||
WaypointManager waypointMgr;
|
||||
std::list<Entity*> entityList;
|
||||
std::list<CharacterData*> characterList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -60,34 +60,34 @@ void RoomManager::UnloadIf(std::function<bool(std::pair<const int, RoomData cons
|
||||
}
|
||||
}
|
||||
|
||||
void RoomManager::PushEntity(Entity* entity) {
|
||||
if (!entity) {
|
||||
throw(std::runtime_error("Failed to push a null entity to a room"));
|
||||
void RoomManager::PushCharacter(CharacterData* character) {
|
||||
if (!character) {
|
||||
throw(std::runtime_error("Failed to push a null character to a room"));
|
||||
}
|
||||
|
||||
RoomData* room = Get(entity->GetRoomIndex());
|
||||
RoomData* room = Get(character->GetRoomIndex());
|
||||
|
||||
if (!room) {
|
||||
throw(std::runtime_error("Failed to push an entity to a non-existant room"));
|
||||
throw(std::runtime_error("Failed to push an character to a non-existant room"));
|
||||
}
|
||||
|
||||
room->entityList.push_back(entity);
|
||||
room->characterList.push_back(character);
|
||||
}
|
||||
|
||||
void RoomManager::PopEntity(Entity const* entity) {
|
||||
//NOTE: to pop an entity from a room, the entity must first exist
|
||||
if (!entity) {
|
||||
throw(std::runtime_error("Failed to pop a null entity to a room"));
|
||||
void RoomManager::PopCharacter(CharacterData const* character) {
|
||||
//NOTE: to pop an character from a room, the character must first exist
|
||||
if (!character) {
|
||||
throw(std::runtime_error("Failed to pop a null character to a room"));
|
||||
}
|
||||
|
||||
RoomData* room = Get(entity->GetRoomIndex());
|
||||
RoomData* room = Get(character->GetRoomIndex());
|
||||
|
||||
if (!room) {
|
||||
throw(std::runtime_error("Failed to pop an entity to a non-existant room"));
|
||||
throw(std::runtime_error("Failed to pop an character to a non-existant room"));
|
||||
}
|
||||
|
||||
room->entityList.remove_if([entity](Entity* ptr) {
|
||||
return entity == ptr;
|
||||
room->characterList.remove_if([character](CharacterData* ptr) {
|
||||
return character == ptr;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#ifndef ROOMMANAGER_HPP_
|
||||
#define ROOMMANAGER_HPP_
|
||||
|
||||
#include "entity.hpp"
|
||||
#include "character_data.hpp"
|
||||
#include "room_data.hpp"
|
||||
#include "singleton.hpp"
|
||||
|
||||
@@ -40,8 +40,8 @@ public:
|
||||
void UnloadAll();
|
||||
void UnloadIf(std::function<bool(std::pair<const int, RoomData const&>)> fn);
|
||||
|
||||
void PushEntity(Entity* entity);
|
||||
void PopEntity(Entity const* entity);
|
||||
void PushCharacter(CharacterData* character);
|
||||
void PopCharacter(CharacterData const* character);
|
||||
|
||||
//accessors and mutators
|
||||
RoomData* Get(int uid);
|
||||
|
||||
Reference in New Issue
Block a user