1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-12 21:47:45 +00:00
sapphire/src/world/Actor/Actor.h

142 lines
3.1 KiB
C
Raw Normal View History

#ifndef _GAME_OBJECT_H_
#define _GAME_OBJECT_H_
2017-08-08 13:53:47 +02:00
2018-03-06 22:22:19 +01:00
#include <Common.h>
2018-10-25 12:44:51 +11:00
#include <memory>
2017-08-08 13:53:47 +02:00
#include "ForwardsZone.h"
2017-08-08 13:53:47 +02:00
#include <set>
#include <map>
#include <queue>
2017-08-08 13:53:47 +02:00
namespace Sapphire::Entity
2018-10-28 21:53:21 +01:00
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
/*!
\class GameObject
\brief Base class for all actor/objects
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
*/
class Actor : public std::enable_shared_from_this< Actor >
{
2018-10-28 21:53:21 +01:00
protected:
/*! Position of the object */
Common::FFXIVARR_POSITION3 m_pos;
/*! Rotation of the object */
float m_rot;
/*! Id of the actor */
uint32_t m_id;
/*! Type of the actor */
Common::ObjKind m_objKind;
/*! Id of the zone the actor currently is in */
uint32_t m_territoryTypeId;
2018-10-28 21:53:21 +01:00
/*! Ptr to the ZoneObj the actor belongs to */
ZonePtr m_pCurrentZone;
2018-10-28 21:53:21 +01:00
/*! list of various actors in range */
std::set< ActorPtr > m_inRangeActor;
std::set< PlayerPtr > m_inRangePlayers;
std::set< BNpcPtr > m_inRangeBNpc;
2018-10-28 21:53:21 +01:00
/*! Parent cell in the zone */
Sapphire::Cell* m_pCell;
2018-10-28 21:53:21 +01:00
public:
explicit Actor( Common::ObjKind type );
2018-10-28 21:53:21 +01:00
virtual ~Actor() {};
2018-10-28 21:53:21 +01:00
virtual void spawn( PlayerPtr pTarget ) {}
2018-10-28 21:53:21 +01:00
virtual void despawn( PlayerPtr pTarget ) {}
2018-10-28 21:53:21 +01:00
uint32_t getId() const;
2018-10-28 21:53:21 +01:00
void setId( uint32_t id );
2018-10-28 21:53:21 +01:00
Common::ObjKind getObjKind() const;
2018-10-28 21:53:21 +01:00
Common::FFXIVARR_POSITION3& getPos();
void setPos( const Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate = true );
void setPos( float x, float y, float z, bool broadcastUpdate = true );
2018-10-28 21:53:21 +01:00
float getRot() const;
2018-10-28 21:53:21 +01:00
void setRot( float rot );
2018-10-28 21:53:21 +01:00
bool isChara() const;
2018-10-28 21:53:21 +01:00
bool isPlayer() const;
2018-10-28 21:53:21 +01:00
bool isEventNpc() const;
2018-10-28 21:53:21 +01:00
bool isBattleNpc() const;
2018-10-28 21:53:21 +01:00
bool isRetainer() const;
2018-10-28 21:53:21 +01:00
bool isCompanion() const;
2018-10-28 21:53:21 +01:00
bool isEventObj() const;
2018-10-28 21:53:21 +01:00
bool isHousingEventObj() const;
2018-10-28 21:53:21 +01:00
bool isAetheryte() const;
2018-10-28 21:53:21 +01:00
///// IN RANGE LOGIC ///////////////////////////////
virtual void onRemoveInRangeActor( Actor& pActor ) {}
2018-10-28 21:53:21 +01:00
// check if another actor is in the actors in range set
bool isInRangeSet( ActorPtr pActor ) const;
CharaPtr getClosestChara();
2018-10-28 21:53:21 +01:00
void sendToInRangeSet( Network::Packets::FFXIVPacketBasePtr pPacket, bool bToSelf = false );
2018-10-28 21:53:21 +01:00
// add an actor to in range set
void addInRangeActor( ActorPtr pActor );
2018-10-28 21:53:21 +01:00
// remove an actor from the in range set
void removeInRangeActor( Actor& actor );
2018-10-28 21:53:21 +01:00
// return true if there is at least one actor in the in range set
bool hasInRangeActor() const;
2018-10-28 21:53:21 +01:00
void removeFromInRange();
2018-10-28 21:53:21 +01:00
// clear the whole in range set, this does no cleanup
virtual void clearInRangeSet();
2018-10-28 21:53:21 +01:00
std::set< ActorPtr > getInRangeActors( bool includeSelf = false );
2018-10-28 21:53:21 +01:00
////////////////////////////////////////////////////
2018-10-28 21:53:21 +01:00
CharaPtr getAsChara();
2018-10-28 21:53:21 +01:00
PlayerPtr getAsPlayer();
2018-10-28 21:53:21 +01:00
EventObjectPtr getAsEventObj();
2018-10-28 21:53:21 +01:00
BNpcPtr getAsBNpc();
2018-10-28 21:53:21 +01:00
ZonePtr getCurrentZone() const;
2018-10-28 21:53:21 +01:00
void setCurrentZone( ZonePtr currZone );
2018-10-28 21:53:21 +01:00
InstanceContentPtr getCurrentInstance() const;
QuestBattlePtr getCurrentQuestBattle() const;
2018-10-28 21:53:21 +01:00
// get the current cell of a region the actor is in
Cell* getCellPtr();
2018-10-28 21:53:21 +01:00
// set the current cell
void setCell( Cell* pCell );
2018-10-28 21:53:21 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif