X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fmap%2FEntity.cpp;h=e922e54c74c1d5deefe18122afc4a8fc6b546d14;hb=978ccdf2644bc445c864dbe581ead365b238cff8;hp=01a8e9c384012a81ce15d5fc872c4342f4fab893;hpb=0ad5ca97b5df217329bc319d62564a9f46ba11d7;p=l2e.git diff --git a/src/map/Entity.cpp b/src/map/Entity.cpp index 01a8e9c..e922e54 100644 --- a/src/map/Entity.cpp +++ b/src/map/Entity.cpp @@ -18,6 +18,7 @@ namespace map { Entity::Entity() : follower(0) , animation(0) +, sprite(0) , partyLayout(0) , monsters(0) , numMonsters(0) @@ -31,7 +32,9 @@ Entity::Entity() void Entity::SetOrientation(Orientation o) { orientation = o; UpdateVelocity(); - runner.SetColOffset(orientation); + if (CanTurn()) { + runner.SetColOffset(orientation); + } } void Entity::SetSpeed(float s) { @@ -39,6 +42,7 @@ void Entity::SetSpeed(float s) { UpdateVelocity(); } + void Entity::StartAnimation(app::Application &ctrl) { runner.Start(ctrl); } @@ -51,6 +55,20 @@ void Entity::StopAnimation() { runner.Stop(); } + +void Entity::SetHandsFree() { + runner.SetRowOffset(0); +} + +void Entity::SetCarrying() { + runner.SetRowOffset(2); +} + +void Entity::SetPushing() { + runner.SetRowOffset(4); +} + + void Entity::AddFollower(Entity *f) { if (follower) { follower->AddFollower(f); @@ -70,6 +88,9 @@ void Entity::RemoveFollower(Entity *f) { void Entity::SetAnimation(const graphics::Animation *a) { animation = a; runner.ChangeAnimation(animation); + if (!sprite) { + sprite = animation->GetSprite(); + } } @@ -112,7 +133,7 @@ void Entity::Render(SDL_Surface *dest, const Vector &offset) const { if (runner.Running()) { runner.Draw(dest, offset + position + spriteOffset); } else { - animation->GetSprite()->Draw(dest, offset + position + spriteOffset, orientation); + sprite->Draw(dest, offset + position + spriteOffset, CanTurn() ? orientation : 0); } } @@ -142,7 +163,12 @@ void Entity::Construct(void *data) { void Entity::Load(void *data) { Entity *entity(reinterpret_cast(data)); - entity->runner.ChangeAnimation(entity->animation); + if (entity->animation) { + entity->runner.ChangeAnimation(entity->animation); + if (!entity->sprite) { + entity->sprite = entity->animation->GetSprite(); + } + } } }