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