mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 09:51:38 +00:00
LWOGhostComponent::LoadFromSaveData reads <ghst i> under <obj> and the client hides its own character again once the scene has loaded when it is set. Nothing wrote or read the element, so a GM was visible again after every world change. GhostComponent now writes <ghst i="1"/> while invisible and reads it back. A save without the element loads as visible and is not given one; an element that is set goes back to 0 when the GM is visible again. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
#ifndef __GHOSTCOMPONENT__H__
|
|
#define __GHOSTCOMPONENT__H__
|
|
|
|
#include "Component.h"
|
|
#include "eReplicaComponentType.h"
|
|
#include <unordered_set>
|
|
#include "PlayerMessages.h"
|
|
|
|
class NiPoint3;
|
|
|
|
namespace tinyxml2 {
|
|
class XMLDocument;
|
|
}
|
|
|
|
class GhostComponent final : public Component {
|
|
public:
|
|
static inline const eReplicaComponentType ComponentType = eReplicaComponentType::GHOST;
|
|
GhostComponent(Entity* parent, const int32_t componentID);
|
|
~GhostComponent() override;
|
|
|
|
void SetGhostOverride(bool value) { m_GhostOverride = value; };
|
|
|
|
const NiPoint3& GetGhostReferencePoint() const { return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint; };
|
|
|
|
const NiPoint3& GetOriginGhostReferencePoint() const { return m_GhostReferencePoint; };
|
|
|
|
const NiPoint3& GetGhostOverridePoint() const { return m_GhostOverridePoint; };
|
|
|
|
bool GetGhostOverride() const { return m_GhostOverride; };
|
|
|
|
void SetGhostReferencePoint(const NiPoint3& value);
|
|
|
|
void SetGhostOverridePoint(const NiPoint3& value);
|
|
|
|
void AddLimboConstruction(const LWOOBJID objectId);
|
|
|
|
void RemoveLimboConstruction(const LWOOBJID objectId);
|
|
|
|
void ConstructLimboEntities();
|
|
|
|
void ObserveEntity(const LWOOBJID id);
|
|
|
|
bool IsObserved(const LWOOBJID id);
|
|
|
|
void GhostEntity(const LWOOBJID id);
|
|
|
|
// The client dropped every object it had (it reloaded the zone in place): nothing counts as sent to it any more
|
|
void ForgetObservedEntities() { m_ObservedEntities.clear(); m_LimboConstructions.clear(); }
|
|
|
|
// LWOGhostComponent::LoadFromSaveData: <ghst i>, whether the GM was invisible when the save was
|
|
// written. The client reads the same element and hides its own character again once the scene has loaded.
|
|
void LoadFromSaveData(const tinyxml2::XMLDocument& doc) override;
|
|
|
|
// Writes <ghst i="1"/> while invisible. A visible character only has an element it already had set back to 0.
|
|
void WriteSaveData(tinyxml2::XMLDocument& doc) override;
|
|
|
|
bool IsGMInvisible() const { return m_IsGMInvisible; }
|
|
|
|
bool OnToggleGMInvis(GameMessages::ToggleGMInvisEvent& event);
|
|
|
|
bool OnGetGMInvis(GameMessages::GetGMInvis& msg);
|
|
|
|
bool MsgGetObjectReportInfo(GameMessages::GetObjectReportInfo& msg);
|
|
|
|
private:
|
|
|
|
NiPoint3 m_GhostReferencePoint;
|
|
|
|
NiPoint3 m_GhostOverridePoint;
|
|
|
|
std::unordered_set<LWOOBJID> m_ObservedEntities;
|
|
|
|
std::unordered_set<LWOOBJID> m_LimboConstructions;
|
|
|
|
bool m_GhostOverride;
|
|
|
|
bool m_IsGMInvisible{ false };
|
|
|
|
};
|
|
|
|
#endif //!__GHOSTCOMPONENT__H__
|