Player input blocked while in conversation.
parent
f20150d225
commit
3bde776c4f
|
@ -1,5 +1,8 @@
|
|||
class_name ConversationActionable
|
||||
extends Area3D
|
||||
|
||||
signal conversation_started
|
||||
|
||||
@export var quest_dialogue_resource: DialogueResource
|
||||
@export var default_dialogue_resource: DialogueResource
|
||||
@export var dialogue_start: String = "start"
|
||||
|
@ -15,3 +18,5 @@ func action() -> void:
|
|||
balloon.start(quest_dialogue_resource, dialogue_start, quest_states)
|
||||
else:
|
||||
balloon.start(default_dialogue_resource, dialogue_start, quest_states)
|
||||
|
||||
conversation_started.emit()
|
||||
|
|
|
@ -16,31 +16,26 @@ var inventory:Inventory = Inventory.new()
|
|||
var selected_tool_slot_index:int = 0
|
||||
var current_tool:ItemResource = null
|
||||
|
||||
var look_direction:Vector3 = Vector3.BACK
|
||||
var look_direction_damper:SpringDamper = SpringDamper.new(Vector3.ZERO)
|
||||
var _direction:Vector3 = Vector3.ZERO
|
||||
var _look_direction:Vector3 = Vector3.BACK
|
||||
var _look_direction_damper:SpringDamper = SpringDamper.new(Vector3.ZERO)
|
||||
|
||||
var is_conversation_active:bool = false
|
||||
|
||||
signal trigger_message(message:String)
|
||||
|
||||
var interaction_state:bool = false
|
||||
|
||||
func _process(_delta):
|
||||
animation_tree.set("parameters/conditions/interact", interaction_state)
|
||||
|
||||
if interaction_state:
|
||||
interaction_state = false
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
if animation_tree.get("parameters/playback").get_current_node() == "Interact":
|
||||
animation_tree.set("parameters/conditions/interact", false)
|
||||
|
||||
func _handle_input() -> void:
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir = Input.get_vector("walk_left", "walk_right", "walk_forward", "walk_back")
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
_direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if _direction:
|
||||
velocity.x = _direction.x * SPEED
|
||||
velocity.z = _direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
@ -48,6 +43,14 @@ func _physics_process(delta):
|
|||
if is_on_floor() and Input.is_action_just_pressed("jump"):
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
func _physics_process(delta):
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity.y -= gravity * delta
|
||||
|
||||
if not is_conversation_active:
|
||||
_handle_input()
|
||||
|
||||
move_and_slide()
|
||||
|
||||
var ground_velocity:Vector2 = Vector2(velocity.x, velocity.z)
|
||||
|
@ -55,11 +58,11 @@ func _physics_process(delta):
|
|||
var is_moving:bool = ground_velocity.length_squared() > 0.1 * 0.1
|
||||
|
||||
if is_moving:
|
||||
look_direction = Vector3(ground_velocity.x, 0, ground_velocity.y).normalized()
|
||||
elif direction.length_squared() > 0.1 * 0.1:
|
||||
look_direction = direction
|
||||
_look_direction = Vector3(ground_velocity.x, 0, ground_velocity.y).normalized()
|
||||
elif _direction.length_squared() > 0.1 * 0.1:
|
||||
_look_direction = _direction
|
||||
|
||||
var damped_look_direction = look_direction_damper.calc(global_basis.z, look_direction, delta)
|
||||
var damped_look_direction = _look_direction_damper.calc(global_basis.z, _look_direction, delta)
|
||||
|
||||
animation_tree.set("parameters/conditions/running", is_moving)
|
||||
animation_tree.set("parameters/conditions/idle", not is_moving)
|
||||
|
@ -129,14 +132,14 @@ func _unhandled_input(_event: InputEvent) -> void:
|
|||
if Input.is_action_just_pressed("ui_accept"):
|
||||
var actionables = actionable_detector.get_overlapping_areas()
|
||||
if actionables.size() > 0:
|
||||
look_direction = (actionables[0].global_position - position).normalized()
|
||||
_look_direction = (actionables[0].global_position - position).normalized()
|
||||
actionables[0].action()
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
|
||||
if Input.is_action_just_pressed("interaction"):
|
||||
interaction_state = true
|
||||
animation_tree.set("parameters/conditions/interact", true)
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
|
|
|
@ -33,7 +33,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.399047, 0)
|
|||
shape = SubResource("CapsuleShape3D_7kfad")
|
||||
|
||||
[node name="RightHandBone" type="BoneAttachment3D" parent="."]
|
||||
transform = Transform3D(-0.00101612, -0.0643421, 0.39479, 0.399977, -0.00423115, 0.000339832, 0.00412149, 0.394768, 0.0643492, -0.196136, 0.250175, 0.0430521)
|
||||
transform = Transform3D(-0.000936468, -0.0640051, 0.394845, 0.399981, -0.00390502, 0.000315472, 0.00380429, 0.394827, 0.0640112, -0.196417, 0.250119, 0.0420737)
|
||||
bone_name = "Knife"
|
||||
bone_idx = 17
|
||||
use_external_skeleton = true
|
||||
|
|
|
@ -7,9 +7,11 @@ extends Node
|
|||
@export var is_completed:bool = false
|
||||
|
||||
@onready var bridge = %Bridge
|
||||
@onready var merchant: NonPlayerCharacter = %Merchant
|
||||
|
||||
var _bridge_transform:Transform3D = Transform3D.IDENTITY
|
||||
var _player:Player = null
|
||||
var _merchant_conversation_actionable:ConversationActionable = null
|
||||
|
||||
signal wrench_delivered
|
||||
|
||||
|
@ -18,9 +20,16 @@ func _ready():
|
|||
bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000)
|
||||
|
||||
_player = get_tree().root.find_child("Player", true, false)
|
||||
_merchant_conversation_actionable = merchant.find_child("Conversation", true, false)
|
||||
assert(_merchant_conversation_actionable != null)
|
||||
_merchant_conversation_actionable.conversation_started.connect(on_dialogue_started)
|
||||
|
||||
func on_dialogue_started() -> void:
|
||||
_player.is_conversation_active = true
|
||||
|
||||
func on_dialogue_ended(_dialog_resource: DialogueResource) -> void:
|
||||
_player.is_conversation_active = false
|
||||
|
||||
if is_completed:
|
||||
return
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=30 format=3 uid="uid://dmagdl5pi6jdj"]
|
||||
[gd_scene load_steps=29 format=3 uid="uid://dmagdl5pi6jdj"]
|
||||
|
||||
[ext_resource type="MeshLibrary" uid="uid://dcpuitbu16j1a" path="res://assets/mesh_library.tres" id="1_q0eym"]
|
||||
[ext_resource type="PackedScene" uid="uid://da5r82nvypfk4" path="res://objects/pickup_item.tscn" id="2_ccr0r"]
|
||||
|
@ -8,10 +8,9 @@
|
|||
[ext_resource type="Resource" uid="uid://det51k1t422rq" path="res://data/items/pickaxe.tres" id="7_3sab5"]
|
||||
[ext_resource type="Resource" uid="uid://bob26ycbled6r" path="res://data/items/dagger.tres" id="7_pt3bs"]
|
||||
[ext_resource type="Resource" uid="uid://cbitlk81jxwfa" path="res://data/items/sword.tres" id="8_45auf"]
|
||||
[ext_resource type="Resource" uid="uid://cktn5p1wetkve" path="res://data/items/axe.tres" id="9_xhfx0"]
|
||||
[ext_resource type="Resource" uid="uid://cwerasgcfgx2p" path="res://data/items/hammer.tres" id="10_wch4q"]
|
||||
[ext_resource type="PackedScene" uid="uid://ccjcjputsddrd" path="res://assets/scene_props/tree_pine.tscn" id="11_5olon"]
|
||||
[ext_resource type="Resource" uid="uid://cum4wf04mfuu6" path="res://data/items/BananenAxt.tres" id="11_fko4k"]
|
||||
[ext_resource type="Resource" uid="uid://cktn5p1wetkve" path="res://data/items/axe.tres" id="11_fko4k"]
|
||||
[ext_resource type="Texture2D" uid="uid://bq3b1hxl5ojh6" path="res://assets/icons/npc_emotes/attention.tres" id="12_3vn8y"]
|
||||
[ext_resource type="PackedScene" uid="uid://dcvf00ymfkdkd" path="res://assets/custom/buildings/LogCabin/pole.tscn" id="12_mmbxl"]
|
||||
[ext_resource type="PackedScene" uid="uid://b38ixieurg6db" path="res://assets/custom/buildings/LogCabin/wall.tscn" id="13_1kigt"]
|
||||
|
@ -90,7 +89,7 @@ item = ExtResource("8_45auf")
|
|||
|
||||
[node name="Item9" parent="Objects" instance=ExtResource("2_ccr0r")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.309352, -5.00679e-06, -1.02607)
|
||||
item = ExtResource("9_xhfx0")
|
||||
item = ExtResource("11_fko4k")
|
||||
|
||||
[node name="Item10" parent="Objects" instance=ExtResource("2_ccr0r")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.581866, -4.76837e-06, 1.16087)
|
||||
|
@ -163,6 +162,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0, -2.00416)
|
|||
[node name="Wall10" parent="Structures/LogCabin" instance=ExtResource("13_1kigt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.2851, 0, -2.00416)
|
||||
|
||||
[node name="Castle" parent="Structures" instance=ExtResource("23_g2ojm")]
|
||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 10.4477, -3.8147e-06, -9.85823)
|
||||
|
||||
[node name="Quests" type="Node" parent="."]
|
||||
|
||||
[node name="BuilderMissingTool" type="Node" parent="Quests" groups=["quest_state"]]
|
||||
|
@ -197,20 +199,17 @@ billboard = 1
|
|||
texture_filter = 0
|
||||
texture = ExtResource("12_3vn8y")
|
||||
|
||||
[node name="Actionable" parent="Quests/BuilderMissingTool/Merchant" instance=ExtResource("14_8oq2l")]
|
||||
[node name="Conversation" parent="Quests/BuilderMissingTool/Merchant" instance=ExtResource("14_8oq2l")]
|
||||
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, 0)
|
||||
quest_dialogue_resource = ExtResource("15_mqfyi")
|
||||
default_dialogue_resource = ExtResource("18_4qvld")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Quests/BuilderMissingTool/Merchant/Actionable"]
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Quests/BuilderMissingTool/Merchant/Conversation"]
|
||||
shape = SubResource("SphereShape3D_ugkqa")
|
||||
|
||||
[node name="Geometry" parent="Quests/BuilderMissingTool/Merchant" instance=ExtResource("22_vjd6d")]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0)
|
||||
|
||||
[node name="Node3D" parent="Quests/BuilderMissingTool/Merchant" instance=ExtResource("23_g2ojm")]
|
||||
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 6.79984, -3.8147e-06, -8.27225)
|
||||
|
||||
[node name="Water" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.239327, 0)
|
||||
mesh = SubResource("PlaneMesh_6aebw")
|
||||
|
|
Loading…
Reference in New Issue