1
0
Fork 0
cuberite-2a/src/Items/ItemFood.h

61 lines
870 B
C
Raw Normal View History

2014-09-12 17:34:19 +00:00
#pragma once
#include "ItemHandler.h"
2020-04-13 16:38:06 +00:00
class cItemFoodHandler:
public cItemHandler
{
2020-04-13 16:38:06 +00:00
using Super = cItemHandler;
2016-02-05 21:45:45 +00:00
public:
2020-04-13 16:38:06 +00:00
constexpr cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo):
2020-04-13 16:38:06 +00:00
Super(a_ItemType),
m_FoodInfo(a_FoodInfo)
{
}
virtual bool IsFood(void) const override
{
return true;
}
virtual FoodInfo GetFoodInfo(const cItem * a_Item) const override
{
UNUSED(a_Item);
return m_FoodInfo;
}
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) const override
{
2020-04-13 16:38:06 +00:00
if (!Super::EatItem(a_Player, a_Item))
{
return false;
}
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();
}
return true;
}
protected:
FoodInfo m_FoodInfo;
~cItemFoodHandler() = default;
};
class cItemSimpleFoodHandler final:
public cItemFoodHandler
{
using cItemFoodHandler::cItemFoodHandler;
};