Issue 315 (#341)

* feat: accept_input implemented

* feat: More fixes for accept_input and tests for it

* feat: play_snd implemented

* fix: Removed game_over and queue_animation commands

* docs: Automatic update of API docs

* fix: FIxes schedule_event command

* feat: Implemented slide and slide_block

* feat: Implemented turn_to

* docs: Automatic update of API docs

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
Co-authored-by: dploeger <dploeger@users.noreply.github.com>
This commit is contained in:
Dennis Ploeger
2021-07-29 23:05:24 +02:00
committed by GitHub
parent df1ec0c814
commit 90f880d090
38 changed files with 622 additions and 480 deletions

View File

@@ -9,7 +9,6 @@
# skipped, but also initiate locked#### down cutscenes with accept_input
# NONE in :setup and accept_input ALL later in :ready.
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name AcceptInputCommand
@@ -40,8 +39,12 @@ func validate(arguments: Array):
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"accept_input: command not implemented",
[]
)
return ESCExecution.RC_ERROR
var mode = escoria.inputs_manager.INPUT_ALL
match command_params[0]:
"NONE":
mode = escoria.inputs_manager.INPUT_NONE
"SKIP":
mode = escoria.inputs_manager.INPUT_SKIP
escoria.inputs_manager.input_mode = mode
return ESCExecution.RC_OK

View File

@@ -1,29 +0,0 @@
# `game_over continue_enabled show_credits`
#
# Ends the game. Use the "continue_enabled" parameter to enable or disable the
# continue button in the main menu afterwards. The "show_credits" parameter
# loads the ui/end_credits scene if true. You can configure it to your regular
# credits scene if you want.
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name GameOverCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
0,
[TYPE_BOOL, TYPE_BOOL],
[false, true]
)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"game_over: command not implemented",
[]
)
return ESCExecution.RC_ERROR

View File

@@ -1,10 +1,8 @@
# `play_snd object file [loop]`
# `play_snd file [player]`
#
# Plays the sound specificed with the "file" parameter on the object, without
# blocking. You can play background sounds, eg. during scene changes, with
# `play_snd bg_snd res://...`
# Plays the sound specificed with the "file" parameter on the sound player
# `player`, without blocking. (player defaults to bg_sound)
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name PlaySndCommand
@@ -14,15 +12,31 @@ class_name PlaySndCommand
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING, TYPE_BOOL],
[null, null, false]
[TYPE_STRING, TYPE_STRING],
[null, "bg_sound"]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.has(arguments[0]):
escoria.logger.report_errors(
"play_snd: invalid sound player",
["Sound player %s not registered" % arguments[0]]
)
return false
if not ResourceLoader.exists(arguments[1]):
escoria.logger.report_errors(
"play_snd: invalid parameter",
["File %s not found" % arguments[1]]
)
return false
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"play_snd: command not implemented",
[]
escoria.object_manager.get_object(command_params[1]).node.set_state(
command_params[0]
)
return ESCExecution.RC_ERROR
return ESCExecution.RC_OK

View File

@@ -1,42 +0,0 @@
# `queue_animation object animation`
#
# Similar to queue_resource, queues the resources necessary to have an
# animation loaded on an item. The resource paths are taken from the item
# placeholders.
#
# @STUB
# @ESC
extends ESCBaseCommand
class_name QueueAnimationCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING],
[null, null]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"queue_animation: invalid first object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
# TODO: Check if animation is valid
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"queue_animation: command not implemented",
[]
)
return ESCExecution.RC_ERROR

View File

@@ -53,21 +53,6 @@ func run(command_params: Array) -> int:
if command_params.size() > 2:
dialog_scene_name = command_params[2]
# Manage translation/voice lines keys in the form of:
# line_key:"Default line text"
# If a line_key exists, we'll set it a label as it will automatically be
# translated
var dialog_key_line = command_params[1].split(":", true, 1)
if dialog_key_line.size() > 1:
dialog_key_line[1] = dialog_key_line[1].trim_prefix("\"")
dict = {
"key": dialog_key_line[0],
"line": dialog_key_line[1] if dialog_key_line.size() > 1 \
else dialog_key_line[0],
"ui": dialog_scene_name
}
escoria.current_state = escoria.GAME_STATE.DIALOG
if !escoria.dialog_player:
@@ -80,6 +65,10 @@ func run(command_params: Array) -> int:
)
return ESCExecution.RC_ERROR
escoria.dialog_player.say(command_params[0], dict)
escoria.dialog_player.say(
command_params[0],
dialog_scene_name,
command_params[1]
)
yield(escoria.dialog_player, "dialog_line_finished")
return ESCExecution.RC_OK

View File

