28 lines
831 B
C++
28 lines
831 B
C++
#include "game/entities/concrete/dust.hpp"
|
|
|
|
#include <string>
|
|
|
|
#include "game/entities/entity_factory.hpp"
|
|
|
|
Dust::Dust(const fkyaml::node& yaml)
|
|
: anim_jump_(AnimationComponent::fromYaml(yaml, "jump")),
|
|
anim_land_(AnimationComponent::fromYaml(yaml, "land")) {
|
|
name_ = yaml.contains("name") ? yaml["name"].get_value<std::string>() : std::string("dust");
|
|
collides_ = false;
|
|
interactable_ = false;
|
|
// Per defecte JUMP; el spawner pot canviar-la abans del primer tick.
|
|
anim_ = anim_jump_;
|
|
}
|
|
|
|
void Dust::setVariant(Variant v) {
|
|
anim_ = (v == Variant::JUMP) ? anim_jump_ : anim_land_;
|
|
if (anim_.has_value()) { anim_->reset(); }
|
|
}
|
|
|
|
void Dust::update(float delta_time) {
|
|
Entity::update(delta_time);
|
|
if (anim_.has_value() && anim_->completed()) { markDead(); }
|
|
}
|
|
|
|
REGISTER_ENTITY("dust", Dust)
|