summaryrefslogblamecommitdiffstats
path: root/src/Items/ItemFood.h
blob: f8137ab6ff72ef55af74c1340fa0bedceb2bca7b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
 











                                   
 
       


                                                             








                                          
                                                                   
         

                                  
         
 






                                                                         




                                                                         


                            


                            




  

#pragma once

#include "ItemHandler.h"





class cItemFoodHandler :
	public cItemHandler
{
	typedef cItemHandler super;

public:
	cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo)
		: super(a_ItemType),
		m_FoodInfo(a_FoodInfo)
	{
	}


	virtual bool IsFood(void) override
	{
		return true;
	}

	virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
	{
		UNUSED(a_Item);
		return m_FoodInfo;
	}

	virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
	{
		if (!super::EatItem(a_Player, a_Item))
		{
			return false;
		}

		if (!a_Player->IsGameModeCreative())
		{
			a_Player->GetInventory().RemoveOneEquippedItem();
		}

		return true;
	}

protected:
	FoodInfo m_FoodInfo;

};