Fixed UI system
This commit is contained in:
9
scripts/Event/Entity/EventEntityTurn.gd
Normal file
9
scripts/Event/Entity/EventEntityTurn.gd
Normal file
@@ -0,0 +1,9 @@
|
||||
class_name EventEntityTurn extends "res://scripts/Event/Event.gd"
|
||||
|
||||
@export var entity:OverworldEntity = null
|
||||
@export var direction:OverworldEntity.Direction = OverworldEntity.Direction.SOUTH
|
||||
|
||||
func start():
|
||||
if entity == null:
|
||||
return
|
||||
entity.direction = direction
|
1
scripts/Event/Entity/EventEntityTurn.gd.uid
Normal file
1
scripts/Event/Entity/EventEntityTurn.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bmcrd2ugqan43
|
52
scripts/Event/Event.gd
Normal file
52
scripts/Event/Event.gd
Normal file
@@ -0,0 +1,52 @@
|
||||
class_name Event extends Node
|
||||
|
||||
const OverworldEntity = preload("res://scripts/Entity/OverworldEntity.gd");
|
||||
|
||||
|
||||
var started:bool = false;
|
||||
var ended:bool = false;
|
||||
var interactor:OverworldEntity = null
|
||||
var interactee:OverworldEntity = null
|
||||
|
||||
# Godot Methods
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if !started || ended:
|
||||
return
|
||||
self.update(delta)
|
||||
|
||||
if self.isDone():
|
||||
self.end()
|
||||
|
||||
# Event methods (cleaned up)
|
||||
func start() -> void:
|
||||
assert(started == false)
|
||||
started = true
|
||||
|
||||
func update(delta:float) -> void:
|
||||
assert(started == true)
|
||||
assert(ended == false)
|
||||
|
||||
func isDone() -> bool:
|
||||
return true
|
||||
|
||||
func end() -> void:
|
||||
assert(ended == false)
|
||||
ended = true
|
||||
|
||||
func reset() -> void:
|
||||
started = false
|
||||
ended = false
|
||||
interactor = null
|
||||
interactee = null
|
||||
|
||||
func onEntityInteract(
|
||||
interactor:OverworldEntity,
|
||||
interactee:OverworldEntity
|
||||
) -> void:
|
||||
self.reset()
|
||||
self.interactor = interactor
|
||||
self.interactee = interactee
|
||||
self.start()
|
1
scripts/Event/Event.gd.uid
Normal file
1
scripts/Event/Event.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cl3vqv8bwyoeu
|
45
scripts/Event/EventConversation.gd
Normal file
45
scripts/Event/EventConversation.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
class_name EventConversation extends "res://scripts/Event/Flow/EventGroup.gd"
|
||||
|
||||
@export var startPauseType:PauseSystem.PauseType = PauseSystem.PauseType.ENTITY_PAUSED
|
||||
@export var endPauseType:PauseSystem.PauseType = PauseSystem.PauseType.NOT_PAUSED
|
||||
|
||||
@export var entities:Array[OverworldEntity] = []
|
||||
|
||||
@export var pauseInteractee:bool = true
|
||||
@export var pauseInteractor:bool = true
|
||||
@export var turnInteractee:bool = true
|
||||
@export var turnInteractor:bool = true
|
||||
|
||||
func start() -> void:
|
||||
# Turn events
|
||||
if interactee != null && interactor != null:
|
||||
if pauseInteractee && turnInteractee:
|
||||
var turn = EventEntityTurn.new()
|
||||
turn.entity = interactee
|
||||
turn.direction = interactee.getDirectionToFace(interactor.position)
|
||||
addExtraEvent(turn, 0)
|
||||
|
||||
if pauseInteractor && turnInteractor:
|
||||
var turn = EventEntityTurn.new()
|
||||
turn.entity = interactor
|
||||
turn.direction = interactor.getDirectionToFace(interactee.position)
|
||||
addExtraEvent(turn, 0)
|
||||
|
||||
# Create start pause event
|
||||
var startPause = EventPause.new()
|
||||
startPause.pauseType = startPauseType
|
||||
startPause.entities = entities
|
||||
startPause.includeInteractee = pauseInteractee
|
||||
startPause.includeInteractor = pauseInteractor
|
||||
addExtraEvent(startPause, 0)
|
||||
|
||||
# Create end pause event.
|
||||
var endPause = EventPause.new()
|
||||
endPause.pauseType = endPauseType
|
||||
endPause.entities = entities
|
||||
endPause.includeInteractee = pauseInteractee
|
||||
endPause.includeInteractor = pauseInteractor
|
||||
addExtraEvent(endPause, -1)
|
||||
|
||||
# Pass off to event group
|
||||
super.start()
|
1
scripts/Event/EventConversation.gd.uid
Normal file
1
scripts/Event/EventConversation.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://tkfc88q8m86f
|
1
scripts/Event/EventGroup.gd.uid
Normal file
1
scripts/Event/EventGroup.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://sqi2ehu4sqa1
|
16
scripts/Event/EventPause.gd
Normal file
16
scripts/Event/EventPause.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
class_name EventPause extends "res://scripts/Event/Event.gd"
|
||||
|
||||
const PauseSystem = preload("res://scripts/Singletons/Pause.gd")
|
||||
|
||||
@export var pauseType:PauseSystem.PauseType = PauseSystem.PauseType.ENTITY_PAUSED
|
||||
@export var entities:Array[OverworldEntity] = []
|
||||
@export var includeInteractee:bool = true
|
||||
@export var includeInteractor:bool = true
|
||||
|
||||
func start() -> void:
|
||||
var ents:Array[OverworldEntity] = entities
|
||||
if interactor != null and includeInteractor:
|
||||
ents.append(interactor)
|
||||
if interactee != null and includeInteractee:
|
||||
ents.append(interactee)
|
||||
PAUSE.pause(pauseType, ents)
|
1
scripts/Event/EventPause.gd.uid
Normal file
1
scripts/Event/EventPause.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bv36suxm08vqe
|
11
scripts/Event/EventTextbox.gd
Normal file
11
scripts/Event/EventTextbox.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name EventTextbox extends "res://scripts/Event/Event.gd"
|
||||
|
||||
# @export var text:Array[String] = [ "Hello Text" ];
|
||||
@export_multiline var text:String = "Hello Text"
|
||||
|
||||
func start() -> void:
|
||||
super.start()
|
||||
VN.getTextbox().setText(self.text);
|
||||
|
||||
func isDone() -> bool:
|
||||
return super.isDone() && VN.getTextbox().isClosed;
|
1
scripts/Event/EventTextbox.gd.uid
Normal file
1
scripts/Event/EventTextbox.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://y7ckj1tn5cro
|
1
scripts/Event/EventWithChildren.gd.uid
Normal file
1
scripts/Event/EventWithChildren.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dj5wl682sbohc
|
78
scripts/Event/Flow/EventGroup.gd
Normal file
78
scripts/Event/Flow/EventGroup.gd
Normal file
@@ -0,0 +1,78 @@
|
||||
class_name EventGroup extends "res://scripts/Event/Flow/EventWithChildren.gd"
|
||||
|
||||
enum ProcessType {
|
||||
SEQUENTIAL,
|
||||
PARALLEL,
|
||||
}
|
||||
|
||||
@export var processType:ProcessType = ProcessType.SEQUENTIAL;
|
||||
|
||||
var childIndex:int = 0
|
||||
|
||||
func start() -> void:
|
||||
super.start()
|
||||
|
||||
# If sequential, start first child
|
||||
if processType == ProcessType.SEQUENTIAL:
|
||||
childIndex = -1
|
||||
nextChild()
|
||||
|
||||
# If parallel, start all children
|
||||
elif processType == ProcessType.PARALLEL:
|
||||
for child in childEvents:
|
||||
startChild(child)
|
||||
|
||||
|
||||
func update(delta:float) -> void:
|
||||
super.update(delta)
|
||||
|
||||
# If sequential, see if the current child is done, if so go to next child
|
||||
if processType == ProcessType.SEQUENTIAL:
|
||||
if childIndex < 0 || childIndex >= childEvents.size():
|
||||
return
|
||||
if childEvents[childIndex].isDone():
|
||||
nextChild()
|
||||
|
||||
func nextChild() -> void:
|
||||
childIndex += 1
|
||||
if childIndex >= childEvents.size():
|
||||
return
|
||||
startChild(childEvents[childIndex])
|
||||
|
||||
func isDone() -> bool:
|
||||
if !super.isDone():
|
||||
return false
|
||||
|
||||
# If sequential, check if we've reached the end of the children
|
||||
if processType == ProcessType.SEQUENTIAL:
|
||||
return childIndex >= childEvents.size()
|
||||
|
||||
# If parallel, check if all children are done
|
||||
elif processType == ProcessType.PARALLEL:
|
||||
for child in childEvents:
|
||||
if !child.isDone():
|
||||
return false
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func end() -> void:
|
||||
for child in childEvents:
|
||||
if child.ended || !child.started:
|
||||
continue
|
||||
child.end()
|
||||
# Send to the parent to end the extra events
|
||||
super.end()
|
||||
|
||||
func reset() -> void:
|
||||
childIndex = -1
|
||||
for child in childEvents:
|
||||
child.reset()
|
||||
# Send to the parent to reset the extra events
|
||||
super.reset()
|
||||
|
||||
func startChild(child:Event) -> void:
|
||||
# Inherits some properties from this event.
|
||||
child.interactee = self.interactee
|
||||
child.interactor = self.interactor
|
||||
child.start()
|
1
scripts/Event/Flow/EventGroup.gd.uid
Normal file
1
scripts/Event/Flow/EventGroup.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bb1qpptyr1rec
|
37
scripts/Event/Flow/EventWithChildren.gd
Normal file
37
scripts/Event/Flow/EventWithChildren.gd
Normal file
@@ -0,0 +1,37 @@
|
||||
class_name EventWithChildren extends "res://scripts/Event/Event.gd"
|
||||
|
||||
var childEvents:Array[Event] = []
|
||||
var extraEvents:Array[Event] = []
|
||||
|
||||
func start():
|
||||
super.start()
|
||||
_updateChildEvents()
|
||||
|
||||
func reset() -> void:
|
||||
super.reset()
|
||||
_cleanupExtraEvents()
|
||||
|
||||
func end() -> void:
|
||||
super.end()
|
||||
_cleanupExtraEvents()
|
||||
|
||||
func _updateChildEvents() -> void:
|
||||
childEvents = []
|
||||
for child in get_children():
|
||||
if child is Event:
|
||||
childEvents.append(child)
|
||||
|
||||
func _cleanupExtraEvents():
|
||||
for event in extraEvents:
|
||||
remove_child(event)
|
||||
event.queue_free()
|
||||
extraEvents = []
|
||||
_updateChildEvents()
|
||||
|
||||
func addExtraEvent(child:Event, position:int) -> void:
|
||||
assert(started == false || ended == true)
|
||||
# Add the child to the extra events list
|
||||
extraEvents.append(child)
|
||||
add_child(child)
|
||||
move_child(child, position)
|
||||
_updateChildEvents()
|
1
scripts/Event/Flow/EventWithChildren.gd.uid
Normal file
1
scripts/Event/Flow/EventWithChildren.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bs78jtft61ro6
|
Reference in New Issue
Block a user