summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-15 21:28:10 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-16 13:19:09 -0600
commitd8d9232a67a03548b827bdb0515fe7a620a488f8 (patch)
treed6e0644f99e0ff89f9b320c0b479ba5a4e398125 /src/localplayer.cpp
parenta6c2b90c2dabac18ad8052d948bc540406b3a613 (diff)
downloadmana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.gz
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.bz2
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.tar.xz
mana-d8d9232a67a03548b827bdb0515fe7a620a488f8.zip
Move more to the event system
Most of Net::InventoryHandler is now done through events. The ActorSpriteManager was also replaced by events. A few odds and ends were taken care of too. Reviewed-by: Bertram
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 33a07373..4577fd16 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -98,6 +98,8 @@ LocalPlayer::LocalPlayer(int id, int subtype):
config.addListener("showownname", this);
setShowName(config.getValue("showownname", 1));
+
+ listen("ActorSprite");
}
LocalPlayer::~LocalPlayer()
@@ -656,24 +658,16 @@ void LocalPlayer::pickUp(FloorItem *item)
{
setDestination(item->getPixelX() + 16, item->getPixelY() + 16);
mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
}
else
{
setDestination(item->getTileX(), item->getTileY());
mPickUpTarget = item;
- mPickUpTarget->addActorSpriteListener(this);
stopAttack();
}
}
}
-void LocalPlayer::actorSpriteDestroyed(const ActorSprite &actorSprite)
-{
- if (mPickUpTarget == &actorSprite)
- mPickUpTarget = 0;
-}
-
Being *LocalPlayer::getTarget() const
{
return mTarget;
@@ -1096,7 +1090,20 @@ void LocalPlayer::optionChanged(const std::string &value)
void LocalPlayer::event(const std::string &channel, const Mana::Event &event)
{
- if (channel == "Attributes")
+ if (channel == "ActorSprite")
+ {
+ if (event.getName() == "Destroyed")
+ {
+ ActorSprite *actor = event.getActor("source");
+
+ if (mPickUpTarget == actor)
+ mPickUpTarget = 0;
+
+ if (mTarget == actor)
+ mTarget = 0;
+ }
+ }
+ else if (channel == "Attributes")
{
if (event.getName() == "UpdateAttribute")
{
@@ -1109,8 +1116,8 @@ void LocalPlayer::event(const std::string &channel, const Mana::Event &event)
}
}
}
- else
- Being::event(channel, event);
+
+ Being::event(channel, event);
}
void LocalPlayer::changeAwayMode()