Horizon Official Technical Documentation
GridUnitExistenceNotifier Struct Reference

#include <GridNotifiers.hpp>

Public Member Functions

 GridUnitExistenceNotifier (const std::shared_ptr< Horizon::Zone::Unit > &unit, unit_viewport_notification_type notif_type)
 
template<class T >
void notify (GridRefManager< T > &m)
 
void Visit (GridRefManager< unit_ns(Player)> &m)
 
template<class NOT_INTERESTED >
void Visit (GridRefManager< NOT_INTERESTED > &)
 
template<>
void Visit (GridRefManager< NPC > &m)
 
template<>
void Visit (GridRefManager< Elemental > &m)
 
template<>
void Visit (GridRefManager< Homunculus > &m)
 
template<>
void Visit (GridRefManager< Mercenary > &m)
 
template<>
void Visit (GridRefManager< Pet > &m)
 
template<>
void Visit (GridRefManager< Monster > &m)
 
template<>
void Visit (GridRefManager< Skill > &m)
 
template<>
void Visit (GridRefManager< Item > &m)
 

Public Attributes

std::weak_ptr< Horizon::Zone::Unit_unit
 
unit_viewport_notification_type _notif_type
 

Constructor & Destructor Documentation

◆ GridUnitExistenceNotifier()

GridUnitExistenceNotifier::GridUnitExistenceNotifier ( const std::shared_ptr< Horizon::Zone::Unit > &  unit,
unit_viewport_notification_type  notif_type 
)
inlineexplicit
69 : _unit(unit), _notif_type(notif_type)
70 { }
unit_viewport_notification_type _notif_type
Definition: GridNotifiers.hpp:66
std::weak_ptr< Horizon::Zone::Unit > _unit
Definition: GridNotifiers.hpp:65

Member Function Documentation

◆ notify()

template<class T >
void GridUnitExistenceNotifier::notify ( GridRefManager< T > &  m)
121{
122 using namespace Horizon::Zone::Units;
123
124 if (!m.get_size())
125 return;
126
127 std::shared_ptr<Horizon::Zone::Unit> src_unit = _unit.lock();
128
129 for (typename GridRefManager<T>::iterator iter = m.begin(); iter != typename GridRefManager<T>::iterator(nullptr); ++iter) {
130 if (iter->source() == nullptr)
131 continue;
132
133 std::shared_ptr<Player> tpl = iter->source()->template downcast<Player>();
134
135 if (src_unit == nullptr || src_unit->guid() == tpl->guid())
136 continue;
137
138 if (tpl->get_session() == nullptr || tpl->get_session()->clif() == nullptr)
139 continue;
140
141 bool is_in_range = tpl->is_in_range_of(src_unit);
142
143 if (_notif_type == EVP_NOTIFY_IN_SIGHT && is_in_range) {
144 if (tpl->unit_is_in_viewport(src_unit))
145 continue;
146 // Target player realizes new unit in viewport.
147 // Source unit doesn't need to realize target as update_viewport() is called when needed/
148 tpl->add_unit_to_viewport(src_unit);
149 } else if (_notif_type == EVP_NOTIFY_OUT_OF_SIGHT && !is_in_range) {
150 if (!tpl->unit_is_in_viewport(src_unit))
151 continue;
152
153 tpl->remove_unit_from_viewport(src_unit, EVP_NOTIFY_OUT_OF_SIGHT);
154 }
156 if (!tpl->unit_is_in_viewport(src_unit))
157 continue;
158
159 tpl->remove_unit_from_viewport(src_unit, _notif_type);
160 }
161 }
162}
@ EVP_NOTIFY_IN_SIGHT
Definition: UnitDefinitions.hpp:837
@ EVP_NOTIFY_OUT_OF_SIGHT
Definition: UnitDefinitions.hpp:838
Forward declaration of GridRefManager, the class that manages GridReference.
Definition: GridRefManager.hpp:41
iterator begin()
Definition: GridRefManager.hpp:54
uint32_t get_size() const
returns the number of Elements in the list (not including the head and tail Elements or the first and...
Definition: Head.hpp:69
Definition: GameLogicProcess.hpp:43

References _notif_type, _unit, GridRefManager< OBJECT >::begin(), EVP_NOTIFY_IN_SIGHT, EVP_NOTIFY_OUT_OF_SIGHT, and Horizon::Structures::LinkedList::Head::get_size().

+ Here is the call graph for this function:

◆ Visit() [1/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Elemental > &  m)

◆ Visit() [2/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Homunculus > &  m)

◆ Visit() [3/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Item > &  m)

◆ Visit() [4/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Mercenary > &  m)

◆ Visit() [5/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Monster > &  m)

◆ Visit() [6/10]

template<class NOT_INTERESTED >
void GridUnitExistenceNotifier::Visit ( GridRefManager< NOT_INTERESTED > &  )
inline
78{ }

◆ Visit() [7/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< NPC > &  m)

◆ Visit() [8/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Pet > &  m)

◆ Visit() [9/10]

template<>
void GridUnitExistenceNotifier::Visit ( GridRefManager< Skill > &  m)

◆ Visit() [10/10]

void GridUnitExistenceNotifier::Visit ( GridRefManager< unit_ns(Player)> &  m)

Member Data Documentation

◆ _notif_type

unit_viewport_notification_type GridUnitExistenceNotifier::_notif_type

Referenced by notify().

◆ _unit

std::weak_ptr<Horizon::Zone::Unit> GridUnitExistenceNotifier::_unit

Referenced by notify().


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