Skip to content

Commit

Permalink
KOTORBASE: Extract method to add creature to the area
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed Feb 25, 2019
1 parent fb6bdea commit 811dac0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/engines/kotorbase/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ void Area::loadDoors(const Aurora::GFF3List &list) {
void Area::loadCreatures(const Aurora::GFF3List &list) {
for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
Creature *creature = _module->createCreature(**c);

loadObject(*creature);
_creatures.push_back(creature);
addCreature(creature);
}
}

Expand Down Expand Up @@ -747,6 +745,11 @@ void Area::processCreaturesActions(float dt) {
}
}

void Area::addCreature(Creature *creature) {
loadObject(*creature);
_creatures.push_back(creature);
}

void Area::removeObject(Object *object) {
if (object == _activeObject) {
_activeObject->leave();
Expand Down
10 changes: 7 additions & 3 deletions src/engines/kotorbase/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ class Area : public Object, public Events::Notifyable {
void toggleTriggers();
void evaluateTriggers(float x, float y);

// Object management

Object *getObjectByTag(const Common::UString &tag);

void addCreature(Creature *creature);
void removeObject(Object *object);


void showAllRooms();

Expand All @@ -142,12 +149,9 @@ class Area : public Object, public Events::Notifyable {
void getCameraStyle(float &distance, float &pitch, float &height) const;
const std::vector<Common::UString> &getRoomsVisibleFrom(const Common::UString &room) const;
Object *getActiveObject();
Object *getObjectByTag(const Common::UString &tag);

void processCreaturesActions(float dt);

void removeObject(Object *object);

protected:
void notifyCameraMoved();

Expand Down

0 comments on commit 811dac0

Please sign in to comment.