diff --git a/Resources/Items/Ammo1.tres b/Resources/Items/Ammo1.tres index ef31f29b..2a226076 100644 --- a/Resources/Items/Ammo1.tres +++ b/Resources/Items/Ammo1.tres @@ -1,8 +1,7 @@ -[gd_resource type="Resource" script_class="LootItem" load_steps=5 format=3 uid="uid://ct1fa2huvy34n"] +[gd_resource type="Resource" script_class="LootItem" load_steps=4 format=3 uid="uid://ct1fa2huvy34n"] [ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="1_31o2l"] [ext_resource type="Texture2D" uid="uid://c5g0qg6u2gm6f" path="res://Sprites/Items/Ammo1.png" id="1_bpftr"] -[ext_resource type="PackedScene" uid="uid://cjv4yahpb0h2l" path="res://Scenes/HUD/Items/ammo.tscn" id="1_qkp4b"] [sub_resource type="AtlasTexture" id="AtlasTexture_3y0hf"] atlas = ExtResource("1_bpftr") @@ -10,6 +9,7 @@ atlas = ExtResource("1_bpftr") [resource] script = ExtResource("1_31o2l") ItemName = &"Ice Ammo" +ShortName = null ItemDescription = &"Ammo for Ice-Based Weapons" ItemKey = &"ICE_AMMO" Item = 3 @@ -19,6 +19,6 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 2 Selectable = false +AutoPickup = true InventorySprite = SubResource("AtlasTexture_3y0hf") -HudItemScene = ExtResource("1_qkp4b") DropScenePath = &"res://Scenes/Items/Ammo1.tscn" diff --git a/Resources/Items/Green_Points_Pickup.tres b/Resources/Items/Green_Points_Pickup.tres index d54af045..03d8df83 100644 --- a/Resources/Items/Green_Points_Pickup.tres +++ b/Resources/Items/Green_Points_Pickup.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("2_fg25e") ItemName = &"Green Points" +ShortName = null ItemDescription = &"Used for upgrades" ItemKey = &"GREEN_POINTS" Item = 11 @@ -15,6 +16,7 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 0 Selectable = false +AutoPickup = true InventorySprite = ExtResource("1_b4fj2") DropScenePath = &"res://Scenes/Items/Green_Points_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Heart_Pickup.tres b/Resources/Items/Heart_Pickup.tres index 6b1762aa..4144f9a0 100644 --- a/Resources/Items/Heart_Pickup.tres +++ b/Resources/Items/Heart_Pickup.tres @@ -13,6 +13,7 @@ metadata/_custom_type_script = "uid://bxgjw8wis5l0t" [resource] script = ExtResource("1_hyh2l") ItemName = &"Health" +ShortName = null ItemDescription = &"Gives back 25% of Max Health on use" ItemKey = &"HEALTH" Item = 4 @@ -23,6 +24,7 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 0 Selectable = true +AutoPickup = true InventorySprite = ExtResource("1_xg75n") DropScenePath = &"res://Scenes/Items/Heart_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Money_Pickup.tres b/Resources/Items/Money_Pickup.tres index 660d247b..edd3f246 100644 --- a/Resources/Items/Money_Pickup.tres +++ b/Resources/Items/Money_Pickup.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("2_swcup") ItemName = &"Credits" +ShortName = null ItemDescription = &"Can be used to buy things" ItemKey = &"CREDITS" Item = 12 @@ -15,6 +16,7 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 0 Selectable = true +AutoPickup = true InventorySprite = ExtResource("1_woor7") DropScenePath = &"res://Scenes/Items/Credits_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Nuclear_Ammo_Pickup.tres b/Resources/Items/Nuclear_Ammo_Pickup.tres index 4eda7531..6304949b 100644 --- a/Resources/Items/Nuclear_Ammo_Pickup.tres +++ b/Resources/Items/Nuclear_Ammo_Pickup.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("2_x45it") ItemName = &"Nuclear Ammo" +ShortName = null ItemDescription = &"Ammo for Nuclear weapons" ItemKey = &"NUCLEAR_AMMO" Item = 3 @@ -15,5 +16,6 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 2 Selectable = false +AutoPickup = true InventorySprite = ExtResource("1_6ly0q") DropScenePath = &"res://Scenes/Items/Nuclear_Gun_Pickup.tscn" diff --git a/Resources/Items/Points_Pickup.tres b/Resources/Items/Points_Pickup.tres index 10105573..fbef47e5 100644 --- a/Resources/Items/Points_Pickup.tres +++ b/Resources/Items/Points_Pickup.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("2_rxsju") ItemName = &"Points" +ShortName = null ItemDescription = &"Necessari for upgrades" ItemKey = &"POINTS" Item = 11 @@ -15,6 +16,7 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 0 Selectable = false +AutoPickup = true InventorySprite = ExtResource("1_nsfmo") DropScenePath = &"res://Scenes/Items/Points_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Power_Pickup.tres b/Resources/Items/Power_Pickup.tres index e7ac9675..245cba98 100644 --- a/Resources/Items/Power_Pickup.tres +++ b/Resources/Items/Power_Pickup.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("1_vw5ht") ItemName = &"Power" +ShortName = null ItemDescription = &"Necessary for upgrades" ItemKey = &"POWER" Item = 10 @@ -15,5 +16,6 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 2 Selectable = false +AutoPickup = true InventorySprite = ExtResource("1_cang8") DropScenePath = &"res://Scenes/Items/Power_Pickup.tscn" diff --git a/Resources/Items/Shield_Pickup.tres b/Resources/Items/Shield_Pickup.tres index e0ea1fe5..1e6f964d 100644 --- a/Resources/Items/Shield_Pickup.tres +++ b/Resources/Items/Shield_Pickup.tres @@ -13,6 +13,7 @@ metadata/_custom_type_script = "uid://bxgjw8wis5l0t" [resource] script = ExtResource("2_xsuq5") ItemName = &"Shield Charge" +ShortName = null ItemDescription = &"Recharges the shield by 25%" ItemKey = &"SHIELD" Item = 8 @@ -23,6 +24,7 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 0 Selectable = true +AutoPickup = true InventorySprite = ExtResource("1_0hq6q") DropScenePath = &"res://Scenes/Items/Shield_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Spider_Bomb_Pickup.tres b/Resources/Items/Spider_Bomb_Pickup.tres index 4e95c2c6..46473fdc 100644 --- a/Resources/Items/Spider_Bomb_Pickup.tres +++ b/Resources/Items/Spider_Bomb_Pickup.tres @@ -34,6 +34,7 @@ metadata/_custom_type_script = "uid://b6fmrnipv88bk" [resource] script = ExtResource("1_lus3u") ItemName = &"SnowBall Bomb" +ShortName = null ItemDescription = &"A snowball packed of explosive, explodes on contact" ItemKey = &"SPIDER_BOMB" Item = 5 @@ -45,6 +46,7 @@ PickupIfMaxed = false ConsumeOnUse = false UiType = 0 Selectable = true +AutoPickup = true InventorySprite = SubResource("AtlasTexture_gpot4") DropScenePath = &"res://Scenes/Items/SpiderBomb_Pickup.tscn" metadata/_custom_type_script = "uid://epnwjptvks3t" diff --git a/Resources/Items/Yin_Yang_Ammo.tres b/Resources/Items/Yin_Yang_Ammo.tres index d941184f..fcca8e16 100644 --- a/Resources/Items/Yin_Yang_Ammo.tres +++ b/Resources/Items/Yin_Yang_Ammo.tres @@ -6,6 +6,7 @@ [resource] script = ExtResource("3_ajs4l") ItemName = &"Yin-Yang Ammo" +ShortName = null ItemDescription = &"Ammo for Ying-Yang based weapons" ItemKey = &"YINYANG_AMMO" Item = 3 @@ -15,5 +16,6 @@ PickupIfMaxed = false ConsumeOnUse = true UiType = 2 Selectable = false +AutoPickup = true InventorySprite = ExtResource("1_jt7l8") DropScenePath = &"res://Scenes/Items/Yin_Yang_Ammo.tscn" diff --git a/Scenes/Items/Ammo1.tscn b/Scenes/Items/Ammo1.tscn index 7cd1801d..544968e9 100644 --- a/Scenes/Items/Ammo1.tscn +++ b/Scenes/Items/Ammo1.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=6 format=3 uid="uid://cmr6fclttrpkb"] +[gd_scene load_steps=5 format=3 uid="uid://cmr6fclttrpkb"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_it180"] [ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="2_j10i4"] -[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_k1yis"] [ext_resource type="SpriteFrames" uid="uid://pmwatoyt2ase" path="res://Resources/Sprites/Ammo_Inventory_Sprite.tres" id="3_6n103"] [sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"] @@ -11,10 +10,12 @@ collision_layer = 4 collision_mask = 2 script = ExtResource("1_it180") -LootTable = Array[ExtResource("2_k1yis")]([ExtResource("2_j10i4")]) +LootTable = [ExtResource("2_j10i4")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = ExtResource("3_6n103") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Credits_Pickup.tscn b/Scenes/Items/Credits_Pickup.tscn index f63c9a74..c540cb42 100644 --- a/Scenes/Items/Credits_Pickup.tscn +++ b/Scenes/Items/Credits_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_4vvwn") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Green_Points_Pickup.tscn b/Scenes/Items/Green_Points_Pickup.tscn index be2d0041..4ae0b483 100644 --- a/Scenes/Items/Green_Points_Pickup.tscn +++ b/Scenes/Items/Green_Points_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_6m0m2") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Heart_Extend_Pickup.tscn b/Scenes/Items/Heart_Extend_Pickup.tscn index 87f29f15..7c21a18a 100644 --- a/Scenes/Items/Heart_Extend_Pickup.tscn +++ b/Scenes/Items/Heart_Extend_Pickup.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=37 format=3 uid="uid://1yxieu8ekvkm"] +[gd_scene load_steps=36 format=3 uid="uid://1yxieu8ekvkm"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_clwuw"] -[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_7y15p"] [ext_resource type="Resource" uid="uid://ciybnocjfpshh" path="res://Resources/Items/Heart_Extend_Pickup.tres" id="3_clwuw"] [ext_resource type="Texture2D" uid="uid://c6gjpfxrux5uq" path="res://Sprites/Items/Heart_Extend_Animated.png" id="4_clwuw"] @@ -229,7 +228,7 @@ animations = [{ collision_layer = 4 collision_mask = 2 script = ExtResource("1_clwuw") -LootTable = Array[ExtResource("2_7y15p")]([ExtResource("3_clwuw")]) +LootTable = [ExtResource("3_clwuw")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") diff --git a/Scenes/Items/Heart_Pickup.tscn b/Scenes/Items/Heart_Pickup.tscn index f3cb8d41..a6adbdbe 100644 --- a/Scenes/Items/Heart_Pickup.tscn +++ b/Scenes/Items/Heart_Pickup.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=8 format=3 uid="uid://b2tihw3iawd2l"] +[gd_scene load_steps=7 format=3 uid="uid://b2tihw3iawd2l"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_j5s0a"] -[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_4oifc"] [ext_resource type="Resource" uid="uid://dodwpect0ldjf" path="res://Resources/Items/Heart_Pickup.tres" id="3_dqwsj"] [ext_resource type="Texture2D" uid="uid://dlkqy5jgchwy" path="res://Sprites/Items/Heart_Pickup.png" id="4_iu1v6"] @@ -26,10 +25,12 @@ animations = [{ collision_layer = 4 collision_mask = 2 script = ExtResource("1_j5s0a") -LootTable = Array[ExtResource("2_4oifc")]([ExtResource("3_dqwsj")]) +LootTable = [ExtResource("3_dqwsj")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_f6vxc") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Points_Pickup.tscn b/Scenes/Items/Points_Pickup.tscn index eead9447..73fcb52c 100644 --- a/Scenes/Items/Points_Pickup.tscn +++ b/Scenes/Items/Points_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_koe11") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Power_Pickup.tscn b/Scenes/Items/Power_Pickup.tscn index 63d8e213..82509777 100644 --- a/Scenes/Items/Power_Pickup.tscn +++ b/Scenes/Items/Power_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_y2inf") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Shield_Pickup.tscn b/Scenes/Items/Shield_Pickup.tscn index 7287a1c2..d442b868 100644 --- a/Scenes/Items/Shield_Pickup.tscn +++ b/Scenes/Items/Shield_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_ga0s1") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/SpiderBomb_Pickup.tscn b/Scenes/Items/SpiderBomb_Pickup.tscn index 244ecbe0..67c10270 100644 --- a/Scenes/Items/SpiderBomb_Pickup.tscn +++ b/Scenes/Items/SpiderBomb_Pickup.tscn @@ -32,3 +32,5 @@ shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_qfvur") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/Items/Yin_Yang_Ammo.tscn b/Scenes/Items/Yin_Yang_Ammo.tscn index 9005aba1..752bf1a2 100644 --- a/Scenes/Items/Yin_Yang_Ammo.tscn +++ b/Scenes/Items/Yin_Yang_Ammo.tscn @@ -1,8 +1,7 @@ -[gd_scene load_steps=8 format=3 uid="uid://sjxkj5jdndxb"] +[gd_scene load_steps=7 format=3 uid="uid://sjxkj5jdndxb"] [ext_resource type="Script" uid="uid://b3h7b30kerf60" path="res://Scripts/Interactables/ItemPickup.cs" id="1_o42iv"] [ext_resource type="Resource" uid="uid://diqm2ju0xakkt" path="res://Resources/Items/Yin_Yang_Ammo.tres" id="2_o42iv"] -[ext_resource type="Script" uid="uid://epnwjptvks3t" path="res://Scripts/Resources/LootItem.cs" id="2_q76u6"] [ext_resource type="Texture2D" uid="uid://b61po207ggn63" path="res://Sprites/Items/Yin_Ammo.png" id="3_o42iv"] [sub_resource type="CircleShape2D" id="CircleShape2D_6vv2s"] @@ -26,10 +25,12 @@ animations = [{ collision_layer = 4 collision_mask = 2 script = ExtResource("1_o42iv") -LootTable = Array[ExtResource("2_q76u6")]([ExtResource("2_o42iv")]) +LootTable = [ExtResource("2_o42iv")] [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CircleShape2D_6vv2s") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] sprite_frames = SubResource("SpriteFrames_8gvnj") + +[connection signal="area_entered" from="." to="." method="_on_area_entered"] diff --git a/Scenes/test.tscn b/Scenes/test.tscn index 72802326..b722f56d 100644 --- a/Scenes/test.tscn +++ b/Scenes/test.tscn @@ -505,6 +505,36 @@ StartingAiState = 1 [node name="HeartPickup" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] position = Vector2(-767, -395) +[node name="HeartPickup2" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-485.312, -517.597) + +[node name="HeartPickup3" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-484.343, -498.209) + +[node name="HeartPickup4" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-462.532, -520.02) + +[node name="HeartPickup5" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-460.836, -501.117) + +[node name="HeartPickup6" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-439.025, -521.716) + +[node name="HeartPickup7" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-439.025, -501.602) + +[node name="HeartPickup8" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-411.156, -521.232) + +[node name="HeartPickup9" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-414.548, -502.572) + +[node name="HeartPickup10" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-391.041, -523.171) + +[node name="HeartPickup11" parent="Parallax2D/Factory Tilemaps/Debug Room" instance=ExtResource("27_jn1m0")] +position = Vector2(-392.495, -504.753) + [node name="RedKeycard_Switch_3" parent="Parallax2D/Factory Tilemaps/Debug Room" node_paths=PackedStringArray("Targets") instance=ExtResource("17_e3v0b")] position = Vector2(-701, -486) Targets = [NodePath("../HorizontalForceField")] diff --git a/Scripts/Interactables/ItemPickup.cs b/Scripts/Interactables/ItemPickup.cs index 3ed9e082..4a0c88f4 100644 --- a/Scripts/Interactables/ItemPickup.cs +++ b/Scripts/Interactables/ItemPickup.cs @@ -1,4 +1,5 @@ -using Cirno.Scripts.Resources; +using System.Linq; +using Cirno.Scripts.Resources; using Godot; using Godot.Collections; @@ -8,19 +9,66 @@ public partial class ItemPickup : Interactable { [Export] public Array LootTable = []; + private bool _autoPickup = false; + + public override void _Ready() + { + _autoPickup = LootTable.Any(x => x.AutoPickup); + // if (LootTable.Any(x => x.AutoPickup)) + // { + // _autoPickup = true; + // } + + //this.AreaEntered += _on_area_entered; + } + public override bool Activate(ActivationType activationType = ActivationType.Toggle) { GD.Print("Attempting to Pickup Item"); if (!MeetsRequirements()) return false; + AddItemsToInventory(); + + return true; + } + + private void AddItemsToInventory() + { + var failedItems = new Array(); foreach (var item in LootTable) { - InventoryManager.Instance.AddItem(item); + if (!InventoryManager.Instance.AddItem(item)) + { + failedItems.Add(item); + } + } + + if (failedItems.Count > 0) + { + foreach (var failedItem in failedItems) + { + var dup = this.Duplicate() as ItemPickup; + this.AddSibling(dup); + dup.LootTable = [failedItem]; + } } // Delet This QueueFree(); - - return true; + } + + private void _on_area_entered(Area2D area) + { + if (!_autoPickup) return; + if (area is InteractionController interactionController) + { + //Check if items are not maxed to avoid a looping autopickup situation + var canAdd = LootTable.Aggregate(false, (current, item) => current || InventoryManager.Instance.CanAddItem(item.ItemKey)); + + if (canAdd) + { + AddItemsToInventory(); + } + } } } \ No newline at end of file diff --git a/Scripts/InventoryManager.cs b/Scripts/InventoryManager.cs index 4040cb42..6382c8a6 100644 --- a/Scripts/InventoryManager.cs +++ b/Scripts/InventoryManager.cs @@ -52,6 +52,11 @@ public partial class InventoryManager : Node2D return _itemsDict.TryGetValue(key, out item); } + public LootItem FindItemInDb(string key) + { + return ItemsDatabase.GetLootItem(key); + } + public bool HasItems(IList itemKeys) { return itemKeys.Aggregate(false, (current, item) => current || GetItemCount(item) > 0); @@ -87,6 +92,19 @@ public partial class InventoryManager : Node2D } + public bool CanAddItem(string itemKey) + { + + var found = TryGetItem(itemKey, out var itm); + if (found) + { + return (itm.Count < itm.Item.Max); + } + + var dbItem = FindItemInDb(itemKey); + return dbItem != null; + } + public bool AddItem(LootItem item) { //var item = new LootItem() { Item = type, Amount = amount }; diff --git a/Scripts/Resources/LootItem.cs b/Scripts/Resources/LootItem.cs index 828a6b9a..56951a29 100644 --- a/Scripts/Resources/LootItem.cs +++ b/Scripts/Resources/LootItem.cs @@ -19,6 +19,7 @@ public partial class LootItem : Resource [Export] public bool ConsumeOnUse; [Export] public UiItemType UiType; [Export] public bool Selectable; + [Export] public bool AutoPickup { get; private set; } = false; [Export] public Texture2D InventorySprite; //[Export] public SpriteFrames WorldSprite; //[Export] public PackedScene HudItemScene;