From 0eb519b35add5b8ac9553ed4716430fbd26b660e Mon Sep 17 00:00:00 2001 From: Gargaj Date: Sat, 12 Dec 2015 20:55:58 +0100 Subject: sheep color inheritance --- src/Mobs/PassiveMonster.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/Mobs/PassiveMonster.cpp') diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp index b700c0c5d..30b46500d 100644 --- a/src/Mobs/PassiveMonster.cpp +++ b/src/Mobs/PassiveMonster.cpp @@ -92,7 +92,26 @@ void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { // Mating finished. Spawn baby Vector3f Pos = (GetPosition() + m_LovePartner->GetPosition()) * 0.5; - m_World->SpawnMob(Pos.x, Pos.y, Pos.z, GetMobType(), true); + UInt32 BabyID = m_World->SpawnMob(Pos.x, Pos.y, Pos.z, GetMobType(), true); + + class cBabyInheritCallback : + public cEntityCallback + { + public: + cPassiveMonster * Baby; + cBabyInheritCallback() : Baby(nullptr) { } + virtual bool Item(cEntity * a_Entity) override + { + Baby = static_cast(a_Entity); + return true; + } + } Callback; + + m_World->DoWithEntityByID(BabyID, Callback); + if (Callback.Baby != nullptr) + { + Callback.Baby->InheritFromParents(this, m_LovePartner); + } cFastRandom Random; m_World->SpawnExperienceOrb(Pos.x, Pos.y, Pos.z, 1 + Random.NextInt(6)); -- cgit v1.2.3