in-world ui textboxes
This commit is contained in:
@@ -14,6 +14,8 @@ enum InteractType {
|
||||
ONE_TIME_ITEM,
|
||||
CUTSCENE,
|
||||
BATTLE_TEST,
|
||||
CHATBOX,
|
||||
PROXIMITY_CHATBOX,
|
||||
};
|
||||
|
||||
@export_category("Identification")
|
||||
@@ -33,6 +35,8 @@ var button := func():
|
||||
@export var dialogueTitle:String = "start"
|
||||
@export var oneTimeItem:ItemResource = null
|
||||
@export var cutscene:CutsceneResource = null
|
||||
@export var chatboxMessage:String = ""
|
||||
@export var chatboxDuration:float = 3.0
|
||||
|
||||
# TEST BATTLE
|
||||
@export_category("Test Battle")
|
||||
|
||||
@@ -33,15 +33,19 @@ func isInteractable() -> bool:
|
||||
if entity.interactType == Entity.InteractType.BATTLE_TEST:
|
||||
return true
|
||||
|
||||
if entity.interactType == Entity.InteractType.CHATBOX:
|
||||
return entity.chatboxMessage != ""
|
||||
|
||||
return false
|
||||
|
||||
func _onConversationInteract(_other:Entity) -> void:
|
||||
func _onConversationInteract(other:Entity) -> void:
|
||||
assert(entity.dialogueResource != null)
|
||||
var cutscene:Cutscene = Cutscene.new()
|
||||
cutscene.addCallable(DialogueAction.getDialogueCallable(
|
||||
entity.dialogueResource,
|
||||
entity.dialogueTitle,
|
||||
[entity]
|
||||
[entity],
|
||||
{"npc": entity, "player": other}
|
||||
))
|
||||
cutscene.start()
|
||||
|
||||
@@ -83,5 +87,11 @@ func onInteract(other:Entity) -> void:
|
||||
cutscene.start()
|
||||
return
|
||||
|
||||
Entity.InteractType.CHATBOX:
|
||||
assert(entity.chatboxMessage != "")
|
||||
var chatbox:WorldChatBox = UI.spawnWorldChatBox(entity)
|
||||
chatbox.showAdvanceable(entity.chatboxMessage)
|
||||
return
|
||||
|
||||
_:
|
||||
pass
|
||||
|
||||
@@ -20,7 +20,8 @@ func _applyGravity() -> void:
|
||||
func _applyPlayerMovement(delta:float):
|
||||
# Interactions, may move
|
||||
if Input.is_action_just_pressed("interact") && interactingArea && interactingArea.hasInteraction():
|
||||
interactingArea.interact()
|
||||
if !UI.hasAdvanceableChatBox():
|
||||
interactingArea.interact()
|
||||
return
|
||||
|
||||
# Directional input
|
||||
@@ -64,7 +65,7 @@ func _applyFriction(delta:float) -> void:
|
||||
func _canMove() -> bool:
|
||||
if UI.dialogueActive:
|
||||
return false
|
||||
if !UI.TEXTBOX.isClosed:
|
||||
if !UI.MAIN_CHATBOX.isClosed:
|
||||
return false
|
||||
if UI.GAME_MENU && UI.GAME_MENU.isOpen():
|
||||
return false
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
class_name EntityProximityArea extends Area3D
|
||||
|
||||
@export var entity:Entity
|
||||
|
||||
var _triggered:bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
body_entered.connect(_onBodyEntered)
|
||||
|
||||
func _onBodyEntered(body:Node3D) -> void:
|
||||
if _triggered:
|
||||
return
|
||||
if !(body is Entity):
|
||||
return
|
||||
if (body as Entity).entityId != "player":
|
||||
return
|
||||
_triggered = true
|
||||
assert(entity != null && entity.chatboxMessage != "")
|
||||
var chatbox:WorldChatBox = UI.spawnWorldChatBox(entity)
|
||||
chatbox.showTimed(entity.chatboxMessage, entity.chatboxDuration)
|
||||
@@ -0,0 +1 @@
|
||||
uid://bq2lsd8uyrtcf
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://d0ywgijpuqy0r"]
|
||||
[gd_scene load_steps=11 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"]
|
||||
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="Script" uid="uid://38ya6vphm5bu" path="res://item/ItemResource.gd" id="4_xf0pb"]
|
||||
[ext_resource type="Script" uid="uid://b5c8g5frishjs" path="res://cutscene/cutscene/TestCutscene.gd" id="5_125nt"]
|
||||
[ext_resource type="Script" uid="uid://8tsov4ihmnxl" path="res://overworld/camera/OverworldCamera.gd" id="7_tr4a0"]
|
||||
[ext_resource type="Script" uid="uid://bq2lsd8uyrtcf" path="res://overworld/entity/EntityProximityArea.gd" id="8_prox"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_125nt"]
|
||||
script = ExtResource("4_xf0pb")
|
||||
@@ -17,6 +18,9 @@ metadata/_custom_type_script = "uid://38ya6vphm5bu"
|
||||
script = ExtResource("5_125nt")
|
||||
metadata/_custom_type_script = "uid://b5c8g5frishjs"
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_prox"]
|
||||
radius = 3.0
|
||||
|
||||
[node name="TestMap" type="Node3D"]
|
||||
script = ExtResource("1_6ms5s")
|
||||
|
||||
@@ -42,6 +46,27 @@ entityId = "ad5a1504-7fbf-45d6-b1bf-6e7af6314066"
|
||||
interactType = 3
|
||||
cutscene = SubResource("Resource_tr4a0")
|
||||
|
||||
[node name="ChatboxNPC" parent="." instance=ExtResource("2_jmygs")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 1.11219, -3)
|
||||
entityId = "c1a2b3c4-d5e6-7890-abcd-ef1234567891"
|
||||
interactType = 5
|
||||
chatboxMessage = "Hey! Press interact again to close this box."
|
||||
|
||||
[node name="ProximityNPC" parent="." instance=ExtResource("2_jmygs")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 1.11219, -4)
|
||||
entityId = "c1a2b3c4-d5e6-7890-abcd-ef1234567892"
|
||||
interactType = 6
|
||||
chatboxMessage = "Hey, over here!"
|
||||
|
||||
[node name="EntityProximityArea" type="Area3D" parent="ProximityNPC" node_paths=PackedStringArray("entity")]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource("8_prox")
|
||||
entity = NodePath("..")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="ProximityNPC/EntityProximityArea"]
|
||||
shape = SubResource("SphereShape3D_prox")
|
||||
|
||||
[node name="TestMapBase" parent="." instance=ExtResource("1_ox0si")]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("2_jmygs")]
|
||||
|
||||
Reference in New Issue
Block a user