tibia-client/src/otclient/core/thing.h

122 lines
6.2 KiB
C
Raw Normal View History

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
#ifndef THING_H
#define THING_H
#include "declarations.h"
2012-01-30 01:00:12 +01:00
#include "thingstype.h"
2011-08-15 23:02:52 +02:00
#include <framework/luascript/luaobject.h>
2011-08-15 16:11:24 +02:00
struct Light
{
uint8 intensity;
uint8 color;
};
2011-08-15 23:02:52 +02:00
class Thing : public LuaObject
2011-08-15 16:11:24 +02:00
{
public:
2011-08-31 22:22:57 +02:00
Thing();
2011-08-15 23:02:52 +02:00
virtual ~Thing() { }
2011-08-15 16:11:24 +02:00
2012-01-30 01:00:12 +01:00
virtual void startAnimation() { }
virtual void draw(const Point& dest, float scaleFactor, bool animate) { }
2011-12-27 03:18:15 +01:00
virtual void setId(uint32 id) { }
void setPosition(const Position& position) { m_position = position; }
2011-08-15 16:11:24 +02:00
virtual uint32 getId() { return 0; }
2012-01-30 01:00:12 +01:00
Position getPosition() { return m_position; }
2011-08-31 22:22:57 +02:00
int getStackPriority();
const TilePtr& getTile();
ContainerPtr getParentContainer();
2012-02-02 21:10:14 +01:00
int getStackpos();
2011-11-14 23:32:55 +01:00
2011-08-15 23:02:52 +02:00
ThingPtr asThing() { return std::static_pointer_cast<Thing>(shared_from_this()); }
virtual ItemPtr asItem() { return nullptr; }
virtual EffectPtr asEffect() { return nullptr; }
2011-11-08 02:44:30 +01:00
virtual MissilePtr asMissile() { return nullptr; }
2012-01-09 06:23:39 +01:00
virtual CreaturePtr asCreature() { return nullptr; }
virtual NpcPtr asNpc() { return nullptr; }
virtual MonsterPtr asMonster() { return nullptr; }
2011-08-15 23:02:52 +02:00
virtual PlayerPtr asPlayer() { return nullptr; }
virtual LocalPlayerPtr asLocalPlayer() { return nullptr; }
2011-12-26 12:53:16 +01:00
virtual AnimatedTextPtr asAnimatedText() { return nullptr; }
2011-12-29 18:45:59 +01:00
virtual StaticTextPtr asStaticText() { return nullptr; }
2011-08-15 16:11:24 +02:00
2012-01-30 01:00:12 +01:00
// type related
2012-01-09 06:23:39 +01:00
bool isGround() { return m_type->properties[ThingType::IsGround]; }
2012-01-30 01:00:12 +01:00
bool isFullGround() { return m_type->properties[ThingType::IsFullGround]; }
2012-02-01 04:47:00 +01:00
bool isTranslucent() { return m_type->properties[ThingType::IsTranslucent]; }
2012-01-09 06:23:39 +01:00
bool isGroundBorder() { return m_type->properties[ThingType::IsGroundBorder]; }
bool isOnBottom() { return m_type->properties[ThingType::IsOnBottom]; }
bool isOnTop() { return m_type->properties[ThingType::IsOnTop]; }
2012-01-30 01:00:12 +01:00
bool isDontHide() { return m_type->properties[ThingType::DontHide]; }
2012-01-09 06:23:39 +01:00
bool isContainer() { return m_type->properties[ThingType::IsContainer]; }
bool isForceUse() { return m_type->properties[ThingType::IsForceUse]; }
bool isMultiUse() { return m_type->properties[ThingType::IsMultiUse]; }
bool isRotateable() { return m_type->properties[ThingType::IsRotateable]; }
bool isNotMoveable() { return m_type->properties[ThingType::IsNotMovable]; }
2012-01-30 01:00:12 +01:00
bool isNotWalkable() { return m_type->properties[ThingType::NotWalkable]; }
2012-01-09 06:23:39 +01:00
bool isPickupable() { return m_type->properties[ThingType::IsPickupable]; }
bool isNotPathable() { return m_type->properties[ThingType::NotPathable]; }
2012-01-30 01:00:12 +01:00
bool isIgnoreLook() { return m_type->properties[ThingType::IgnoreLook]; }
bool isHangable() { return m_type->properties[ThingType::IsHangable]; }
bool isHookSouth() { return m_type->properties[ThingType::HookSouth]; }
bool isHookEast() { return m_type->properties[ThingType::HookEast]; }
2012-01-09 06:23:39 +01:00
bool isStackable() { return m_type->properties[ThingType::IsStackable]; }
2012-02-03 00:23:51 +01:00
bool isAnimateAlways() { return m_type->properties[ThingType::AnimateAlways]; }
2012-02-02 21:10:14 +01:00
bool isLyingCorpse() { return m_type->properties[ThingType::IsLyingCorpse]; }
2012-01-30 01:00:12 +01:00
bool blocksProjectile() { return m_type->properties[ThingType::BlockProjectile]; }
2012-01-09 06:23:39 +01:00
bool isFluid() { return m_type->properties[ThingType::IsFluid]; }
bool isFluidContainer() { return m_type->properties[ThingType::IsFluidContainer]; }
2012-01-30 01:00:12 +01:00
Size getDimension() { return Size(m_type->dimensions[ThingType::Width], m_type->dimensions[ThingType::Height]); }
int getDimensionWidth() { return m_type->dimensions[ThingType::Width]; }
int getDimensionHeight() { return m_type->dimensions[ThingType::Height]; }
2012-02-07 08:59:20 +01:00
int getExactSize() { return m_type->dimensions[ThingType::ExactSize]; }
2012-01-30 01:00:12 +01:00
Point getDisplacement() { return Point(m_type->parameters[ThingType::DisplacementX], m_type->parameters[ThingType::DisplacementY]); }
int getNumPatternsX() { return m_type->dimensions[ThingType::PatternX]; }
int getNumPatternsY() { return m_type->dimensions[ThingType::PatternY]; }
int getNumPatternsZ() { return m_type->dimensions[ThingType::PatternZ]; }
int getDisplacementX() { return m_type->parameters[ThingType::DisplacementX]; }
int getDisplacementY() { return m_type->parameters[ThingType::DisplacementY]; }
int getLayers() { return m_type->dimensions[ThingType::Layers]; }
int getAnimationPhases() { return m_type->dimensions[ThingType::AnimationPhases]; }
int getGroundSpeed() { return m_type->parameters[ThingType::GroundSpeed]; }
int getElevation() { return m_type->parameters[ThingType::Elevation]; }
int getMinimapColor() { return m_type->parameters[ThingType::MiniMapColor]; }
2012-02-02 21:10:14 +01:00
int getSpriteId(int w = 0, int h = 0, int layer = 0,
int xPattern = 0, int yPattern = 0, int zPattern = 0,
int animation = 0) { return m_type->getSpriteId(w, h, layer, xPattern, yPattern, zPattern, animation); }
2012-01-03 00:08:04 +01:00
2011-08-15 16:11:24 +02:00
protected:
2012-02-02 21:10:14 +01:00
void internalDraw(const Point& dest, float scaleFactor, int w, int h, int xPattern, int yPattern, int zPattern, int layer, int animationPhase);
void internalDraw(const Point& dest, float scaleFactor, int xPattern, int yPattern, int zPattern, int animationPhase);
2011-08-15 16:11:24 +02:00
2012-01-30 01:00:12 +01:00
Position m_position;
ThingType *m_type;
2011-08-15 16:11:24 +02:00
};
2011-08-15 21:15:49 +02:00
#endif