Entity::Entity()
: follower(0)
, animation(0)
+, sprite(0)
, partyLayout(0)
, monsters(0)
, numMonsters(0)
void Entity::SetOrientation(Orientation o) {
orientation = o;
UpdateVelocity();
- runner.SetColOffset(orientation);
+ if (CanTurn()) {
+ runner.SetColOffset(orientation);
+ }
}
void Entity::SetSpeed(float s) {
UpdateVelocity();
}
+
void Entity::StartAnimation(app::Application &ctrl) {
runner.Start(ctrl);
}
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);
void Entity::SetAnimation(const graphics::Animation *a) {
animation = a;
runner.ChangeAnimation(animation);
+ if (!sprite) {
+ sprite = animation->GetSprite();
+ }
}
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);
}
}
void Entity::Load(void *data) {
Entity *entity(reinterpret_cast<Entity *>(data));
- entity->runner.ChangeAnimation(entity->animation);
+ if (entity->animation) {
+ entity->runner.ChangeAnimation(entity->animation);
+ if (!entity->sprite) {
+ entity->sprite = entity->animation->GetSprite();
+ }
+ }
}
}