The Chest Core is a lightweight and extensible library for creating containers, slots, and inventory-like data structures. It provides abstractions and ready-to-use base implementations, allowing to build storage systems.
The library revolves around the concepts of Container and Slot. A Container holds multiple Slot objects, and each Slot can store an item. The library provides base implementations and interfaces to simplify the creation of custom containers and slots.
using TheChest.Core.Containers;
using TheChest.Core.Slots;
var slots = new ISlot<int>[]
{
new Slot<int>(0),
new Slot<int>(0),
new Slot<int>(5)
};
var container = new Container<int>(slots);To install the library via Nuget, you can use the following command:
dotnet add package TheChest.CoreAlternatively, you can download the DLL file and reference it directly in your project.
You can also download only the .cs files needed to use inside your project.
The library provides ready-to-use implementations such as Container<T> and Slot<T>. These can be used directly or extended to add custom behavior. For example:
using TheChest.Core.Containers;
public class MyContainer : Container<int>
{
public MyContainer(ISlot<int>[] items) : base(items)
{
if (items.Length != 10)
throw new System.ArgumentException("Invalid container size");
}
public override int Size
{
get
{
return 10;
}
}
}using TheChest.Core.Slots;
public class CustomSlot : Slot<string>
{
public CustomSlot(string item) : base(item)
{
}
public override bool IsEmpty => this.content == null;
public override bool IsFull => this.content != null;
}If you need more control, you can implement the interfaces directly. For example:
using TheChest.Core.Containers.Interfaces;
using TheChest.Core.Slots.Interfaces;
public class MyContainer : IContainer<int>
{
private readonly ISlot<int>[] slots;
public int Size { get; }
public bool IsFull { get; }
public bool IsEmpty { get; }
public MyContainer(ISlot<int>[] slots)
{
if (slots.Length != 10)
throw new System.ArgumentException("Invalid container size");
this.slots = slots ?? throw new ArgumentNullException(nameof(slots));
}
}using TheChest.Core.Slots.Interfaces;
public class CustomSlot : ISlot<int>
{
protected int? content;
public bool IsEmpty => content == 0;
public bool IsFull => content != 0;
public CustomSlot(int? item)
{
content = item;
}
}TheChest targets .NET Standard 2.1 and is tested against supported .NET runtimes.
Currently tested runtimes include:
- .NET 6
- .NET 7
- .NET 8
- .NET 9
- .NET 10
Compatibility with other platforms implementing .NET Standard 2.1 may (or may not) vary.
For the complete runtime compatibility matrix, known issues, and testing policy, see Compatibility.
The plans for future versions of The Chest Core are in this GitHub Project Board, with insights into upcoming features, improvements, and release timelines.