37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ChestInstance : MonoBehaviour
|
|
{
|
|
[Tooltip("The Scriptable Object that defines the default loot for this chest.")]
|
|
[SerializeField] private Chest chestData;
|
|
|
|
// This list holds the unique items for this specific chest instance.
|
|
public List<Item> runtimeLootItems;
|
|
|
|
// State for this specific instance
|
|
public bool isOpened { get; private set; }
|
|
public bool isLocked { get; private set; }
|
|
|
|
// A property to access the chest's name from the data asset.
|
|
public string ChestName => chestData.chestName;
|
|
|
|
void Awake()
|
|
{
|
|
// When the chest is created, copy the state and loot from the template.
|
|
isOpened = chestData.isOpened;
|
|
isLocked = chestData.isLocked;
|
|
runtimeLootItems = new List<Item>(chestData.lootItems);
|
|
}
|
|
|
|
// You can add methods here to change the state of this specific instance
|
|
public void Open()
|
|
{
|
|
isOpened = true;
|
|
}
|
|
|
|
public void Unlock()
|
|
{
|
|
isLocked = false;
|
|
}
|
|
} |