@@ -20,7 +20,7 @@ func configure() -> ESCCommandArgumentDescriptor:
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[1]):
if not escoria.object_manager.has(arguments[1]):
escoria.logger.report_errors(
"sched_event: invalid object",
[

View File

@@ -11,12 +11,16 @@ extends ESCBaseCommand
class_name SlideCommand
# A hash of tweens currently active for animated items
var _tweens: Dictionary
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING, TYPE_INT],
[null, null, null]
[null, null, -1]
)
@@ -34,17 +38,64 @@ func validate(arguments: Array):
escoria.logger.report_errors(
"slide: invalid second object",
[
"Object with global id %s not found" % arguments[0]
"Object with global id %s not found" % arguments[1]
]
)
return false
return .validate(arguments)
# Slide the object by generating a tween
#
# #### Parameters
#
# - source: The item to slide
# - destination: The destination item to slide to
# - speed: The speed at which to slide (will default to the
#
# **Returns** The generated (and started) tween
func _slide_object(
source: ESCObject,
destination: ESCObject,
speed: int = -1
) -> Tween:
if speed == -1:
speed = source.node.speed
if _tweens.has(source.global_id):
var tween = (_tweens.get(source.global_id) as Tween)
tween.stop_all()
if (escoria.main as Node).has_node(tween.name):
(escoria.main as Node).remove_child(tween)
var tween = Tween.new()
(escoria.main as Node).add_child(tween)
var duration = source.node.position.distance_to(
destination.node.position
) / speed
tween.interpolate_property(
source.node,
"global_position",
source.node.global_position,
destination.node.global_position,
duration
)
tween.start()
_tweens[source.global_id] = tween
return tween
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"slide: command not implemented",
[]
_slide_object(
escoria.object_manager.get_object(command_params[0]),
escoria.object_manager.get_object(command_params[1]),
command_params[2]
)
return ESCExecution.RC_ERROR
return ESCExecution.RC_OK

View File

@@ -7,44 +7,16 @@
#
# @STUB
# @ESC
extends ESCBaseCommand
extends SlideCommand
class_name SlideBlockCommand
# Return the descriptor of the arguments of this command
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_STRING, TYPE_INT],
[null, null, null]
)
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.objects.has(arguments[0]):
escoria.logger.report_errors(
"slide_block: invalid first object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
if not escoria.object_manager.objects.has(arguments[1]):
escoria.logger.report_errors(
"slide_block: invalid second object",
[
"Object with global id %s not found" % arguments[0]
]
)
return false
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"slide_block: command not implemented",
[]
var tween = _slide_object(
escoria.object_manager.get_object(command_params[0]),
escoria.object_manager.get_object(command_params[1]),
command_params[2]
)
return ESCExecution.RC_ERROR
yield(tween, "tween_all_completed")
return ESCExecution.RC_OK

View File

@@ -1,4 +1,4 @@
# `turn_to object degrees`
# `turn_to object degrees [immediate]`
#
# Turns object to a degrees angle with a directions animation.
#
@@ -6,6 +6,9 @@
# When turning to the destination angle, animations are played if they're
# defined in animations. object must be player or interactive. degrees must
# be between [0, 360] or an error is reported.
#
# Set immediate to true to show directly switch to the direction and not
# show intermediate angles
#
# @STUB
# @ESC
@@ -17,8 +20,8 @@ class_name TurnToCommand
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_STRING, TYPE_INT],
[null, true]
[TYPE_STRING, TYPE_INT, TYPE_BOOL],
[null, null, false]
)
@@ -32,13 +35,22 @@ func validate(arguments: Array):
]
)
return false
if arguments[1] < 0 or arguments[1] > 360:
escoria.logger.report_errors(
"turn_to: invalid degrees",
[
"Degree %d not between 0 and 360" % arguments[1]
]
)
return false
return .validate(arguments)
# Run the command
func run(command_params: Array) -> int:
escoria.logger.report_errors(
"turn_to: command not implemented",
[]
)
return ESCExecution.RC_ERROR
(escoria.object_manager.get_object(command_params[0]).node as ESCItem)\
.set_angle(
command_params[1],
command_params[2]
)
return ESCExecution.RC_OK

View File

@@ -15,3 +15,10 @@ var timeout: float
func _init(p_event: ESCEvent, p_timeout: float):
self.event = p_event
self.timeout = p_timeout
# Run the event
#
# **Returns** The execution code
func run() -> int:
return event.run()

View File

@@ -318,7 +318,9 @@ func has_moved() -> bool:
#
# #### Parameters
#
# Set the angle
# - deg: The angle degree to set
# - immediate: Set the angle immediately. If false will show intermediate
# angles
func set_angle(deg: int, immediate = true):
_movable.set_angle(deg, immediate)