1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00

ActorFilters now functional

This commit is contained in:
mordred 2019-04-05 13:15:14 +02:00
parent ec691c5499
commit 127d969eec
4 changed files with 16 additions and 10 deletions

View file

@ -54,6 +54,11 @@ Sapphire::Common::FFXIVARR_POSITION3& Sapphire::Entity::Actor::getPos()
return m_pos; return m_pos;
} }
const Sapphire::Common::FFXIVARR_POSITION3& Sapphire::Entity::Actor::getPos() const
{
return m_pos;
}
void Sapphire::Entity::Actor::setPos( float x, float y, float z, bool broadcastUpdate ) void Sapphire::Entity::Actor::setPos( float x, float y, float z, bool broadcastUpdate )
{ {
m_pos.x = x; m_pos.x = x;

View file

@ -58,6 +58,7 @@ namespace Sapphire::Entity
Common::ObjKind getObjKind() const; Common::ObjKind getObjKind() const;
Common::FFXIVARR_POSITION3& getPos(); Common::FFXIVARR_POSITION3& getPos();
const Common::FFXIVARR_POSITION3& getPos() const;
void setPos( const Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate = true ); void setPos( const Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate = true );

View file

@ -20,6 +20,7 @@ file( GLOB SERVER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
StatusEffect/*.c* StatusEffect/*.c*
Territory/*.c* Territory/*.c*
Territory/Housing/*.c* Territory/Housing/*.c*
Util/*.c*
Navi/*.c*) Navi/*.c*)
add_executable( world ${SERVER_SOURCE_FILES} ) add_executable( world ${SERVER_SOURCE_FILES} )

View file

@ -15,21 +15,18 @@ namespace Sapphire::World::Util
public: public:
ActorFilter() = default; ActorFilter() = default;
virtual ~ActorFilter() = default; virtual ~ActorFilter() = default;
virtual bool conditionApplies( const Entity::Actor& actor ); virtual bool conditionApplies( const Entity::Actor& actor ) = 0;
}; };
/////////////////////////////////////////////////////////////////////////////
class ActorFilterInRange : public ActorFilter class ActorFilterInRange : public ActorFilter
{ {
FFXIVARR_POSITION3 m_startPos; Common::FFXIVARR_POSITION3 m_startPos;
float m_range; float m_range;
public: public:
ActorFilterInRange( FFXIVARR_POSITION3 startPos, float range ) : m_startPos( startPos ), m_range( range ); ActorFilterInRange( Common::FFXIVARR_POSITION3 startPos, float range );
bool conditionApplies( const Entity::Actor& actor ) override;
bool conditionApplies( const Entity::Actor& actor ) override
{
return Util::distance( m_startPos.x, m_startPos.y, m_startPos.z,
actor.getPos().x, actor.getPos().y, actor.getPos().z ) <= m_range;
}
}; };
// usage in psudocode // usage in psudocode
@ -45,3 +42,5 @@ namespace Sapphire::World::Util
// return resultSet; // return resultSet;
// //
} }
#endif