added poses for items in shelf

This commit is contained in:
Nikolai Fesenko
2025-08-19 15:39:24 +02:00
parent 31c9a69132
commit 88007d247a
6 changed files with 209 additions and 7 deletions

View File

@@ -34,7 +34,7 @@ func add_shelf(object):
func add_item_to_shelf(shelf, item):
item.shelf_owner = shelf
shelf.stored_items.append(item)
shelf.add_item(item)
func get_item(id):
return get_item_from_id(id)

View File

@@ -3,12 +3,15 @@ extends Interactable
var test: bool = false
@export var items_pos_master: Node
var item_poses: Array
func _init() -> void:
max_person_using = 1
can_store = true
func _ready() -> void:
self.owner = $".."
print(self)
#object_placed.connect(_on_object_placed.bind(self))
@@ -20,14 +23,29 @@ func start_action(person, object):
func give_out(person):
var pose = get_item_pose(person.target_item)
pose.remove_item()
person.hold_item(person.target_item)
stored_items.erase(person.target_item)
func add_item(item):
stored_items.append(item)
print(item_poses)
for pose in item_poses:
if pose.is_free:
pose.add_item(item)
break
func get_item_pose(item):
for pose in item_poses:
if pose.item == item:
return pose
return null
func create():
for pose in items_pos_master.get_children():
item_poses.append(pose)
var newItem = ItemManager.get_item(0).instantiate()
ItemManager.add_shelf(self)
ItemManager.add_item_to_shelf(self, newItem)

View File

@@ -110,4 +110,5 @@ func drop_item():
func _on_item_received():
if holdingItem != null:
holdingItem.use()
pass
#holdingItem.use()

18
Scripts/pose_item.gd Normal file
View File

@@ -0,0 +1,18 @@
extends Node3D
var is_free: bool
var item
func _init() -> void:
is_free = true
func add_item(new_item):
is_free = false
item = new_item
self.add_child(item)
item.position = global_position
print("item added")
func remove_item():
self.remove_child(item)

1
Scripts/pose_item.gd.uid Normal file
View File

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