Files
2025-08-01 08:34:51 -07:00

3.2 KiB
Executable File

Cutscene Editor Plugin - Resource Management Update

Overview

This update refactors the Cutscene Editor Plugin to focus on managing cutscene resources rather than generating GDScript code. The changes improve the integration between the visual editor and the runtime system by using a structured data format that can be directly loaded and executed.

Key Changes

1. CutsceneResource.gd

  • Removed parallel_connections array (simplified data structure)
  • Added unique ID generation for nodes and connections
  • Updated methods to work with IDs instead of names
  • Added validation method to check resource integrity
  • Updated metadata to version 2.0

2. CutsceneGraphEdit.gd

  • Updated load_from_cutscene to work with new resource structure
  • Updated save_to_cutscene to generate proper resource format
  • Modified node deletion to work with node IDs
  • Added helper method for generating unique connection IDs

3. CutsceneGenerator.gd

  • Removed all code generation functionality
  • Focused on converting resources to runtime actions
  • Updated data access methods to work with new structure
  • Simplified parallel execution handling

4. Node Files

  • All node files already properly initialize node_id property
  • No changes needed to individual node implementations

5. Documentation

  • Updated README.md files to reflect new resource-based approach
  • Added usage examples for resource-based cutscene execution
  • Documented the new resource structure

6. Examples and Tests

  • Added test scripts for the new resource-based system
  • Created example showing resource-based cutscene execution

Benefits

  1. Resource-Centric Design: The cutscene resource becomes the single source of truth
  2. Clean Data Structure: Consistent format for nodes and connections
  3. Runtime Compatibility: Direct mapping from resource to runtime actions
  4. No Code Generation: Eliminates complexity of code generation
  5. Extensibility: Easy to add new node and action types
  6. Better Integration: Tighter coupling between editor and runtime systems

Migration Path

  1. Backward Compatibility: Existing cutscene files can still be loaded
  2. Automatic Conversion: Resources are converted to new format when saved
  3. Documentation: Clear migration guide provided in README files

Usage

To use the new resource-based system:

  1. Create cutscenes using the visual editor as before
  2. Save the cutscene as a resource file
  3. Load and execute the cutscene at runtime using the CutsceneGenerator:
# Load the cutscene resource
var cutscene_resource = preload("res://path/to/your/cutscene.tscn")

# Generate actions from the resource
var generator = CutsceneGenerator.new()
var cutscene_manager = generator.generate_cutscene(cutscene_resource)

# Add to scene and start
add_child(cutscene_manager)
cutscene_manager.start()

Testing

The update includes comprehensive tests to verify the new functionality:

  • Unit tests for CutsceneResource methods
  • Integration tests for the resource-based workflow
  • Example scenes demonstrating the new approach

Future Improvements

  1. Add more comprehensive validation for resource integrity
  2. Implement resource version migration utilities
  3. Add support for more complex node types
  4. Improve error handling and reporting