item can be stored, added poses to shelf
This commit is contained in:
@@ -1,9 +1,34 @@
|
||||
extends Node3D
|
||||
class_name Item
|
||||
|
||||
|
||||
|
||||
var item_name
|
||||
var shelf_owner
|
||||
var is_being_used: bool
|
||||
|
||||
var outline_material: ShaderMaterial
|
||||
var static_body: StaticBody3D
|
||||
|
||||
func _ready() -> void:
|
||||
set_outline_shader()
|
||||
|
||||
func use():
|
||||
print(str(self) + "is used")
|
||||
|
||||
|
||||
func set_outline_shader():
|
||||
static_body = $StaticBody3D
|
||||
static_body.mouse_entered.connect(_on_mouse_enter)
|
||||
static_body.mouse_exited.connect(_on_mouse_exit)
|
||||
|
||||
func _on_mouse_enter():
|
||||
enable_outline()
|
||||
func _on_mouse_exit():
|
||||
disable_outline()
|
||||
|
||||
|
||||
func enable_outline():
|
||||
outline_material.set_shader_parameter("is_active", true)
|
||||
func disable_outline():
|
||||
outline_material.set_shader_parameter("is_active", false)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
extends Item
|
||||
|
||||
|
||||
@export var mesh: MeshInstance3D
|
||||
|
||||
func _init() -> void:
|
||||
item_name = "food"
|
||||
is_being_used = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
outline_material = mesh.get_surface_override_material(0).next_pass
|
||||
set_outline_shader()
|
||||
|
||||
func use():
|
||||
print("Object eaten")
|
||||
|
||||
@@ -22,6 +22,7 @@ func _on_object_placed(build_postion):
|
||||
newObject.static_body.input_ray_pickable = true
|
||||
newObject.global_position = build_postion
|
||||
BuildManager.add_object_to_array(newObject)
|
||||
newObject.ActionNode.create()
|
||||
if newObject.ActionNode != null:
|
||||
newObject.ActionNode.create()
|
||||
#newObject.restore_default_shaders()
|
||||
self.add_child(newObject)
|
||||
|
||||
@@ -6,8 +6,25 @@ extends Node3D
|
||||
|
||||
signal interact(person,interact_object)
|
||||
|
||||
signal object_selected_signal
|
||||
signal object_unselected_signal
|
||||
signal object_over_mouse_signal
|
||||
|
||||
|
||||
|
||||
var object_selected
|
||||
var object_over_mouse
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
interact.connect(_on_interact)
|
||||
|
||||
func _on_interact(person, object):
|
||||
object.start_action(person, object)
|
||||
|
||||
|
||||
func _on_object_selected():
|
||||
pass
|
||||
|
||||
func _on_object_unselected():
|
||||
pass
|
||||
|
||||
@@ -53,3 +53,5 @@ func get_item_from_id(id):
|
||||
|
||||
|
||||
|
||||
func create_item(item_id):
|
||||
return ItemManager.get_item(0).instantiate()
|
||||
|
||||
@@ -31,9 +31,10 @@ func give_out(person):
|
||||
|
||||
func add_item(item):
|
||||
stored_items.append(item)
|
||||
print(item_poses)
|
||||
|
||||
for pose in item_poses:
|
||||
if pose.is_free:
|
||||
print(pose)
|
||||
pose.add_item(item)
|
||||
break
|
||||
|
||||
@@ -46,6 +47,6 @@ func get_item_pose(item):
|
||||
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)
|
||||
ItemManager.add_item_to_shelf(self, ItemManager.create_item(0))
|
||||
ItemManager.add_item_to_shelf(self, ItemManager.create_item(0))
|
||||
|
||||
@@ -84,7 +84,6 @@ func set_target_position():
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
print(22)
|
||||
is_target_reached = true
|
||||
nav_agent.target_position = self.global_position
|
||||
Global.interact.emit(self, target_object)
|
||||
@@ -98,6 +97,7 @@ func _on_timer_timeout() -> void:
|
||||
|
||||
|
||||
func hold_item(item):
|
||||
is_holding_item = true
|
||||
var newItem = item.duplicate()
|
||||
holdingItem = newItem
|
||||
holdingItem.position = Vector3(0,0.976, -0.065)
|
||||
|
||||
@@ -15,4 +15,5 @@ func add_item(new_item):
|
||||
|
||||
|
||||
func remove_item():
|
||||
is_free = true
|
||||
self.remove_child(item)
|
||||
|
||||
Reference in New Issue
Block a user