refactor interact system
interact only after PopupItemMenu button clicked
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user