Skip to content

A inventory system being made in Godot 4 C# for future games

License

Notifications You must be signed in to change notification settings

Valks-Games/Inventory

Repository files navigation

Preview.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

  1. Features
  2. Implemented Controls
  3. Todo
  4. Example Code
  5. Contributing
  6. Previews

Features

  • Inventories of varying sizes can be defined
  • Inventory slot size can be customized
  • Player Inventory Hotbar
  • Smooth player inventory open / close animations

Implemented Controls

  • Left Click to pick up / place item stack
  • Hold + Left Click to continuously pick up items of the same type
  • Shift + Left Click to transfer item stack from inventories A to B
  • Hold + Shift + Left Click to continuously transfer item stack from inventories A to B
  • Shift + Right Click to split stack
  • Right Click to pick up / place single item
  • Hold + Right Click to continuously place a single item
  • Double Click to pick up all items of the same type
  • Shift + R to sort items in all open inventories by descending item count
  • Shift + T to take all items from the 'other inventory' and put them in the players inventory
  • 1 2 3 4 5 6 7 8 9 to move / swap items to player hotbar slots
  • I to open the players inventory
  • E to 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

Preview.mp4
Preview.mp4
1.mp4
2.mp4
3.mp4
4.mp4

About

A inventory system being made in Godot 4 C# for future games

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages