Skip to content

Commit

Permalink
NWN: Set the correct model state for doors and placeables
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 29, 2014
1 parent 425f146 commit 7ed0242
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/engines/nwn/door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ Door::Door(Module &module, const Aurora::GFFStruct &door) : Situated(kObjectType
Door::~Door() {
}

void Door::setVisible(bool visible) {
if (visible)
setModelState();

Situated::setVisible(visible);
}

void Door::load(const Aurora::GFFStruct &door) {
Common::UString temp = door.getString("TemplateResRef");

Expand Down Expand Up @@ -188,6 +195,29 @@ void Door::evaluateLink() {
_evaluatedLink = true;
}

void Door::setModelState() {
if (!_model)
return;

switch (_state) {
case kStateClosed:
_model->setState("closed");
break;

case kStateOpened1:
_model->setState("opened1");
break;

case kStateOpened2:
_model->setState("opened2");
break;

default:
_model->setState("");
break;
}
}

} // End of namespace NWN

} // End of namespace Engines
6 changes: 6 additions & 0 deletions src/engines/nwn/door.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Door : public Situated {
Door(Module &module, const Aurora::GFFStruct &door);
~Door();

/** Show/Hide the door's model. */
void setVisible(bool visible);

/** Is the door open? */
bool isOpen() const;

Expand Down Expand Up @@ -103,6 +106,9 @@ class Door : public Situated {

/** Evaluate our link. */
void evaluateLink();

/** Sync the model state with the door state. */
void setModelState();
};

} // End of namespace NWN
Expand Down
42 changes: 42 additions & 0 deletions src/engines/nwn/placeable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ Placeable::Placeable(const Aurora::GFFStruct &placeable) : Situated(kObjectTypeP
Placeable::~Placeable() {
}

void Placeable::setVisible(bool visible) {
if (visible)
setModelState();

Situated::setVisible(visible);
}

void Placeable::load(const Aurora::GFFStruct &placeable) {
Common::UString temp = placeable.getString("TemplateResRef");

Expand Down Expand Up @@ -86,6 +93,41 @@ bool Placeable::isOpen() const {
return _state == kStateOpen;
}

void Placeable::setModelState() {
if (!_model)
return;

switch (_state) {
case kStateDefault:
_model->setState("default");
break;

case kStateOpen:
_model->setState("open");
break;

case kStateClosed:
_model->setState("close");
break;

case kStateDestroyed:
_model->setState("dead");
break;

case kStateActivated:
_model->setState("on");
break;

case kStateDeactivated:
_model->setState("off");
break;

default:
_model->setState("");
break;
}
}

} // End of namespace NWN

} // End of namespace Engines
6 changes: 6 additions & 0 deletions src/engines/nwn/placeable.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class Placeable : public Situated {
Placeable(const Aurora::GFFStruct &placeable);
~Placeable();

/** Show/Hide the placeable's model. */
void setVisible(bool visible);

/** Is the placeable open? */
bool isOpen() const;

Expand All @@ -68,6 +71,9 @@ class Placeable : public Situated {

/** Load from a placeable instance. */
void load(const Aurora::GFFStruct &placeable);

/** Sync the model state with the placeable state. */
void setModelState();
};

} // End of namespace NWN
Expand Down

0 comments on commit 7ed0242

Please sign in to comment.