trash can

This commit is contained in:
Rendo 2025-10-16 22:21:30 +05:00
commit 39c52694da
11 changed files with 57 additions and 5 deletions

View file

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="1_53h7j"]
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="1_x27pp"]
[ext_resource type="PackedScene" uid="uid://b0h8dd82b3ox5" path="res://scenes/conveyor.tscn" id="2_hinjf"]
[ext_resource type="PackedScene" uid="uid://b0h8dd82b3ox5" path="res://scenes/structures/conveyor.tscn" id="2_hinjf"]
[sub_resource type="AtlasTexture" id="AtlasTexture_uvy8r"]
atlas = ExtResource("1_x27pp")

View file

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="1_mqcr0"]
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="1_sh8t1"]
[ext_resource type="PackedScene" uid="uid://dfatkxv6n55dw" path="res://scenes/debug_assembler.tscn" id="2_kf3x0"]
[ext_resource type="PackedScene" uid="uid://dfatkxv6n55dw" path="res://scenes/structures/debug_assembler.tscn" id="2_kf3x0"]
[sub_resource type="AtlasTexture" id="AtlasTexture_kf3x0"]
atlas = ExtResource("1_sh8t1")

View file

@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="Prototype" load_steps=4 format=3 uid="uid://jhe8wtjoo6c6"]
[ext_resource type="Texture2D" uid="uid://ugbe4qcmgfw0" path="res://icon.svg" id="1_movbu"]
[ext_resource type="PackedScene" uid="uid://cteh8r405wqwk" path="res://scenes/debug_item_deposit.tscn" id="2_wp7ck"]
[ext_resource type="PackedScene" uid="uid://cteh8r405wqwk" path="res://scenes/structures/debug_item_deposit.tscn" id="2_wp7ck"]
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="3_benq7"]
[resource]

View file

@ -0,0 +1,15 @@
[gd_resource type="Resource" script_class="Prototype" load_steps=5 format=3 uid="uid://wxfa130pbn18"]
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="1_erjr6"]
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="1_jurq1"]
[ext_resource type="PackedScene" uid="uid://dpsrwmum6rbmi" path="res://scenes/structures/trash_can.tscn" id="2_qlygk"]
[sub_resource type="AtlasTexture" id="AtlasTexture_lldoj"]
atlas = ExtResource("1_erjr6")
region = Rect2(80, 0, 16, 16)
[resource]
script = ExtResource("1_jurq1")
scene = ExtResource("2_qlygk")
preview = SubResource("AtlasTexture_lldoj")
metadata/_custom_type_script = "uid://c80sp6f77l5ha"

View file

@ -0,0 +1,27 @@
[gd_scene load_steps=8 format=3 uid="uid://dpsrwmum6rbmi"]
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_818vg"]
[ext_resource type="Script" uid="uid://bd4ojfqrl8idm" path="res://scripts/inventory/inventory_slot.gd" id="2_y1ram"]
[ext_resource type="Script" uid="uid://1scdy7mttx5h" path="res://scripts/inventory/storage.gd" id="3_lldoj"]
[ext_resource type="Script" uid="uid://dwx8y8c6guldd" path="res://scripts/structures/trash_can.gd" id="4_mfdbk"]
[ext_resource type="Texture2D" uid="uid://gfkhedfdi7ug" path="res://sprites/atlasses/Popekko.png" id="5_y1ram"]
[sub_resource type="Resource" id="Resource_fvoq6"]
resource_local_to_scene = true
script = ExtResource("3_lldoj")
capacity = 1
metadata/_custom_type_script = "uid://1scdy7mttx5h"
[sub_resource type="AtlasTexture" id="AtlasTexture_lldoj"]
atlas = ExtResource("5_y1ram")
region = Rect2(80, 0, 16, 16)
[node name="TrashCan" type="Node2D"]
script = ExtResource("1_818vg")
inventory = SubResource("Resource_fvoq6")
[node name="Can" type="Node2D" parent="."]
script = ExtResource("4_mfdbk")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = SubResource("AtlasTexture_lldoj")

View file

@ -53,11 +53,11 @@ func add(stack: Stack, _context: InventoryContext = null) -> Stack:
func can_add(item : Item = null, _context: InventoryContext = null) -> bool:
if item == null:
for i in range(internal_array):
for i in range(capacity):
return internal_array[i].amount == 0
return false
else:
for i in range(internal_array):
for i in range(capacity):
if internal_array[i].amount == 0:
return (internal_array[i].filter != null and internal_array[i].filter.is_equal(item)) or internal_array[i].filter == null
return internal_array[i].held_item.is_equal(item)

View file

@ -0,0 +1,9 @@
extends StructureBehaviour
@onready var inventory : Storage = structure_parent.inventory
func _ready() -> void:
inventory.stack_added.connect(on_stack_added)
func on_stack_added(_stack : Stack, _position: int) -> void:
inventory.internal_array[0].amount = 0

View file

@ -0,0 +1 @@
uid://dwx8y8c6guldd