Room system now uses CharacterData instead of Entity

This commit is contained in:
Kayne Ruse
2015-01-13 00:42:16 +11:00
parent 1923f90329
commit cd06ccc1a5
7 changed files with 30 additions and 30 deletions
+14 -14
View File
@@ -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;
});
}