Deleted non-CC0 assets
Managed room7 camera pushes
This commit is contained in:
@@ -32,6 +32,7 @@ var commands = {
|
||||
"anim": { "min_args": 2, "types": [TYPE_STRING, TYPE_STRING, TYPE_BOOL, TYPE_BOOL, TYPE_BOOL] },
|
||||
"camera_push": { "min_args": 1, "types": [TYPE_STRING] },
|
||||
"camera_set_drag_margin_enabled": { "min_args": 2, "types": [TYPE_BOOL, TYPE_BOOL] },
|
||||
"camera_set_limits": { "min_args": 1, "types": [TYPE_INT]},
|
||||
"camera_set_pos": { "min_args": 3, "types": [TYPE_REAL, TYPE_INT, TYPE_INT] },
|
||||
"camera_set_target": { "min_args": 1, "types": [TYPE_REAL] },
|
||||
"camera_set_zoom": { "min_args": 1, "types": [TYPE_REAL] },
|
||||
|
||||
@@ -134,7 +134,11 @@ func camera_push(command_params : Array):
|
||||
var target = escoria.esc_runner.get_object(command_params[0])
|
||||
var time = command_params[1] if command_params.size() > 1 else 1
|
||||
var type = command_params[2] if command_params.size() > 2 else "QUAD"
|
||||
escoria.main.current_scene.game.get_node("camera").push(target, time, type)
|
||||
escoria.esc_runner.get_object("camera").push(target, time, type)
|
||||
|
||||
|
||||
func camera_set_limits(command_params : Array):
|
||||
escoria.main.set_camera_limits(command_params[0])
|
||||
|
||||
|
||||
"""
|
||||
@@ -163,8 +167,10 @@ This is the default behavior (default follow object is "player").
|
||||
If there's more than 1 object, the camera follows the average position of all
|
||||
the objects specified.
|
||||
"""
|
||||
func camera_set_target():
|
||||
pass
|
||||
func camera_set_target(command_params : Array):
|
||||
var speed = command_params[0]
|
||||
var target = escoria.esc_runner.get_object(command_params[1])
|
||||
escoria.esc_runner.get_object("camera").set_target(target, speed)
|
||||
|
||||
|
||||
"""
|
||||
@@ -180,7 +186,7 @@ func camera_set_zoom():
|
||||
|
||||
"""
|
||||
camera_set_zoom_height pixels [time]
|
||||
Similar to the command abo/ve, but uses pixel height instead of magnitude to zoom.
|
||||
Similar to the command above, but uses pixel height instead of magnitude to zoom.
|
||||
"""
|
||||
func camera_set_zoom_height():
|
||||
pass
|
||||
|
||||
@@ -60,6 +60,7 @@ func _enter_tree():
|
||||
add_child(area)
|
||||
|
||||
func _ready():
|
||||
# escoria.register_object(self)
|
||||
mouse_filter = MOUSE_FILTER_IGNORE
|
||||
area.connect("input_event", self, "manage_input")
|
||||
connect("gui_input", self, "manage_input_texturerect")
|
||||
@@ -71,6 +72,11 @@ func _ready():
|
||||
# connect("mouse_moved_on_bg", escoria.inputs_manager, "_on_mouse_moved_on_bg")
|
||||
|
||||
func manage_input(_viewport, event, _shape_idx):
|
||||
if event.is_action_pressed("switch_action_verb"):
|
||||
if event.button_index == BUTTON_WHEEL_UP:
|
||||
escoria.inputs_manager._on_mousewheel_action(-1)
|
||||
elif event.button_index == BUTTON_WHEEL_DOWN:
|
||||
escoria.inputs_manager._on_mousewheel_action(1)
|
||||
if event is InputEventMouseButton:
|
||||
var p = get_global_mouse_position()
|
||||
if event.doubleclick:
|
||||
@@ -95,3 +101,21 @@ func manage_input_texturerect(event):
|
||||
emit_signal("right_click_on_bg", event.position)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
func get_full_area_rect2() -> Rect2:
|
||||
var area_rect2 : Rect2 = Rect2()
|
||||
var pos = get_global_position()
|
||||
var size : Vector2
|
||||
if get_texture():
|
||||
size = get_texture().get_size()
|
||||
else:
|
||||
size = rect_size
|
||||
|
||||
if rect_scale.x != 1 or rect_scale.y != 1:
|
||||
size.x *= rect_scale.x
|
||||
size.y *= rect_scale.y
|
||||
|
||||
area_rect2 = area_rect2.expand(pos)
|
||||
area_rect2 = area_rect2.expand(pos + size)
|
||||
return area_rect2
|
||||
|
||||
@@ -245,6 +245,7 @@ func update_terrain(on_event_finished_name = null):
|
||||
return
|
||||
|
||||
var pos = position
|
||||
var gpos = global_position
|
||||
z_index = pos.y if pos.y <= VisualServer.CANVAS_ITEM_Z_MAX else VisualServer.CANVAS_ITEM_Z_MAX
|
||||
|
||||
var color
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
tool
|
||||
extends Node2D
|
||||
class_name ESCRoom
|
||||
|
||||
@@ -7,11 +8,33 @@ func get_class():
|
||||
export(String) var global_id = ""
|
||||
export(String, FILE, "*.esc") var esc_script = ""
|
||||
export(PackedScene) var player_scene
|
||||
export(Rect2) var camera_limits = Rect2()
|
||||
export(Array, Rect2) var camera_limits : Array = [Rect2()] setget set_camera_limits
|
||||
var player
|
||||
onready var game = $game
|
||||
|
||||
### EDITOR TOOLS ###
|
||||
enum EDITOR_ROOM_DEBUG_DISPLAY {
|
||||
NONE,
|
||||
CAMERA_LIMITS
|
||||
}
|
||||
export(EDITOR_ROOM_DEBUG_DISPLAY) var editor_debug_mode = EDITOR_ROOM_DEBUG_DISPLAY.NONE setget set_editor_debug_mode
|
||||
onready var camera_limits_colors : Array = [
|
||||
ColorN("red"), ColorN("blue"), ColorN("green")
|
||||
]
|
||||
### END EDITOR TOOLS ###
|
||||
|
||||
func _enter_tree():
|
||||
randomize()
|
||||
|
||||
|
||||
func _ready():
|
||||
if camera_limits.empty():
|
||||
camera_limits.push_back(Rect2())
|
||||
if camera_limits.size() == 1 and camera_limits[0].has_no_area():
|
||||
camera_limits[0] = Rect2(0, 0, $background.rect_size.x, $background.rect_size.y)
|
||||
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
|
||||
if player_scene:
|
||||
player = player_scene.instance()
|
||||
@@ -25,3 +48,31 @@ func _ready():
|
||||
if global_id.empty():
|
||||
global_id = name
|
||||
|
||||
func _draw():
|
||||
if !Engine.is_editor_hint():
|
||||
return
|
||||
if editor_debug_mode == EDITOR_ROOM_DEBUG_DISPLAY.NONE:
|
||||
return
|
||||
|
||||
# If there are more camera limits than colors defined for them, add more.
|
||||
if camera_limits.size() > camera_limits_colors.size():
|
||||
for i in camera_limits.size() - camera_limits_colors.size():
|
||||
camera_limits_colors.push_back(Color(randf(), randf(), randf(), 1.0))
|
||||
|
||||
# Draw lines for camera limits
|
||||
for i in camera_limits.size():
|
||||
draw_rect(camera_limits[i], camera_limits_colors[i], false, 10.0)
|
||||
var default_font = Control.new().get_font("font")
|
||||
|
||||
draw_string(default_font, Vector2(camera_limits[i].position.x + 30,
|
||||
camera_limits[i].position.y + 30), str(i), camera_limits_colors[i])
|
||||
|
||||
return
|
||||
|
||||
func set_camera_limits(p_camera_limits : Array) -> void:
|
||||
camera_limits = p_camera_limits
|
||||
update()
|
||||
|
||||
func set_editor_debug_mode(p_editor_debug_mode : int) -> void:
|
||||
editor_debug_mode = p_editor_debug_mode
|
||||
update()
|
||||
|
||||
Reference in New Issue
Block a user