Improved conversations and input blocking.
parent
e9db7b1095
commit
396d884ff0
|
@ -1,8 +1,6 @@
|
||||||
class_name ConversationActionable
|
class_name ConversationActionable
|
||||||
extends Area3D
|
extends Area3D
|
||||||
|
|
||||||
signal conversation_started
|
|
||||||
|
|
||||||
@export var dialogue_start: String = "start"
|
@export var dialogue_start: String = "start"
|
||||||
@export var related_quest_path: NodePath
|
@export var related_quest_path: NodePath
|
||||||
|
|
||||||
|
@ -25,5 +23,3 @@ func action() -> void:
|
||||||
balloon.start(quest_dialogue_resource, dialogue_start, quest_states)
|
balloon.start(quest_dialogue_resource, dialogue_start, quest_states)
|
||||||
else:
|
else:
|
||||||
balloon.start(default_dialogue_resource, dialogue_start, quest_states)
|
balloon.start(default_dialogue_resource, dialogue_start, quest_states)
|
||||||
|
|
||||||
conversation_started.emit()
|
|
||||||
|
|
|
@ -56,7 +56,9 @@ func _physics_process(delta):
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
velocity.y -= gravity * delta
|
velocity.y -= gravity * delta
|
||||||
|
|
||||||
if not is_input_blocked:
|
if is_input_blocked:
|
||||||
|
velocity = Vector3.ZERO
|
||||||
|
else:
|
||||||
_handle_input()
|
_handle_input()
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
@ -68,7 +70,6 @@ func _physics_process(delta):
|
||||||
_target_look_direction = Vector3(velocity.x, 0, velocity.z).normalized()
|
_target_look_direction = Vector3(velocity.x, 0, velocity.z).normalized()
|
||||||
|
|
||||||
_current_look_direction = basis.z
|
_current_look_direction = basis.z
|
||||||
#_target_look_direction = _current_look_direction
|
|
||||||
|
|
||||||
update_look_direction(delta)
|
update_look_direction(delta)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ config/icon="res://icon.svg"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd"
|
DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd"
|
||||||
|
InteractionSystem="*res://systems/InteractionSystem.gd"
|
||||||
|
|
||||||
[dialogue_manager]
|
[dialogue_manager]
|
||||||
|
|
||||||
|
|
|
@ -9,32 +9,12 @@ extends QuestBase
|
||||||
@onready var merchant: NonPlayerCharacter = %Merchant
|
@onready var merchant: NonPlayerCharacter = %Merchant
|
||||||
|
|
||||||
var _bridge_transform:Transform3D = Transform3D.IDENTITY
|
var _bridge_transform:Transform3D = Transform3D.IDENTITY
|
||||||
var _merchant_conversation_actionable:ConversationActionable = null
|
|
||||||
|
|
||||||
signal wrench_delivered
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
super._ready()
|
super._ready()
|
||||||
|
|
||||||
_bridge_transform = bridge.global_transform
|
_bridge_transform = bridge.global_transform
|
||||||
bridge.global_transform = Transform3D.IDENTITY.translated(Vector3.UP * -1000)
|
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):
|
func _process(_delta):
|
||||||
if is_hammer_delivered:
|
if is_hammer_delivered:
|
||||||
|
|
|
@ -49,6 +49,8 @@ func load_scene(scene_resource:PackedScene):
|
||||||
|
|
||||||
_game_build_system = scene.find_child("BuildSystem", true, false) as BuildSystem
|
_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():
|
func save_game():
|
||||||
var player:Player = scene.find_child("Player", true, false)
|
var player:Player = scene.find_child("Player", true, false)
|
||||||
|
|
|
@ -12,7 +12,6 @@ var _player_camera_offset:Vector3 = Vector3.ZERO
|
||||||
func _ready():
|
func _ready():
|
||||||
_player_camera_offset = camera.global_position - player.global_position + Vector3.UP * 1
|
_player_camera_offset = camera.global_position - player.global_position + Vector3.UP * 1
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
if build_system.is_active and build_system.build_item != null:
|
if build_system.is_active and build_system.build_item != null:
|
||||||
|
|
|
@ -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
|
|
@ -104,6 +104,7 @@ func start(dialogue_resource: DialogueResource, title: String, extra_game_states
|
||||||
temporary_game_states = [self] + extra_game_states
|
temporary_game_states = [self] + extra_game_states
|
||||||
is_waiting_for_input = false
|
is_waiting_for_input = false
|
||||||
resource = dialogue_resource
|
resource = dialogue_resource
|
||||||
|
InteractionSystem.start_conversation(dialogue_resource)
|
||||||
self.dialogue_line = await resource.get_next_dialogue_line(title, temporary_game_states)
|
self.dialogue_line = await resource.get_next_dialogue_line(title, temporary_game_states)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue