cleanup
This commit is contained in:
234
manual_cutscene.gd
Executable file
234
manual_cutscene.gd
Executable file
@@ -0,0 +1,234 @@
|
||||
extends Node2D
|
||||
|
||||
# Test script for the new resource-based cutscene system
|
||||
|
||||
# Character nodes
|
||||
@onready var character1: Node2D = $Character1
|
||||
@onready var character2: Node2D = $Character2
|
||||
|
||||
# Cutscene manager
|
||||
var cutscene_manager: CutsceneManager
|
||||
|
||||
func _ready() -> void:
|
||||
# Initialize the cutscene system
|
||||
setup_cutscene()
|
||||
|
||||
# Start the cutscene after a short delay to see the initial positions
|
||||
var start_timer = Timer.new()
|
||||
start_timer.wait_time = 1.0
|
||||
start_timer.one_shot = true
|
||||
start_timer.connect("timeout", start_cutscene)
|
||||
add_child(start_timer)
|
||||
start_timer.start()
|
||||
|
||||
func setup_cutscene() -> void:
|
||||
# Create the cutscene manager
|
||||
cutscene_manager = CutsceneManager.new()
|
||||
add_child(cutscene_manager)
|
||||
|
||||
# Connect to cutscene signals
|
||||
cutscene_manager.connect("cutscene_started", _on_cutscene_started)
|
||||
cutscene_manager.connect("cutscene_completed", _on_cutscene_completed)
|
||||
cutscene_manager.connect("action_started", _on_action_started)
|
||||
cutscene_manager.connect("action_completed", _on_action_completed)
|
||||
|
||||
# Create a cutscene resource with the same sequence as the original example
|
||||
var cutscene_resource = create_test_cutscene_resource()
|
||||
|
||||
# Generate actions from the resource
|
||||
var generator = CutsceneGenerator.new()
|
||||
cutscene_manager = generator.generate_cutscene(self, cutscene_resource)
|
||||
|
||||
# Add the cutscene manager to the scene
|
||||
add_child(cutscene_manager)
|
||||
|
||||
# Connect to cutscene signals
|
||||
cutscene_manager.connect("cutscene_started", _on_cutscene_started)
|
||||
cutscene_manager.connect("cutscene_completed", _on_cutscene_completed)
|
||||
cutscene_manager.connect("action_started", _on_action_started)
|
||||
cutscene_manager.connect("action_completed", _on_action_completed)
|
||||
|
||||
func create_test_cutscene_resource() -> CutsceneResource:
|
||||
# Create a new cutscene resource
|
||||
var resource = CutsceneResource.new()
|
||||
|
||||
# Create nodes for the cutscene
|
||||
var entry_node = {
|
||||
"id": "entry_1",
|
||||
"type": "entry",
|
||||
"position": {"x": 100, "y": 100},
|
||||
"parameters": {}
|
||||
}
|
||||
|
||||
var move1_node = {
|
||||
"id": "move_1",
|
||||
"type": "move",
|
||||
"position": {"x": 250, "y": 100},
|
||||
"parameters": {
|
||||
"character": "Character1",
|
||||
"target_x": 234,
|
||||
"target_y": 591,
|
||||
"speed": 100.0
|
||||
}
|
||||
}
|
||||
|
||||
var move2_node = {
|
||||
"id": "move_2",
|
||||
"type": "move",
|
||||
"position": {"x": 250, "y": 150},
|
||||
"parameters": {
|
||||
"character": "Character2",
|
||||
"target_x": 912,
|
||||
"target_y": 235,
|
||||
"speed": 100.0
|
||||
}
|
||||
}
|
||||
|
||||
var turn_node = {
|
||||
"id": "turn_1",
|
||||
"type": "turn",
|
||||
"position": {"x": 400, "y": 100},
|
||||
"parameters": {
|
||||
"character": "character2",
|
||||
"target": "character1",
|
||||
"turn_speed": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
var dialogue1_node = {
|
||||
"id": "dialogue_1",
|
||||
"type": "dialogue",
|
||||
"position": {"x": 550, "y": 100},
|
||||
"parameters": {
|
||||
"character": "character2",
|
||||
"text": "Hello there, friend!",
|
||||
"duration": 2.0
|
||||
}
|
||||
}
|
||||
|
||||
var wait_node = {
|
||||
"id": "wait_1",
|
||||
"type": "wait",
|
||||
"position": {"x": 700, "y": 100},
|
||||
"parameters": {
|
||||
"duration": 1.0
|
||||
}
|
||||
}
|
||||
|
||||
var dialogue2_node = {
|
||||
"id": "dialogue_2",
|
||||
"type": "dialogue",
|
||||
"position": {"x": 850, "y": 100},
|
||||
"parameters": {
|
||||
"character": "character1",
|
||||
"text": "That was surprising!",
|
||||
"duration": 2.0
|
||||
}
|
||||
}
|
||||
|
||||
var exit_node = {
|
||||
"id": "exit_1",
|
||||
"type": "exit",
|
||||
"position": {"x": 1000, "y": 100},
|
||||
"parameters": {}
|
||||
}
|
||||
|
||||
# Add nodes to resource
|
||||
resource.add_node(entry_node)
|
||||
resource.add_node(move1_node)
|
||||
resource.add_node(move2_node)
|
||||
resource.add_node(turn_node)
|
||||
resource.add_node(dialogue1_node)
|
||||
resource.add_node(wait_node)
|
||||
resource.add_node(dialogue2_node)
|
||||
resource.add_node(exit_node)
|
||||
|
||||
# Create connections
|
||||
var connections = [
|
||||
{
|
||||
"id": "conn_1",
|
||||
"from_node": "entry_1",
|
||||
"from_port": 0,
|
||||
"to_node": "move_1",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_2",
|
||||
"from_node": "entry_1",
|
||||
"from_port": 0,
|
||||
"to_node": "move_2",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_3",
|
||||
"from_node": "move_1",
|
||||
"from_port": 0,
|
||||
"to_node": "turn_node",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_4",
|
||||
"from_node": "move_2",
|
||||
"from_port": 0,
|
||||
"to_node": "turn_node",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_5",
|
||||
"from_node": "turn_node",
|
||||
"from_port": 0,
|
||||
"to_node": "dialogue_1",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_6",
|
||||
"from_node": "dialogue_1",
|
||||
"from_port": 0,
|
||||
"to_node": "wait_node",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_7",
|
||||
"from_node": "wait_node",
|
||||
"from_port": 0,
|
||||
"to_node": "dialogue_2",
|
||||
"to_port": 0
|
||||
},
|
||||
{
|
||||
"id": "conn_8",
|
||||
"from_node": "dialogue_2",
|
||||
"from_port": 0,
|
||||
"to_node": "exit_1",
|
||||
"to_port": 0
|
||||
}
|
||||
]
|
||||
|
||||
# Add connections to resource
|
||||
for conn in connections:
|
||||
resource.add_connection(conn)
|
||||
|
||||
return resource
|
||||
|
||||
func start_cutscene() -> void:
|
||||
print("Starting cutscene...")
|
||||
cutscene_manager.start()
|
||||
|
||||
func _on_cutscene_started() -> void:
|
||||
print("Cutscene started!")
|
||||
|
||||
func _on_cutscene_completed() -> void:
|
||||
print("Cutscene completed!")
|
||||
print("Final positions:")
|
||||
print("Character1: %s" % character1.position)
|
||||
print("Character2: %s" % character2.position)
|
||||
|
||||
func _on_action_started(action: Action) -> void:
|
||||
print("Action started: %s, %s" % action.name)
|
||||
|
||||
func _on_action_completed(action: Action) -> void:
|
||||
print("Action completed: %s, %s" % action.name)
|
||||
|
||||
# Clean up when the node is removed
|
||||
func _exit_tree() -> void:
|
||||
if cutscene_manager:
|
||||
cutscene_manager.queue_free()
|
||||
Reference in New Issue
Block a user