2024-09-10 07:26:29 +00:00
|
|
|
using BlueWater.Items;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace BlueWater.Tycoons
|
|
|
|
{
|
|
|
|
public class Barrel : InteractionFurniture
|
|
|
|
{
|
|
|
|
[SerializeField]
|
|
|
|
private string _idx;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private LiquidData _liquidData;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private int _currentAmount;
|
|
|
|
|
|
|
|
private LiquidController _liquidController;
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
{
|
|
|
|
base.Awake();
|
|
|
|
|
|
|
|
_liquidController = FindAnyObjectByType<LiquidController>();
|
|
|
|
_liquidData = ItemManager.Instance.GetLiquidDataByIdx(_idx);
|
|
|
|
_currentAmount = _liquidData.GetMaxAmount();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Interaction()
|
|
|
|
{
|
|
|
|
_liquidController.SetBarrel(this);
|
|
|
|
_liquidController.ActiveIsPouring();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void CancelInteraction()
|
|
|
|
{
|
|
|
|
_liquidController.InActiveIsPouring();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 1. 플레이어가 빈 잔을 들고 있거나 완성되지 않은 잔을 들고 있을 때
|
|
|
|
/// </summary>
|
|
|
|
public override bool CanInteraction()
|
|
|
|
{
|
2024-09-10 10:25:05 +00:00
|
|
|
return !CurrentTycoonPlayer.IsCarriedItem();
|
2024-09-10 07:26:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool CanConsume(int amount)
|
|
|
|
{
|
|
|
|
return _currentAmount - amount > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Consume(int amount)
|
|
|
|
{
|
|
|
|
if (_currentAmount == int.MaxValue)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_currentAmount -= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool TryConsume(int amount)
|
|
|
|
{
|
|
|
|
if (!CanConsume(amount)) return false;
|
|
|
|
|
|
|
|
Consume(amount);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public LiquidData GetLiquidData() => _liquidData;
|
|
|
|
}
|
|
|
|
}
|