Refactor conversation stuff

This commit is contained in:
2026-01-14 23:20:56 -06:00
parent d916e65990
commit 5af98a69a2
18 changed files with 136 additions and 35 deletions

View File

@@ -11,6 +11,7 @@ enum MovementType {
enum InteractType {
NONE,
CONVERSATION,
ONE_TIME_ITEM,
TEST_BATTLE
};
@@ -27,7 +28,10 @@ var button := func():
# Interaction settings
@export_category("Interactions")
@export var interactType:InteractType = InteractType.NONE
@export var conversation:Array[ConversationElement] = []
@export var conversation:Array[ConversationResource] = []
@export_category("One-Time Item")
@export var oneTimeItem:ItemResource = null
# TEST BATTLE
@export_category("Test Battle")

View File

@@ -27,6 +27,7 @@ size = Vector3(1.3, 1.3, 1.3)
[node name="Entity" type="CharacterBody3D"]
script = ExtResource("1_8e8ef")
entityId = "35ce980f-3df9-4e09-b365-1a228948cf78"
metadata/_custom_type_script = "uid://c8146flooxeue"
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]

View File

@@ -1,5 +1,5 @@
class_name EntityInteractableArea extends Area3D
# const BattleStartAction = preload("res://cutscene/battle/BattleStartAction.gd")
const ItemAction = preload("res://cutscene/item/ItemAction.gd")
@export var entity:Entity
@@ -16,6 +16,15 @@ func isInteractable() -> bool:
if entity.interactType == Entity.InteractType.TEST_BATTLE:
return true
if entity.interactType == Entity.InteractType.ONE_TIME_ITEM:
if entity.oneTimeItem == null:
return false
if entity.oneTimeItem.quantity <= 0:
return false
if entity.oneTimeItem.item == Item.ItemId.NULL:
return false
return true
return false
@@ -24,6 +33,13 @@ func _onConversationInteract(_other:Entity) -> void:
cutscene.addConversation(entity.conversation)
cutscene.start()
func _onItemInteract(_other:Entity) -> void:
assert(entity.oneTimeItem != null)
var cutscene:Cutscene = Cutscene.new()
cutscene.addCallable(ItemAction.getItemCallable(entity.oneTimeItem.toItemStack()))
cutscene.addCallable(ConversationAction.getTextboxCallable('This should be last'))
cutscene.start()
func onInteract(other:Entity) -> void:
if entity.interactType == Entity.InteractType.NONE:
return
@@ -33,6 +49,10 @@ func onInteract(other:Entity) -> void:
_onConversationInteract(other)
return
Entity.InteractType.ONE_TIME_ITEM:
_onItemInteract(other)
return
Entity.InteractType.TEST_BATTLE:
var cutscene:Cutscene = Cutscene.new()
cutscene.addCallable(BattleStartAction.getStartBattleCallable({

View File

@@ -1,15 +1,22 @@
[gd_scene load_steps=6 format=3 uid="uid://d0ywgijpuqy0r"]
[gd_scene load_steps=8 format=3 uid="uid://d0ywgijpuqy0r"]
[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://by4a0r2hp0w6s" path="res://overworld/entity/Entity.tscn" id="2_jmygs"]
[ext_resource type="Script" uid="uid://b40rstjkpompc" path="res://cutscene/conversation/ConversationElement.gd" id="3_p7git"]
[ext_resource type="Script" uid="uid://yn7kxdargafx" path="res://cutscene/conversation/ConversationResource.gd" id="3_p7git"]
[ext_resource type="Script" uid="uid://38ya6vphm5bu" path="res://item/ItemResource.gd" id="4_xf0pb"]
[sub_resource type="Resource" id="Resource_p7git"]
[sub_resource type="Resource" id="Resource_xf0pb"]
script = ExtResource("3_p7git")
entity = NodePath(".")
label = "Hello!"
metadata/_custom_type_script = "uid://b40rstjkpompc"
label = "Test"
metadata/_custom_type_script = "uid://yn7kxdargafx"
[sub_resource type="Resource" id="Resource_125nt"]
script = ExtResource("4_xf0pb")
item = 1
quantity = 2
metadata/_custom_type_script = "uid://38ya6vphm5bu"
[node name="TestMap" type="Node3D"]
script = ExtResource("1_6ms5s")
@@ -18,12 +25,13 @@ script = ExtResource("1_6ms5s")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00883961, 1.11219, 0.0142021)
entityId = "bcabec96-8d33-4c16-a997-3bb3b0562b33"
interactType = 1
conversation = Array[ExtResource("3_p7git")]([SubResource("Resource_p7git")])
conversation = Array[ExtResource("3_p7git")]([SubResource("Resource_xf0pb")])
[node name="NotPlayer2" parent="." instance=ExtResource("2_jmygs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00883961, 1.11219, 4.34543)
entityId = "ad5a1504-7fbf-45d6-b1bf-6e7af6314066"
interactType = 2
oneTimeItem = SubResource("Resource_125nt")
[node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")]