From 028a5735c5f98aa10718c94de07d2f4b4c1fa6b3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 29 Sep 2021 23:17:03 +0100 Subject: Spectation: add dedicated pathway for spectator mode (#5303) * Spectation: add dedicated pathway for spectator mode + Sync player rotation with spectated entity. + Add dedicated infrastructure to cPlayer for handling spectation, instead of misusing entity riding. * Avoid infinite recursion when exiting spectation, fixes #5296 * AttachTo: Change parameter to reference --- src/Entities/Entity.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/Entities/Entity.h') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 1384870b8..285ae8fac 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -452,11 +452,11 @@ public: /** Gets entity (vehicle) attached to this entity */ cEntity * GetAttached(); - /** Attaches to the specified entity; detaches from any previous one first */ - virtual void AttachTo(cEntity * a_AttachTo); + /** Attaches to the specified entity; detaches from any previous one first. */ + void AttachTo(cEntity & a_AttachTo); - /** Detaches from the currently attached entity, if any */ - virtual void Detach(void); + /** Detaches from the currently attached entity, if any. */ + void Detach(void); /** Returns true if this entity is attached to the specified entity */ bool IsAttachedTo(const cEntity * a_Entity) const; @@ -578,10 +578,10 @@ protected: float m_Health; float m_MaxHealth; - /** The entity to which this entity is attached (vehicle), nullptr if none */ + /** The entity to which this entity is attached (vehicle), nullptr if none. */ cEntity * m_AttachedTo; - /** The entity which is attached to this entity (rider), nullptr if none */ + /** The entity which is attached to this entity (rider), nullptr if none. */ cEntity * m_Attachee; /** Stores whether head yaw has been set manually */ @@ -683,6 +683,9 @@ protected: /** If has any mobs are leashed, broadcasts every leashed entity to this. */ void BroadcastLeashedMobs(); + /** Called when this entity dismounts from m_AttachedTo. */ + virtual void OnDetach(); + private: /** Whether the entity is ticking or not. If not, it is scheduled for removal or world-teleportation. */ -- cgit v1.2.3