diff --git a/Resources/Items/Cheat_Gun_Item.tres b/Resources/Items/Cheat_Gun_Item.tres index 2ab4dc17..f5a290ee 100644 --- a/Resources/Items/Cheat_Gun_Item.tres +++ b/Resources/Items/Cheat_Gun_Item.tres @@ -1,6 +1,5 @@ -[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cfq121rs3bsu8"] +[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cfq121rs3bsu8"] -[ext_resource type="PackedScene" uid="uid://pemr2lrv3ylk" path="res://Scenes/HUD/Items/ying_yang_gun_huditem.tscn" id="1_i6xgq"] [ext_resource type="Resource" uid="uid://ckppo2seg313h" path="res://Resources/Weapons/Cheat_Gun.tres" id="2_0na1t"] [ext_resource type="Texture2D" uid="uid://cwy7g861vnbj1" path="res://Sprites/Items/Cheat_Gun.png" id="2_0vddk"] [ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="3_i0e51"] @@ -8,6 +7,7 @@ [resource] script = ExtResource("3_i0e51") ItemName = &"Cheat Gun" +ShortName = &"CHAET" ItemDescription = &"Does massive damage" ItemKey = &"CHEAT_GUN" Item = 9 @@ -19,5 +19,4 @@ ConsumeOnUse = false UiType = 1 Selectable = true InventorySprite = ExtResource("2_0vddk") -HudItemScene = ExtResource("1_i6xgq") DropScenePath = &"res://Scenes/Items/Cheat_Gun_Pickup.tscn" diff --git a/Resources/Items/IceShotgun.tres b/Resources/Items/IceShotgun.tres index d08fdf8a..f7056102 100644 --- a/Resources/Items/IceShotgun.tres +++ b/Resources/Items/IceShotgun.tres @@ -1,6 +1,5 @@ -[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://dau0s8ob7qnpc"] +[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://dau0s8ob7qnpc"] -[ext_resource type="PackedScene" uid="uid://bqb3gbnrkqewt" path="res://Scenes/HUD/Items/ice_shotgun_huditem.tscn" id="1_13ven"] [ext_resource type="Resource" uid="uid://cyntngidhcbkc" path="res://Resources/Weapons/Ice_Shotgun_Weapon.tres" id="2_3le6e"] [ext_resource type="Texture2D" uid="uid://b46usr10jhmev" path="res://Sprites/Items/Ice_Shotgun.png" id="2_4ibag"] [ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="3_cjfxs"] @@ -8,6 +7,7 @@ [resource] script = ExtResource("3_cjfxs") ItemName = &"Ice Shotgun" +ShortName = &"IC-27" ItemDescription = &"Shoots ice pellets in a wide spread" ItemKey = &"ICE_SHOTGUN" Item = 9 @@ -19,5 +19,4 @@ ConsumeOnUse = false UiType = 1 Selectable = true InventorySprite = ExtResource("2_4ibag") -HudItemScene = ExtResource("1_13ven") DropScenePath = &"res://Scenes/Items/Ice_Shotgun_Pickup.tscn" diff --git a/Resources/Items/IcicleGun.tres b/Resources/Items/IcicleGun.tres index 863c5349..4b069843 100644 --- a/Resources/Items/IcicleGun.tres +++ b/Resources/Items/IcicleGun.tres @@ -1,13 +1,13 @@ -[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://cs3ihltcn2166"] +[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://cs3ihltcn2166"] [ext_resource type="Resource" uid="uid://b8apu0l5fm4k" path="res://Resources/Weapons/IcicleGun.tres" id="1_itajb"] -[ext_resource type="PackedScene" uid="uid://cicthr1v5v4s2" path="res://Scenes/HUD/Items/icicle_gun.tscn" id="1_lfbsh"] [ext_resource type="Texture2D" uid="uid://duwiasewxvcb5" path="res://Sprites/Items/Icicle_Gun.png" id="2_eaoas"] [ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_hy2hk"] [resource] script = ExtResource("2_hy2hk") ItemName = &"Icicle Gun" +ShortName = &"IC-9" ItemDescription = &"Cirno\'s custom gun, shoots ice pellets and never runs out of ammo" ItemKey = &"ICICLE_GUN" Item = 9 @@ -19,5 +19,4 @@ ConsumeOnUse = false UiType = 1 Selectable = true InventorySprite = ExtResource("2_eaoas") -HudItemScene = ExtResource("1_lfbsh") -DropScenePath = "res://Scenes/Items/IcicleGun.tscn" +DropScenePath = null diff --git a/Resources/Items/IcicleRepeater.tres b/Resources/Items/IcicleRepeater.tres index 53947409..b0550885 100644 --- a/Resources/Items/IcicleRepeater.tres +++ b/Resources/Items/IcicleRepeater.tres @@ -7,6 +7,7 @@ [resource] script = ExtResource("4_k6in2") ItemName = &"Icicle Repeater" +ShortName = &"IC-18" ItemDescription = &"Shoots ice pellets at a high rate" ItemKey = &"ICICLE_REPEATER" Item = 9 diff --git a/Resources/Items/NuclearGunPickup.tres b/Resources/Items/NuclearGunPickup.tres index c8eb6be9..f3743b65 100644 --- a/Resources/Items/NuclearGunPickup.tres +++ b/Resources/Items/NuclearGunPickup.tres @@ -7,6 +7,7 @@ [resource] script = ExtResource("4_imbrn") ItemName = &"Nuclear Gun (MP-42)" +ShortName = &"MP-42" ItemDescription = &"Shoots micro suns" ItemKey = &"NUCLEAR_GUN" Item = 9 diff --git a/Resources/Items/Yin_Yang_Gun_Pickup.tres b/Resources/Items/Yin_Yang_Gun_Pickup.tres index 289291bd..fd2c4df8 100644 --- a/Resources/Items/Yin_Yang_Gun_Pickup.tres +++ b/Resources/Items/Yin_Yang_Gun_Pickup.tres @@ -7,6 +7,7 @@ [resource] script = ExtResource("2_2w24o") ItemName = &"Yin-Yang Gun" +ShortName = &"SM-3" ItemDescription = &"A weapon that shoots explosive Yin-Yang Orbs" ItemKey = &"YINYANG_GUN" Item = 9 diff --git a/Scenes/HUD/HUD.tscn b/Scenes/HUD/HUD.tscn index 6260a476..bdf4e31e 100644 --- a/Scenes/HUD/HUD.tscn +++ b/Scenes/HUD/HUD.tscn @@ -279,7 +279,7 @@ script = ExtResource("10_oflr6") ItemsFilter = Array[int]([0, 1, 2, 13, 10, 11, 12]) metadata/_tab_index = 3 -[node name="Status" type="PanelContainer" parent="InventoryMenu" node_paths=PackedStringArray("HealthExpansionCounter", "ShieldExpansionCounter")] +[node name="Status" type="PanelContainer" parent="InventoryMenu" node_paths=PackedStringArray("HealthExpansionCounter", "ShieldExpansionCounter", "WeaponButton")] layout_mode = 2 theme = ExtResource("9_sx5r0") theme_override_styles/panel = ExtResource("13_sjdna") @@ -288,6 +288,7 @@ HealthExpansionName = &"HEALTH_EXTEND" ShieldExpansionName = &"SHIELD_EXTEND" HealthExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/HealthExtensions") ShieldExpansionCounter = NodePath("MarginContainer/HBoxContainer/VBoxContainer3/HBoxContainer/ShieldExtensions") +WeaponButton = NodePath("MarginContainer/HBoxContainer/VBoxContainer2/EquippedWeapon") metadata/_tab_index = 4 [node name="MarginContainer" type="MarginContainer" parent="InventoryMenu/Status"] @@ -304,7 +305,7 @@ layout_mode = 2 size_flags_horizontal = 2 alignment = 1 -[node name="Button" type="Button" parent="InventoryMenu/Status/MarginContainer/HBoxContainer/VBoxContainer2"] +[node name="EquippedWeapon" type="Button" parent="InventoryMenu/Status/MarginContainer/HBoxContainer/VBoxContainer2"] layout_mode = 2 text = "IC-9 " diff --git a/Scripts/Resources/ItemsDatabase.cs b/Scripts/Resources/ItemsDatabase.cs index 1039957c..b6137076 100644 --- a/Scripts/Resources/ItemsDatabase.cs +++ b/Scripts/Resources/ItemsDatabase.cs @@ -1,4 +1,5 @@ -using Godot; +using System.Linq; +using Godot; using Godot.Collections; namespace Cirno.Scripts.Resources; @@ -8,4 +9,9 @@ public partial class ItemsDatabase : Resource { [Export] public Array LootItems { get; set; } = new(); + + public LootItem GetLootItem(string itemName) + { + return LootItems.FirstOrDefault(x => x.ItemKey == itemName); + } } \ No newline at end of file diff --git a/Scripts/Resources/LootItem.cs b/Scripts/Resources/LootItem.cs index 086245cc..828a6b9a 100644 --- a/Scripts/Resources/LootItem.cs +++ b/Scripts/Resources/LootItem.cs @@ -7,6 +7,7 @@ namespace Cirno.Scripts.Resources; public partial class LootItem : Resource { [Export] public StringName ItemName { get; set; } + [Export] public StringName ShortName { get; set; } [Export] public StringName ItemDescription { get; set; } [Export] public StringName ItemKey { get; set; } [Export] public ItemTypes Item; @@ -19,8 +20,8 @@ public partial class LootItem : Resource [Export] public UiItemType UiType; [Export] public bool Selectable; [Export] public Texture2D InventorySprite; - [Export] public SpriteFrames WorldSprite; - [Export] public PackedScene HudItemScene; + //[Export] public SpriteFrames WorldSprite; + //[Export] public PackedScene HudItemScene; [Export(PropertyHint.File)] public StringName DropScenePath { get; private set; } // Has to be a string path to avoid recursion issues } diff --git a/Scripts/UI/StatusMenu.cs b/Scripts/UI/StatusMenu.cs index f17bbb80..2d4cb808 100644 --- a/Scripts/UI/StatusMenu.cs +++ b/Scripts/UI/StatusMenu.cs @@ -1,5 +1,6 @@ using Godot; using System; +using System.Linq; using Cirno.Scripts.Resources; public partial class StatusMenu : PanelContainer @@ -7,11 +8,15 @@ public partial class StatusMenu : PanelContainer [Export] public StringName HealthExpansionName { get; private set; } [Export] public StringName ShieldExpansionName { get; private set; } + + //[Export] public ItemsDatabase ItemsDatabase { get; private set; } [Export] public Button HealthExpansionCounter { get; private set; } [Export] public Button ShieldExpansionCounter { get; private set; } + [Export] public Button WeaponButton { get; private set; } + public override void _Ready() { CallDeferred(MethodName.InitializeDeferred); @@ -31,6 +36,23 @@ public partial class StatusMenu : PanelContainer ShieldExpansionCounter.Text = $"x{shieldExpansions}"; InventoryManager.Instance.ItemAdded += InstanceOnItemAdded; + + InventoryManager.Instance.WeaponEquip += InstanceOnWeaponEquip; + } + + private void InstanceOnWeaponEquip(string itemKey) + { + //var weaponData = ItemsDatabase.GetLootItem(itemKey); + + var succ = InventoryManager.Instance.TryGetItem(itemKey, out var item); + if (!succ) + { + GD.Print($"Could not get item {itemKey}"); + return; + } + + WeaponButton.Text = item.Item.ShortName; + WeaponButton.Icon = item.Item.InventorySprite; } private void InstanceOnItemAdded(LootItem item, int currentamount)