From 3b4e7795c9ab3036988a1a7dfe6f5ed2ad12199d Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 17 May 2010 19:16:11 -0600 Subject: Remove Monster, Player, and NPC classes Instead of having these three subclasses with minor differences, this commit merges them back into Being. In the future, we can make Beings that are talkable to some, attackable by others, etc. This also puts back support for monster equipment. Also changes remaining references to Being::Type and the constants to refer to ActorSprite::Type. Reviewed-by: Freeyorp --- src/game.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index b75d3cdf..c7c1d213 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -37,7 +37,6 @@ #include "localplayer.h" #include "log.h" #include "map.h" -#include "npc.h" #include "particle.h" #include "playerrelations.h" #include "sound.h" @@ -207,7 +206,7 @@ static void destroyGuiWindows() Game *Game::mInstance = 0; Game::Game(): - mLastTarget(Being::UNKNOWN), + mLastTarget(ActorSprite::UNKNOWN), mCurrentMap(0), mMapName("") { assert(!mInstance); @@ -756,7 +755,7 @@ void Game::handleInput() return; // Moving player around - if (player_node->isAlive() && !NPC::isTalking() && + if (player_node->isAlive() && !Being::isTalking() && !chatWindow->isInputFocused() && !quitDialog) { // Get the state of the keyboard keys @@ -835,7 +834,7 @@ void Game::handleInput() { // Only auto target Monsters target = beingManager->findNearestLivingBeing(player_node, - 20, Being::MONSTER); + 20, ActorSprite::MONSTER); } player_node->attack(target, newTarget); } @@ -847,14 +846,14 @@ void Game::handleInput() (joystick && joystick->buttonPressed(3))) && !keyboard.isKeyActive(keyboard.KEY_TARGET)) { - Being::Type currentTarget = Being::UNKNOWN; + ActorSprite::Type currentTarget = ActorSprite::UNKNOWN; if (keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || (joystick && joystick->buttonPressed(3))) - currentTarget = Being::MONSTER; + currentTarget = ActorSprite::MONSTER; else if (keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER)) - currentTarget = Being::PLAYER; + currentTarget = ActorSprite::PLAYER; else if (keyboard.isKeyActive(keyboard.KEY_TARGET_NPC)) - currentTarget = Being::NPC; + currentTarget = ActorSprite::NPC; Being *target = beingManager->findNearestLivingBeing(player_node, 20, currentTarget); @@ -868,7 +867,7 @@ void Game::handleInput() } else { - mLastTarget = Being::UNKNOWN; // Reset last target + mLastTarget = ActorSprite::UNKNOWN; // Reset last target } // Talk to the nearest NPC if 't' pressed @@ -879,8 +878,8 @@ void Game::handleInput() if (target) { - if (target->getType() == Being::NPC) - static_cast(target)->talk(); + if (target->canTalk()) + target->talkTo(); } } -- cgit v1.2.3-70-g09d2