using System; using System.Collections; using System.Collections.Generic; using BITFALL.Entities.Inventory; using BITFALL.Player.Inventory; using BITKit; using BITKit.Entities; using UnityEngine; namespace BITFALL.Player.Survival { public class PlayerEatService : EntityBehavior { [Inject] private IPlayerSurvivalService _survival; [Inject] private IEntityInventory _inventory; public override void OnStart() { _inventory.OnUsedItem += OnUseItem; } private void OnUseItem(IBasicItem arg) { if (arg.GetAssetable().TryGetProperty(out var addHunger) && _survival.Elements.TryGetAny(x => x is PlayerSurvivalHunger, out var element)) { element.Value += addHunger.Value; } if (arg.GetAssetable().TryGetProperty(out var addThirst) && _survival.Elements.TryGetAny(x => x is PlayerSurvivalThirst, out element)) { element.Value += addThirst.Value; } } } }