Improved conversations and input blocking.

main
Martin Felis 2024-11-15 13:09:38 +01:00
parent e9db7b1095
commit 396d884ff0
8 changed files with 33 additions and 27 deletions

View File

@ -1,8 +1,6 @@
class_name ConversationActionable
extends Area3D
signal conversation_started
@export var dialogue_start: String = "start"
@export var related_quest_path: NodePath
@ -25,5 +23,3 @@ 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()

View File

@ -56,7 +56,9 @@ func _physics_process(delta):
if not is_on_floor():
velocity.y -= gravity * delta
if not is_input_blocked:
if is_input_blocked:
velocity = Vector3.ZERO
else:
_handle_input()
move_and_slide()
@ -68,7 +70,6 @@ func _physics_process(delta):
_target_look_direction = Vector3(velocity.x, 0, velocity.z).normalized()
_current_look_direction = basis.z
#_target_look_direction = _current_look_direction
update_look_direction(delta)

View File

@ -18,6 +18,7 @@ config/icon="res://icon.svg"
[autoload]
DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd"
InteractionSystem="*res://systems/InteractionSystem.gd"
[dialogue_manager]

View File

@ -9,9 +9,6 @@ extends QuestBase
@onready var merchant: NonPlayerCharacter = %Merchant
var _bridge_transform:Transform3D = Transform3D.IDENTITY
var _merchant_conversation_actionable:ConversationActionable = null
signal wrench_delivered
func _ready():
super._ready()
@ -19,23 +16,6 @@ func _ready():
_bridge_transform = bridge.global_transform
bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000)
_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_input_blocked = true
func on_dialogue_ended(_dialog_resource: DialogueResource) -> void:
_player.is_input_blocked = false
if is_completed:
return
if is_hammer_delivered and not is_bridge_built:
wrench_delivered.emit()
func _process(_delta):
if is_hammer_delivered:
is_bridge_built = true

View File

@ -49,6 +49,8 @@ func load_scene(scene_resource:PackedScene):
_game_build_system = scene.find_child("BuildSystem", true, false) as BuildSystem
var player:Player = scene.find_child("Player", true, false)
InteractionSystem.player = player
func save_game():
var player:Player = scene.find_child("Player", true, false)

View File

@ -12,7 +12,6 @@ var _player_camera_offset:Vector3 = Vector3.ZERO
func _ready():
_player_camera_offset = camera.global_position - player.global_position + Vector3.UP * 1
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
if build_system.is_active and build_system.build_item != null:

View File

@ -0,0 +1,26 @@
extends Node
signal conversation_started
signal conversation_stopped
var is_conversation_active:bool = false
var player:Player = null
func _ready():
if not DialogueManager.is_connected("dialogue_ended", InteractionSystem.stop_conversation):
DialogueManager.connect("dialogue_ended", InteractionSystem.stop_conversation)
func start_conversation(resource: DialogueResource) -> void:
is_conversation_active = true
print ("Conversation started")
emit_signal("conversation_started")
if player:
player.is_input_blocked = true
func stop_conversation(resource: DialogueResource) -> void:
is_conversation_active = false
print ("Conversation stopped")
emit_signal("conversation_stopped")
if player:
player.is_input_blocked = false

View File

@ -104,6 +104,7 @@ func start(dialogue_resource: DialogueResource, title: String, extra_game_states
temporary_game_states = [self] + extra_game_states
is_waiting_for_input = false
resource = dialogue_resource
InteractionSystem.start_conversation(dialogue_resource)
self.dialogue_line = await resource.get_next_dialogue_line(title, temporary_game_states)