// // Created by hbenjamin on 03/06/2021. // #include #include #include #include #include #include #include "AnimatorSystem.hpp" #include "Component/Renderer/Drawable3DComponent.hpp" #include "Component/Health/HealthComponent.hpp" using Keyboard = RAY::Controller::Keyboard; namespace RAY3D = RAY::Drawables::Drawables3D; using Key = RAY::Controller::Keyboard::Key; namespace BBM { AnimatorSystem::AnimatorSystem(WAL::Wal &wal) : System(wal) {} void AnimatorSystem::onFixedUpdate(WAL::ViewEntity &entity) { const auto &controllable = entity.get(); auto drawable = entity.get().drawable.get(); auto &animation = entity.get(); auto anim = dynamic_cast(drawable); auto health = entity->tryGetComponent(); if ((health && health->getHealthPoint() <= 0) || entity->shouldDelete()) return; if (anim && controllable.move != Vector2f(0, 0)) { anim->setRotationAngle(controllable.move.angle(Vector2f(-1, 0))); animation.setAnimIndex(0); return; } animation.setAnimIndex(1); } }