Cleaned and improved some event stuff
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
class_name EventGetItem extends "res://scripts/Event/Item/EventItem.gd"
|
||||
|
||||
const EventConversation = preload("res://scripts/Event/EventConversation.gd")
|
||||
|
||||
enum GetType {
|
||||
FOUND,
|
||||
GIVEN,
|
||||
@@ -7,14 +9,20 @@ enum GetType {
|
||||
|
||||
@export var showText: bool = true
|
||||
@export var getType:GetType = GetType.FOUND;
|
||||
@export var removeNode:Node = null
|
||||
|
||||
var conversationEvent:EventConversation = null
|
||||
var textboxEvent:EventTextbox = null
|
||||
|
||||
func start() -> void:
|
||||
super.start()
|
||||
getInventory().addItem(itemType, quantity)
|
||||
|
||||
# Should show text?
|
||||
if !showText:
|
||||
super.start()
|
||||
return
|
||||
|
||||
|
||||
# What text to show?
|
||||
var textKey:String
|
||||
match getType:
|
||||
GetType.FOUND:
|
||||
@@ -22,12 +30,29 @@ func start() -> void:
|
||||
GetType.GIVEN:
|
||||
textKey = "event.get_item.given"
|
||||
_:
|
||||
pass
|
||||
super.start()
|
||||
return
|
||||
|
||||
# Create translation context
|
||||
var ctx = TransContext.new()
|
||||
ctx.addInteger("quantity", quantity)
|
||||
ctx.addContext("item", ITEM.getItem(itemType).getTransContext())
|
||||
VN.getTextbox().setText(ctx.transPlural(textKey, textKey + "_plural", quantity));
|
||||
|
||||
# Create conversation
|
||||
conversationEvent = EventConversation.new()
|
||||
addChildEvent(conversationEvent)
|
||||
|
||||
# Create textbox
|
||||
textboxEvent = EventTextbox.new()
|
||||
textboxEvent.transContext = ctx
|
||||
textboxEvent.text = textKey
|
||||
textboxEvent.textPlural = textKey + "_plural"
|
||||
textboxEvent.count = quantity
|
||||
conversationEvent.addChildEvent(textboxEvent)
|
||||
|
||||
# Begin processing
|
||||
super.start()
|
||||
startChild(conversationEvent)
|
||||
|
||||
func isDone() -> bool:
|
||||
if !super.isDone():
|
||||
@@ -35,5 +60,13 @@ func isDone() -> bool:
|
||||
|
||||
if !showText:
|
||||
return true
|
||||
|
||||
return VN.getTextbox().isClosed;
|
||||
return conversationEvent.isDone()
|
||||
|
||||
func end() -> void:
|
||||
if removeNode:
|
||||
var parent = removeNode.get_parent()
|
||||
if parent:
|
||||
parent.remove_child(removeNode)
|
||||
removeNode.queue_free()
|
||||
removeNode = null
|
||||
super.end()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
class_name EventItem extends Event
|
||||
class_name EventItem extends "res://scripts/Event/Flow/EventWithChildren.gd"
|
||||
const Inventory = preload("res://scripts/Item/Inventory.gd")
|
||||
|
||||
@export var itemType:Item.Type = Item.Type.POTION
|
||||
|
Reference in New Issue
Block a user