26 lines
502 B
C#
26 lines
502 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
// class, not interface so Unity shows fields in Editor
|
|
public class InventoryHolder : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private new string name;
|
|
|
|
public readonly IInventory Inventory;
|
|
|
|
public string Name => name == null || name == "" ? gameObject.name : name;
|
|
|
|
public float Capacity;
|
|
|
|
public InventoryHolder()
|
|
{
|
|
Inventory = new Inventory2(0, () => Name);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
Inventory.Capacity = Capacity;
|
|
}
|
|
}
|