Refactor all gameItem into one object for easier stats

This commit is contained in:
derek.holloway
2025-12-17 19:13:10 -08:00
parent 063b70a4d5
commit 25e86a6990
201 changed files with 1829 additions and 868 deletions
+11 -10
View File
@@ -1,6 +1,5 @@
using Godot;
using Godot.Collections;
using System.Diagnostics;
public partial class SelectTool : Node3D, ITool {
@@ -8,7 +7,6 @@ public partial class SelectTool : Node3D, ITool {
Options _Options;
Reference _Reference;
ItemStats _Stats;
[Export] PackedScene SelectToolFrame;
[Export] Material HoverMaterial;
@@ -50,19 +48,23 @@ public partial class SelectTool : Node3D, ITool {
int ItemID = ((Pickup)test).ItemID;
int Quantity = ((Pickup)test).Quantity;
StatItem ItemStats = _Stats.stats[ ItemID ];
PickupItem item = new PickupItem( ItemID, ItemStats.ItemName, ItemStats.InventorySize, ItemStats.Weight, ItemStats.IsQuantityItem, Quantity, ItemStats.MaxQuantity, ItemStats.ToolPath );
GameItem item = new GameItem(ItemID);
item.GameObject = test;
if (item.ItemStats.IsQuantityItem) {
item.InventoryObject.Quantity = Quantity;
}
if( _lookingAt == null ) {
_lookingAt = test.GetChild<MeshInstance3D>( 1 );
_defaultMaterial = _lookingAt.GetSurfaceOverrideMaterial( 0 );
_lookingAt.SetSurfaceOverrideMaterial( 0, HoverMaterial );
_SelectToolFrame.Visible = true;
_SelectToolFrame.GetChild<Label>( 0 ).Text = item.Name;
_SelectToolFrame.GetChild<Label>( 1 ).Text = "Slot : " + item.GridSize.ToString();
_SelectToolFrame.GetChild<Label>( 2 ).Text = "Weight : " + item.Weight;
if (item.isQuantityItem ) {
_SelectToolFrame.GetChild<Label>( 3 ).Text = "Capacity : " + item.Quantity + "/" + item.MaxQuantity;
_SelectToolFrame.GetChild<Label>( 0 ).Text = item.ItemStats.ItemName;
_SelectToolFrame.GetChild<Label>( 1 ).Text = "Slot : " + item.ItemStats.InventorySize.ToString();
_SelectToolFrame.GetChild<Label>( 2 ).Text = "Weight : " + item.ItemStats.InventoryWeight;
if (item.ItemStats.IsQuantityItem ) {
_SelectToolFrame.GetChild<Label>( 3 ).Text = "Capacity : " + item.InventoryObject.Quantity + "/" + item.ItemStats.MaxQuantity;
_SelectToolFrame.Size = new Vector2( _SelectToolFrame.Size.X, 95 );
} else {
_SelectToolFrame.GetChild<Label>( 3 ).Text = "";
@@ -91,7 +93,6 @@ public partial class SelectTool : Node3D, ITool {
public void Equiped() {
_Options = GetNode<Options>( "/root/Options" );
_Reference = GetNode<Reference>("/root/Reference");
_Stats = (ItemStats)_Reference.ItemSpawnPath;
_SelectToolFrame = SelectToolFrame.Instantiate<Control>();
GetNode( "/root/GameRoot/UI/GameUI/Game" ).AddChild( _SelectToolFrame );
equipped = true;