revival/game/Assets/Scripts/Artefacts/ArtefactInventory.cs

31 lines
720 B
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2021-02-23 14:05:42 +01:00
[CreateAssetMenu(menuName = "KernelPanic/Artefacts/Inventory")]
public class ArtefactInventory : ScriptableObject
{
2021-02-23 14:05:42 +01:00
private readonly List<Artefact> artefactList = new List<Artefact>();
2021-02-23 14:05:42 +01:00
public void addA(Artefact a)
{
//check if duplicate in the list
foreach (Artefact x in artefactList)
{
if (x.artefactID == a.artefactID)
2021-02-23 14:05:42 +01:00
{
Debug.LogError($"{a} already exists in inventory", this);
return;
}
}
2021-02-23 14:05:42 +01:00
artefactList.Add(a);
}
2021-04-27 01:57:07 +02:00
private void OnDisable()
{
artefactList.Clear();
}
}