Horizon Official Technical Documentation
Appearance.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_TRAITS_APPEARANCE_HPP
31#define HORIZON_ZONE_GAME_TRAITS_APPEARANCE_HPP
32
34#include <memory>
35namespace Horizon
36{
37namespace Zone
38{
39class Unit;
40namespace Units
41{
42 class Player;
43}
44namespace Traits
45{
47 {
48 public:
49 Appearance(std::weak_ptr<Unit> unit, unit_appearance_type type, uint32_t id = 0, uint32_t id_left = 0)
50 : _unit(unit), _type(type), _id(id), _id_left(id_left)
51 { }
53
54 void set(uint32_t id) { _id = id; notify_update(); }
55 uint32_t get() { return _id; }
56
57 void set_left(uint32_t id) { _id_left = id; notify_update(); }
58 uint32_t get_left() { return _id_left; }
59
60 virtual void notify_update();
61
63
64 protected:
65 std::shared_ptr<Unit> get_unit() { return _unit.lock(); }
66
67 private:
68 std::weak_ptr<Unit> _unit;
70 uint32_t _id{0};
71 uint32_t _id_left{0};
72 };
73
75 {
76 public:
77 BaseAppearance(std::weak_ptr<Unit> unit, uint32_t id = 0)
78 : Appearance(unit, UAT_BASE, id)
79 { }
81 };
82
83 class HairColor : public Appearance
84 {
85 public:
86 HairColor(std::weak_ptr<Unit> unit, uint32_t id = 0)
87 : Appearance(unit, UAT_HAIR_COLOR, id)
88 { }
90 };
91
92 class ClothColor : public Appearance
93 {
94 public:
95 ClothColor(std::weak_ptr<Unit> unit, uint32_t id = 0)
96 : Appearance(unit, UAT_CLOTH_COLOR, id)
97 { }
99 };
100
102 {
103 public:
104 WeaponSprite(std::weak_ptr<Unit> unit, uint32_t id = 0, uint32_t id_left = 0)
105 : Appearance(unit, UAT_WEAPON_SPRITE, id, id_left)
106 { }
108 };
109
111 {
112 public:
113 ShieldSprite(std::weak_ptr<Unit> unit, uint32_t id = 0)
114 : Appearance(unit, UAT_SHIELD_SPRITE, id)
115 { }
117 };
118
119 class RobeSprite : public Appearance
120 {
121 public:
122 RobeSprite(std::weak_ptr<Unit> unit, uint32_t id = 0)
123 : Appearance(unit, UAT_ROBE_SPRITE, id)
124 { }
126 };
127
129 {
130 public:
131 HeadTopSprite(std::weak_ptr<Unit> unit, uint32_t id = 0)
133 { }
135 };
136
138 {
139 public:
140 HeadMidSprite(std::weak_ptr<Unit> unit, uint32_t id = 0)
142 { }
144 };
145
147 {
148 public:
149 HeadBottomSprite(std::weak_ptr<Unit> unit, uint32_t id = 0)
151 { }
153 };
154
155 class HairStyle : public Appearance
156 {
157 public:
158 HairStyle(std::weak_ptr<Unit> unit, uint32_t id = 0)
159 : Appearance(unit, UAT_HAIR_STYLE, id)
160 { }
162 };
163
164 class BodyStyle : public Appearance
165 {
166 public:
167 BodyStyle(std::weak_ptr<Unit> unit, uint32_t id = 0)
168 : Appearance(unit, UAT_BODY_STYLE, id)
169 { }
171 };
172}
173}
174}
175
176#endif /* HORIZON_ZONE_GAME_TRAITS_APPEARANCE_HPP */
unit_appearance_type
Definition: UnitDefinitions.hpp:448
@ UAT_HAIR_COLOR
Definition: UnitDefinitions.hpp:455
@ UAT_HEAD_MID_SPRITE
Definition: UnitDefinitions.hpp:454
@ UAT_BODY_STYLE
Definition: UnitDefinitions.hpp:462
@ UAT_HEAD_TOP_SPRITE
Definition: UnitDefinitions.hpp:453
@ UAT_CLOTH_COLOR
Definition: UnitDefinitions.hpp:456
@ UAT_WEAPON_SPRITE
Definition: UnitDefinitions.hpp:451
@ UAT_BASE
Definition: UnitDefinitions.hpp:449
@ UAT_HEAD_BOTTOM_SPRITE
Definition: UnitDefinitions.hpp:452
@ UAT_HAIR_STYLE
Definition: UnitDefinitions.hpp:450
@ UAT_ROBE_SPRITE
Definition: UnitDefinitions.hpp:461
@ UAT_SHIELD_SPRITE
Definition: UnitDefinitions.hpp:457
Definition: Appearance.hpp:47
uint32_t get()
Definition: Appearance.hpp:55
unit_appearance_type get_type()
Definition: Appearance.hpp:62
Appearance(std::weak_ptr< Unit > unit, unit_appearance_type type, uint32_t id=0, uint32_t id_left=0)
Definition: Appearance.hpp:49
std::weak_ptr< Unit > _unit
Definition: Appearance.hpp:68
unit_appearance_type _type
Definition: Appearance.hpp:69
~Appearance()
Definition: Appearance.hpp:52
uint32_t _id_left
Definition: Appearance.hpp:71
void set_left(uint32_t id)
Definition: Appearance.hpp:57
uint32_t _id
Definition: Appearance.hpp:70
virtual void notify_update()
Definition: Appearance.cpp:38
uint32_t get_left()
Definition: Appearance.hpp:58
std::shared_ptr< Unit > get_unit()
Definition: Appearance.hpp:65
void set(uint32_t id)
Definition: Appearance.hpp:54
Definition: Appearance.hpp:75
BaseAppearance(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:77
~BaseAppearance()
Definition: Appearance.hpp:80
Definition: Appearance.hpp:165
BodyStyle(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:167
~BodyStyle()
Definition: Appearance.hpp:170
Definition: Appearance.hpp:93
~ClothColor()
Definition: Appearance.hpp:98
ClothColor(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:95
Definition: Appearance.hpp:84
~HairColor()
Definition: Appearance.hpp:89
HairColor(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:86
Definition: Appearance.hpp:156
HairStyle(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:158
~HairStyle()
Definition: Appearance.hpp:161
Definition: Appearance.hpp:147
~HeadBottomSprite()
Definition: Appearance.hpp:152
HeadBottomSprite(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:149
Definition: Appearance.hpp:138
HeadMidSprite(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:140
~HeadMidSprite()
Definition: Appearance.hpp:143
Definition: Appearance.hpp:129
~HeadTopSprite()
Definition: Appearance.hpp:134
HeadTopSprite(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:131
Definition: Appearance.hpp:120
~RobeSprite()
Definition: Appearance.hpp:125
RobeSprite(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:122
Definition: Appearance.hpp:111
ShieldSprite(std::weak_ptr< Unit > unit, uint32_t id=0)
Definition: Appearance.hpp:113
~ShieldSprite()
Definition: Appearance.hpp:116
Definition: Appearance.hpp:102
WeaponSprite(std::weak_ptr< Unit > unit, uint32_t id=0, uint32_t id_left=0)
Definition: Appearance.hpp:104
~WeaponSprite()
Definition: Appearance.hpp:107
Definition: ReferenceListTest.cpp:114
Definition: Element.hpp:7