blob: 7ec879b5daa8a0dadabd121f647048676be0df6d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#pragma once
#include "ItemHandler.h"
class cItemFoodHandler:
public cItemHandler
{
using Super = cItemHandler;
public:
constexpr cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo):
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
{
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;
};
|