First commit for private source control. Older commits available on Github.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Managers.Player.Data.Inventory
|
||||
{
|
||||
public class Backpack
|
||||
{
|
||||
private readonly List<ItemDataSo> _items = new();
|
||||
|
||||
public IReadOnlyList<ItemDataSo> Items => _items;
|
||||
|
||||
|
||||
public void AddItem(ItemDataSo item)
|
||||
{
|
||||
if (_items.Any(x => x.UniqueID == item.UniqueID))
|
||||
return;
|
||||
|
||||
Debug.Log($"Adding item {item.UniqueID}");
|
||||
|
||||
_items.Add(item);
|
||||
}
|
||||
|
||||
public void RemoveItem(ItemDataSo item)
|
||||
{
|
||||
if (_items.All(x => x.UniqueID != item.UniqueID)) return;
|
||||
|
||||
_items.Remove(item);
|
||||
}
|
||||
|
||||
public void RemoveItem(string uniqueID)
|
||||
{
|
||||
var item = _items.FirstOrDefault(x => x.UniqueID == uniqueID);
|
||||
|
||||
if (item) _items.Remove(item);
|
||||
}
|
||||
|
||||
public void ClearItems()
|
||||
{
|
||||
_items.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 855a4eee12334e29938a4b6c564aa157
|
||||
timeCreated: 1769701500
|
||||
Reference in New Issue
Block a user