Skip to content

Commit

Permalink
feat: Optimized ESCCamera (#434)
Browse files Browse the repository at this point in the history
Co-authored-by: Dennis Ploeger <[email protected]>
  • Loading branch information
dploeger and dploeger authored Nov 12, 2021
1 parent c325c7f commit 15b3e30
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
)

Expand All @@ -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
13 changes: 13 additions & 0 deletions addons/escoria-core/game/core-scripts/esc_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 1 addition & 10 deletions addons/escoria-core/game/core-scripts/esc_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading

0 comments on commit 15b3e30

Please sign in to comment.