Horizon Official Technical Documentation
Item.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_ENTITIES_ITEM_HPP
31#define HORIZON_ZONE_GAME_ENTITIES_ITEM_HPP
32
37
38namespace Horizon
39{
40namespace Zone
41{
42class Map;
43namespace Units
44{
45class Item : public Unit, public GridObject<Item>
46{
47public:
48 explicit Item(int64_t uuid, std::shared_ptr<item_entry_data> entry, int32_t amount, std::shared_ptr<Map> map, MapCoords mcoords);
49 explicit Item(int64_t uuid, std::shared_ptr<Map> map, MapCoords mcoords, int is_identified, int amount, std::shared_ptr<const item_config_data> item_d);
50 ~Item();
51
52 void initialize();
53 bool finalize() override;
54
55 std::shared_ptr<item_entry_data> entry() { return _entry; }
56 std::shared_ptr<const item_config_data> config() const { return _config; }
57
58 int is_identified() const { return _is_identified; }
59 int amount() const { return _amount; }
60
61 int x_area() const { return _x_area; }
62 int y_area() const { return _y_area; }
63
64 void set_x_area(int x) { _x_area = x; }
65 void set_y_area(int y) { _y_area = y; }
66
67 void stop_movement() override;
68 void on_pathfinding_failure() override;
69 void on_movement_begin(int32_t time) override;
70 void on_movement_step() override;
71 void on_movement_end() override;
72
73 virtual void on_status_effect_start(std::shared_ptr<status_change_entry> sce) override;
74 virtual void on_status_effect_end(std::shared_ptr<status_change_entry> sce) override;
75 virtual void on_status_effect_change(std::shared_ptr<status_change_entry> sce) override;
76
77private:
78 std::shared_ptr<item_entry_data> _entry{ nullptr };
79 std::shared_ptr<const item_config_data> _config{ nullptr };
81 int _amount{ 0 };
82 int _x_area{ 0 }, _y_area{ 0 };
83};
84}
85}
86}
87
88#endif //HORIZON_ZONE_GAME_ENTITIES_ITEM_HPP
Definition: GridObject.hpp:42
Definition: Unit.hpp:102
std::shared_ptr< Map > map()
Map & Map Container.
Definition: Unit.hpp:165
uint64_t uuid() const
Unit Data.
Definition: Unit.hpp:140
Definition: Item.hpp:46
std::shared_ptr< const item_config_data > _config
Definition: Item.hpp:79
int _y_area
Definition: Item.hpp:82
std::shared_ptr< item_entry_data > _entry
Definition: Item.hpp:78
int y_area() const
Definition: Item.hpp:62
~Item()
Definition: Item.cpp:48
bool finalize() override
Definition: Item.cpp:61
int _amount
Definition: Item.hpp:81
void set_y_area(int y)
Definition: Item.hpp:65
int _is_identified
Definition: Item.hpp:80
int is_identified() const
Definition: Item.hpp:58
void initialize()
Definition: Item.cpp:53
virtual void on_status_effect_start(std::shared_ptr< status_change_entry > sce) override
Definition: Item.cpp:87
int x_area() const
Definition: Item.hpp:61
virtual void on_status_effect_change(std::shared_ptr< status_change_entry > sce) override
Definition: Item.cpp:95
void on_movement_begin(int32_t time) override
Definition: Item.cpp:74
virtual void on_status_effect_end(std::shared_ptr< status_change_entry > sce) override
Definition: Item.cpp:91
void on_movement_end() override
Definition: Item.cpp:82
void on_pathfinding_failure() override
Definition: Item.cpp:70
int _x_area
Definition: Item.hpp:82
void set_x_area(int x)
Definition: Item.hpp:64
void on_movement_step() override
Definition: Item.cpp:78
std::shared_ptr< item_entry_data > entry()
Definition: Item.hpp:55
Item(int64_t uuid, std::shared_ptr< item_entry_data > entry, int32_t amount, std::shared_ptr< Map > map, MapCoords mcoords)
Definition: Item.cpp:36
void stop_movement() override
Definition: Item.cpp:66
std::shared_ptr< const item_config_data > config() const
Definition: Item.hpp:56
int amount() const
Definition: Item.hpp:59
Definition: Element.hpp:7