2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 09:41:47 -04:00
|
|
|
#pragma once
|
2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 09:41:47 -04:00
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Sign.h"
|
|
|
|
#include "../Player.h"
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockBedHandler :
|
|
|
|
public cBlockHandler
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-03 04:52:11 -04:00
|
|
|
cBlockBedHandler(BLOCKTYPE a_BlockType)
|
|
|
|
: cBlockHandler(a_BlockType)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-03 04:52:11 -04:00
|
|
|
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
|
|
|
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
|
|
|
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
2012-09-29 09:41:47 -04:00
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
virtual bool IsUseable(void) override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-09-29 16:43:42 -04:00
|
|
|
return true;
|
2012-09-29 09:41:47 -04:00
|
|
|
}
|
2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 16:43:42 -04:00
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
// Reset meta to zero
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
|
2012-09-29 09:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
virtual bool DoesAllowBlockOnTop() override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-29 16:43:42 -04:00
|
|
|
// Bed specific helper functions
|
2012-10-01 17:08:15 -04:00
|
|
|
static NIBBLETYPE RotationToMetaData(float a_Rotation)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
a_Rotation += 180 + (180/4); // So its not aligned with axis
|
|
|
|
if( a_Rotation > 360.f ) a_Rotation -= 360.f;
|
|
|
|
|
|
|
|
a_Rotation = (a_Rotation/360) * 4;
|
|
|
|
|
|
|
|
return ((char)a_Rotation+2) % 4;
|
|
|
|
}
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
switch (a_MetaData)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
case 0: // south +z
|
|
|
|
return Vector3i(0, 0, 1);
|
|
|
|
case 1: // west -x
|
|
|
|
return Vector3i(-1, 0, 0);
|
|
|
|
case 2: // north -z
|
|
|
|
return Vector3i(0, 0, -1);
|
|
|
|
case 3: // east +x
|
|
|
|
return Vector3i(1, 0, 0);
|
2012-09-29 09:41:47 -04:00
|
|
|
};
|
|
|
|
return Vector3i();
|
|
|
|
}
|
2012-10-01 17:08:15 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|