Creepy-simulation
 
Loading...
Searching...
No Matches
Creeper.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5#include <optional>
6
7#include "Steve.hpp"
8#include "Unit.hpp"
9#include "utils.hpp"
14class CreepersParams final : public UnitsParams {
15 public:
20 enum class State : std::uint8_t { Born, Walk, Hissing, Explodes, Sleep, Dead, GoToSteve, Bonk };
22 static constexpr size_t creepers_num_changing_state = 250;
30 CreepersParams(double moveRadius, double explodeRadius, const std::shared_ptr<FieldParams> &fieldParams,
31 uint32_t unitsCount);
32};
40class Creeper final : public Unit, public std::enable_shared_from_this<Creeper> {
41 std::shared_ptr<CreepersParams> params_;
43 std::shared_ptr<Steve> target_;
49 Point moveTo(Point to);
55 Point bonkedMove(Point to);
56
57 public:
63 Creeper(size_t id, const std::shared_ptr<CreepersParams> &params);
67 void begin();
72 void steveSearch(const std::shared_ptr<Steve> &steve);
76 void walk() override;
77
78 void updateState(const std::shared_ptr<Unit> &another) override;
79
80 void die() override;
81
82 [[nodiscard]] decltype(state_) getState() const { return state_; }
83};
Represents an individual creeper in the simulation.
Definition Creeper.hpp:40
void begin()
Initializes the creeper's behavior.
Definition Creeper.cpp:14
void walk() override
Executes the walking behavior of the creeper.
Definition Creeper.cpp:70
void steveSearch(const std::shared_ptr< Steve > &steve)
Searches for a Steve target.
Definition Creeper.cpp:34
void die() override
Executes the death behavior of the unit.
Definition Creeper.cpp:106
decltype(state_) getState() const
Definition Creeper.hpp:82
void updateState(const std::shared_ptr< Unit > &another) override
Updates the state of the unit based on interaction with another unit.
Definition Creeper.cpp:108
Configuration parameters for creepers in the simulation.
Definition Creeper.hpp:14
static constexpr size_t creepers_num_changing_state
Definition Creeper.hpp:22
State
Possible states of a creeper.
Definition Creeper.hpp:20
double explodeRadiusSquare
Definition Creeper.hpp:21
Represents a generic unit in the simulation.
Definition Unit.hpp:63
Configuration parameters shared among multiple units.
Definition Unit.hpp:12
Represents a 2D point with x and y coordinates.
Definition utils.hpp:10