You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.1 KiB

using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Major Project/Inventory", order = 150)]
public class Inventory : ScriptableObject
{
[SerializeField]
protected List<InventoryData> AllElements = new List<InventoryData>();
public void Add(LogicBlock element)
{
InventoryData data;
try
{
data = AllElements.First(p => p.element == element);
}
catch
{
data = new InventoryData() { element = element };
AllElements.Add(data);
}
data.Count++;
}
public void Remove(LogicBlock element) {
if (!AllElements.Exists(p => p.element == element))
return;
InventoryData data = AllElements.First(p => p.element == element);
if (!data.infinit)
data.Count--;
}
[System.Serializable]
public class InventoryData
{
public LogicBlock element;
public int Count;
public bool infinit = false;
}
}