Testing cutscene setup
This commit is contained in:
@@ -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
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
item/Backpack.gd.uid
Normal file
1
item/Backpack.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://d16p8hn52bby7
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -29,4 +28,4 @@ func onInteract(other:Entity) -> void:
|
|||||||
_onConversationInteract(other)
|
_onConversationInteract(other)
|
||||||
return
|
return
|
||||||
_:
|
_:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
@@ -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]
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user