1
0

Added basic ocelot behavior (#3829)

This commit is contained in:
Bond-009
2017-07-12 12:42:02 +02:00
committed by Lukas Pioch
parent b61898c30c
commit 6a19841121
10 changed files with 369 additions and 21 deletions

View File

@@ -6,6 +6,8 @@
#include "../Entities/Player.h"
#include "../UI/ChestWindow.h"
#include "../ClientHandle.h"
#include "../Mobs/Ocelot.h"
#include "../BoundingBox.h"
@@ -217,11 +219,36 @@ void cChestEntity::DestroyWindow()
class cFindSittingCat :
public cEntityCallback
{
virtual bool Item(cEntity * a_Entity) override
{
return (
(a_Entity->GetEntityType() == cEntity::etMonster) &&
(static_cast<cMonster *>(a_Entity)->GetMobType() == eMonsterType::mtOcelot) &&
(static_cast<cOcelot *>(a_Entity)->IsSitting())
);
}
};
bool cChestEntity::IsBlocked()
{
// TODO: cats are an obstruction
cFindSittingCat FindSittingCat;
return (
(GetPosY() >= cChunkDef::Height - 1) ||
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()))
!cBlockInfo::IsTransparent(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ())) ||
(
(GetWorld()->GetBlock(GetPosX(), GetPosY() + 1, GetPosZ()) == E_BLOCK_AIR) &&
!GetWorld()->ForEachEntityInBox(cBoundingBox(Vector3d(GetPosX(), GetPosY() + 1, GetPosZ()), 1, 1), FindSittingCat)
)
);
}