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
|
||||
Reference in New Issue
Block a user