DarkflameServer/dGame/Player.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

137 lines
3.0 KiB
C
Raw Normal View History

#pragma once
#include "Entity.h"
/**
* Extended Entity for player data and behavior.
*
* Contains properties only a player entity would require, like associated SystemAddress and User.
*
* Keeps track of which entities are observed by this user for ghosting.
*/
class Player final : public Entity
{
public:
explicit Player(const LWOOBJID& objectID, EntityInfo info, User* user, Entity* parentEntity = nullptr);
2022-07-28 13:39:57 +00:00
/**
* Getters
*/
User* GetParentUser() const override;
2022-07-28 13:39:57 +00:00
SystemAddress GetSystemAddress() const override;
2022-07-28 13:39:57 +00:00
NiPoint3 GetRespawnPosition() const override;
2022-07-28 13:39:57 +00:00
NiQuaternion GetRespawnRotation() const override;
const NiPoint3& GetGhostReferencePoint() const;
const NiPoint3& GetOriginGhostReferencePoint() const;
const NiPoint3& GetGhostOverridePoint() const;
bool GetGhostOverride() const;
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
2021-12-11 13:21:00 +00:00
uint64_t GetDroppedCoins();
/**
* Setters
*/
2022-07-28 13:39:57 +00:00
void SetSystemAddress(const SystemAddress& value) override;
2022-07-28 13:39:57 +00:00
void SetRespawnPos(NiPoint3 position) override;
2022-07-28 13:39:57 +00:00
void SetRespawnRot(NiQuaternion rotation) override;
void SetGhostReferencePoint(const NiPoint3& value);
void SetGhostOverridePoint(const NiPoint3& value);
void SetGhostOverride(bool value);
2021-12-11 13:21:00 +00:00
void SetDroppedCoins(uint64_t value);
/**
* Wrapper for sending an in-game mail.
*
* @param sender id of the sender. LWOOBJID_EMPTY for system mail
* @param senderName name of the sender. Max 32 characters.
* @param subject mail subject. Max 50 characters.
* @param body mail body. Max 400 characters.
* @param attachment LOT of the attached item. LOT_NULL if no attachment.
* @param attachmentCount stack size for attachment.
*/
void SendMail(LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const;
2022-07-28 13:39:57 +00:00
/**
* Wrapper for transfering the player to another instance.
*
* @param zoneId zoneID for the new instance.
* @param cloneId cloneID for the new instance.
*/
void SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId = 0);
/**
* Ghosting
*/
void AddLimboConstruction(LWOOBJID objectId);
2022-07-28 13:39:57 +00:00
void RemoveLimboConstruction(LWOOBJID objectId);
void ConstructLimboEntities();
void ObserveEntity(int32_t id);
bool IsObserved(int32_t id);
void GhostEntity(int32_t id);
/**
* Static methods
*/
static Player* GetPlayer(const SystemAddress& sysAddr);
static Player* GetPlayer(const std::string& name);
2022-07-28 13:39:57 +00:00
static Player* GetPlayer(LWOOBJID playerID);
static const std::vector<Player*>& GetAllPlayers();
2022-07-28 13:39:57 +00:00
~Player() override;
private:
SystemAddress m_SystemAddress;
2022-07-28 13:39:57 +00:00
NiPoint3 m_respawnPos;
2022-07-28 13:39:57 +00:00
NiQuaternion m_respawnRot;
2022-07-28 13:39:57 +00:00
User* m_ParentUser;
NiPoint3 m_GhostReferencePoint;
NiPoint3 m_GhostOverridePoint;
bool m_GhostOverride;
std::vector<int32_t> m_ObservedEntities;
2022-07-28 13:39:57 +00:00
int32_t m_ObservedEntitiesLength;
int32_t m_ObservedEntitiesUsed;
std::vector<LWOOBJID> m_LimboConstructions;
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
2021-12-11 13:21:00 +00:00
uint64_t m_DroppedCoins;
static std::vector<Player*> m_Players;
};