diff --git a/.idea/.idea.Godot Grid Inventory/.idea/.gitignore b/.idea/.idea.Godot Grid Inventory/.idea/.gitignore
new file mode 100644
index 0000000..f853ab4
--- /dev/null
+++ b/.idea/.idea.Godot Grid Inventory/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/modules.xml
+/projectSettingsUpdater.xml
+/contentModel.xml
+/.idea.Godot Grid Inventory.iml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.Godot Grid Inventory/.idea/.name b/.idea/.idea.Godot Grid Inventory/.idea/.name
new file mode 100644
index 0000000..0650d65
--- /dev/null
+++ b/.idea/.idea.Godot Grid Inventory/.idea/.name
@@ -0,0 +1 @@
+Godot Grid Inventory
\ No newline at end of file
diff --git a/.idea/.idea.Godot Grid Inventory/.idea/encodings.xml b/.idea/.idea.Godot Grid Inventory/.idea/encodings.xml
new file mode 100644
index 0000000..7a6d6bc
--- /dev/null
+++ b/.idea/.idea.Godot Grid Inventory/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Godot Grid Inventory/.idea/indexLayout.xml b/.idea/.idea.Godot Grid Inventory/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.Godot Grid Inventory/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Godot Grid Inventory/.idea/vcs.xml b/.idea/.idea.Godot Grid Inventory/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/.idea.Godot Grid Inventory/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Grid Inventory System/.idea/workspace.xml b/.idea/.idea.Grid Inventory System/.idea/workspace.xml
new file mode 100644
index 0000000..72df897
--- /dev/null
+++ b/.idea/.idea.Grid Inventory System/.idea/workspace.xml
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 0
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1704938262746
+
+
+ 1704938262746
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.godot_grid_inventory.dir/.idea/.gitignore b/.idea/.idea.godot_grid_inventory.dir/.idea/.gitignore
new file mode 100644
index 0000000..cbd0701
--- /dev/null
+++ b/.idea/.idea.godot_grid_inventory.dir/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/contentModel.xml
+/projectSettingsUpdater.xml
+/.idea.godot_grid_inventory.iml
+/modules.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.godot_grid_inventory.dir/.idea/encodings.xml b/.idea/.idea.godot_grid_inventory.dir/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.godot_grid_inventory.dir/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.godot_grid_inventory.dir/.idea/indexLayout.xml b/.idea/.idea.godot_grid_inventory.dir/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.godot_grid_inventory.dir/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.godot_grid_inventory.dir/.idea/vcs.xml b/.idea/.idea.godot_grid_inventory.dir/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/.idea.godot_grid_inventory.dir/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Code/Grid/Enums/EnumInventoryGridCellState.cs b/Code/Grid/Enums/EnumInventoryGridCellState.cs
new file mode 100644
index 0000000..89df10a
--- /dev/null
+++ b/Code/Grid/Enums/EnumInventoryGridCellState.cs
@@ -0,0 +1,7 @@
+namespace GodotGridInventory.Code.Grid.Enums;
+
+public enum EnumInventoryGridCellState
+{
+ Available,
+ Unavailable
+}
\ No newline at end of file
diff --git a/Code/Grid/InventoryCell.cs b/Code/Grid/InventoryCell.cs
new file mode 100644
index 0000000..c96199e
--- /dev/null
+++ b/Code/Grid/InventoryCell.cs
@@ -0,0 +1,21 @@
+using Godot;
+using GodotGridInventory.Code.Grid.Enums;
+
+namespace GodotGridInventory.Code.Grid;
+
+public class InventoryCell
+{
+ private readonly InventoryGrid _parentGrid;
+ public Vector2 Position { get; set; }
+ public EnumInventoryGridCellState State { get; set; }
+ public ItemConfiguration? Item { get; set; } = null;
+
+
+ public InventoryCell(Vector2 position, InventoryGrid parentGrid)
+ {
+ _parentGrid = parentGrid;
+ State = EnumInventoryGridCellState.Available;
+ Item = null;
+ Position = position;
+ }
+}
\ No newline at end of file
diff --git a/Code/Grid/InventoryGrid.cs b/Code/Grid/InventoryGrid.cs
new file mode 100644
index 0000000..2a49ea2
--- /dev/null
+++ b/Code/Grid/InventoryGrid.cs
@@ -0,0 +1,166 @@
+using System.Collections.Generic;
+using System.Linq;
+using Godot;
+using GodotGridInventory.Code.Grid.Enums;
+
+namespace GodotGridInventory.Code.Grid;
+
+public class InventoryGrid
+{
+ private readonly int _gridWidth;
+ private readonly int _gridHeight;
+
+ private readonly List _gridCells = new();
+
+ public InventoryGrid(int width, int height)
+ {
+ _gridWidth = width;
+ _gridHeight = height;
+ InitializeGrid();
+ }
+
+ private void InitializeGrid()
+ {
+ for(var x = 0; x < _gridWidth; x++)
+ {
+ for(var y = 0; y < _gridHeight; y++)
+ {
+ var cellPosition = new Vector2(x, y);
+ var cell = new InventoryCell(cellPosition, this);
+ _gridCells.Add(cell);
+ }
+ }
+ }
+
+ #region Private Methods
+ ///
+ /// Sets the item of a cell at a given position.
+ ///
+ /// The position of the cell to update.
+ /// The item to set the cell to.
+ private void SetCellItem(Vector2 position, ItemConfiguration item)
+ {
+ var cell = _gridCells.FirstOrDefault(cell => cell.Position == position);
+ if(cell != null)
+ {
+ cell.Item = item;
+ }
+ }
+
+ ///
+ /// Clears the item of a cell at a given position.
+ ///
+ /// The position of the cell to update.
+ private void ClearCellItem(Vector2 position)
+ {
+ var cell = _gridCells.FirstOrDefault(cell => cell.Position == position);
+ if(cell != null)
+ {
+ cell.Item = null;
+ }
+ }
+
+ ///
+ /// Sets the state of a cell at a given position in inventory grid space.
+ ///
+ /// The position of the cell to set.
+ /// The state to set the cell
+ private void SetCellState(Vector2 position, EnumInventoryGridCellState state)
+ {
+ var cell = _gridCells.FirstOrDefault(cell => cell.Position == position);
+ if(cell != null)
+ {
+ cell.State = state;
+ }
+ }
+
+ ///
+ /// Sets the state of a selection of cells at a given position and size in inventory grid space.
+ ///
+ /// The position of the cells to set from the top left..
+ /// The size of the area to set starting at the top left.
+ /// The state to set the cells
+ private void SetCellAreaState(Vector2 position, Vector2 size, EnumInventoryGridCellState state)
+ {
+ foreach (var cell in _gridCells.Where(cell => cell.Position.X >= position.X && cell.Position.X < position.X + size.X && cell.Position.Y >= position.Y && cell.Position.Y < position.Y + size.Y))
+ {
+ cell.State = state;
+ }
+ }
+
+ ///
+ /// Gets the first available cell position that can fit an item of a given size.
+ ///
+ /// The size to check for.
+ /// The first coordinates available for something of the given size, or null if no space available.
+ private Vector2? GetAvailableCellPosition(Vector2 size)
+ {
+ var availableCells = _gridCells.Where(cell => cell.State == EnumInventoryGridCellState.Available);
+ var cell = availableCells.FirstOrDefault();
+ if(cell != null)
+ {
+ return cell.Position;
+ }
+
+ for (int x = 0; x <= _gridWidth - size.X; x++)
+ {
+ for (int y = 0; y <= _gridHeight - size.Y; y++)
+ {
+ // Check if the area is available
+ if (IsSpaceAvailable(new Vector2(x, y), size))
+ {
+ return new Vector2(x,y);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ ///
+ /// This checks all of the cells in a space to see if all of them are available.
+ ///
+ /// The top left position of the item in the inventories grid space.
+ /// The size of the item in inventory grid space.
+ /// A List of cells that are available for the item to be placed in.
+ private bool IsSpaceAvailable(Vector2 position, Vector2 size)
+ {
+ var cells = _gridCells.Where( cell => cell.Position.X >= position.X && cell.Position.X < position.X + size.X && cell.Position.Y >= position.Y && cell.Position.Y < position.Y + size.Y);
+ return cells.All(cell => cell.State == EnumInventoryGridCellState.Available);
+ }
+ #endregion
+
+ #region Public Methods
+
+ ///
+ /// Adds an item to the inventory grid.
+ ///
+ /// The ID of the item to add.
+ /// The position to add the item at in inventory grid space. If null then will insert at first available place.
+ ///
+ public bool AddItem(string itemId, Vector2? position)
+ {
+ var item = ItemDatabase.Instance.GetItemConfiguration(itemId);
+ if(item == null)
+ {
+ GD.PrintErr("Attempted to add item with id " + itemId + ", which does not exist.");
+ return false;
+ }
+
+ if(position.HasValue==false)
+ {
+ position = GetAvailableCellPosition(item.Size);
+ }
+
+ if (position.HasValue==false)
+ {
+ GD.PrintErr("Attempted to add item with id " + itemId + ", but there is no space available.");
+ return false;
+ }
+
+ SetCellAreaState((Vector2)position, item.Size, EnumInventoryGridCellState.Unavailable);
+ return true;
+ }
+ #endregion
+
+}
\ No newline at end of file
diff --git a/Code/InventoryController.cs b/Code/InventoryController.cs
new file mode 100644
index 0000000..e5c40e3
--- /dev/null
+++ b/Code/InventoryController.cs
@@ -0,0 +1,8 @@
+using Godot;
+
+namespace GodotGridInventory.Code;
+
+public class InventoryController : Node
+{
+
+}
\ No newline at end of file
diff --git a/Code/ItemDatabase/ItemDatabase.cs b/Code/ItemDatabase/ItemDatabase.cs
new file mode 100644
index 0000000..fe8f7d0
--- /dev/null
+++ b/Code/ItemDatabase/ItemDatabase.cs
@@ -0,0 +1,33 @@
+using System.Linq;
+using Godot;
+using Godot.Collections;
+
+namespace GodotGridInventory.Code;
+
+public class ItemDatabase
+{
+ public static ItemDatabase Instance { get; } = new();
+ private readonly Dictionary _itemDatabase = new();
+
+
+
+ public ItemConfiguration GetItemConfiguration(string id)
+ {
+ return _itemDatabase[id];
+ }
+
+ private void InitializeItemDatabase()
+ {
+ GD.Print("Initializing the item database.");
+ var items = DirAccess.GetFilesAt(ItemDatabaseConstants.ITEMS_PATH).Where(filePath => filePath.EndsWith(ItemDatabaseConstants.ITEM_EXTENSION));
+ foreach (var item in items)
+ {
+ var itemResource = GD.Load(item);
+ if (itemResource != null)
+ {
+ _itemDatabase.Add(itemResource.Id, itemResource);
+ GD.Print($"Loaded item {itemResource.Name} with id {itemResource.Id} into the item database.");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Code/ItemDatabase/ItemDatabaseConstants.cs b/Code/ItemDatabase/ItemDatabaseConstants.cs
new file mode 100644
index 0000000..0d74828
--- /dev/null
+++ b/Code/ItemDatabase/ItemDatabaseConstants.cs
@@ -0,0 +1,7 @@
+namespace GodotGridInventory.Code;
+
+public class ItemDatabaseConstants
+{
+ public static string ITEMS_PATH = "res://grid_inventory_system/items";
+ public static string ITEM_EXTENSION = ".tres";
+}
\ No newline at end of file
diff --git a/Code/Items/Enums/EnumItemActions.cs b/Code/Items/Enums/EnumItemActions.cs
new file mode 100644
index 0000000..8124a78
--- /dev/null
+++ b/Code/Items/Enums/EnumItemActions.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace GodotGridInventory.Code.Items.Enums;
+
+[Flags]
+public enum EnumItemActions
+{
+ None = 0,
+ Examine = 1 << 1,
+ Equip = 1 << 2,
+ Use = 1 << 3,
+ Open = 1 << 4,
+ Drop = 1 << 5,
+ Destroy = 1 << 6
+}
\ No newline at end of file
diff --git a/Code/Items/ItemConfiguration.cs b/Code/Items/ItemConfiguration.cs
new file mode 100644
index 0000000..8238d73
--- /dev/null
+++ b/Code/Items/ItemConfiguration.cs
@@ -0,0 +1,15 @@
+using Godot;
+using System;
+using GodotGridInventory.Code.Items.Enums;
+
+[GlobalClass, Icon("res://icon.svg")]
+public partial class ItemConfiguration : Resource
+{
+ [Export] public string Id { get; set; }
+ [Export] public string Name { get; set; }
+ [Export] public string Description { get; set; }
+ [Export] public Vector2 Size { get; set; }
+ [Export] public Texture2D Texture { get; set; }
+ [Export] public EnumItemActions Actions { get; set; }
+ [Export] public string[] Slots { get; set; }
+}
diff --git a/Godot Grid Inventory.csproj b/Godot Grid Inventory.csproj
new file mode 100644
index 0000000..595f480
--- /dev/null
+++ b/Godot Grid Inventory.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+ net7.0
+ net8.0
+ true
+ GodotGridInventory
+
+
\ No newline at end of file
diff --git a/Godot Grid Inventory.sln b/Godot Grid Inventory.sln
new file mode 100644
index 0000000..7a48343
--- /dev/null
+++ b/Godot Grid Inventory.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Godot Grid Inventory", "Godot Grid Inventory.csproj", "{93B1D768-2E58-417C-B620-206485D0BF80}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ ExportDebug|Any CPU = ExportDebug|Any CPU
+ ExportRelease|Any CPU = ExportRelease|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {93B1D768-2E58-417C-B620-206485D0BF80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {93B1D768-2E58-417C-B620-206485D0BF80}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93B1D768-2E58-417C-B620-206485D0BF80}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
+ {93B1D768-2E58-417C-B620-206485D0BF80}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
+ {93B1D768-2E58-417C-B620-206485D0BF80}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
+ {93B1D768-2E58-417C-B620-206485D0BF80}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/Resources/Items/debug_item_small.tres b/Resources/Items/debug_item_small.tres
new file mode 100644
index 0000000..ac7e038
--- /dev/null
+++ b/Resources/Items/debug_item_small.tres
@@ -0,0 +1,14 @@
+[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://c8ge77yvt0q84"]
+
+[ext_resource type="Script" path="res://Code/Items/ItemConfiguration.cs" id="1_8ae1i"]
+[ext_resource type="Texture2D" uid="uid://bj3tjdbw5xdlj" path="res://icon.svg" id="1_arnqm"]
+
+[resource]
+script = ExtResource("1_8ae1i")
+Id = "item_small"
+Name = "Item Small"
+Description = "A small item."
+Size = Vector2(3, 3)
+Texture = ExtResource("1_arnqm")
+Actions = 0
+Slots = PackedStringArray()
diff --git a/debug.gd b/debug.gd
deleted file mode 100644
index 55f9fc6..0000000
--- a/debug.gd
+++ /dev/null
@@ -1,33 +0,0 @@
-extends Node
-
-
-@export var inventory:InventoryController
-@export var grid:GridContainer
-func _ready():
- var items = ItemDb.ITEMS
- for item in items:
- var button = Button.new()
- grid.add_child(button)
- button.text = "Spawn "+item
- button.connect("pressed", func():
- inventory.pickup_item(item))
-
-
-func _on_button_3_pressed():
- $"..".pickup_item("small_debug_item")
-
-
-func _on_button_2_pressed():
- $"..".pickup_item("medium_debug_item")
-
-
-func _on_button_pressed():
- $"..".pickup_item("large_debug_item")
-
-
-func _on_button_4_pressed():
- $"..".pickup_item("shirt")
-
-
-func _on_button_5_pressed():
- $"..".pickup_item("hat")
diff --git a/grid_inventory_system/debug/debug_ui.tscn b/grid_inventory_system/debug/debug_ui.tscn
deleted file mode 100644
index 1c313c9..0000000
--- a/grid_inventory_system/debug/debug_ui.tscn
+++ /dev/null
@@ -1,20 +0,0 @@
-[gd_scene load_steps=3 format=3 uid="uid://c2c7v5idagdqr"]
-
-[ext_resource type="Script" path="res://debug.gd" id="1_qtffx"]
-
-[sub_resource type="GDScript" id="GDScript_fqjhy"]
-
-[node name="DEBUG" type="Node" node_paths=PackedStringArray("grid")]
-script = ExtResource("1_qtffx")
-grid = NodePath("Items/GridContainer")
-
-[node name="Items" type="ScrollContainer" parent="."]
-anchors_preset = 9
-anchor_bottom = 1.0
-offset_right = 228.0
-grow_vertical = 2
-script = SubResource("GDScript_fqjhy")
-
-[node name="GridContainer" type="GridContainer" parent="Items"]
-unique_name_in_owner = true
-layout_mode = 2
diff --git a/grid_inventory_system/debug/hat.png b/grid_inventory_system/debug/hat.png
deleted file mode 100644
index a0c47f1..0000000
Binary files a/grid_inventory_system/debug/hat.png and /dev/null differ
diff --git a/grid_inventory_system/debug/hat.png.import b/grid_inventory_system/debug/hat.png.import
deleted file mode 100644
index fae23e0..0000000
--- a/grid_inventory_system/debug/hat.png.import
+++ /dev/null
@@ -1,34 +0,0 @@
-[remap]
-
-importer="texture"
-type="CompressedTexture2D"
-uid="uid://ghlfm76i4kve"
-path="res://.godot/imported/hat.png-706aaac0cb9cc74c2e7d8c97ed023b0c.ctex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://grid_inventory_system/debug/hat.png"
-dest_files=["res://.godot/imported/hat.png-706aaac0cb9cc74c2e7d8c97ed023b0c.ctex"]
-
-[params]
-
-compress/mode=3
-compress/high_quality=false
-compress/lossy_quality=0.7
-compress/hdr_compression=1
-compress/normal_map=0
-compress/channel_pack=0
-mipmaps/generate=false
-mipmaps/limit=-1
-roughness/mode=0
-roughness/src_normal=""
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/normal_map_invert_y=false
-process/hdr_as_srgb=false
-process/hdr_clamp_exposure=false
-process/size_limit=0
-detect_3d/compress_to=1
diff --git a/grid_inventory_system/debug/shirt.png b/grid_inventory_system/debug/shirt.png
deleted file mode 100644
index 73a53ea..0000000
Binary files a/grid_inventory_system/debug/shirt.png and /dev/null differ
diff --git a/grid_inventory_system/debug/shirt.png.import b/grid_inventory_system/debug/shirt.png.import
deleted file mode 100644
index 9db8585..0000000
--- a/grid_inventory_system/debug/shirt.png.import
+++ /dev/null
@@ -1,34 +0,0 @@
-[remap]
-
-importer="texture"
-type="CompressedTexture2D"
-uid="uid://bdfcmsyry3sg3"
-path="res://.godot/imported/shirt.png-c04d1f8c53dc5f843f267734a8b0f810.ctex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://grid_inventory_system/debug/shirt.png"
-dest_files=["res://.godot/imported/shirt.png-c04d1f8c53dc5f843f267734a8b0f810.ctex"]
-
-[params]
-
-compress/mode=3
-compress/high_quality=false
-compress/lossy_quality=0.7
-compress/hdr_compression=1
-compress/normal_map=0
-compress/channel_pack=0
-mipmaps/generate=false
-mipmaps/limit=-1
-roughness/mode=0
-roughness/src_normal=""
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/normal_map_invert_y=false
-process/hdr_as_srgb=false
-process/hdr_clamp_exposure=false
-process/size_limit=0
-detect_3d/compress_to=1
diff --git a/grid_inventory_system/items/body.tres b/grid_inventory_system/items/body.tres
deleted file mode 100644
index efb3d4b..0000000
--- a/grid_inventory_system/items/body.tres
+++ /dev/null
@@ -1,18 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://bu1t7ogoct2pm"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="1_f4bsa"]
-[ext_resource type="Texture2D" uid="uid://bdfcmsyry3sg3" path="res://grid_inventory_system/debug/shirt.png" id="1_gmlai"]
-
-[resource]
-script = ExtResource("1_f4bsa")
-item_id = "shirt"
-item_name = "Shirt"
-item_description = "This is a shirt"
-item_size = Vector2(256, 256)
-item_usable = false
-item_openable = false
-item_droppable = false
-item_destroyable = false
-item_equipment = true
-item_equipment_slot = "BODY"
-item_texture = ExtResource("1_gmlai")
diff --git a/grid_inventory_system/items/head.tres b/grid_inventory_system/items/head.tres
deleted file mode 100644
index 733d16a..0000000
--- a/grid_inventory_system/items/head.tres
+++ /dev/null
@@ -1,18 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://cauw4i0kveld6"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="1_hflmv"]
-[ext_resource type="Texture2D" uid="uid://ghlfm76i4kve" path="res://grid_inventory_system/debug/hat.png" id="1_vm0jo"]
-
-[resource]
-script = ExtResource("1_hflmv")
-item_id = "hat"
-item_name = "Hat"
-item_description = "This is a hat"
-item_size = Vector2(224, 160)
-item_usable = false
-item_openable = false
-item_droppable = false
-item_destroyable = false
-item_equipment = true
-item_equipment_slot = "HEAD"
-item_texture = ExtResource("1_vm0jo")
diff --git a/grid_inventory_system/items/large_debug_item.tres b/grid_inventory_system/items/large_debug_item.tres
deleted file mode 100644
index 08394b9..0000000
--- a/grid_inventory_system/items/large_debug_item.tres
+++ /dev/null
@@ -1,18 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://d2orfaiyhg0sa"]
-
-[ext_resource type="Texture2D" uid="uid://bdvx58rwnaeev" path="res://icon.svg" id="1_l6twi"]
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="2_40ofh"]
-
-[resource]
-script = ExtResource("2_40ofh")
-item_id = "large_debug_item"
-item_name = "Debug Item Large"
-item_description = "A large item for debugging."
-item_size = Vector2(256, 256)
-item_usable = true
-item_openable = false
-item_droppable = false
-item_destroyable = true
-item_equipment = false
-item_equipment_slot = "NONE"
-item_texture = ExtResource("1_l6twi")
diff --git a/grid_inventory_system/items/medium_debug_item.tres b/grid_inventory_system/items/medium_debug_item.tres
deleted file mode 100644
index 50005f4..0000000
--- a/grid_inventory_system/items/medium_debug_item.tres
+++ /dev/null
@@ -1,18 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://drkcx6hkx0ay8"]
-
-[ext_resource type="Texture2D" uid="uid://bdvx58rwnaeev" path="res://icon.svg" id="1_jwlst"]
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="2_xdqd2"]
-
-[resource]
-script = ExtResource("2_xdqd2")
-item_id = "medium_debug_item"
-item_name = "Debug Item Medium"
-item_description = "A medium item for debugging."
-item_size = Vector2(128, 128)
-item_usable = false
-item_openable = true
-item_droppable = true
-item_destroyable = false
-item_equipment = false
-item_equipment_slot = "NONE"
-item_texture = ExtResource("1_jwlst")
diff --git a/grid_inventory_system/items/small_debug_item.tres b/grid_inventory_system/items/small_debug_item.tres
deleted file mode 100644
index 1365464..0000000
--- a/grid_inventory_system/items/small_debug_item.tres
+++ /dev/null
@@ -1,18 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=3 format=3 uid="uid://p3m1yi3kw1q6"]
-
-[ext_resource type="Texture2D" uid="uid://bdvx58rwnaeev" path="res://icon.svg" id="1_g0vsl"]
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="2_lq0i6"]
-
-[resource]
-script = ExtResource("2_lq0i6")
-item_id = "small_debug_item"
-item_name = "Debug Item Small"
-item_description = "A small item for debugging."
-item_size = Vector2(64, 64)
-item_usable = false
-item_openable = false
-item_droppable = false
-item_destroyable = true
-item_equipment = false
-item_equipment_slot = "NONE"
-item_texture = ExtResource("1_g0vsl")
diff --git a/grid_inventory_system/items/weapon.tres b/grid_inventory_system/items/weapon.tres
deleted file mode 100644
index 8805e94..0000000
--- a/grid_inventory_system/items/weapon.tres
+++ /dev/null
@@ -1,13 +0,0 @@
-[gd_resource type="Resource" script_class="ItemConfiguration" load_steps=2 format=3 uid="uid://cvy3nwmcgx5le"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemConfiguration.gd" id="1_jvmcf"]
-
-[resource]
-script = ExtResource("1_jvmcf")
-item_id = "item"
-item_name = "Item Name"
-item_description = "This is the default item description."
-item_size = Vector2(3, 3)
-item_usable = false
-item_equipment = false
-item_equipment_slot = "NONE"
diff --git a/grid_inventory_system/scenes/ContextMenu.tscn b/grid_inventory_system/scenes/ContextMenu.tscn
deleted file mode 100644
index d96757f..0000000
--- a/grid_inventory_system/scenes/ContextMenu.tscn
+++ /dev/null
@@ -1,50 +0,0 @@
-[gd_scene load_steps=2 format=3 uid="uid://bkmpq37oqwww8"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ContextMenu.gd" id="1_dwa8t"]
-
-[node name="ContextMenu" type="Panel" node_paths=PackedStringArray("use_button", "open_button", "drop_button", "destroy_button")]
-custom_minimum_size = Vector2(160, 0)
-offset_left = 240.0
-offset_top = 102.0
-offset_right = 400.0
-offset_bottom = 210.0
-script = ExtResource("1_dwa8t")
-use_button = NodePath("ContextOptions/Use")
-open_button = NodePath("ContextOptions/Open")
-drop_button = NodePath("ContextOptions/Drop")
-destroy_button = NodePath("ContextOptions/Destroy")
-
-[node name="ContextOptions" type="GridContainer" parent="."]
-layout_mode = 0
-offset_left = 5.0
-offset_top = 4.0
-offset_right = 95.0
-offset_bottom = 42.0
-
-[node name="Use" type="Button" parent="ContextOptions"]
-custom_minimum_size = Vector2(150, 0)
-layout_mode = 2
-size_flags_horizontal = 3
-theme_override_font_sizes/font_size = 10
-text = "Use"
-
-[node name="Open" type="Button" parent="ContextOptions"]
-custom_minimum_size = Vector2(150, 0)
-layout_mode = 2
-size_flags_horizontal = 3
-theme_override_font_sizes/font_size = 10
-text = "Open"
-
-[node name="Drop" type="Button" parent="ContextOptions"]
-custom_minimum_size = Vector2(150, 0)
-layout_mode = 2
-size_flags_horizontal = 3
-theme_override_font_sizes/font_size = 10
-text = "Drop"
-
-[node name="Destroy" type="Button" parent="ContextOptions"]
-custom_minimum_size = Vector2(150, 0)
-layout_mode = 2
-size_flags_horizontal = 3
-theme_override_font_sizes/font_size = 10
-text = "Destroy"
diff --git a/grid_inventory_system/scenes/Inventory.tscn b/grid_inventory_system/scenes/Inventory.tscn
deleted file mode 100644
index ae214ac..0000000
--- a/grid_inventory_system/scenes/Inventory.tscn
+++ /dev/null
@@ -1,129 +0,0 @@
-[gd_scene load_steps=5 format=3 uid="uid://brs6u78mwggbp"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/InventoryController.gd" id="1_pdgp8"]
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/ItemSlot.gd" id="2_7s2pc"]
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/InventoryGrid.gd" id="3_05dq4"]
-[ext_resource type="PackedScene" uid="uid://c2c7v5idagdqr" path="res://grid_inventory_system/debug/debug_ui.tscn" id="4_w8gq7"]
-
-[node name="Inventory" type="Control" node_paths=PackedStringArray("inventory_grid", "inventory_loot_grid", "inventory_background", "inventory_equipment_slots")]
-layout_mode = 3
-anchors_preset = 15
-anchor_right = 1.0
-anchor_bottom = 1.0
-grow_horizontal = 2
-grow_vertical = 2
-script = ExtResource("1_pdgp8")
-inventory_grid = NodePath("UI/Background/Items")
-inventory_loot_grid = NodePath("UI/Background/ColorRect/LootItems")
-inventory_background = NodePath("UI/Background")
-inventory_equipment_slots = NodePath("UI/Background/Equipment")
-
-[node name="UI" type="CanvasLayer" parent="."]
-
-[node name="Background" type="ColorRect" parent="UI"]
-anchors_preset = 8
-anchor_left = 0.5
-anchor_top = 0.5
-anchor_right = 0.5
-anchor_bottom = 0.5
-offset_left = -473.5
-offset_top = -462.0
-offset_right = 473.5
-offset_bottom = 9.0
-grow_horizontal = 2
-grow_vertical = 2
-color = Color(0.121569, 0.121569, 0.121569, 1)
-
-[node name="Equipment" type="ColorRect" parent="UI/Background"]
-layout_mode = 1
-anchors_preset = 11
-anchor_left = 1.0
-anchor_right = 1.0
-anchor_bottom = 1.0
-offset_left = -237.0
-offset_top = 4.0
-offset_right = -4.0
-offset_bottom = -4.0
-grow_horizontal = 0
-grow_vertical = 2
-color = Color(0.184314, 0.184314, 0.184314, 1)
-script = ExtResource("2_7s2pc")
-
-[node name="HEAD" type="ColorRect" parent="UI/Background/Equipment"]
-layout_mode = 1
-anchors_preset = 5
-anchor_left = 0.5
-anchor_right = 0.5
-offset_left = -37.0
-offset_top = 16.5
-offset_right = 38.0
-offset_bottom = 91.5
-grow_horizontal = 2
-color = Color(0.278431, 0.278431, 0.278431, 1)
-
-[node name="BODY" type="ColorRect" parent="UI/Background/Equipment"]
-layout_mode = 1
-anchors_preset = 4
-anchor_top = 0.5
-anchor_bottom = 0.5
-offset_left = 32.5
-offset_top = -121.0
-offset_right = 202.5
-offset_bottom = 49.0
-grow_vertical = 2
-color = Color(0.278431, 0.278431, 0.278431, 1)
-
-[node name="WEAPON" type="ColorRect" parent="UI/Background/Equipment"]
-layout_mode = 1
-anchors_preset = 4
-anchor_top = 0.5
-anchor_bottom = 0.5
-offset_left = 7.5
-offset_top = 91.0
-offset_right = 227.5
-offset_bottom = 194.0
-grow_vertical = 2
-color = Color(0.278431, 0.278431, 0.278431, 1)
-
-[node name="ColorRect" type="ColorRect" parent="UI/Background"]
-layout_mode = 0
-offset_left = -3.0
-offset_top = 470.0
-offset_right = 711.0
-offset_bottom = 717.0
-color = Color(0.105882, 0.105882, 0.105882, 0.905882)
-
-[node name="LootItems" type="ColorRect" parent="UI/Background/ColorRect"]
-layout_mode = 1
-anchors_preset = 9
-anchor_bottom = 1.0
-offset_left = 15.0
-offset_top = 8.0
-offset_right = 704.0
-offset_bottom = -14.0
-grow_vertical = 2
-color = Color(0.164706, 0.164706, 0.164706, 1)
-script = ExtResource("3_05dq4")
-inventory_item_grid_width = 21
-inventory_item_grid_height = 7
-inventory_grid_default_color = Color(1, 1, 1, 1)
-inventory_grid_used_color = Color(0, 1, 0, 1)
-
-[node name="Items" type="ColorRect" parent="UI/Background"]
-layout_mode = 1
-anchors_preset = 9
-anchor_bottom = 1.0
-offset_left = 12.0
-offset_top = 8.0
-offset_right = 701.0
-offset_bottom = -8.0
-grow_vertical = 2
-color = Color(0.164706, 0.164706, 0.164706, 1)
-script = ExtResource("3_05dq4")
-inventory_item_grid_width = 21
-inventory_item_grid_height = 14
-inventory_grid_default_color = Color(1, 1, 1, 1)
-inventory_grid_used_color = Color(0, 1, 0, 1)
-
-[node name="DEBUG" parent="." node_paths=PackedStringArray("inventory") instance=ExtResource("4_w8gq7")]
-inventory = NodePath("..")
diff --git a/grid_inventory_system/scenes/InventorySlot.tscn b/grid_inventory_system/scenes/InventorySlot.tscn
deleted file mode 100644
index 5e890c7..0000000
--- a/grid_inventory_system/scenes/InventorySlot.tscn
+++ /dev/null
@@ -1,22 +0,0 @@
-[gd_scene load_steps=3 format=3 uid="uid://b1nobn0glk4ru"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/InventorySlot.gd" id="1_wp4po"]
-[ext_resource type="Texture2D" uid="uid://bdvx58rwnaeev" path="res://icon.svg" id="2_1w5re"]
-
-[node name="InventorySlot" type="Control"]
-layout_mode = 3
-anchors_preset = 15
-anchor_right = 1.0
-anchor_bottom = 1.0
-offset_right = -1888.0
-offset_bottom = -1048.0
-grow_horizontal = 2
-grow_vertical = 2
-script = ExtResource("1_wp4po")
-
-[node name="TextureRect" type="TextureRect" parent="."]
-layout_mode = 1
-offset_right = 10.0
-offset_bottom = 10.0
-texture = ExtResource("2_1w5re")
-expand_mode = 1
diff --git a/grid_inventory_system/scenes/Item.tscn b/grid_inventory_system/scenes/Item.tscn
deleted file mode 100644
index 93261d3..0000000
--- a/grid_inventory_system/scenes/Item.tscn
+++ /dev/null
@@ -1,25 +0,0 @@
-[gd_scene load_steps=3 format=3 uid="uid://dtir5hovd6i3h"]
-
-[ext_resource type="Script" path="res://grid_inventory_system/scripts/Item.gd" id="1_cs6rn"]
-[ext_resource type="Texture2D" uid="uid://bdvx58rwnaeev" path="res://icon.svg" id="2_uetec"]
-
-[node name="Item" type="Control" node_paths=PackedStringArray("graphic")]
-clip_contents = true
-layout_mode = 3
-anchors_preset = 0
-offset_right = 100.0
-offset_bottom = 100.0
-script = ExtResource("1_cs6rn")
-graphic = NodePath("Graphic")
-
-[node name="Graphic" type="TextureRect" parent="."]
-unique_name_in_owner = true
-clip_contents = true
-layout_mode = 0
-offset_right = 40.0
-offset_bottom = 40.0
-pivot_offset = Vector2(20, 20)
-texture = ExtResource("2_uetec")
-expand_mode = 1
-
-[node name="Node" type="Node" parent="."]
diff --git a/grid_inventory_system/scripts/ContextMenu.gd b/grid_inventory_system/scripts/ContextMenu.gd
deleted file mode 100644
index 4661e35..0000000
--- a/grid_inventory_system/scripts/ContextMenu.gd
+++ /dev/null
@@ -1,19 +0,0 @@
-extends Panel
-class_name ContextMenu
-
-@export var use_button:Button
-@export var open_button:Button
-@export var drop_button:Button
-@export var destroy_button:Button
-
-func set_use(disabled):
- use_button.disabled=disabled
-
-func set_open(disabled):
- open_button.disabled=disabled
-
-func set_drop(disabled):
- drop_button.disabled=disabled
-
-func set_destroy(disabled):
- destroy_button.disabled=disabled
diff --git a/grid_inventory_system/scripts/InventoryController.gd b/grid_inventory_system/scripts/InventoryController.gd
deleted file mode 100644
index a07d890..0000000
--- a/grid_inventory_system/scripts/InventoryController.gd
+++ /dev/null
@@ -1,173 +0,0 @@
-extends Control
-class_name InventoryController
-const ITEM_BASE = preload("res://grid_inventory_system/scenes/Item.tscn")
-const CONTEXT_MENU = preload("res://grid_inventory_system/scenes/ContextMenu.tscn")
-@export var inventory_open_input:String = "inventory_open"
-@export var inventory_close_input:String = "inventory_close"
-@export var inventory_use_input:String = "inventory_use"
-@export var inventory_grab_input:String = "inventory_grab"
-@export var inventory_rotate_input:String = "inventory_rotate"
-@export var inventory_grid:Control
-@export var inventory_loot_grid:Control
-@export var inventory_background:Control
-@export var inventory_equipment_slots:Control
-
-
-var inventory_open = true
-var inventory_item_dragged = null
-var inventory_item_cursor_offset = Vector2()
-var inventory_item_dragged_last_container = null
-var inventory_item_dragged_last_pos = Vector2()
-var inventory_context_menu:Control = null
-var inventory_context_menu_item
-
-
-signal inventory_item_equipped(item_config,slot)
-signal inventory_item_unequipped(item_config,slot)
-signal inventory_item_dropped(item_config)
-signal inventory_item_grabbed(item_config, x, y, container)
-signal inventory_item_released(item_config, x, y, container)
-signal inventory_item_used(item_config, x, y)
-signal inventory_item_destroyed(item_config, x, y)
-signal inventory_item_opened(item_config, x, y)
-
-func _ready():
- if(inventory_grid==null):
- printerr("The inventory grid was not assigned to the inventory controller!")
- if(inventory_background==null):
- printerr("The inventory background was not assigned to the inventory controller!")
- if(inventory_grid==null):
- printerr("The inventory equipment slots was not assigned to the inventory controller!")
-
-func _process(delta):
- if(Input.is_action_just_pressed(inventory_open_input) and inventory_open==false):
- inventory_open = true
- inventory_background.visible=true
-
- if(Input.is_action_just_pressed(inventory_close_input) and inventory_open==true):
- inventory_open = false
- inventory_background.visible=false
-
- if(Input.is_action_just_pressed(inventory_rotate_input) and inventory_open==true and inventory_item_dragged != null):
- inventory_item_dragged.rotate_item(90)
-
- var cursor_pos = get_global_mouse_position()
-
- if Input.is_action_just_pressed("inventory_grab"):
- grab(cursor_pos)
-
- if Input.is_action_just_released("inventory_grab"):
- release(cursor_pos)
-
- if Input.is_action_just_pressed("inventory_use"):
- try_to_open_context_menu()
-
-
- if inventory_item_dragged != null:
- inventory_item_dragged.global_position = cursor_pos + inventory_item_cursor_offset
-
-func try_to_open_context_menu():
- var mouse_position = get_global_mouse_position()
- var c = _get_container_mouse_over()
- if c != null and c.has_method("grab_item"):
- var item = c.check_item(mouse_position)
- if item != null:
- if(inventory_context_menu!=null):
- inventory_context_menu.queue_free()
- show_context_menu(mouse_position,item)
- else:
- hide_context_menu()
-
-
-# Function to show the context menu at a specific position
-func show_context_menu(mouse_pos: Vector2, item):
- inventory_context_menu = CONTEXT_MENU.instantiate()
- inventory_background.add_child(inventory_context_menu)
- inventory_context_menu.global_position = mouse_pos + Vector2(-20,-15)
- inventory_context_menu.set_use(not item.item_config.item_usable)
- inventory_context_menu.set_drop(not item.item_config.item_droppable)
- inventory_context_menu.set_destroy(not item.item_config.item_destroyable)
- inventory_context_menu.set_open(not item.item_config.item_openable)
- inventory_context_menu_item = item
-# Function to hide the context menu
-func hide_context_menu():
- if(inventory_context_menu!=null):
- inventory_context_menu_item=null
- inventory_context_menu.queue_free()
-
-func context_menu_open():
- print("OPEN!")
-
-func context_menu_use():
- print("USED!")
-
-func context_menu_destroy():
- print("DESTROYED!")
-
-func context_menu_drop():
- print("DROPPED!")
-
-func grab(cursor_pos):
- var c = _get_container_mouse_over()
- if c != null and c.has_method("grab_item"):
- inventory_item_dragged = c.grab_item(cursor_pos)
- if inventory_item_dragged != null:
- add_child(inventory_item_dragged)
- inventory_item_dragged_last_container = c
- inventory_item_dragged_last_pos = inventory_item_dragged.global_position
- inventory_item_cursor_offset = inventory_item_dragged.global_position - cursor_pos
- if(inventory_context_menu_item==inventory_item_dragged):
- release(cursor_pos)
-
-func release(cursor_pos):
- if inventory_item_dragged == null:
- return
- var c = _get_container_mouse_over()
- if c == null:
- drop_item()
- elif c.has_method("insert_item"):
- if c.insert_item(inventory_item_dragged):
- inventory_item_dragged = null
- else:
- return_item()
- else:
- return_item()
-
-func use(cursor_pos):
- pass
-
-func pickup_item(item_id):
- var item = ITEM_BASE.instantiate()
- item.set_meta("id", item_id)
- item.init_item(item_id)
- if not inventory_grid.insert_item_at_first_available_spot(item):
- item.queue_free()
- return false
- return true
-
-func drop_item():
- inventory_item_dropped.emit(inventory_item_dragged.item_config)
- inventory_item_dragged.queue_free()
- inventory_item_dragged = null
-
-# Function to return the dragged item to its original position or container
-func return_item():
- inventory_item_dragged.global_position = inventory_item_dragged_last_pos
- inventory_item_dragged_last_container.insert_item(inventory_item_dragged)
- inventory_item_dragged = null
-
-func _get_container_mouse_over():
-
- if(_is_mouse_ontop_of_control(inventory_grid)==true):
- return inventory_grid
- elif(_is_mouse_ontop_of_control(inventory_loot_grid)==true):
- return inventory_loot_grid
- elif(_is_mouse_ontop_of_control(inventory_equipment_slots)==true):
- return inventory_equipment_slots
- elif(_is_mouse_ontop_of_control(inventory_background)==true):
- return inventory_background
- return null
-
-func _is_mouse_ontop_of_control(c):
- var cursor_pos = get_global_mouse_position()
- return c.get_global_rect().has_point(cursor_pos)
diff --git a/grid_inventory_system/scripts/InventoryGrid.gd b/grid_inventory_system/scripts/InventoryGrid.gd
deleted file mode 100644
index bfcb8e0..0000000
--- a/grid_inventory_system/scripts/InventoryGrid.gd
+++ /dev/null
@@ -1,149 +0,0 @@
-extends ColorRect
-class_name InventoryItemGrid
-
-# Arrays to store inventory items and the grid representation
-var inventory_item_grid_items = []
-
-# 2D dictionary to represent the inventory grid, where each cell has information about usage and a corresponding ColorRect node
-var inventory_item_grid = {}
-var inventory_item_grid_cell_size = 32
-@export var inventory_item_grid_width = 0
-@export var inventory_item_grid_height = 0
-@export var inventory_grid_default_color: Color
-@export var inventory_grid_used_color: Color
-
-# Signals for item-related events
-signal weapon_equipped(weapon_id, item)
-signal weapon_unequipped(weapon_id, item)
-signal item_used(item_id)
-
-func _ready():
- # Initialize the inventory grid
- for x in range(inventory_item_grid_width):
- inventory_item_grid[x] = {}
- for y in range(inventory_item_grid_height):
- inventory_item_grid[x][y] = {}
- inventory_item_grid[x][y]["used"] = false
-
- # Create ColorRect nodes for each grid cell and set their default colors
- for y in range(inventory_item_grid_height):
- for x in range(inventory_item_grid_width):
- var color_rect = ColorRect.new()
- color_rect.global_position = Vector2(x * inventory_item_grid_cell_size, y * inventory_item_grid_cell_size)
- color_rect.size = Vector2(inventory_item_grid_cell_size - 2, inventory_item_grid_cell_size - 2)
- add_child(color_rect)
- color_rect.color = inventory_grid_default_color
- inventory_item_grid[x][y]["rect"] = color_rect
-
-# Function to insert an item into the inventory grid
-func insert_item(item):
- var item_pos = item.global_position-global_position
- var g_pos = pos_to_grid_coord(item_pos)
- var item_size = get_grid_size(item)
-
- # Check if there is enough space to insert the item
- if is_grid_space_available(g_pos.x, g_pos.y, item_size.x, item_size.y)==true:
- set_grid_space(g_pos.x, g_pos.y, item_size.x, item_size.y, true)
- item.position = Vector2(g_pos.x, g_pos.y) * inventory_item_grid_cell_size
- var parent = item.get_parent()
- if(parent!=null):
- parent.remove_child(item)
- add_child(item)
- inventory_item_grid_items.append(item)
- return true
- else:
- return false
-
-# Function to grab an item from the inventory grid based on a position
-func grab_item(pos):
- var item = get_item_under_pos(pos)
- if item == null:
- return null
-
- var item_pos = item.position
- var g_pos = pos_to_grid_coord(item_pos)
- var item_size = get_grid_size(item)
- set_grid_space(g_pos.x, g_pos.y, item_size.x, item_size.y, false)
-
- inventory_item_grid_items.remove_at(inventory_item_grid_items.find(item))
- return item
-
-func check_item(pos):
- var item = get_item_under_pos(pos)
- if item == null:
- return null
- return item
-
-# Function to use an item from the inventory grid based on a position
-func use_item(pos):
- var item = get_item_under_pos(pos)
- if item == null:
- return null
-
- # Emit signal if the item is usable
- if item.item_config.item_usable == true:
- item_used.emit(item.item_config.item_id)
- item.queue_free()
-
- var item_size = get_grid_size(item)
- var item_pos = item.global_position-global_position
- var g_pos = pos_to_grid_coord(item_pos)
- inventory_item_grid_items.remove_at(inventory_item_grid_items.find(item))
- set_grid_space(g_pos.x, g_pos.y, item_size.x, item_size.y, false)
-
-# Function to convert global position to grid coordinates
-func pos_to_grid_coord(pos):
- var results = {}
- results.x = int(pos.x / inventory_item_grid_cell_size)
- results.y = int(pos.y / inventory_item_grid_cell_size)
- return results
-
-# Function to get the grid size of an item in terms of grid cells
-func get_grid_size(item):
- var results = {}
- var s = item.size
- results.x = int(clamp(s.x / inventory_item_grid_cell_size, 1.0, 500.0))
- results.y = int(clamp(s.y / inventory_item_grid_cell_size, 1.0, 500.0))
- return results
-
-# Function to check if there is enough space in the grid to place an item
-func is_grid_space_available(x, y, w, h):
- if x < 0 or y < 0:
- return false
- if x + w > inventory_item_grid_width or y + h > inventory_item_grid_height:
- return false
- for i in range(x, x + w):
- for j in range(y, y + h):
- if inventory_item_grid[i][j]["used"] == true:
- return false
- return true
-
-# Function to set the usage state of grid cells and update ColorRect colors accordingly
-func set_grid_space(x, y, w, h, state):
- for i in range(x, x + w):
- for j in range(y, y + h):
- if state == true:
- inventory_item_grid[i][j]["used"] = true
- inventory_item_grid[i][j]["rect"].color = inventory_grid_used_color
- else:
- inventory_item_grid[i][j]["used"] = false
- inventory_item_grid[i][j]["rect"].color = inventory_grid_default_color
-
-# Function to get the item under a given position
-func get_item_under_pos(pos):
- for item in inventory_item_grid_items:
- if item.get_global_rect().has_point(pos):
- return item
- return null
-# Function to insert an item at the first available spot in the grid
-# Function to insert an item at the first available spot in the grid
-func insert_item_at_first_available_spot(item):
- for x in range(inventory_item_grid_width):
- for y in range(inventory_item_grid_height):
- if inventory_item_grid[x][y]["used"] == false:
- item.global_position = global_position+ Vector2(x * inventory_item_grid_cell_size, y * inventory_item_grid_cell_size)
- if insert_item(item) == true:
- print("Item inserted at:", item.position)
- return true
- return false
-
diff --git a/grid_inventory_system/scripts/InventorySlot.gd b/grid_inventory_system/scripts/InventorySlot.gd
deleted file mode 100644
index 438eeba..0000000
--- a/grid_inventory_system/scripts/InventorySlot.gd
+++ /dev/null
@@ -1,11 +0,0 @@
-extends Control
-
-enum slot_state { free, used }
-
-@export var in_use = false
-
-func used():
- in_use = true
-
-func free():
- in_use = false
diff --git a/grid_inventory_system/scripts/Item.gd b/grid_inventory_system/scripts/Item.gd
deleted file mode 100644
index b200047..0000000
--- a/grid_inventory_system/scripts/Item.gd
+++ /dev/null
@@ -1,25 +0,0 @@
-extends Control
-class_name ItemGraphic
-@export var item_config:ItemConfiguration
-@export var graphic:TextureRect
-
-func init_item(item_id):
- var dbItem = ItemDb.get_item(item_id)
- item_config = dbItem
- graphic.set_size(Vector2(dbItem.item_size.x, dbItem.item_size.y))
- set_size(Vector2(dbItem.item_size.x, dbItem.item_size.y))
- graphic.texture = dbItem.item_texture
- graphic.pivot_offset = Vector2(graphic.size.x/2.0, graphic.size.y/2.0)
- pivot_offset = Vector2(graphic.size.x/2.0, graphic.size.y/2.0)
- graphic.position = Vector2()
- print("TEST")
-
-func rotate_item(amount):
- graphic.rotation_degrees = graphic.rotation_degrees+amount
- if(graphic.rotation_degrees==90 or graphic.rotation_degrees==270):
- set_size(Vector2(item_config.item_size.y, item_config.item_size.x))
- else:
- set_size(Vector2(item_config.item_size.x, item_config.item_size.y))
-
- if(graphic.rotation_degrees==360):
- graphic.rotation_degrees=0
diff --git a/grid_inventory_system/scripts/ItemConfiguration.gd b/grid_inventory_system/scripts/ItemConfiguration.gd
deleted file mode 100644
index 49bd6c9..0000000
--- a/grid_inventory_system/scripts/ItemConfiguration.gd
+++ /dev/null
@@ -1,15 +0,0 @@
-extends Resource
-class_name ItemConfiguration
-@export var item_id:String = "item"
-@export var item_name:String = "Item Name"
-@export var item_description:String = "This is the default item description."
-@export var item_size:Vector2 = Vector2(3,3)
-
-@export var item_usable:bool = false
-@export var item_openable:bool = false
-@export var item_droppable:bool = false
-@export var item_destroyable:bool = false
-
-@export var item_equipment:bool = false
-@export var item_equipment_slot:String = "NONE"
-@export var item_texture:Texture2D
diff --git a/grid_inventory_system/scripts/ItemDB.gd b/grid_inventory_system/scripts/ItemDB.gd
deleted file mode 100644
index d7a5475..0000000
--- a/grid_inventory_system/scripts/ItemDB.gd
+++ /dev/null
@@ -1,19 +0,0 @@
-extends Node
-
-# Dictionary to store loaded items with their item_id as the key
-var ITEMS = {}
-
-func _ready():
- # Load items from the "items" directory and populate the ITEMS dictionary
- for i in DirAccess.get_files_at("res://grid_inventory_system/items"):
- if(i.ends_with(".tres")):
- var item = load("res://grid_inventory_system/items/" + i)
- ITEMS[item.item_id] = item
-
-# Function to retrieve an item based on its item_id
-func get_item(item_id):
- # Check if the item_id exists in the ITEMS dictionary
- if ITEMS.has(item_id):
- return ITEMS[item_id]
- else:
- return null
diff --git a/grid_inventory_system/scripts/ItemSlot.gd b/grid_inventory_system/scripts/ItemSlot.gd
deleted file mode 100644
index 13def12..0000000
--- a/grid_inventory_system/scripts/ItemSlot.gd
+++ /dev/null
@@ -1,72 +0,0 @@
-extends ColorRect
-class_name ItemSlot
-
-# Reference to child slots
-@onready var slots = get_children()
-
-# Dictionary to store items associated with their respective slots
-var items = {}
-
-# Signals for item-related events
-signal weapon_equipped(weapon_id, item)
-signal weapon_unequipped(weapon_id, item)
-
-func _ready():
- # Initialize the items dictionary with slots
- for slot in slots:
- items[slot.name] = null
-
-# Function to insert an item into the equipment slots
-func insert_item(item):
- # Calculate the center position of the item
- var item_pos = item.global_position + item.size / 2
- # Get the slot under the item's position
- var slot = get_slot_under_pos(item_pos)
-
- # Check if the item can be inserted into the slot
- if slot == null:
- return false
-
- # Retrieve item slot information from the ItemDb
- var item_slot = ItemDb.get_item(item.get_meta("id")).item_equipment_slot
- # Check if the item's slot matches the target slot
- if item_slot != slot.name:
- return false
- # Check if the slot is already occupied
- if items[item_slot] != null:
- return false
-
- # Place the item in the slot and emit the weapon_equipped signal
- items[item_slot] = item
- item.global_position = slot.global_position + slot.size / 2 - item.size / 2
- weapon_equipped.emit(item.item_config.item_id, item.item_config)
- return true
-
-# Function to grab an item from the equipment slots
-func grab_item(pos):
- # Get the item under the specified position
- var item = get_item_under_pos(pos)
- if item == null:
- return null
-
- # Retrieve item slot information from the ItemDb
- var item_slot = ItemDb.get_item(item.get_meta("id")).item_equipment_slot
- # Remove the item from the slot and emit the weapon_unequipped signal
- items[item_slot] = null
- weapon_unequipped.emit(item.item_config.item_id, item.item_config)
- return item
-
-# Function to get the slot under a specified position
-func get_slot_under_pos(pos):
- return get_thing_under_pos(slots, pos)
-
-# Function to get the item under a specified position
-func get_item_under_pos(pos):
- return get_thing_under_pos(items.values(), pos)
-
-# Generic function to get the object (slot or item) under a specified position
-func get_thing_under_pos(arr, pos):
- for thing in arr:
- if thing != null and thing.get_global_rect().has_point(pos):
- return thing
- return null
diff --git a/icon.svg.import b/icon.svg.import
index 7897860..2d2e94f 100644
--- a/icon.svg.import
+++ b/icon.svg.import
@@ -2,7 +2,7 @@
importer="texture"
type="CompressedTexture2D"
-uid="uid://bdvx58rwnaeev"
+uid="uid://bj3tjdbw5xdlj"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
@@ -15,7 +15,7 @@ dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.cte
[params]
-compress/mode=3
+compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
diff --git a/main.tscn b/main.tscn
new file mode 100644
index 0000000..9963955
--- /dev/null
+++ b/main.tscn
@@ -0,0 +1,3 @@
+[gd_scene format=3 uid="uid://cc8f5p1w5xdyx"]
+
+[node name="Node" type="Node"]
diff --git a/project.godot b/project.godot
index d596111..be0e022 100644
--- a/project.godot
+++ b/project.godot
@@ -10,53 +10,14 @@ config_version=5
[application]
-config/name="Grid Inventory System"
-run/main_scene="res://grid_inventory_system/scenes/Inventory.tscn"
-config/features=PackedStringArray("4.2", "Forward Plus")
+config/name="Godot Grid Inventory"
+config/features=PackedStringArray("4.2", "C#", "Forward Plus")
config/icon="res://icon.svg"
[autoload]
-ItemDb="*res://grid_inventory_system/scripts/ItemDB.gd"
+ItemDatabase="*res://Code/ItemDatabase.cs"
-[display]
+[dotnet]
-window/size/viewport_width=1920
-window/size/viewport_height=1080
-window/stretch/mode="canvas_items"
-
-[editor]
-
-export/convert_text_resources_to_binary=false
-
-[input]
-
-inventory_open={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
-]
-}
-inventory_close={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"echo":false,"script":null)
-]
-}
-inventory_use={
-"deadzone": 0.5,
-"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null)
-]
-}
-inventory_grab={
-"deadzone": 0.5,
-"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
-]
-}
-inventory_rotate={
-"deadzone": 0.5,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"echo":false,"script":null)
-]
-}
-mouse={
-"deadzone": 0.5,
-"events": []
-}
+project/assembly_name="Godot Grid Inventory"