Skip to content

Commit

Permalink
fix: changes camera target vs limit errors to warnings and makes sure…
Browse files Browse the repository at this point in the history
… they're in the right places
  • Loading branch information
BHSDuncan authored and StraToN committed Aug 9, 2022
1 parent abb01b7 commit e4bb111
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ func validate(arguments: Array):
% [get_command_name(), arguments[0]]
)
return false

var target_pos = (escoria.object_manager.get_object(arguments[0]).node as ESCItem).global_position
var camera: ESCCamera = escoria.object_manager.get_object(escoria.object_manager.CAMERA).node as ESCCamera
var camera_limit: Rect2 = Rect2(camera.limit_left, camera.limit_top, camera.limit_right - camera.limit_left, camera.limit_bottom - camera.limit_top)

if not camera_limit.has_point(target_pos):
escoria.logger.warn(
self,
"[%s]: invalid camera position. Camera cannot be moved to %s at position %s as this is outside the current camera limit %s."
% [
get_command_name(),
arguments[0],
target_pos,
camera_limit
]
)
return false

if not arguments[2] in SUPPORTED_TRANSITIONS:
escoria.logger.error(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func validate(arguments: Array):
var camera_limit: Rect2 = Rect2(camera.limit_left, camera.limit_top, camera.limit_right - camera.limit_left, camera.limit_bottom - camera.limit_top)

if not camera_limit.has_point(new_pos):
escoria.logger.error(
escoria.logger.warn(
self,
"[%s]: invalid camera position. Camera cannot be moved to %s as this is outside the current camera limit %s."
% [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func validate(arguments: Array):
var new_pos: Vector2 = Vector2(camera.position.x + shift_by.x, camera.position.y + shift_by.y)

if not camera_limit.has_point(new_pos):
escoria.logger.error(
escoria.logger.warn(
self,
"[%s]: invalid camera position. Camera cannot be moved by %s to %s as this is outside the current camera limit %s."
% [
Expand Down
2 changes: 1 addition & 1 deletion addons/escoria-core/game/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func set_camera_limits(camera_limit_id: int = 0, scene: Node = current_scene) ->

escoria.logger.info(
self,
"Setting camera limits from scene " + area
"Setting camera limits from scene " + str(area)
)
limits = ESCCameraLimits.new(
area.position.x,
Expand Down

0 comments on commit e4bb111

Please sign in to comment.