vectozavr-shooter/engine/animation/ATranslate.h

37 lines
1.1 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 29.01.2021.
//
#ifndef ENGINE_ATRANSLATE_H
#define ENGINE_ATRANSLATE_H
#include "Animation.h"
2021-10-09 13:41:12 +03:00
#include "../Object.h"
2021-09-13 15:53:43 +03:00
class ATranslate final : public Animation {
2021-09-13 15:53:43 +03:00
private:
2021-10-28 16:58:02 +03:00
const std::weak_ptr<Object> _object;
const Vec3D _translationValue;
2021-10-02 20:36:07 +03:00
2021-10-28 16:58:02 +03:00
void update() override {
2021-11-09 22:54:20 +03:00
auto obj = _object.lock();
if (obj == nullptr) {
2021-10-28 16:58:02 +03:00
stop();
return;
}
2021-09-13 15:53:43 +03:00
2021-11-09 22:54:20 +03:00
obj->translate(_translationValue * dprogress());
2021-10-28 16:58:02 +03:00
}
2021-10-31 11:39:08 +03:00
2021-10-28 16:58:02 +03:00
public:
2021-10-31 11:39:08 +03:00
ATranslate(std::weak_ptr<Object> object, const Vec3D &t, double duration = 1, LoopOut looped = LoopOut::None,
InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped,
interpolationType),
2021-11-09 22:54:20 +03:00
_object(object),
2021-10-31 11:39:08 +03:00
_translationValue(t) {
2021-09-13 15:53:43 +03:00
}
};
#endif //INC_3DZAVR_ATRANSLATE_H