Fix issue with UI container update

This commit is contained in:
Vova
2023-12-18 10:50:05 +02:00
parent 6bd4971672
commit f6e0b24d81
3 changed files with 58 additions and 28 deletions
+12 -5
View File
@@ -1,9 +1,11 @@
using Assets.Scripts.Interfaces;
using System;
using System.Collections.Generic;
using UnityEngine;
public class Player : BaseCharacter
{
public event EventHandler<bool> OnContainerChanged;
public static Player Instance { get; private set; }
[SerializeField]
@@ -118,16 +120,21 @@ public class Player : BaseCharacter
containerItem.transform.parent = _holdPoint;
containerItem.transform.localPosition = Vector3.zero;
_containerItem = containerItem;
OnContainerChanged.Invoke(this,true);
}
public void ClearContainerItem()
{
OnContainerChanged.Invoke(this, false);
Destroy(_containerItem.gameObject);
_containerItem = null;
}
public ContainerItem GetContainerItem()
{
return _containerItem;
}
public void ClearContainerItem()
{
Destroy(_containerItem.gameObject);
_containerItem = null;
}
public bool IsHoldContainerItem()
{
return _containerItem != null;