feat: Optimized ESCCamera (#434)

Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-11-12 16:55:26 +01:00
committed by GitHub
parent c325c7f66d
commit 15b3e30e28
8 changed files with 342 additions and 267 deletions

View File

@@ -39,6 +39,6 @@ func run(command_params: Array) -> int:
.push(
escoria.object_manager.get_object(command_params[0]).node,
command_params[1],
command_params[2]
Tween.new().get("TRANS_%s" % command_params[2])
)
return ESCExecution.RC_OK

View File

@@ -13,7 +13,12 @@ class_name CameraShiftCommand
func configure() -> ESCCommandArgumentDescriptor:
return ESCCommandArgumentDescriptor.new(
2,
[TYPE_INT, TYPE_INT, [TYPE_INT, TYPE_REAL], TYPE_STRING],
[
[TYPE_INT, TYPE_REAL],
[TYPE_INT, TYPE_REAL],
[TYPE_INT, TYPE_REAL],
TYPE_STRING
],
[null, null, 1, "QUAD"]
)
@@ -22,9 +27,11 @@ func configure() -> ESCCommandArgumentDescriptor:
func run(command_params: Array) -> int:
(escoria.object_manager.get_object("_camera").node as ESCCamera)\
.shift(
command_params[0],
command_params[1],
Vector2(
command_params[0],
command_params[1]
),
command_params[2],
command_params[3]
Tween.new().get("TRANS_%s" % command_params[3])
)
return ESCExecution.RC_OK

View File

@@ -124,6 +124,10 @@ export(float) var v_speed_damp: float = 1.0
export(NodePath) var animation_player_node: NodePath = "" \
setget _set_animation_player_node
# The node that references the camera position and zoom if this item is used
# as a camera target
export(NodePath) var camera_node
# ESCAnimationsResource (for walking, idling...)
var animations: ESCAnimationResource
@@ -456,6 +460,15 @@ func stop_talking():
)
# Return the camera position if a camera_position_node exists or the
# global position of the player
func get_camera_node():
if camera_node and get_node(camera_node):
return get_node(camera_node)
return self
# Detect the child nodes and set respective references
func _detect_children() -> void:
# Initialize collision variable.

View File

@@ -4,8 +4,7 @@ extends ESCItem
class_name ESCPlayer, "res://addons/escoria-core/design/esc_player.svg"
# The node that references the camera position
export(NodePath) var camera_position_node
# Wether the player can be selected like an item
export(bool) var selectable = false
@@ -23,11 +22,3 @@ func _ready():
else:
tooltip_name = ""
disconnect("input_event", self, "manage_input")
# Return the camera position if a camera_position_node exists or the
# global position of the player
func get_camera_pos():
if camera_position_node and get_node(camera_position_node):
return get_node(camera_position_node).global_position
return global_position