item animation sync fixed

This commit is contained in:
Henrique 2011-11-02 22:36:05 -02:00
parent b66cf3373f
commit 1406e23c23
3 changed files with 11 additions and 7 deletions

View File

@ -36,12 +36,7 @@ void Item::draw(int x, int y)
{ {
const ThingType& type = g_thingsType.getItemType(m_id); const ThingType& type = g_thingsType.getItemType(m_id);
if(type.animationPhases > 1) { m_animation = (g_platform.getTicks() % (500 * type.animationPhases)) / 500;
if(g_platform.getTicks() - m_lastTicks > 500) {
m_animation++;
m_lastTicks = g_platform.getTicks();
}
}
/*if(type.group == Otc::ThingSplashGroup || type.group == Otc::ThingFluidGroup) { /*if(type.group == Otc::ThingSplashGroup || type.group == Otc::ThingFluidGroup) {
//xPattern = m_count % type.xPattern; //xPattern = m_count % type.xPattern;

View File

@ -32,6 +32,14 @@ Thing::Thing() : m_id(0)
m_animation = 0; m_animation = 0;
} }
void Thing::setId(uint32 id)
{
int oldId = m_id;
m_id = id;
onIdChange(oldId);
}
void Thing::setPosition(const Position& position) void Thing::setPosition(const Position& position)
{ {
Position oldPosition = m_position; Position oldPosition = m_position;

View File

@ -41,7 +41,7 @@ public:
virtual void draw(int x, int y) = 0; virtual void draw(int x, int y) = 0;
void setId(uint32 id) { m_id = id; } void setId(uint32 id);
void setPosition(const Position& position); void setPosition(const Position& position);
uint32 getId() const { return m_id; } uint32 getId() const { return m_id; }
@ -49,6 +49,7 @@ public:
int getStackPriority(); int getStackPriority();
virtual const ThingType& getType() = 0; virtual const ThingType& getType() = 0;
virtual void onIdChange(int) {}
virtual void onPositionChange(const Position&) {} virtual void onPositionChange(const Position&) {}
ThingPtr asThing() { return std::static_pointer_cast<Thing>(shared_from_this()); } ThingPtr asThing() { return std::static_pointer_cast<Thing>(shared_from_this()); }