Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1#ifndef STATE_H
2#define STATE_H
3
5
6#include <functional>
7#include <optional>
8
9class randomizer;
10class runtime_stack;
11
14namespace mazes
15{
17 struct state
18 {
19 enum class ID : unsigned int
20 {
21 EMPTY = 0,
22 LINK_WITH_BINARY_TREE = 1,
23 LINK_WITH_DFS = 2,
24 LINK_WITH_SIDEWINDER = 3,
25 LINK_WITH_PRIMS = 4,
26 LOAD = 5,
27 PARSE = 6,
28 WRITE_TO_IMAGE = 7,
29 WRITE_TO_STRING = 8,
30 WRITE_TO_WF_OBJ = 9,
31 LINK_WITH_MASKED = 10,
32 TOTAL = 11
33 };
34
35 explicit state(const runtime_app::context &c, runtime_stack *rs)
36 : ctx(c), _runtime_stack(rs)
37 {
38 }
39
40 virtual ~state() = default;
41
42 virtual void draw() const noexcept = 0;
43
47 [[nodiscard]] virtual bool update(randomizer &rng, double delta_time) noexcept = 0;
48
49 protected:
50 void request_stack_push(ID state_id) const noexcept;
51
52 void request_stack_pop() const noexcept;
53
54 void request_stack_clear() const noexcept;
55
56 [[nodiscard]] const runtime_app::context &get_context() const noexcept;
57
58 [[nodiscard]] runtime_stack &get_stack() const noexcept;
59
60 private:
61 std::reference_wrapper<const runtime_app::context> ctx;
62 runtime_stack *_runtime_stack;
63 };
64} // namespace mazes
65
66#endif // STATE_H
Provides random-number generating capabilities.
Definition randomizer.h:16
The main application class for the maze builder, responsible for managing the runtime stack and resou...
Definition runtime_app.h:28
Class representing the runtime stack of states in the maze builder application.
Definition runtime_stack.h:25
struct representing the context passed to states in the runtime_app stack
Definition runtime_app.h:34
virtual bool update(randomizer &rng, double delta_time) noexcept=0
Update the state with the elapsed time.