Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Optimized ESCCamera #434

Merged
merged 1 commit into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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