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

#include <AttributesImpl.hpp>

+ Inheritance diagram for Horizon::Zone::Traits::SPRegeneration:
+ Collaboration diagram for Horizon::Zone::Traits::SPRegeneration:

Public Member Functions

 SPRegeneration (std::weak_ptr< Unit > unit)
 
 ~SPRegeneration ()
 
void on_observable_changed (Intelligence *)
 
void on_observable_changed (MaxSP *)
 
int32_t compute ()
 
void set_intelligence (Intelligence *int_)
 
void set_max_sp (MaxSP *msp)
 
- Public Member Functions inherited from Horizon::Zone::Traits::Attribute
 Attribute ()=default
 
 Attribute (std::weak_ptr< Unit > unit, status_point_type st_type, int32_t base=0, int32_t equip=0, int32_t status=0)
 
 Attribute (const Attribute &other)
 
 Attribute (Attribute &&other) noexcept
 
std::shared_ptr< Unitunit ()
 
void unit (std::shared_ptr< Unit > e)
 
virtual void set_base (int32_t val, bool notify=true)
 
virtual void add_base (int32_t val, bool notify=true)
 
virtual void sub_base (int32_t val, bool notify=true)
 
virtual int32_t get_base () const
 
virtual void set_equip (int32_t val, bool notify=true)
 
virtual void add_equip (int32_t val, bool notify=true)
 
virtual void sub_equip (int32_t val, bool notify=true)
 
virtual int32_t get_equip () const
 
virtual void set_status (int32_t val, bool notify=true)
 
virtual void add_status (int32_t val, bool notify=true)
 
virtual void sub_status (int32_t val, bool notify=true)
 
virtual int32_t get_status () const
 
virtual int32_t total () const
 
virtual int32_t compute ()
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator+ (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator/ (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator* (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
TT operator- (TT right)
 
int operator+ (Attribute const &right) const
 
double operator/ (Attribute const &right)
 
double operator* (Attribute const &right)
 
int operator- (Attribute const &right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator== (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator!= (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator> (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator>= (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator< (TT right)
 
template<typename TT , typename std::enable_if< std::is_integral< TT >::value >::type * = nullptr>
bool operator<= (TT right)
 
bool operator== (Attribute const &right)
 
bool operator!= (Attribute const &right)
 
bool operator> (Attribute const &right)
 
bool operator>= (Attribute const &right)
 
bool operator< (Attribute const &right)
 
bool operator<= (Attribute const &right)
 
Attribute operator= (Attribute &right)
 
Attribute operator= (Attribute &&right)
 
void add_permanent_change (s_attribute_change_values change, std::string source)
 
void remove_permanent_change (std::string source)
 
void add_temporary_change (s_attribute_change_values change, uint64_t duration, std::string source)
 
void remove_temporary_change (std::string source)
 
void add_periodic_change (s_attribute_change_values change, uint64_t duration, uint64_t interval, std::string source)
 
void remove_periodic_change (std::string source)
 
void update (uint64_t delta)
 
void apply (bool notify=true)
 
void reset ()
 
void notify ()
 
status_point_type get_type () const
 
bool needs_recalculation () const
 
void recalculate (bool flag)
 
bool is_compute_ready () const
 

Private Attributes

Intelligence_int {nullptr}
 
MaxSP_max_sp {nullptr}
 

Additional Inherited Members

- Protected Attributes inherited from Horizon::Zone::Traits::Attribute
status_point_type _status_point_type {status_point_type::STATUS_POINT_INVALID}
 
int32_t _base_val {0}
 
int32_t _equip_val {0}
 
int32_t _status_val {0}
 
bool _apply_periodic_changes {false}
 
bool _recalculate_flag {false}
 
bool _calculate_ready {false}
 

Constructor & Destructor Documentation

◆ SPRegeneration()

Horizon::Zone::Traits::SPRegeneration::SPRegeneration ( std::weak_ptr< Unit unit)
inline
1440 { }
@ STATUS_SP_REGEN
Definition: UnitDefinitions.hpp:444
std::shared_ptr< Unit > unit()
Definition: Attribute.hpp:259

◆ ~SPRegeneration()

Horizon::Zone::Traits::SPRegeneration::~SPRegeneration ( )
inline
1441{ }

Member Function Documentation

◆ compute()

int32_t SPRegeneration::compute ( )
virtual

Reimplemented from Horizon::Zone::Traits::Attribute.

893{
894 if (unit()->type() == UNIT_PLAYER) {
895 int int_ = _int->total();
896 int max_sp = _max_sp->total();
897 set_base(1 + (int_/6) + (max_sp/100));
898 if (int_ >= 120)
899 add_base(((int_ - 120) >> 1) + 4);
900 }
901
902 return total();
903}
@ UNIT_PLAYER
Definition: UnitDefinitions.hpp:45
virtual void set_base(int32_t val, bool notify=true)
Definition: Attribute.hpp:262
virtual void add_base(int32_t val, bool notify=true)
Definition: Attribute.cpp:244
virtual int32_t total() const
Definition: Attribute.hpp:289
MaxSP * _max_sp
Definition: AttributesImpl.hpp:1453
Intelligence * _int
Definition: AttributesImpl.hpp:1452

References Horizon::Zone::Traits::s_attribute_change_values::set_base(), and UNIT_PLAYER.

Referenced by on_observable_changed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ on_observable_changed() [1/2]

void Horizon::Zone::Traits::SPRegeneration::on_observable_changed ( Intelligence )
inline
1443{ if (is_compute_ready()) compute(); }
bool is_compute_ready() const
Definition: Attribute.hpp:412
int32_t compute()
Definition: Attribute.cpp:892

References compute(), and Horizon::Zone::Traits::Attribute::is_compute_ready().

+ Here is the call graph for this function:

◆ on_observable_changed() [2/2]

void Horizon::Zone::Traits::SPRegeneration::on_observable_changed ( MaxSP )
inline
1444{ if (is_compute_ready()) compute(); }

References compute(), and Horizon::Zone::Traits::Attribute::is_compute_ready().

+ Here is the call graph for this function:

◆ set_intelligence()

void Horizon::Zone::Traits::SPRegeneration::set_intelligence ( Intelligence int_)
inline
1448{ _int = int_; }

References _int.

◆ set_max_sp()

void Horizon::Zone::Traits::SPRegeneration::set_max_sp ( MaxSP msp)
inline
1449{ _max_sp = msp; }

References _max_sp.

Member Data Documentation

◆ _int

Intelligence* Horizon::Zone::Traits::SPRegeneration::_int {nullptr}
private

Referenced by set_intelligence().

◆ _max_sp

MaxSP* Horizon::Zone::Traits::SPRegeneration::_max_sp {nullptr}
private

Referenced by set_max_sp().


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