Horizon Official Technical Documentation
Cell.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_ZONE_GAME_CELL_HPP
31#define HORIZON_ZONE_GAME_CELL_HPP
32
33#include "Utility/Utility.hpp"
35
36namespace Horizon
37{
38namespace Zone
39{
40#pragma pack(push, 1)
41struct Cell
42{
43public:
44 Cell(uint8_t type)
45 : _type((map_cell_types) type)
46 {
48 }
49
51 {
52
53 }
54
56 {
57 //
58 }
59
60 void set_type(uint8_t type) { _type = (map_cell_types) type; validate_type(_type); }
62
64 {
65 switch (type)
66 {
67 case CELL_WALKABLE_SHOOTABLE_WATER: setWater(); // walkable water
69 case CELL_WALKABLE_SHOOTABLE_2: // ???
70 case CELL_WALKABLE_SHOOTABLE_4: // ???
72 case CELL_CLIFF_ONLY_SHOOTABLE_5: setShootable(); // gap (snipable)
73 case CELL_NONWALKABLE_GROUND: break;
74
75// case 0: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // walkable ground
76// case 1: cell.walkable = 0; cell.shootable = 0; cell.water = 0; break; // non-walkable ground
77// case 2: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
78// case 3: cell.walkable = 1; cell.shootable = 1; cell.water = 1; break; // walkable water
79// case 4: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
80// case 5: cell.walkable = 0; cell.shootable = 1; cell.water = 0; break; // gap (snipable)
81// case 6: cell.walkable = 1; cell.shootable = 1; cell.water = 0; break; // ???
82 default:
83 break;
84 }
85 }
86
87 bool isWalkable() { return setting._walkable ? true : false; }
88 void setWalkable() { setting._walkable = 1; }
89
90 bool isShootable() { return setting._shootable ? true : false; }
91 void setShootable() { setting._shootable = 1; }
92
93 bool isWater() { return setting._is_water ? true : false; }
94 void setWater() { setting._is_water = 1; }
95
96private:
97 struct {
98 unsigned _walkable : 1;
99 unsigned _shootable : 1;
100 unsigned _is_water : 1;
101 unsigned unused : 5;
104};
105#pragma pack(pop)
106}
107}
108
109#endif /* HORIZON_ZONE_GAME_CELL_HPP */
map_cell_types
Definition: MapDefinitions.hpp:34
@ CELL_NONWALKABLE_GROUND
Definition: MapDefinitions.hpp:36
@ CELL_WALKABLE_SHOOTABLE_2
Definition: MapDefinitions.hpp:37
@ CELL_CLIFF_ONLY_SHOOTABLE_5
Definition: MapDefinitions.hpp:40
@ CELL_WALKABLE_SHOOTABLE_GROUND_0
Definition: MapDefinitions.hpp:35
@ CELL_WALKABLE_SHOOTABLE_6
Definition: MapDefinitions.hpp:41
@ CELL_WALKABLE_SHOOTABLE_4
Definition: MapDefinitions.hpp:39
@ CELL_WALKABLE_SHOOTABLE_WATER
Definition: MapDefinitions.hpp:38
Definition: Element.hpp:7
Definition: Cell.hpp:42
void setShootable()
Definition: Cell.hpp:91
~Cell()
Definition: Cell.hpp:55
struct Horizon::Zone::Cell::@134 setting
map_cell_types get_type()
Definition: Cell.hpp:61
void setWalkable()
Definition: Cell.hpp:88
void set_type(uint8_t type)
Definition: Cell.hpp:60
Cell(uint8_t type)
Definition: Cell.hpp:44
unsigned _walkable
Definition: Cell.hpp:98
bool isShootable()
Definition: Cell.hpp:90
unsigned _is_water
Definition: Cell.hpp:100
Cell()
Definition: Cell.hpp:50
bool isWater()
Definition: Cell.hpp:93
map_cell_types _type
Definition: Cell.hpp:103
unsigned unused
Definition: Cell.hpp:101
unsigned _shootable
Definition: Cell.hpp:99
bool isWalkable()
Definition: Cell.hpp:87
void validate_type(map_cell_types type)
Definition: Cell.hpp:63
void setWater()
Definition: Cell.hpp:94