chore: Simplify and move Player functionality to relevant component (#1408)

* Moving and organizing Player code

- Move code to CharacterComponent
- Remove extraneous interfaces
- Simplify some code greatly
- Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.)
- Update code to use CharacterComponent for sending to zone instead of Player*.

* Moving and organizing Player code

- Move code to CharacterComponent
- Remove extraneous interfaces
- Simplify some code greatly
- Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.)
- Update code to use CharacterComponent for sending to zone instead of Player*.
- Remove static storage container (static containers can be destroyed before exit/terminate handler executes)

* remove player cast

* Remove extra includes
This commit is contained in:
David Markowitz
2024-01-12 09:39:51 -08:00
committed by GitHub
parent 66cc582a9a
commit 929d029f12
15 changed files with 200 additions and 305 deletions

View File

@@ -18,64 +18,44 @@ public:
* Getters
*/
User* GetParentUser() const override;
User* GetParentUser() const override { return m_ParentUser; };
SystemAddress GetSystemAddress() const override;
const SystemAddress& GetSystemAddress() const override { return m_SystemAddress; };
NiPoint3 GetRespawnPosition() const override;
const NiPoint3& GetRespawnPosition() const override { return m_respawnPos; };
NiQuaternion GetRespawnRotation() const override;
const NiQuaternion& GetRespawnRotation() const override { return m_respawnRot; };
const NiPoint3& GetGhostReferencePoint() const;
const NiPoint3& GetGhostReferencePoint() const { return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint; };
const NiPoint3& GetOriginGhostReferencePoint() const;
const NiPoint3& GetOriginGhostReferencePoint() const { return m_GhostReferencePoint; };
const NiPoint3& GetGhostOverridePoint() const;
const NiPoint3& GetGhostOverridePoint() const { return m_GhostOverridePoint; };
bool GetGhostOverride() const;
bool GetGhostOverride() const { return m_GhostOverride; };
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot();
std::map<LWOOBJID, Loot::Info>& GetDroppedLoot() { return m_DroppedLoot; };
uint64_t GetDroppedCoins();
uint64_t GetDroppedCoins() const { return m_DroppedCoins; };
/**
* Setters
*/
void SetGhostOverride(bool value) { m_GhostOverride = value; };
void SetDroppedCoins(const uint64_t value) { m_DroppedCoins = value; };
void SetSystemAddress(const SystemAddress& value) override;
void SetRespawnPos(NiPoint3 position) override;
void SetRespawnPos(const NiPoint3& position) override;
void SetRespawnRot(NiQuaternion rotation) override;
void SetRespawnRot(const NiQuaternion& rotation) override;
void SetGhostReferencePoint(const NiPoint3& value);
void SetGhostOverridePoint(const NiPoint3& value);
void SetGhostOverride(bool value);
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;
/**
* 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
*/
@@ -86,11 +66,11 @@ public:
void ConstructLimboEntities();
void ObserveEntity(int32_t id);
void ObserveEntity(const int32_t id);
bool IsObserved(int32_t id);
bool IsObserved(const int32_t id);
void GhostEntity(int32_t id);
void GhostEntity(const int32_t id);
/**
* Static methods
@@ -122,15 +102,9 @@ private:
std::vector<int32_t> m_ObservedEntities;
int32_t m_ObservedEntitiesLength;
int32_t m_ObservedEntitiesUsed;
std::vector<LWOOBJID> m_LimboConstructions;
std::map<LWOOBJID, Loot::Info> m_DroppedLoot;
uint64_t m_DroppedCoins;
static std::vector<Player*> m_Players;
};