chore: changed the inventory controller so it populated all of the inventory model fields

This commit is contained in:
Damien Ostler 2024-01-12 00:01:16 -05:00
parent 79472fa58e
commit d8da370026
2 changed files with 14 additions and 7 deletions

View File

@ -1,18 +1,20 @@
using System.Collections.Generic;
using System.Linq;
using Godot;
using GodotGridInventory.Code.UI;
namespace GodotGridInventory.Code.Grid;
#nullable enable
public class InventoryModel
{
public int Id { get; set; }
public string Name { get; set; }
public int Id { get; init; }
public string Name { get; init; } = string.Empty;
public int GridWidth { get; set; }
public int GridHeight { get; set; }
public List<Item> Items { get; set; }
public List<Item> Items { get; set; } = new List<Item>();
public List<InventoryCell> Cells { get; set; } = new List<InventoryCell>();
public InventoryGrid? Grid { get; set; }
public InventoryGrid? Grid { get; set; } = null;
public InventoryGridInterface? GridInterface { get; set; } = null;
public bool Open { get; set; } = false;
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Godot;
@ -58,7 +59,11 @@ public partial class InventoryController : Node
Name = name,
Items = items.Select( item=> _itemDatabase.GetItemConfiguration(item)).ToList(),
Cells = inventoryGrid.GridCells,
Open = false
Open = false,
Grid = inventoryGrid,
GridInterface = null,
GridWidth = (int)Math.Round(size.X),
GridHeight = (int)Math.Round(size.Y)
});
_inventoryIdCounter++;