summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Slime.cpp
diff options
context:
space:
mode:
authorKingCol13 <kingsleydgs@gmail.com>2021-12-18 21:21:26 +0100
committerAlexander Harkness <me@bearbin.net>2021-12-18 21:46:03 +0100
commit2cd7e63e873dc3c1faaac6d3381cdce01023373b (patch)
treebfd68280c9f75ed68c1d959a593f64a1e3cc2b94 /src/Mobs/Slime.cpp
parentAdd delay to new slime spawns after slime death. (diff)
downloadcuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar.gz
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar.bz2
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar.lz
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar.xz
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.tar.zst
cuberite-2cd7e63e873dc3c1faaac6d3381cdce01023373b.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Slime.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index f2b16f071..2aeecfc98 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -71,7 +71,6 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI)
if (m_Size != 1)
{
- // Queue slimes to be spawned after death animation delay:
auto & Random = GetRandomProvider();
int SpawnAmount = Random.RandInt(2, 4);
@@ -80,18 +79,18 @@ void cSlime::KilledBy(TakeDamageInfo & a_TDI)
double AddX = (i % 2 - 0.5) * m_Size / 4.0;
double AddZ = (i / 2 - 0.5) * m_Size / 4.0;
- Vector3d SpawnPos(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ);
- double Yaw = Random.RandReal(360.0f);
- int Size = m_Size/2;
- auto lambda = [SpawnPos, Yaw, Size](cWorld &a_World)
+ // Queue slimes to be spawned after the 1 second death animation has finished playing:
+ m_World->ScheduleTask(cTickTime(20), [
+ Position = GetPosition() + Vector3d(AddX, 0.5, AddZ),
+ Yaw = Random.RandReal(360.0f),
+ Size = m_Size / 2
+ ](cWorld & a_World)
{
auto NewSlime = std::make_unique<cSlime>(Size);
- NewSlime->SetPosition(SpawnPos);
+ NewSlime->SetPosition(Position);
NewSlime->SetYaw(Yaw);
a_World.SpawnMobFinalize(std::move(NewSlime));
- };
- cTickTime DelayTime(20);
- m_World->ScheduleTask(DelayTime, lambda);
+ });
}
}
Super::KilledBy(a_TDI);