Inventory
Inventory copied to clipboard
A inventory system being made in Godot 4 C# for future games
https://user-images.githubusercontent.com/6277739/217958511-d5182a65-60e9-464d-82d3-23a069720ae3.mp4
A Game Inventory being made in Godot 4 C#
The goal of this project is to attempt to perfect a game inventory system so it can be used across all games that make use of inventories.
As of writing this, this project requires Godot 4 Release Candidate 1 (v4.0.rc1.mono.official [8843d9ad3]). If you are unsure which version this project is on, please check the Inventory.csproj file, the version will be displayed in there.
Table of Contents
- Features
- Implemented Controls
- Todo
- Example Code
- Contributing
- Previews
Features
- [x] Inventories of varying sizes can be defined
- [x] Inventory slot size can be customized
- [x] Player Inventory Hotbar
- [x] Smooth player inventory open / close animations
Implemented Controls
- [x]
Left Clickto pick up / place item stack - [x]
Hold + Left Clickto continuously pick up items of the same type - [x]
Shift + Left Clickto transfer item stack from inventories A to B - [x]
Hold + Shift + Left Clickto continuously transfer item stack from inventories A to B - [x]
Shift + Right Clickto split stack - [x]
Right Clickto pick up / place single item - [x]
Hold + Right Clickto continuously place a single item - [x]
Double Clickto pick up all items of the same type - [x]
Shift + Rto sort items in all open inventories by descending item count - [x]
Shift + Tto take all items from the 'other inventory' and put them in the players inventory - [x]
123456789to move / swap items to player hotbar slots - [x]
Ito open the players inventory - [x]
Eto interact with objects in the world
Todo
- Hotkey to deposit all items from player inventory to 'other inventory'
- Make item panel description popup only appear after small delay
- Saving / loading inventory data
- Allow items to define their own max stack sizes
- Q = Drop Item (x1)
- Ctrl + Q = Drop Stack
- Maybe implementing ENet-CSharp and syncing all of this inventory stuff over the network. (There would be a demo where 2 players would see each other walking around and see the inventory update when the other player interacts with it)
- Giving items a category property so the sorting hotkey can sort by category or any other item property for that matter
- Add item rarities (maybe rare items have a glowing outline achieved used Godot Shaders)
Example Code
private Inventory ChestInv { get; set; }
private Inventory PlayerInv { get; set; }
public override void _Ready()
{
ChestInv = new Inventory(this);
ChestInv.SetAnchor(Control.LayoutPreset.CenterTop);
for (int i = 0; i < 9; i++)
ChestInv.SetItem(i, new Item(Items.Coin));
ChestInv.SetItem(0, 2, new Item(Items.Coin, 3));
ChestInv.SetItem(1, 2, new Item(Items.CoinSnowy));
PlayerInv = new Inventory(this);
PlayerInv.SetAnchor(Control.LayoutPreset.CenterBottom);
for (int i = 18; i < 27; i++)
PlayerInv.SetItem(i, new Item(Items.CoinPink));
Inventory.PlayerInventory = PlayerInv;
Inventory.OtherInventory = ChestInv;
}
Contributing
Please talk to me over Discord va#9904 before you do anything.
Have a look at the todo list and the projects issues for things to do. On top of all that, I'm always trying to find ways to clean up the code and make it more humanly readable.
Please follow this code style
Previews
https://user-images.githubusercontent.com/6277739/218189596-f6c9edb2-67ca-4aca-9c7d-214f145699e3.mp4
https://user-images.githubusercontent.com/6277739/218189290-9169f504-fc31-4cd6-99f3-4ba92eb4ff75.mp4
https://user-images.githubusercontent.com/6277739/217701119-4f5dcf6e-3004-4f91-b966-8de9b8ba98c7.mp4
https://user-images.githubusercontent.com/6277739/217701126-bbe38e2b-e962-4ad8-a6ce-28c29035e0d0.mp4
https://user-images.githubusercontent.com/6277739/217701135-0271306f-b915-4006-b333-18eb170ac19b.mp4
https://user-images.githubusercontent.com/6277739/217701142-748b222a-4f6d-46e3-bbc5-b333c83d628e.mp4