added user action
This commit is contained in:
10
Scripts/Interactable.gd
Normal file
10
Scripts/Interactable.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name Interactable
|
||||
extends Node
|
||||
|
||||
var can_pick: bool
|
||||
|
||||
var can_store: bool
|
||||
var stored_objects: Array
|
||||
|
||||
func action(person):
|
||||
print("action!")
|
||||
1
Scripts/Interactable.gd.uid
Normal file
1
Scripts/Interactable.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dt4rrjht2fx2b
|
||||
@@ -14,6 +14,7 @@ signal preview_created
|
||||
signal preview_destroyed
|
||||
|
||||
signal object_placed(build_postion)
|
||||
signal object_added(object)
|
||||
|
||||
var build_mode: bool = false
|
||||
|
||||
@@ -22,6 +23,7 @@ var is_object_selected: bool
|
||||
|
||||
var global_y = 2.903
|
||||
|
||||
var builded_objects: Array
|
||||
|
||||
func _ready() -> void:
|
||||
is_object_selected = false
|
||||
@@ -52,3 +54,8 @@ func get_preview_object():
|
||||
|
||||
func _on_object_selected():
|
||||
is_object_selected = true
|
||||
|
||||
|
||||
func add_object_to_array(object):
|
||||
builded_objects.append(object)
|
||||
object_added.emit(object)
|
||||
|
||||
@@ -7,7 +7,7 @@ extends Node3D
|
||||
|
||||
var default_shaders: Array
|
||||
var staic_body: StaticBody3D
|
||||
|
||||
var ActionNode: Node3D
|
||||
|
||||
func _ready() -> void:
|
||||
BuildManager.preview_created.connect(_on_preview_create)
|
||||
@@ -17,9 +17,9 @@ func _ready() -> void:
|
||||
staic_body = $StaticBody3D
|
||||
staic_body.mouse_entered.connect(_on_mouse_enter)
|
||||
staic_body.mouse_exited.connect(_on_mouse_exit)
|
||||
print(staic_body)
|
||||
|
||||
|
||||
|
||||
ActionNode = $ActionNode
|
||||
|
||||
func set_default_shaders():
|
||||
var amount_shaders = meshInstance.get_surface_override_material_count()
|
||||
default_shaders.resize( amount_shaders)
|
||||
@@ -53,7 +53,8 @@ func _on_preview_create():
|
||||
|
||||
|
||||
func _on_object_placed(build_postion):
|
||||
|
||||
#BuildManager.add_object_to_array(self)
|
||||
#print(ActionNode.global_position)
|
||||
restore_default_shaders()
|
||||
|
||||
|
||||
|
||||
@@ -20,4 +20,5 @@ func _input(event: InputEvent) -> void:
|
||||
func _on_object_placed(build_postion):
|
||||
var newObject = BuildManager.get_preview_object().instantiate()
|
||||
newObject.global_position = build_postion
|
||||
BuildManager.add_object_to_array(newObject)
|
||||
self.add_child(newObject)
|
||||
|
||||
@@ -4,25 +4,12 @@ extends Node3D
|
||||
|
||||
@export var debugLabel1: Label
|
||||
|
||||
#signal exit_build_mode
|
||||
#signal enter_build_mode
|
||||
#
|
||||
#signal preview_created
|
||||
#signal preview_destroyed
|
||||
#
|
||||
#signal object_placed(build_postion)
|
||||
#
|
||||
#var build_mode: bool = false
|
||||
signal interact(person,interact_object)
|
||||
|
||||
func _ready() -> void:
|
||||
print(outline_shader)
|
||||
|
||||
interact.connect(_on_interact)
|
||||
|
||||
#func _input(event: InputEvent) -> void:
|
||||
#if event.is_action_released("enter_build_mode"):
|
||||
#if build_mode:
|
||||
#exit_build_mode.emit()
|
||||
#build_mode = false
|
||||
#else:
|
||||
#enter_build_mode.emit()
|
||||
#build_mode = true
|
||||
|
||||
func _on_interact(person, object):
|
||||
object.action(person)
|
||||
|
||||
9
Scripts/objects/DoubleBeds.gd
Normal file
9
Scripts/objects/DoubleBeds.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
extends Interactable
|
||||
|
||||
func _ready() -> void:
|
||||
can_pick = false
|
||||
can_store = false
|
||||
|
||||
|
||||
func action(person):
|
||||
print(str(person) + " is sleeping")
|
||||
1
Scripts/objects/DoubleBeds.gd.uid
Normal file
1
Scripts/objects/DoubleBeds.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://fjdtka5s1dxi
|
||||
@@ -6,18 +6,19 @@ var shirt_shader: ShaderMaterial
|
||||
var meshI: MeshInstance3D
|
||||
|
||||
var start_pos: Vector3
|
||||
|
||||
var target_object: Node3D
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
meshI = $MeshInstance3D
|
||||
shirt_shader = meshI.get_surface_override_material(1)
|
||||
|
||||
BuildManager.object_placed.connect(_on_object_placed)
|
||||
BuildManager.object_added.connect(_on_object_added)
|
||||
|
||||
set_random_shirt()
|
||||
|
||||
start_pos = global_position
|
||||
|
||||
#nav_agent.target_position = Vector3(-15.955,3.486,-58.942)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -26,10 +27,12 @@ func _physics_process(delta: float) -> void:
|
||||
velocity = new_velocity
|
||||
move_and_slide()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("test"):
|
||||
set_target_position()
|
||||
|
||||
|
||||
func _on_object_placed(build_position):
|
||||
nav_agent.target_position = Vector3(-14.305,3.486,-59.836)
|
||||
func _on_object_added(object):
|
||||
set_target(object)
|
||||
|
||||
|
||||
func set_random_shirt():
|
||||
@@ -38,5 +41,19 @@ func set_random_shirt():
|
||||
pass
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_navigation_finished() -> void:
|
||||
nav_agent.target_position = start_pos
|
||||
func set_target(object):
|
||||
target_object = object
|
||||
#nav_agent.target_position = target_object.ActionNode.global_position
|
||||
func set_target_position():
|
||||
var newPos = target_object.ActionNode.global_position
|
||||
newPos.y = self.position.y
|
||||
nav_agent.target_position = newPos
|
||||
|
||||
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
Global.interact.emit(self, target_object.ActionNode)
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user