From d8d9232a67a03548b827bdb0515fe7a620a488f8 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 15 Aug 2010 21:28:10 -0600 Subject: 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 --- src/localplayer.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/localplayer.cpp') 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() -- cgit v1.2.3-70-g09d2