#Blog 12 Cooking
The islander is able to build a bonfire in the world, with this bonfire they can cook foods and keep warm if it is currently in a cold weather condition.
Displaying the UI
I first needed to determine whether or not the player was in the area to display the cooking UI, I used an actor overlap to detect this. This also set the player temperature to 18 if they are in the area of the bonfire. When the player presses E and they are currently overlapping the actor it creates the UI and displays it to the player, along with this it detects when the player leaves the actor overlap and removes the UI.
UI
The UI is what calls the rest of the events in the bonfire actor so I will show this first. The player can deposit the amount of raw rabbit, and the 4 kinds of fish into the bonfire by clicking on the representative image. The player must then add wood to the bonfire or else they wont be able to light the fire if they don’t also have flint on them. Once the raw food has been deposited they can light the fire and the food will start to cook, on top of this the player can also convert Unboiled water that is used in farming to boiled water that allows the player to drink it to increase hydration preventing sickness. Once the player clicks the collect button at the top right it will get all the currently cooked amounts of food and add it to the game mode inventory.
For the numbers in the UI I am using the same blueprints as the other inventory systems in the game.
Clicking the light fire button will call the light fire event on the bonfire actor, also the add wood button checks to see if the gamemode has more than 0 sticks, if its true then it increases the wood amount on the bonfire and reduces the gamemode’s stick amount by -1.
Adding Meat to the fire
Using similar blueprints to the adding wood button, when the player clicks the representing button for each item it checks to see if the gamemode has more than 0 of that item if it does then it reduces that amount by -1 then increase the bonfires temporary inventory by 1.
Convert water/Collect Items
When the player clicks the boil water button it gets the current unboiled water amount and sets the boiled water amount to that amount, then it sets the unboiled amount back to 0. Clicking Collect Items calls the collect all items event in the bonfire.
Decaying Wood Amount
This slowly ticks the current wood amount down if the fire is lit and the wood amount is more than 0. If both are false then it sets the fire lit node to false and removes the fire particle effect. If both are true though then it removes a wood amount and waits 30 seconds before running again.
Collecting All Currently Cooked Items
When this event is called it gets the custom gamemode and increase the cooked fish and cooked rabbit amount by the currently cooked rabbit and fish amount in the bonfire then sets those variables back to 0.
Tempoary Bonfire Inventory
Due to the fact that the bonfire is storing resource data I have created a small inventory in the bonfire to store the amount of wood, raw rabbit, fish 1, fish 2, fish 3, fish 4, cooked fish and cooked rabbit while it is being held by the bonfire.
Cooking the items
These Events check to see if the current amount of that item in the temp inventory is more than 0 if it is and the fire is lit then it will decrease that amount by -1 and increase the cooked version of that item by 1, then it will wait for 10 seconds before running again. All these events are called by the UI when the player presses the light fire button it calls the cook items event that runs each of these cooking events.


















