diff options
author | Gargaj <gargaj@conspiracy.hu> | 2015-12-12 20:55:58 +0100 |
---|---|---|
committer | Gargaj <gargaj@conspiracy.hu> | 2015-12-13 13:04:18 +0100 |
commit | 0eb519b35add5b8ac9553ed4716430fbd26b660e (patch) | |
tree | 1853aaa787b482c9d12e9de6ce40d84772b7527a /src/Mobs/Sheep.cpp | |
parent | Merge pull request #2741 from SafwatHalaby/mTarget2 (diff) | |
download | cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.gz cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.bz2 cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.lz cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.xz cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.tar.zst cuberite-0eb519b35add5b8ac9553ed4716430fbd26b660e.zip |
Diffstat (limited to 'src/Mobs/Sheep.cpp')
-rw-r--r-- | src/Mobs/Sheep.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp index 5f763508b..7bca03e7e 100644 --- a/src/Mobs/Sheep.cpp +++ b/src/Mobs/Sheep.cpp @@ -131,6 +131,46 @@ void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) +void cSheep::InheritFromParents(cPassiveMonster * a_Parent1, cPassiveMonster * a_Parent2) +{ + static const struct + { + short Parent1, Parent2, Child; + } ColorInheritance[] = + { + { E_META_WOOL_BLUE, E_META_WOOL_RED, E_META_WOOL_PURPLE }, + { E_META_WOOL_BLUE, E_META_WOOL_GREEN, E_META_WOOL_CYAN }, + { E_META_WOOL_YELLOW, E_META_WOOL_RED, E_META_WOOL_ORANGE }, + { E_META_WOOL_GREEN, E_META_WOOL_WHITE, E_META_WOOL_LIGHTGREEN }, + { E_META_WOOL_RED, E_META_WOOL_WHITE, E_META_WOOL_PINK }, + { E_META_WOOL_WHITE, E_META_WOOL_BLACK, E_META_WOOL_GRAY }, + { E_META_WOOL_PURPLE, E_META_WOOL_PINK, E_META_WOOL_MAGENTA }, + { E_META_WOOL_WHITE, E_META_WOOL_GRAY, E_META_WOOL_LIGHTGRAY }, + { E_META_WOOL_BLUE, E_META_WOOL_WHITE, E_META_WOOL_LIGHTBLUE }, + }; + cSheep * Parent1 = static_cast<cSheep *>(a_Parent1); + cSheep * Parent2 = static_cast<cSheep *>(a_Parent2); + for (size_t i = 0; i < ARRAYCOUNT(ColorInheritance); i++) + { + if ( + ((Parent1->GetFurColor() == ColorInheritance[i].Parent1) && (Parent2->GetFurColor() == ColorInheritance[i].Parent2)) || + ((Parent1->GetFurColor() == ColorInheritance[i].Parent2) && (Parent2->GetFurColor() == ColorInheritance[i].Parent1)) + ) + { + SetFurColor(ColorInheritance[i].Child); + m_World->BroadcastEntityMetadata(*this); + return; + } + } + cFastRandom Random; + SetFurColor((Random.NextInt(100) < 50) ? Parent1->GetFurColor() : Parent2->GetFurColor()); + m_World->BroadcastEntityMetadata(*this); +} + + + + + NIBBLETYPE cSheep::GenerateNaturalRandomColor(void) { cFastRandom Random; |