Testing cutscene setup

This commit is contained in:
2026-01-08 22:23:07 -06:00
parent 316e4a154a
commit cd2dd3fe0e
12 changed files with 58 additions and 10 deletions

View File

@@ -1,5 +0,0 @@
extends Resource
class_name ConversationElement
@export_node_path("Entity") var entity:NodePath
@export_multiline var label: String

37
cutscene/Cutscene.gd Normal file
View File

@@ -0,0 +1,37 @@
class_name CutsceneSingleton extends Node
const CUTSCENE_CONTINUE = -1
const CUTSCENE_END = -2
var running:bool = false
func setConversation(conversation:Array[ConversationElement]) -> void:
var functions:Array[Callable] = []
for element in conversation:
functions.append(element.sceneItem)
setScene(functions)
func setScene(functions:Array[Callable]) -> void:
if functions.size() == 0:
return
running = true
var index = 0
while true:
var result = await functions[index].call()
match result:
CUTSCENE_CONTINUE:
index += 1
CUTSCENE_END:
break
_:
index = result
if index >= functions.size() || index < 0:
break
running = false

1
cutscene/Cutscene.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://pbitw4oq8pni

View File

@@ -0,0 +1 @@
uid://d1crdj75ap0kx

View File

@@ -0,0 +1,9 @@
extends Resource
class_name ConversationElement
@export_node_path("Entity") var entity:NodePath
@export_multiline var label: String
func sceneItem() -> int:
await UI.TEXTBOX.setTextAndWait(label)
return CutsceneSingleton.CUTSCENE_CONTINUE

1
item/Backpack.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://d16p8hn52bby7

View File

@@ -1,5 +1,5 @@
class_name Entity extends CharacterBody3D class_name Entity extends CharacterBody3D
const ConversationElement = preload("res://ConversationElement.gd") const ConversationElement = preload("res://cutscene/conversation/ConversationElement.gd")
enum MovementType { enum MovementType {
NONE, NONE,

View File

@@ -17,8 +17,7 @@ func isInteractable() -> bool:
return true return true
func _onConversationInteract(_other:Entity) -> void: func _onConversationInteract(_other:Entity) -> void:
print("Starting conversation with ", entity.name) CUTSCENE.setConversation(entity.conversation)
pass
func onInteract(other:Entity) -> void: func onInteract(other:Entity) -> void:
if entity.interactType == Entity.InteractType.NONE: if entity.interactType == Entity.InteractType.NONE:

View File

@@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://xe6pcuq741xi" path="res://overworld/map/TestMap.gd" id="1_6ms5s"] [ext_resource type="Script" uid="uid://xe6pcuq741xi" path="res://overworld/map/TestMap.gd" id="1_6ms5s"]
[ext_resource type="PackedScene" uid="uid://cluuhtfjeodwb" path="res://overworld/map/TestMapBase.tscn" id="1_ox0si"] [ext_resource type="PackedScene" uid="uid://cluuhtfjeodwb" path="res://overworld/map/TestMapBase.tscn" id="1_ox0si"]
[ext_resource type="PackedScene" uid="uid://by4a0r2hp0w6s" path="res://overworld/entity/Entity.tscn" id="2_jmygs"] [ext_resource type="PackedScene" uid="uid://by4a0r2hp0w6s" path="res://overworld/entity/Entity.tscn" id="2_jmygs"]
[ext_resource type="Script" uid="uid://b40rstjkpompc" path="res://ConversationElement.gd" id="3_p7git"] [ext_resource type="Script" uid="uid://b40rstjkpompc" path="res://cutscene/conversation/ConversationElement.gd" id="3_p7git"]
[sub_resource type="Resource" id="Resource_p7git"] [sub_resource type="Resource" id="Resource_p7git"]
script = ExtResource("3_p7git") script = ExtResource("3_p7git")

View File

@@ -23,6 +23,7 @@ UI="*res://ui/UI.tscn"
QUEST="*res://quest/Quest.tscn" QUEST="*res://quest/Quest.tscn"
OVERWORLD="*res://overworld/Overworld.gd" OVERWORLD="*res://overworld/Overworld.gd"
SCENE="*res://scene/Scene.gd" SCENE="*res://scene/Scene.gd"
CUTSCENE="*res://cutscene/Cutscene.gd"
ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd" ControllerIcons="*res://addons/controller_icons/ControllerIcons.gd"
[debug] [debug]

View File

@@ -71,3 +71,7 @@ func setText(text:String) -> void:
await get_tree().process_frame# Absolutely needed to make the text wrap await get_tree().process_frame# Absolutely needed to make the text wrap
label.text = text; label.text = text;
label.visible_characters = 0; label.visible_characters = 0;
func setTextAndWait(text:String) -> void:
await setText(text);
await self.textboxClosing