aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/pink/actors/actor.cpp34
-rw-r--r--engines/pink/actors/actor.h7
2 files changed, 27 insertions, 14 deletions
diff --git a/engines/pink/actors/actor.cpp b/engines/pink/actors/actor.cpp
index f92c1cb833..fefe1f9834 100644
--- a/engines/pink/actors/actor.cpp
+++ b/engines/pink/actors/actor.cpp
@@ -40,7 +40,7 @@ Sequencer *Actor::getSequencer() {
return _page->getSequencer();
}
-Action *Actor::findAction(Common::String &name) {
+Action *Actor::findAction(const Common::String &name) {
return *Common::find_if(_actions.begin(), _actions.end(), [&name]
(Action* action) {
return name == action->getName();
@@ -51,27 +51,39 @@ GamePage *Actor::getPage() const {
return _page;
}
-void Actor::setIdleAction(bool unk) {
- assert(_action == nullptr);
-
- uint i;
- for (i = 0; i < _actions.size(); ++i) {
- if (_action[i].getName() == "Idle") {
- _action = _actions[i];
- break;
- }
+void Actor::init(bool unk) {
+ if (!_action) {
+ _action = findAction({"Idle"});
}
+
if (!_action) {
_isActionEnd = 1;
}
else {
_isActionEnd = 0;
- //call action virt method
+ _action->play(unk);
}
}
+void Actor::hide() {
+ setAction({"Hide"});
+}
+
void Actor::endAction() {
_isActionEnd = 1;
}
+void Actor::setAction(const Common::String &name) {
+ Action *newAction = findAction(name);
+ if (_action) {
+ _isActionEnd = 1;
+ _action->end();
+ }
+ if (newAction) {
+ _isActionEnd = 0;
+ _action = newAction;
+ _action->play(0);
+ }
+}
+
} // End of namespace Pink
diff --git a/engines/pink/actors/actor.h b/engines/pink/actors/actor.h
index 4e494bddf5..54661bd48c 100644
--- a/engines/pink/actors/actor.h
+++ b/engines/pink/actors/actor.h
@@ -40,14 +40,15 @@ public:
{};
virtual void deserialize(Archive &archive);
- Action *findAction(Common::String &name);
-
Sequencer *getSequencer();
GamePage *getPage() const;
- void setIdleAction(bool unk);
+ void init(bool unk);
+ void hide();
void endAction();
+ Action *findAction(const Common::String &name);
+ void setAction(const Common::String &name);
protected:
GamePage *_page;