improvements
This commit is contained in:
35
scripts/base_character.gd
Normal file
35
scripts/base_character.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends Node2D
|
||||
|
||||
# Base character class that can display dialogue
|
||||
# This extends Node2D to be compatible with Godot's scene system
|
||||
|
||||
# Reference to the dialogue system
|
||||
var dialogue_system: Node = null
|
||||
|
||||
# Signals
|
||||
signal dialogue_started()
|
||||
signal dialogue_completed()
|
||||
|
||||
func _ready():
|
||||
# Find and setup dialogue system
|
||||
dialogue_system = get_node_or_null("DialogueSystem")
|
||||
if dialogue_system:
|
||||
dialogue_system.connect("dialogue_started", self._on_dialogue_started)
|
||||
dialogue_system.connect("dialogue_completed", self._on_dialogue_completed)
|
||||
else:
|
||||
print("Warning: No dialogue system found on character")
|
||||
|
||||
func trigger_dialogue(text: String, duration: float = 3.0) -> void:
|
||||
"""Public method to trigger dialogue on this character"""
|
||||
if dialogue_system:
|
||||
dialogue_system.trigger_dialogue(text, duration)
|
||||
else:
|
||||
print("Warning: No dialogue system found on character")
|
||||
|
||||
func _on_dialogue_started():
|
||||
"""Handle dialogue start signal"""
|
||||
emit_signal("dialogue_started")
|
||||
|
||||
func _on_dialogue_completed():
|
||||
"""Handle dialogue completion signal"""
|
||||
emit_signal("dialogue_completed")
|
||||
Reference in New Issue
Block a user