Files
HauntedBloodlines/Assets/Scripts/Inventory/Items/CandleHolderPickable.cs
2025-05-29 22:31:40 +03:00

62 lines
2.0 KiB
C#

using UnityEngine;
using System.Collections;
using InfallibleCode;
using TRInventoryUpdatable;
namespace TRInventoryUpdatable
{
public class CandleHolderPickable : MonoBehaviour, IPickable
{
public bool HasCandle;
public float candleLife;
ExaminableItem examinableItem;
private void Start()
{
examinableItem = GetComponent<ExaminableItem>();
}
public void Pickup()
{
var ringInventory = RingInventory.GetInstance();
var inventoryManager = InventoryManager.GetInstance();
var gameProgress = GameProgressManager.GetInstance();
if (ringInventory == null || inventoryManager == null || gameProgress == null)
{
Debug.LogError("CandleHolderPickable: One or more required instances are null!");
return;
}
if (inventoryManager.candleHolderOnRingInventory == null)
{
Debug.LogError("CandleHolderPickable: candleHolderOnRingInventory is null!");
return;
}
Debug.Log("Attempting to add candle Holder to inventory...");
ringInventory.AddItemToKeysAndItemsInventory(inventoryManager.candleHolderOnRingInventory.transform);
Debug.Log("Activating candleHolderOnRingInventory...");
inventoryManager.candleHolderOnRingInventory.SetActive(true);
Debug.Log("Saving candle Holder data temporarily...");
inventoryManager.SaveTemporarilyCandleHolderInventoryItemData(true, HasCandle, candleLife);
gameProgress.CandleHolderIsObtained = true;
Debug.Log("Disabling Candle Holder game object...");
if (examinableItem != null)
{
examinableItem.examineItem.GotItemExitDisplayingItem3d();
}
StartCoroutine(DestroyAfterSeconds());
}
IEnumerator DestroyAfterSeconds()
{
yield return new WaitForSecondsRealtime(0.1f);
Destroy(gameObject);
}
}
}