30#ifndef HORIZON_ZONE_GAME_TRAITS_ATTRIBUTES_HPP
31#define HORIZON_ZONE_GAME_TRAITS_ATTRIBUTES_HPP
173 void apply(
bool notify =
true);
190 std::chrono::high_resolution_clock::time_point
start_time{std::chrono::high_resolution_clock::now()};
197 void apply(
bool notify =
true);
199 void update(uint64_t delta);
217 std::chrono::high_resolution_clock::time_point
last_update{std::chrono::high_resolution_clock::now()};
218 std::chrono::high_resolution_clock::time_point
start_time{std::chrono::high_resolution_clock::now()};
225 void update(uint64_t delta);
293 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
295 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
297 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
299 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
307 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
309 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
311 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
313 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
315 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
317 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* =
nullptr>
status_point_type
Definition: UnitDefinitions.hpp:87
@ STATUS_POINT_INVALID
Definition: UnitDefinitions.hpp:88
Definition: Attribute.hpp:50
virtual void set_max(int32_t val)
Definition: Attribute.hpp:65
virtual void sub_max(int32_t val)
Definition: Attribute.hpp:62
virtual void add_max(int32_t val)
Definition: Attribute.hpp:61
virtual void set_min(int32_t val)
Definition: Attribute.hpp:56
virtual int32_t get_min() const
Definition: Attribute.hpp:54
int32_t _min
Definition: Attribute.hpp:71
virtual void sub_min(int32_t val)
Definition: Attribute.hpp:53
virtual int32_t get_max() const
Definition: Attribute.hpp:63
int32_t _max
Definition: Attribute.hpp:71
virtual void add_min(int32_t val)
Definition: Attribute.hpp:52
Definition: Attribute.hpp:233
Attribute(const Attribute &other)
Definition: Attribute.hpp:246
virtual void set_equip(int32_t val, bool notify=true)
Definition: Attribute.hpp:271
virtual void sub_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:256
TT operator/(TT right)
Definition: Attribute.hpp:296
void add_temporary_change(s_attribute_change_values change, uint64_t duration, std::string source)
Definition: Attribute.hpp:357
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262
void remove_temporary_change(std::string source)
Definition: Attribute.hpp:362
bool _recalculate_flag
Definition: Attribute.hpp:420
void update(uint64_t delta)
Definition: Attribute.hpp:377
bool operator>(TT right)
Definition: Attribute.hpp:312
Attribute operator=(Attribute &right)
Definition: Attribute.hpp:327
virtual void set_status(int32_t val, bool notify=true)
Definition: Attribute.hpp:280
bool operator<(TT right)
Definition: Attribute.hpp:316
TT operator*(TT right)
Definition: Attribute.hpp:298
virtual void sub_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:264
int32_t _base_val
Definition: Attribute.hpp:416
TT operator-(TT right)
Definition: Attribute.hpp:300
virtual void add_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:244
virtual int32_t compute()
Definition: Attribute.hpp:291
bool _calculate_ready
Definition: Attribute.hpp:421
virtual int32_t get_equip() const
Definition: Attribute.hpp:278
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259
virtual void sub_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:248
Attribute(std::weak_ptr< Unit > unit, status_point_type st_type, int32_t base=0, int32_t equip=0, int32_t status=0)
Definition: Attribute.hpp:239
bool needs_recalculation() const
Definition: Attribute.hpp:409
std::weak_ptr< Unit > _unit
Definition: Attribute.hpp:423
TT operator+(TT right)
Definition: Attribute.hpp:294
void reset()
Definition: Attribute.hpp:397
virtual int32_t get_status() const
Definition: Attribute.hpp:287
TemporaryChanges _temporary_changes
Definition: Attribute.hpp:425
void remove_periodic_change(std::string source)
Definition: Attribute.hpp:372
void remove_permanent_change(std::string source)
Definition: Attribute.hpp:352
void unit(std::shared_ptr< Unit > e)
Definition: Attribute.hpp:260
virtual void add_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:252
PeriodicChanges _periodic_changes
Definition: Attribute.hpp:426
void notify()
Definition: Attribute.cpp:269
void recalculate(bool flag)
Definition: Attribute.hpp:410
status_point_type _status_point_type
Definition: Attribute.hpp:415
bool operator<=(TT right)
Definition: Attribute.hpp:318
int32_t _equip_val
Definition: Attribute.hpp:417
int32_t _status_val
Definition: Attribute.hpp:418
bool _apply_periodic_changes
Definition: Attribute.hpp:419
Attribute(Attribute &&other) noexcept
Definition: Attribute.hpp:253
bool operator==(TT right)
Definition: Attribute.hpp:308
PermanentChanges _permanent_changes
Definition: Attribute.hpp:424
void apply(bool notify=true)
Definition: Attribute.hpp:385
bool operator!=(TT right)
Definition: Attribute.hpp:310
void add_permanent_change(s_attribute_change_values change, std::string source)
Definition: Attribute.hpp:347
virtual int32_t get_base() const
Definition: Attribute.hpp:269
bool operator>=(TT right)
Definition: Attribute.hpp:314
void add_periodic_change(s_attribute_change_values change, uint64_t duration, uint64_t interval, std::string source)
Definition: Attribute.hpp:367
virtual void add_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:260
status_point_type get_type() const
Definition: Attribute.hpp:407
bool is_compute_ready() const
Definition: Attribute.hpp:412
virtual int32_t total() const
Definition: Attribute.hpp:289
Definition: Attribute.hpp:207
PeriodicChanges(Attribute *attr)
Definition: Attribute.hpp:209
void add_change(s_attribute_change_values change, uint64_t duration, uint64_t interval, std::string source)
Definition: Attribute.cpp:145
void update(uint64_t delta)
Definition: Attribute.cpp:155
Attribute * _attr
Definition: Attribute.hpp:229
void remove_change(std::string source)
Definition: Attribute.cpp:150
std::vector< s_periodic_change > _changes
Definition: Attribute.hpp:228
Definition: Attribute.hpp:159
PermanentChanges(Attribute *attr)
Definition: Attribute.hpp:161
std::vector< s_permanent_change > _changes
Definition: Attribute.hpp:176
Attribute * _attr
Definition: Attribute.hpp:177
void add_change(s_attribute_change_values change, std::string source)
Definition: Attribute.cpp:70
void apply(bool notify=true)
Definition: Attribute.cpp:80
void remove_change(std::string source)
Definition: Attribute.cpp:75
Definition: Attribute.hpp:181
TemporaryChanges(Attribute *attr)
Definition: Attribute.hpp:183
void remove_change(std::string source)
Definition: Attribute.cpp:106
void update(uint64_t delta)
Definition: Attribute.cpp:132
void apply(bool notify=true)
Definition: Attribute.cpp:111
Attribute * _attr
Definition: Attribute.hpp:203
std::vector< s_temporary_change > _changes
Definition: Attribute.hpp:202
void add_change(s_attribute_change_values change, uint64_t duration, std::string source)
Definition: Attribute.cpp:101
Definition: Attribute.hpp:93
Attribute * get_attribute()
Definition: Attribute.hpp:102
ApplyLiveAttribute(Attribute *attr)
Definition: Attribute.hpp:95
Attribute * _attr
Definition: Attribute.hpp:105
bool is_valid()
Definition: Attribute.hpp:100
void update_with_live_attribute(s_attribute_change_values *change)
Definition: Attribute.cpp:45
Definition: ReferenceListTest.cpp:114
Definition: Element.hpp:7
Definition: Attribute.hpp:212
std::chrono::high_resolution_clock::time_point last_update
Definition: Attribute.hpp:217
s_attribute_change_values change
Definition: Attribute.hpp:213
std::string source
Definition: Attribute.hpp:216
std::chrono::high_resolution_clock::time_point start_time
Definition: Attribute.hpp:218
uint64_t duration
Definition: Attribute.hpp:214
uint64_t interval
Definition: Attribute.hpp:215
Definition: Attribute.hpp:164
std::string source
Definition: Attribute.hpp:166
s_attribute_change_values change
Definition: Attribute.hpp:165
Definition: Attribute.hpp:186
s_attribute_change_values change
Definition: Attribute.hpp:187
std::string source
Definition: Attribute.hpp:189
uint64_t duration
Definition: Attribute.hpp:188
std::chrono::high_resolution_clock::time_point start_time
Definition: Attribute.hpp:190
Definition: Attribute.hpp:79
Attribute * _attr
Definition: Attribute.hpp:90
s_attribute_min_max(int32_t min, int32_t max)
Definition: Attribute.hpp:80
void update_with_live_attribute()
Definition: Attribute.cpp:60
bool is_valid()
Definition: Attribute.hpp:87
s_attribute_min_max()=default
Definition: Attribute.hpp:77
s_attribute_change_values(ApplyLiveAttribute apply_live_attribute, s_attribute_min_max minmax=s_attribute_min_max(0, 0), std::function< void(s_attribute_change_values &)> client_notify_function=nullptr)
Definition: Attribute.hpp:118
int32_t equip
Definition: Attribute.hpp:109
int32_t status
Definition: Attribute.hpp:110
void set_equip(int32_t val)
Definition: Attribute.hpp:127
int32_t get_min()
Definition: Attribute.hpp:135
int32_t get_status() const
Definition: Attribute.hpp:129
void set_max(int32_t val)
Definition: Attribute.hpp:133
void set_min(int32_t val)
Definition: Attribute.hpp:136
ApplyLiveAttribute apply_live_attribute
Definition: Attribute.hpp:112
int32_t get_equip() const
Definition: Attribute.hpp:126
s_attribute_change_values(Attribute *attr, s_attribute_min_max minmax=s_attribute_min_max(0, 0), std::function< void(s_attribute_change_values &)> client_notify_function=nullptr)
Definition: Attribute.hpp:120
void set_status(int32_t val)
Definition: Attribute.hpp:130
int32_t get_base() const
Definition: Attribute.hpp:123
void set_live_attribute(Attribute *attr)
Definition: Attribute.hpp:149
int32_t get_max()
Definition: Attribute.hpp:132
void set_client_notify_function(std::function< void(s_attribute_change_values &)> func)
Definition: Attribute.hpp:155
ApplyLiveAttribute get_live_attribute()
Definition: Attribute.hpp:148
s_attribute_min_max minmax
Definition: Attribute.hpp:111
s_attribute_change_values(int32_t base, int32_t equip=0, int32_t status=0, s_attribute_min_max minmax=s_attribute_min_max(0, 0), std::function< void(s_attribute_change_values &)> client_notify_function=nullptr)
Definition: Attribute.hpp:116
int32_t base
Definition: Attribute.hpp:108
void set_base(int32_t val)
Definition: Attribute.hpp:124
void update_with_live_attribute()
Definition: Attribute.hpp:138
s_attribute_change_values()=default
std::function< void(s_attribute_change_values &)> client_notify_function
Definition: Attribute.hpp:113
std::function< void(s_attribute_change_values &)> get_client_notify_function()
Definition: Attribute.hpp:154
Definition: Horizon.hpp:84
int max
Definition: Horizon.hpp:94
void set_min(int min)
Definition: Horizon.hpp:87
int min
Definition: Horizon.hpp:93
int get_max()
Definition: Horizon.hpp:91
int get_min()
Definition: Horizon.hpp:90
void set_max(int max)
Definition: Horizon.hpp:88