2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#include "tile.h"
|
|
|
|
#include "item.h"
|
2011-08-31 17:03:33 +02:00
|
|
|
#include "thingstype.h"
|
2011-08-17 06:45:55 +02:00
|
|
|
#include "map.h"
|
2011-08-20 04:08:27 +02:00
|
|
|
#include "game.h"
|
2011-08-17 06:45:55 +02:00
|
|
|
#include "localplayer.h"
|
2011-08-31 22:22:57 +02:00
|
|
|
#include "effect.h"
|
2011-11-10 07:53:16 +01:00
|
|
|
#include <otclient/net/protocolgame.h>
|
2011-08-20 04:08:27 +02:00
|
|
|
#include <framework/graphics/fontmanager.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-31 01:39:14 +02:00
|
|
|
Tile::Tile(const Position& position)
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
2011-08-31 22:22:57 +02:00
|
|
|
m_drawElevation = 0;
|
2012-01-30 01:00:12 +01:00
|
|
|
m_position = position;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2012-01-30 19:18:10 +01:00
|
|
|
void Tile::draw(const Point& dest, float scaleFactor, int drawFlags)
|
2011-08-17 06:45:55 +02:00
|
|
|
{
|
2012-01-30 22:28:08 +01:00
|
|
|
int drawElevation = 0;
|
2012-02-02 17:37:52 +01:00
|
|
|
bool animate = drawFlags & Otc::DrawAnimations;
|
2012-01-31 18:06:55 +01:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
// first bottom items
|
2012-02-02 21:10:14 +01:00
|
|
|
if(drawFlags & Otc::DrawGround || drawFlags & Otc::DrawGroundBorders || drawFlags & Otc::DrawCommonItems) {
|
2012-01-30 19:18:10 +01:00
|
|
|
for(const ThingPtr& thing : m_things) {
|
|
|
|
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom())
|
|
|
|
break;
|
|
|
|
|
2012-02-02 17:37:52 +01:00
|
|
|
if((thing->isGround() && drawFlags & Otc::DrawGround) ||
|
|
|
|
(thing->isGroundBorder() && drawFlags & Otc::DrawGroundBorders) ||
|
2012-02-02 21:10:14 +01:00
|
|
|
(thing->isOnBottom() && drawFlags & Otc::DrawCommonItems))
|
2012-02-02 17:37:52 +01:00
|
|
|
thing->draw(dest - drawElevation*scaleFactor, scaleFactor, animate);
|
2012-01-30 19:18:10 +01:00
|
|
|
|
2012-01-30 22:28:08 +01:00
|
|
|
drawElevation += thing->getElevation();
|
|
|
|
if(drawElevation > Otc::MAX_ELEVATION)
|
|
|
|
drawElevation = Otc::MAX_ELEVATION;
|
2012-01-30 19:18:10 +01:00
|
|
|
}
|
2011-08-31 23:41:04 +02:00
|
|
|
}
|
|
|
|
|
2012-02-02 21:10:14 +01:00
|
|
|
int redrawPreviousOnTopW = 0;
|
|
|
|
int redrawPreviousOnTopH = 0;
|
|
|
|
|
2012-01-30 19:18:10 +01:00
|
|
|
if(drawFlags & Otc::DrawCommonItems) {
|
2012-02-02 21:10:14 +01:00
|
|
|
// now common items in reverse order
|
2012-01-30 19:18:10 +01:00
|
|
|
for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
|
|
|
|
const ThingPtr& thing = *it;
|
2012-01-30 22:28:08 +01:00
|
|
|
if(thing->isOnTop() || thing->isOnBottom() || thing->isGroundBorder() || thing->isGround() || thing->asCreature())
|
2012-01-30 19:18:10 +01:00
|
|
|
break;
|
2012-02-02 17:37:52 +01:00
|
|
|
thing->draw(dest - drawElevation*scaleFactor, scaleFactor, animate);
|
2012-01-30 19:18:10 +01:00
|
|
|
|
2012-02-02 21:10:14 +01:00
|
|
|
if(thing->isLyingCorpse()) {
|
|
|
|
redrawPreviousOnTopW = std::max(thing->getDimensionWidth(), redrawPreviousOnTopW);
|
|
|
|
redrawPreviousOnTopH = std::max(thing->getDimensionHeight(), redrawPreviousOnTopH);
|
|
|
|
}
|
|
|
|
|
2012-01-30 22:28:08 +01:00
|
|
|
drawElevation += thing->getElevation();
|
|
|
|
if(drawElevation > Otc::MAX_ELEVATION)
|
|
|
|
drawElevation = Otc::MAX_ELEVATION;
|
2012-01-30 19:18:10 +01:00
|
|
|
}
|
2011-08-31 02:28:06 +02:00
|
|
|
}
|
2011-08-20 04:08:27 +02:00
|
|
|
|
2012-02-02 21:10:14 +01:00
|
|
|
// must redraw previous creatures/ontop above lying corpses
|
|
|
|
if(redrawPreviousOnTopH > 0 || redrawPreviousOnTopW > 0) {
|
|
|
|
int onTopRedrawFlags = drawFlags & (Otc::DrawCreatures | Otc::DrawEffects | Otc::DrawWalls);
|
|
|
|
if(onTopRedrawFlags) {
|
|
|
|
for(int y=-redrawPreviousOnTopH;y<=0;++y) {
|
|
|
|
for(int x=-redrawPreviousOnTopW;x<=0;++x) {
|
|
|
|
if(x == 0 && y == 0)
|
|
|
|
continue;
|
|
|
|
const TilePtr& tile = g_map.getTile(m_position.translated(x,y));
|
|
|
|
if(tile) {
|
|
|
|
tile->draw(dest + Point(x*Otc::TILE_PIXELS, y*Otc::TILE_PIXELS)*scaleFactor, scaleFactor, onTopRedrawFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-30 22:28:08 +01:00
|
|
|
// creatures
|
2012-01-30 19:18:10 +01:00
|
|
|
if(drawFlags & Otc::DrawCreatures) {
|
2012-02-02 17:37:52 +01:00
|
|
|
if(animate) {
|
|
|
|
for(const CreaturePtr& creature : m_walkingCreatures) {
|
|
|
|
creature->draw(Point(dest.x + ((creature->getPosition().x - m_position.x)*Otc::TILE_PIXELS - drawElevation)*scaleFactor,
|
|
|
|
dest.y + ((creature->getPosition().y - m_position.y)*Otc::TILE_PIXELS - drawElevation)*scaleFactor), scaleFactor, animate);
|
2012-01-30 22:28:08 +01:00
|
|
|
|
2012-02-02 17:37:52 +01:00
|
|
|
}
|
2012-01-30 22:28:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
|
|
|
|
CreaturePtr creature = (*it)->asCreature();
|
2012-02-02 17:37:52 +01:00
|
|
|
if(creature && (!creature->isWalking() || !animate))
|
|
|
|
creature->draw(dest - drawElevation, scaleFactor, animate);
|
2011-09-01 00:42:52 +02:00
|
|
|
}
|
2011-08-31 02:28:06 +02:00
|
|
|
}
|
2011-08-20 04:08:27 +02:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
// effects
|
2012-01-30 19:18:10 +01:00
|
|
|
if(drawFlags & Otc::DrawEffects) {
|
|
|
|
for(const EffectPtr& effect : m_effects)
|
2012-02-02 17:37:52 +01:00
|
|
|
effect->draw(dest, scaleFactor, animate);
|
2012-01-30 19:18:10 +01:00
|
|
|
}
|
2011-08-20 04:08:27 +02:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
// top items
|
2012-01-30 19:18:10 +01:00
|
|
|
if(drawFlags & Otc::DrawWalls) {
|
|
|
|
for(const ThingPtr& thing : m_things) {
|
|
|
|
if(thing->isOnTop())
|
2012-02-02 17:37:52 +01:00
|
|
|
thing->draw(dest - drawElevation, scaleFactor, animate);
|
2012-01-30 19:18:10 +01:00
|
|
|
}
|
2011-08-31 02:28:06 +02:00
|
|
|
}
|
2011-08-31 22:22:57 +02:00
|
|
|
}
|
2011-08-31 02:28:06 +02:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
void Tile::clean()
|
|
|
|
{
|
2012-02-02 21:10:14 +01:00
|
|
|
while(!m_things.empty())
|
|
|
|
removeThing(m_things.front());
|
2011-08-31 22:22:57 +02:00
|
|
|
}
|
2011-08-31 01:39:14 +02:00
|
|
|
|
2012-01-30 22:28:08 +01:00
|
|
|
void Tile::addWalkingCreature(const CreaturePtr& creature)
|
|
|
|
{
|
|
|
|
m_walkingCreatures.push_back(creature);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Tile::removeWalkingCreature(const CreaturePtr& creature)
|
|
|
|
{
|
|
|
|
auto it = std::find(m_walkingCreatures.begin(), m_walkingCreatures.end(), creature);
|
|
|
|
if(it != m_walkingCreatures.end())
|
|
|
|
m_walkingCreatures.erase(it);
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
|
|
|
if(!thing)
|
2011-08-31 22:22:57 +02:00
|
|
|
return nullptr;
|
|
|
|
|
2012-01-30 01:00:12 +01:00
|
|
|
thing->setPosition(m_position);
|
|
|
|
|
2011-12-30 15:15:23 +01:00
|
|
|
if(EffectPtr effect = thing->asEffect()) {
|
|
|
|
m_effects.push_back(effect);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
if(stackPos < 0) {
|
|
|
|
stackPos = 0;
|
|
|
|
int priority = thing->getStackPriority();
|
|
|
|
for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
|
|
|
|
int otherPriority = m_things[stackPos]->getStackPriority();
|
|
|
|
if(otherPriority > priority || (otherPriority == priority && otherPriority == 5))
|
|
|
|
break;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
2011-08-31 22:22:57 +02:00
|
|
|
} else if(stackPos > (int)m_things.size())
|
|
|
|
stackPos = m_things.size();
|
|
|
|
|
|
|
|
ThingPtr oldObject;
|
|
|
|
if(stackPos < (int)m_things.size())
|
|
|
|
oldObject = m_things[stackPos];
|
|
|
|
m_things.insert(m_things.begin() + stackPos, thing);
|
2012-01-30 01:00:12 +01:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
return oldObject;
|
2011-08-16 07:47:35 +02:00
|
|
|
}
|
|
|
|
|
2012-02-02 21:10:14 +01:00
|
|
|
bool Tile::removeThing(ThingPtr thing)
|
2012-01-30 01:00:12 +01:00
|
|
|
{
|
|
|
|
if(!thing)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
bool removed = false;
|
|
|
|
|
|
|
|
if(EffectPtr effect = thing->asEffect()) {
|
|
|
|
auto it = std::find(m_effects.begin(), m_effects.end(), effect);
|
|
|
|
if(it != m_effects.end()) {
|
|
|
|
m_effects.erase(it);
|
|
|
|
removed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
auto it = std::find(m_things.begin(), m_things.end(), thing);
|
|
|
|
if(it != m_things.end()) {
|
|
|
|
m_things.erase(it);
|
|
|
|
removed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset values managed by this tile
|
|
|
|
if(removed) {
|
|
|
|
//thing->setDrawOffset(0);
|
|
|
|
//thing->setStackpos(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return removed;
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
ThingPtr Tile::getThing(int stackPos)
|
2011-08-16 07:47:35 +02:00
|
|
|
{
|
2011-08-31 22:22:57 +02:00
|
|
|
if(stackPos >= 0 && stackPos < (int)m_things.size())
|
|
|
|
return m_things[stackPos];
|
|
|
|
return nullptr;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2012-01-03 23:27:31 +01:00
|
|
|
int Tile::getThingStackpos(const ThingPtr& thing)
|
|
|
|
{
|
|
|
|
for(uint stackpos = 0; stackpos < m_things.size(); ++stackpos)
|
|
|
|
if(thing == m_things[stackpos])
|
|
|
|
return stackpos;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-01-03 21:41:00 +01:00
|
|
|
ThingPtr Tile::getTopThing()
|
|
|
|
{
|
|
|
|
if(isEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
return m_things[m_things.size() - 1];
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
std::vector<CreaturePtr> Tile::getCreatures()
|
2011-08-17 06:45:55 +02:00
|
|
|
{
|
2011-08-31 22:22:57 +02:00
|
|
|
std::vector<CreaturePtr> creatures;
|
|
|
|
for(const ThingPtr& thing : m_things) {
|
|
|
|
if(CreaturePtr creature = thing->asCreature())
|
|
|
|
creatures.push_back(creature);
|
|
|
|
}
|
|
|
|
return creatures;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
ItemPtr Tile::getGround()
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
2011-08-31 22:22:57 +02:00
|
|
|
ThingPtr firstObject = getThing(0);
|
|
|
|
if(!firstObject)
|
|
|
|
return nullptr;
|
2012-01-30 01:00:12 +01:00
|
|
|
if(firstObject->isGround())
|
2011-08-31 22:22:57 +02:00
|
|
|
return firstObject->asItem();
|
|
|
|
return nullptr;
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
2011-08-31 01:39:14 +02:00
|
|
|
|
2012-01-15 22:19:52 +01:00
|
|
|
int Tile::getGroundSpeed()
|
|
|
|
{
|
|
|
|
int groundSpeed = 100;
|
|
|
|
if(ItemPtr ground = getGround())
|
|
|
|
groundSpeed = ground->getGroundSpeed();
|
|
|
|
return groundSpeed;
|
|
|
|
}
|
|
|
|
|
2012-01-04 14:02:35 +01:00
|
|
|
ThingPtr Tile::getTopLookThing()
|
2011-12-30 19:14:50 +01:00
|
|
|
{
|
2012-01-04 14:39:08 +01:00
|
|
|
if(isEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
2012-01-06 17:16:47 +01:00
|
|
|
for(uint i = 0; i < m_things.size(); ++i) {
|
2012-01-04 14:02:35 +01:00
|
|
|
ThingPtr thing = m_things[i];
|
2012-01-30 01:00:12 +01:00
|
|
|
if(!thing->isIgnoreLook() && (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()))
|
2012-01-04 14:02:35 +01:00
|
|
|
return thing;
|
2012-01-02 20:01:48 +01:00
|
|
|
}
|
2012-01-04 14:02:35 +01:00
|
|
|
|
2012-01-04 14:39:08 +01:00
|
|
|
return m_things[0];
|
2012-01-04 14:02:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ThingPtr Tile::getTopUseThing()
|
|
|
|
{
|
|
|
|
if(isEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
2012-01-06 17:16:47 +01:00
|
|
|
for(uint i = 0; i < m_things.size(); ++i) {
|
2012-01-04 14:02:35 +01:00
|
|
|
ThingPtr thing = m_things[i];
|
2012-01-06 17:16:47 +01:00
|
|
|
if(thing->isForceUse() || (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->asCreature()))
|
2012-01-04 14:02:35 +01:00
|
|
|
return thing;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_things[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
CreaturePtr Tile::getTopCreature()
|
|
|
|
{
|
|
|
|
CreaturePtr creature;
|
2012-01-06 17:16:47 +01:00
|
|
|
for(uint i = 0; i < m_things.size(); ++i) {
|
2012-01-04 14:02:35 +01:00
|
|
|
ThingPtr thing = m_things[i];
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->asLocalPlayer()) // return local player if there is no other creature
|
2012-01-04 14:02:35 +01:00
|
|
|
creature = thing->asCreature();
|
|
|
|
else if(thing->asCreature() && !thing->asLocalPlayer())
|
|
|
|
return thing->asCreature();
|
|
|
|
}
|
|
|
|
return creature;
|
2011-12-30 19:14:50 +01:00
|
|
|
}
|
|
|
|
|
2012-01-20 02:12:26 +01:00
|
|
|
ThingPtr Tile::getTopMoveThing()
|
|
|
|
{
|
|
|
|
if(isEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
for(uint i = 0; i < m_things.size(); ++i) {
|
|
|
|
ThingPtr thing = m_things[i];
|
|
|
|
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->asCreature()) {
|
|
|
|
if(i > 0 && thing->isNotMoveable())
|
|
|
|
return m_things[i-1];
|
|
|
|
return thing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_things[0];
|
|
|
|
}
|
|
|
|
|
2012-01-09 21:54:37 +01:00
|
|
|
ThingPtr Tile::getTopMultiUseThing()
|
|
|
|
{
|
|
|
|
// this is related to classic controls, getting top item, forceuse or creature
|
|
|
|
if(isEmpty())
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
for(uint i = 0; i < m_things.size(); ++i) {
|
|
|
|
ThingPtr thing = m_things[i];
|
|
|
|
if(thing->isForceUse() || (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop())) {
|
|
|
|
if(i > 0 && thing->isFluid())
|
|
|
|
return m_things[i-1];
|
|
|
|
return thing;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_things[0];
|
|
|
|
}
|
|
|
|
|
2011-11-05 21:34:49 +01:00
|
|
|
bool Tile::isWalkable()
|
|
|
|
{
|
|
|
|
if(!getGround())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for(const ThingPtr& thing : m_things) {
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->isNotWalkable())
|
2011-11-05 21:34:49 +01:00
|
|
|
return false;
|
2011-12-30 15:15:23 +01:00
|
|
|
|
|
|
|
if(CreaturePtr creature = thing->asCreature()) {
|
|
|
|
if(!creature->getPassable())
|
|
|
|
return false;
|
|
|
|
}
|
2011-11-05 21:34:49 +01:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-02 00:00:46 +02:00
|
|
|
bool Tile::isFullGround()
|
|
|
|
{
|
2012-01-30 01:00:12 +01:00
|
|
|
ItemPtr ground = getGround();
|
|
|
|
if(ground && ground->isFullGround())
|
2011-09-02 00:00:46 +02:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
bool Tile::isFullyOpaque()
|
2011-08-31 01:39:14 +02:00
|
|
|
{
|
2011-08-31 22:22:57 +02:00
|
|
|
ThingPtr firstObject = getThing(0);
|
2012-01-30 01:00:12 +01:00
|
|
|
return firstObject && firstObject->isFullGround();
|
2011-08-31 01:39:14 +02:00
|
|
|
}
|
2011-09-02 00:00:46 +02:00
|
|
|
|
|
|
|
bool Tile::isLookPossible()
|
|
|
|
{
|
|
|
|
for(const ThingPtr& thing : m_things) {
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->blocksProjectile())
|
2011-09-02 00:00:46 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2011-11-10 07:53:16 +01:00
|
|
|
|
2012-01-04 15:30:28 +01:00
|
|
|
bool Tile::isClickable()
|
|
|
|
{
|
2012-01-30 01:00:12 +01:00
|
|
|
bool hasGround = false;
|
|
|
|
bool hasOnBottom = false;
|
|
|
|
bool hasIgnoreLook = false;
|
2012-01-04 15:30:28 +01:00
|
|
|
for(const ThingPtr& thing : m_things) {
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->isGround())
|
2012-01-04 15:30:28 +01:00
|
|
|
hasGround = true;
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->isOnBottom())
|
2012-01-04 15:30:28 +01:00
|
|
|
hasOnBottom = true;
|
2012-01-30 01:00:12 +01:00
|
|
|
if(thing->isIgnoreLook())
|
2012-01-04 15:30:28 +01:00
|
|
|
hasIgnoreLook = true;
|
|
|
|
|
|
|
|
if((hasGround || hasOnBottom) && !hasIgnoreLook)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-30 01:00:12 +01:00
|
|
|
bool Tile::isEmpty()
|
|
|
|
{
|
|
|
|
return m_things.size() == 0;
|
|
|
|
}
|
|
|
|
|
2012-02-02 17:55:42 +01:00
|
|
|
bool Tile::mustHookEast()
|
|
|
|
{
|
|
|
|
for(const ThingPtr& thing : m_things)
|
|
|
|
if(thing->isHookEast())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Tile::mustHookSouth()
|
|
|
|
{
|
|
|
|
for(const ThingPtr& thing : m_things)
|
|
|
|
if(thing->isHookSouth())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-30 15:15:23 +01:00
|
|
|
bool Tile::hasCreature()
|
|
|
|
{
|
|
|
|
for(const ThingPtr& thing : m_things)
|
|
|
|
if(thing->asCreature())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-30 01:00:12 +01:00
|
|
|
bool Tile::limitsFloorsView()
|
2012-01-02 20:01:48 +01:00
|
|
|
{
|
2012-01-30 01:00:12 +01:00
|
|
|
// ground and walls limits the view
|
|
|
|
ThingPtr firstThing = getThing(0);
|
|
|
|
if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || firstThing->isOnBottom()))
|
|
|
|
return true;
|
|
|
|
return false;
|
2012-01-02 20:01:48 +01:00
|
|
|
}
|
2012-02-02 21:10:14 +01:00
|
|
|
|
|
|
|
bool Tile::canErase()
|
|
|
|
{
|
|
|
|
return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty();
|
|
|
|
}
|
|
|
|
|