yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
crumble_floor_model.cc
Go to the documentation of this file.
2
3#include <cstdlib>
4
5namespace yaze::editor {
6
8 switch (word) {
9 case 0x0C62:
10 case 0x0C63:
12 case 0x0CCC:
14 case 0x01E9:
16 default:
18 }
19}
20
21namespace {
23 if (cell == CrumbleFloorCell::kIntact) {
25 } else if (cell == CrumbleFloorCell::kCracked) {
27 }
28}
29} // namespace
30
31void CrumbleFloorModel::Reset(const Words& words) {
32 words_ = words;
33 route_.clear();
34 Rebuild();
35}
36
37absl::Status CrumbleFloorModel::Step(int x, int y) {
38 if (x < 0 || y < 0 || x >= kWidth || y >= kWidth) {
39 return absl::InvalidArgumentError("Choose a cell inside this room.");
40 }
41 const int next = y * kWidth + x;
42 if (current() == next) {
43 return absl::OkStatus(); // Standing still does not wear the tile.
44 }
45 if (route_.size() >= kMaxSteps) {
46 return absl::ResourceExhaustedError(
47 "512-cell rehearsal limit. Reset to start again.");
48 }
49 if (current() &&
50 std::abs(x - *current() % kWidth) + std::abs(y - *current() / kWidth) !=
51 1) {
52 return absl::InvalidArgumentError(
53 "Choose an adjacent cell; jumps are not modeled.");
54 }
55 if (cells_[next] == CrumbleFloorCell::kPit) {
56 return absl::FailedPreconditionError(
57 "That cell is a pit. Back removes the last step.");
58 }
59 if (cells_[next] == CrumbleFloorCell::kOther) {
60 return absl::FailedPreconditionError(
61 "Only highlighted crumble cells are modeled.");
62 }
63 if (current()) {
64 Depart(cells_[*current()]);
65 }
66 route_.push_back(next);
67 return absl::OkStatus();
68}
69
71 if (!route_.empty()) {
72 route_.pop_back();
73 Rebuild();
74 }
75}
76
78 for (int i = 0; i < kCellCount; ++i) {
80 }
81 for (size_t i = 1; i < route_.size(); ++i) {
82 Depart(cells_[route_[i - 1]]);
83 }
84}
85
86} // namespace yaze::editor
std::array< CrumbleFloorCell, kCellCount > cells_
absl::Status Step(int x, int y)
std::optional< int > current() const
std::array< uint16_t, kCellCount > Words
Editors are the view controllers for the application.
CrumbleFloorCell ClassifyCrumbleFloorWord(uint16_t word)