2018-02-20 22:46:44 +01:00
|
|
|
#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
|
|
|
|
2018-09-09 23:56:22 +02:00
|
|
|
#include "ForwardsZone.h"
|
2017-08-08 13:53:47 +02:00
|
|
|
#include <set>
|
|
|
|
#include <map>
|
2017-12-05 11:21:56 +01:00
|
|
|
#include <queue>
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-11-29 16:55:48 +01: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-02-28 10:26:03 +01:00
|
|
|
|
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 */
|
2018-12-02 15:32:22 +11:00
|
|
|
uint32_t m_territoryTypeId;
|
2018-10-28 21:53:21 +01:00
|
|
|
/*! Ptr to the ZoneObj the actor belongs to */
|
|
|
|
ZonePtr m_pCurrentZone;
|
2018-02-20 22:46:44 +01:00
|
|
|
|
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-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
/*! Parent cell in the zone */
|
2018-11-29 16:55:48 +01:00
|
|
|
Sapphire::Cell* m_pCell;
|
2018-02-22 18:12:36 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
public:
|
|
|
|
explicit Actor( Common::ObjKind type );
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
virtual ~Actor() {};
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
virtual void spawn( PlayerPtr pTarget ) {}
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
virtual void despawn( PlayerPtr pTarget ) {}
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
uint32_t getId() const;
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void setId( uint32_t id );
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
Common::ObjKind getObjKind() const;
|
2018-02-20 22:46:44 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
Common::FFXIVARR_POSITION3& getPos();
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2019-02-01 00:04:19 +11:00
|
|
|
void setPos( const Common::FFXIVARR_POSITION3& pos, bool broadcastUpdate = true );
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2019-02-01 00:04:19 +11:00
|
|
|
void setPos( float x, float y, float z, bool broadcastUpdate = true );
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
float getRot() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void setRot( float rot );
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isChara() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isPlayer() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isEventNpc() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isBattleNpc() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isRetainer() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isCompanion() const;
|
2018-02-22 15:31:10 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isEventObj() const;
|
2018-02-22 18:12:36 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isHousingEventObj() const;
|
2018-02-22 18:12:36 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
bool isAetheryte() const;
|
2018-02-25 17:23:52 +11:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
///// IN RANGE LOGIC ///////////////////////////////
|
|
|
|
virtual void onRemoveInRangeActor( Actor& pActor ) {}
|
2018-02-22 18:12:36 +01:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
// check if another actor is in the actors in range set
|
|
|
|
bool isInRangeSet( ActorPtr pActor ) const;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-01-17 23:54:47 +01:00
|
|
|
CharaPtr getClosestChara();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void sendToInRangeSet( Network::Packets::FFXIVPacketBasePtr pPacket, bool bToSelf = false );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
// add an actor to in range set
|
|
|
|
void addInRangeActor( ActorPtr pActor );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
// remove an actor from the in range set
|
|
|
|
void removeInRangeActor( Actor& actor );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
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-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void removeFromInRange();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
// clear the whole in range set, this does no cleanup
|
|
|
|
virtual void clearInRangeSet();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
std::set< ActorPtr > getInRangeActors( bool includeSelf = false );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
////////////////////////////////////////////////////
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
CharaPtr getAsChara();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
PlayerPtr getAsPlayer();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
EventObjectPtr getAsEventObj();
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
BNpcPtr getAsBNpc();
|
2018-09-09 23:56:22 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
ZonePtr getCurrentZone() const;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
void setCurrentZone( ZonePtr currZone );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
InstanceContentPtr getCurrentInstance() const;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2019-03-31 23:45:03 +02:00
|
|
|
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-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
// set the current cell
|
|
|
|
void setCell( Cell* pCell );
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
};
|
2017-08-08 13:53:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|