Refactor stats
This commit is contained in:
18
Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs
Normal file
18
Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IItemSlot : IHBoxContainer
|
||||
{
|
||||
public InventoryItem Item { get; set; }
|
||||
|
||||
public void SetItemStyle();
|
||||
|
||||
public void SetSelectedItemStyle();
|
||||
|
||||
public void SetEquippedItemStyle();
|
||||
|
||||
public void SetEquippedSelectedItemStyle();
|
||||
}
|
||||
1
Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs.uid
Normal file
1
Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cyit2s4ahwfqf
|
||||
@@ -4,6 +4,7 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
@@ -344,7 +345,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
if (equipableItem.IsEquipped)
|
||||
{
|
||||
ItemEffectLabel.Text = $"{itemSlot.Item.GetType()} unequipped.";
|
||||
Player.Unequip(equipableItem);
|
||||
Player.EquipmentComponent.Unequip(equipableItem);
|
||||
itemSlot.SetSelectedItemStyle();
|
||||
if (equipableItem.ItemTag == ItemTag.BreaksOnChange)
|
||||
Player.Inventory.Remove(equipableItem);
|
||||
@@ -352,7 +353,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
else
|
||||
{
|
||||
ItemEffectLabel.Text = $"{itemSlot.Item.GetType()} equipped.";
|
||||
Player.Equip(equipableItem);
|
||||
Player.EquipmentComponent.Equip(equipableItem);
|
||||
itemSlot.SetEquippedSelectedItemStyle();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Game.Implementation;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
public interface IItemSlot : IHBoxContainer
|
||||
{
|
||||
public InventoryItem Item { get; set; }
|
||||
|
||||
public void SetItemStyle();
|
||||
|
||||
public void SetSelectedItemStyle();
|
||||
|
||||
public void SetEquippedItemStyle();
|
||||
|
||||
public void SetEquippedSelectedItemStyle();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ItemSlot : HBoxContainer, IItemSlot
|
||||
{
|
||||
@@ -27,8 +14,6 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
|
||||
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
//[Node] public Label EquipBonus { get; set; } = default!;
|
||||
|
||||
[Node] public TextureRect ItemTexture { get; set; } = default!;
|
||||
|
||||
[Node] public Label ItemName { get; set; } = default!;
|
||||
@@ -36,7 +21,9 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
|
||||
[Node] public Label ItemCount { get; set; } = default!;
|
||||
|
||||
private static LabelSettings ItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextBold.tres");
|
||||
|
||||
private static LabelSettings SelectedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontItalicized.tres");
|
||||
|
||||
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontEquipped.tres");
|
||||
|
||||
private static LabelSettings SelectedEquippedItemFont => GD.Load<LabelSettings>("res://src/ui/label_settings/MainTextFontSelectedEquipped.tres");
|
||||
@@ -45,9 +32,9 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
|
||||
{
|
||||
ItemName.Text = Item.ItemName;
|
||||
ItemTexture.Texture = Item.GetTexture();
|
||||
Player.EquippedWeapon.Sync += EquipableItem_Sync;
|
||||
Player.EquippedArmor.Sync += EquipableItem_Sync;
|
||||
Player.EquippedAccessory.Sync += EquipableItem_Sync;
|
||||
Player.EquipmentComponent.EquippedWeapon.Sync += EquipableItem_Sync;
|
||||
Player.EquipmentComponent.EquippedArmor.Sync += EquipableItem_Sync;
|
||||
Player.EquipmentComponent.EquippedAccessory.Sync += EquipableItem_Sync;
|
||||
|
||||
if (Item is IStackable stackableItem)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user