30 lines
665 B
C#
30 lines
665 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class ResourceSource : InventoryHolder
|
|
{
|
|
[SerializeReference]
|
|
public Resource Resource;
|
|
|
|
public InventoryHolder ParentInventory;
|
|
|
|
public float InitialCapacity;
|
|
|
|
private readonly IInventory _inventory;
|
|
|
|
public override IInventory Inventory => _inventory;
|
|
|
|
public ResourceSource()
|
|
{
|
|
_inventory = new Inventory2(InitialCapacity);
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
_inventory.Capacity = InitialCapacity;
|
|
|
|
if (ParentInventory != null && ParentInventory.Inventory is VirtualInventory)
|
|
((VirtualInventory)ParentInventory.Inventory).RegisterChild(_inventory);
|
|
}
|
|
}
|