inventory refactor + inv ui interactable
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="2_1q5bp"]
|
||||
[ext_resource type="Script" uid="uid://jnye5pe1bgqw" path="res://entities/plants/scripts/plant_type.gd" id="2_x4nie"]
|
||||
[ext_resource type="Texture2D" uid="uid://c00jac2jlgdfu" path="res://entities/plants/assets/sprites/solita/growing.png" id="3_j4n5p"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/solita/mature.png" id="4_njidq"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_yn0yu"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3fdsj"]
|
||||
@@ -12,6 +11,9 @@ script = ExtResource("2_1q5bp")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_j4n5p"]
|
||||
metadata/__load_path__ = "res://entities/plants/assets/sprites/default_plant_glowing.png"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_auuc2"]
|
||||
atlas = ExtResource("6_yn0yu")
|
||||
region = Rect2(335, 74, 134, 142)
|
||||
@@ -24,6 +26,6 @@ default_growing_time = 3
|
||||
default_plant_score = 2
|
||||
seed_texture = SubResource("AtlasTexture_auuc2")
|
||||
growing_texture = ExtResource("3_j4n5p")
|
||||
mature_texture = ExtResource("4_njidq")
|
||||
mature_texture = SubResource("Resource_j4n5p")
|
||||
default_harvest_effects = Array[ExtResource("1_mksys")]([SubResource("Resource_3fdsj")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@@ -127,12 +127,14 @@ func try_move(move_to : Vector2):
|
||||
|
||||
func pick_item(item : Item) -> Item:
|
||||
play_sfx("pick")
|
||||
if inventory.length() >= inventory.size:
|
||||
var available_slot_ind = inventory.get_best_available_slot_ind()
|
||||
if available_slot_ind == inventory.current_item_ind:
|
||||
var current_item : Item = inventory.get_item()
|
||||
inventory.set_item(item, inventory.current_item_ind)
|
||||
inventory.set_item(item, available_slot_ind)
|
||||
return current_item
|
||||
else :
|
||||
inventory.add_item(item)
|
||||
if inventory.set_item(item, available_slot_ind):
|
||||
inventory.set_current_item(available_slot_ind);
|
||||
return null
|
||||
|
||||
func drop_item():
|
||||
@@ -176,7 +178,7 @@ func upgrade_max_energy(amount = 1):
|
||||
player_updated.emit(self)
|
||||
|
||||
func upgrade_inventory_size(amount = 1):
|
||||
inventory.size += amount
|
||||
inventory.items.resize(inventory.items.size() + amount)
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user