47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using UnityEngine;
|
|
|
|
namespace Ashwild.Storage
|
|
{
|
|
/// <summary>
|
|
/// Authoring data for one kind of storage chest: how many slots it holds, the title shown at the
|
|
/// top of its window, and how wide the grid is laid out. Follows the SO-for-data /
|
|
/// MonoBehaviour-for-logic split (like ItemData / BuildableData) — a small chest and a large chest
|
|
/// are two assets of this type dropped on two Chest prefabs, with no code change.
|
|
/// </summary>
|
|
[CreateAssetMenu(fileName = "NewChestData", menuName = "Storage/Chest Data")]
|
|
public class ChestData : ScriptableObject
|
|
{
|
|
#region Serialized Fields
|
|
|
|
[Header("Identity")]
|
|
[Tooltip("Title shown at the top of the chest window.")]
|
|
[SerializeField] private string displayName = "Coffre";
|
|
|
|
[Header("Layout")]
|
|
[Tooltip("Total number of storage slots this chest holds.")]
|
|
[SerializeField] private int slotCount = 20;
|
|
|
|
[Tooltip("How many slots per row the chest grid is laid out with (used by the UI layout).")]
|
|
[SerializeField] private int columns = 5;
|
|
|
|
#endregion
|
|
|
|
#region Public API
|
|
|
|
public string DisplayName => displayName;
|
|
|
|
/// <summary>
|
|
/// Number of storage slots, clamped to at least one so a misconfigured asset never seeds an
|
|
/// empty, unusable chest.
|
|
/// </summary>
|
|
public int SlotCount => Mathf.Max(1, slotCount);
|
|
|
|
/// <summary>
|
|
/// Slots per row for the grid layout, clamped to at least one.
|
|
/// </summary>
|
|
public int Columns => Mathf.Max(1, columns);
|
|
|
|
#endregion
|
|
}
|
|
}
|