From 4b60d55d8d97da113dbb2e90c2a4834e8e813629 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 7 Feb 2022 00:53:44 +0000 Subject: Spectation: keep track of spectators + Keep a list of spectators so that pointer clean-up can happen when the spectated is killed. * Fix invalid game state when riding/spectating and then entering or leaving spectator mode. --- src/Entities/Entity.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Entities/Entity.h') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 941d07339..2f9ba229b 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -135,11 +135,17 @@ public: Adds the entity to the world. */ bool Initialize(OwnedEntity a_Self, cWorld & a_EntityWorld); + /** Called when a player begins spectating this entity. */ + void OnAcquireSpectator(cPlayer & a_Player); + /** Called when the entity is added to a world. e.g after first spawning or after successfuly moving between worlds. \param a_World The world being added to. */ virtual void OnAddToWorld(cWorld & a_World); + /** Called when a player stops spectating this entity. */ + void OnLoseSpectator(cPlayer & a_Player); + /** Called when the entity is removed from a world. e.g. When the entity is destroyed or moved to a different world. \param a_World The world being removed from. */ @@ -723,4 +729,7 @@ private: /** List of leashed mobs to this entity */ cMonsterList m_LeashedMobs; + + /** List of players who are spectating this entity. */ + std::vector m_Spectators; } ; // tolua_export -- cgit v1.2.3