-
Печенин Данила Михайлович authoredd55b9527
#pragma once
#include <States/GameState/Entities/IEntity.h>
#include <States/GameState/Entities/IVisitable.h>
#include <random>
struct IDynamicEntity : IEntity, IVisitable {
[[nodiscard]] virtual std::unique_ptr<IDynamicEntity> clone() const = 0;
virtual void action() = 0;
~IDynamicEntity() override = default;
};
class Enemy final : public IDynamicEntity {
public:
Enemy();
[[nodiscard]] std::unique_ptr<IDynamicEntity> clone() const override;
void action() override;
void draw_into(sf::RenderWindow& window) const override;
void prepare_for_first_drawing() override;
void prepare_for_drawing() override;
sf::FloatRect getBounds() const { return m_rectangle.getGlobalBounds(); }
std::unique_ptr<IGameEvent> accept(IVisitor* ptr_visitor) override { return ptr_visitor->visit(this); }
private:
sf::RectangleShape m_rectangle;
sf::Vector2f m_estimated_position;
bool m_is_moving = false;
float m_distance_limit;
sf::Clock m_stopwatch;
std::mt19937 m_rng{std::random_device{}()};
std::uniform_int_distribution<size_t> m_dist_milliseconds{300, 10000};
std::uniform_int_distribution<> m_dist_direction{0, 3};
};