summaryrefslogblamecommitdiffstats
path: root/src/Items/ItemFood.h
blob: 29d733cabd0cbe56be0d97fc9748405ac4c24f96 (plain) (tree)
1
2
3
4
5
6
7
8
9
 







                        
                       

                           
                                   
 
       


                                                              
                                      








                                          
                                                                   
         

                                  
         
 

                                                                         
                                                      



                                     




                                                                         


                            


                            




  

#pragma once

#include "ItemHandler.h"





class cItemFoodHandler:
	public cItemHandler
{
	using Super = cItemHandler;

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;

};