Horizon Official Technical Documentation
Horizon::Zone::Traits::PermanentChanges Class Reference

#include <Attribute.hpp>

+ Collaboration diagram for Horizon::Zone::Traits::PermanentChanges:

Classes

struct  s_permanent_change
 

Public Member Functions

 PermanentChanges (Attribute *attr)
 
void add_change (s_attribute_change_values change, std::string source)
 
void remove_change (std::string source)
 
void apply (bool notify=true)
 

Private Attributes

std::vector< s_permanent_change_changes
 
Attribute_attr
 

Constructor & Destructor Documentation

◆ PermanentChanges()

Horizon::Zone::Traits::PermanentChanges::PermanentChanges ( Attribute attr)
inline
161: _attr(attr) {}
Attribute * _attr
Definition: Attribute.hpp:177

Member Function Documentation

◆ add_change()

void PermanentChanges::add_change ( s_attribute_change_values  change,
std::string  source 
)
71{
72 _changes.push_back({ change, source });
73}
std::vector< s_permanent_change > _changes
Definition: Attribute.hpp:176

Referenced by Horizon::Zone::Traits::Attribute::add_permanent_change().

+ Here is the caller graph for this function:

◆ apply()

void PermanentChanges::apply ( bool  notify = true)
81{
82 for (auto &change : _changes)
83 {
84 if (change.change.get_base() > 0)
85 _attr->add_base(change.change.get_base(), notify);
86 else
87 _attr->sub_base(change.change.get_base(), notify);
88
89 if (change.change.get_equip() > 0)
90 _attr->add_equip(change.change.get_equip(), notify);
91 else
92 _attr->sub_equip(change.change.get_equip(), notify);
93
94 if (change.change.get_status() > 0)
95 _attr->add_status(change.change.get_status(), notify);
96 else
97 _attr->sub_status(change.change.get_status(), notify);
98 }
99}
virtual void sub_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:256
virtual void sub_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:264
virtual void add_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:244
virtual void sub_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:248
virtual void add_equip(int32_t val, bool notify=true)
Definition: Attribute.cpp:252
virtual void add_status(int32_t val, bool notify=true)
Definition: Attribute.cpp:260

Referenced by Horizon::Zone::Traits::Attribute::apply().

+ Here is the caller graph for this function:

◆ remove_change()

void PermanentChanges::remove_change ( std::string  source)
76{
77 _changes.erase(std::remove_if(_changes.begin(), _changes.end(), [source](s_permanent_change const &change) { return change.source == source; }), _changes.end());
78}

Referenced by Horizon::Zone::Traits::Attribute::remove_permanent_change().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _attr

Attribute* Horizon::Zone::Traits::PermanentChanges::_attr
private

◆ _changes

std::vector<s_permanent_change> Horizon::Zone::Traits::PermanentChanges::_changes
private

The documentation for this class was generated from the following files: