summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 0bb8b97bc..b6a67859b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -134,6 +134,15 @@ bool cEntity::Initialize(OwnedEntity a_Self, cWorld & a_EntityWorld)
+void cEntity::OnAcquireSpectator(cPlayer & a_Player)
+{
+ m_Spectators.push_back(&a_Player);
+}
+
+
+
+
+
void cEntity::OnAddToWorld(cWorld & a_World)
{
// Spawn the entity on the clients:
@@ -146,6 +155,19 @@ void cEntity::OnAddToWorld(cWorld & a_World)
+void cEntity::OnLoseSpectator(cPlayer & a_Player)
+{
+ const auto Spectator = std::find(m_Spectators.begin(), m_Spectators.end(), &a_Player);
+
+ ASSERT(Spectator != m_Spectators.end());
+ std::swap(*Spectator, m_Spectators.back());
+ m_Spectators.pop_back();
+}
+
+
+
+
+
void cEntity::OnRemoveFromWorld(cWorld & a_World)
{
// Remove all mobs from the leashed list of mobs:
@@ -154,6 +176,13 @@ void cEntity::OnRemoveFromWorld(cWorld & a_World)
m_LeashedMobs.front()->Unleash(false, true);
}
+ for (const auto Player : m_Spectators)
+ {
+ Player->OnLoseSpectated();
+ }
+
+ m_Spectators.clear();
+
if (m_AttachedTo != nullptr)
{
Detach();