refactor interact system

interact only after PopupItemMenu button clicked
This commit is contained in:
Vova
2023-11-16 16:11:39 +02:00
parent c2bb35a46d
commit 1774ab5b18
12 changed files with 100 additions and 61 deletions
+6 -7
View File
@@ -12,12 +12,11 @@ public class Fridge : BaseInteractableObject
private List<FoodItemSO> _foodObjects = new List<FoodItemSO>();
public override void Interact(Player player)
{
base.Interact(player);
if (player.IsHoldContainerItem())
protected override void InteractAction()
{
if (_player.IsHoldContainerItem())
{
var playerContainer = player.GetContainerItem();
var playerContainer = _player.GetContainerItem();
if (!playerContainer.IsSalebleItems())
{
if (_foodObjects.Count + playerContainer.GetItems().Count <= _containerSO.MaxCapacity)
@@ -27,7 +26,7 @@ public class Fridge : BaseInteractableObject
_foodObjects.Add(item);
}
player.ClearContainerItem();
_player.ClearContainerItem();
Debug.Log($"Fridge have {_foodObjects.Count} pices of food");
}
else
@@ -39,7 +38,7 @@ public class Fridge : BaseInteractableObject
//Eat menu
if (_foodObjects.Count > 0)
{
var hunger = player.Stats[StatsId.Food].MaxValue - player.Stats[StatsId.Food].Value;
var hunger = _player.Stats[StatsId.Food].MaxValue - _player.Stats[StatsId.Food].Value;
var eatingItems = _foodObjects.Count < (hunger / 10) ? _foodObjects.Count : (hunger / 10);
StartCoroutine(EatRoutine(eatingItems));
_foodObjects.RemoveRange(0, (int)eatingItems);