Testing cutscene setup
This commit is contained in:
37
cutscene/Cutscene.gd
Normal file
37
cutscene/Cutscene.gd
Normal 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
1
cutscene/Cutscene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://pbitw4oq8pni
|
||||
1
cutscene/CutsceneScene.gd.uid
Normal file
1
cutscene/CutsceneScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d1crdj75ap0kx
|
||||
9
cutscene/conversation/ConversationElement.gd
Normal file
9
cutscene/conversation/ConversationElement.gd
Normal 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
cutscene/conversation/ConversationElement.gd.uid
Normal file
1
cutscene/conversation/ConversationElement.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b40rstjkpompc
|
||||
Reference in New Issue
Block a user