Continued camera effects adding (zoom, shift)
Added trigger behaviour to ESCItem and removed ESCTriggerZone.
This commit is contained in:
@@ -440,28 +440,19 @@ func register_object(name : String, val : Object, force : bool = false):
|
||||
|
||||
# Most objects have states/animations, but don't count on it
|
||||
# if val.has_method("set_state"):
|
||||
if val is ESCItem or val is ESCPlayer or val is ESCCharacter or val is ESCHotspot:
|
||||
if val is ESCItem or val is ESCPlayer or val is ESCCharacter:
|
||||
if name in states:
|
||||
set_state(name, [states[name], true])
|
||||
else:
|
||||
set_state(name, [esctypes.OBJ_DEFAULT_STATE])
|
||||
|
||||
if val is ESCItem or val is ESCHotspot:
|
||||
if val is ESCItem:
|
||||
if val.is_interactive:
|
||||
set_interactive(name, true)
|
||||
|
||||
|
||||
# if val.has_method("set_active"):
|
||||
# if name in actives:
|
||||
# val.set_active(actives[name])
|
||||
|
||||
# if val.has_method("set_interactive"):
|
||||
# if name in interactives:
|
||||
# val.set_interactive(interactives[name])
|
||||
|
||||
if val.get("esc_script") != null and !val.get("esc_script").empty():
|
||||
objects_events_table[name] = escoria.esc_compiler.load_esc_file(val.esc_script)
|
||||
|
||||
|
||||
|
||||
func get_object(name):
|
||||
if !(name in objects):
|
||||
@@ -588,11 +579,6 @@ func set_state(global_id : String, p_params : Array):
|
||||
# animation_node = obj.get("animation")
|
||||
if obj.get_animation_player() != null:
|
||||
animation_node = obj.get_animation_player()
|
||||
elif obj is ESCHotspot and obj.get_item_child_if_any() != null:
|
||||
#if obj.get_item_child_if_any().get("animation") != null:
|
||||
# animation_node = obj.get_item_child_if_any().animation
|
||||
if obj.get_item_child_if_any().get_animation_player() != null:
|
||||
animation_node = obj.get_item_child_if_any().get_animation_player()
|
||||
|
||||
if animation_node:
|
||||
animation_node.stop()
|
||||
@@ -614,7 +600,7 @@ func set_state(global_id : String, p_params : Array):
|
||||
var animation = actual_animator.get_animation(p_params[0])
|
||||
var animation_length = animation.length
|
||||
animation_node.seek(animation_length)
|
||||
|
||||
print_debug("Item " + obj.global_id + " changed state to: " + p_params[0])
|
||||
|
||||
"""
|
||||
When object is active, it is VISIBLE.
|
||||
|
||||
@@ -156,10 +156,13 @@ camera_set_pos speed x y
|
||||
Moves the camera to a position defined by "x" and "y", at the speed defined by
|
||||
"speed" in pixels per second. If speed is 0, camera is teleported to the position.
|
||||
"""
|
||||
func camera_set_pos():
|
||||
func camera_set_pos(command_params : Array):
|
||||
# var speed = command_params[0]
|
||||
# var x = command_params[1]
|
||||
# var y = command_params[2]
|
||||
# escoria.esc_runner.get_object("camera").set_pos(speed, x, y)
|
||||
pass
|
||||
|
||||
|
||||
"""
|
||||
camera_set_target speed object [object2 object3 ...]
|
||||
Configures the camera to follow 1 or more objects, using "speed" as speed limit.
|
||||
@@ -180,8 +183,10 @@ the camera out, and smaller values zooms in, relative to the default value of 1.
|
||||
An optional time in seconds controls how long it takes for the camera to zoom
|
||||
into position.
|
||||
"""
|
||||
func camera_set_zoom():
|
||||
pass
|
||||
func camera_set_zoom(command_params : Array):
|
||||
var zoom_level = command_params[0]
|
||||
var speed = command_params[0] if command_params.size() > 1 else 0
|
||||
escoria.esc_runner.get_object("camera").set_camera_zoom(zoom_level, speed)
|
||||
|
||||
|
||||
"""
|
||||
@@ -198,8 +203,12 @@ Shift camera by x and y pixels over time seconds.
|
||||
- type is any of the Tween.TransitionType values without the prefix, eg. LINEAR,
|
||||
QUART or CIRC; defaults to QUART.
|
||||
"""
|
||||
func camera_shift():
|
||||
pass
|
||||
func camera_shift(command_params : Array):
|
||||
var x = command_params[0]
|
||||
var y = command_params[1]
|
||||
var time = command_params[2]
|
||||
var type = command_params[3] if command_params.size() > 3 else "QUAD"
|
||||
escoria.esc_runner.get_object("camera").shift(x, y, time, type)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
@@ -20,10 +20,23 @@ var MovableScript = load("res://addons/escoria-core/game/core-scripts/behaviors/
|
||||
|
||||
export(String) var global_id
|
||||
export(String, FILE, "*.esc") var esc_script
|
||||
|
||||
# If true, the ESC script may have an ":exit_scene" event to manage scene changes
|
||||
export(bool) var is_exit
|
||||
|
||||
# is_trigger If true, object is considered as trigger. Allows using :trigger_in and
|
||||
# :trigger_out verbs in ESC scripts.
|
||||
export(bool) var is_trigger
|
||||
export(String) var trigger_in_verb = "trigger_in"
|
||||
export(String) var trigger_out_verb = "trigger_out"
|
||||
|
||||
# is_interactive : If true, object is not "focusable".
|
||||
export(bool) var is_interactive = true
|
||||
|
||||
# player_orients_on_arrival : If true, player orients towards 'interaction_direction' as
|
||||
# player character arrives.
|
||||
export(bool) var player_orients_on_arrival = true
|
||||
|
||||
export(ESCPlayer.Directions) var interaction_direction
|
||||
export(String) var tooltip_name
|
||||
export(String) var default_action
|
||||
@@ -97,6 +110,7 @@ var last_deg : int
|
||||
var last_dir : int
|
||||
|
||||
func _ready():
|
||||
assert(!global_id.empty())
|
||||
|
||||
# Adds movable behavior
|
||||
Movable = Node.new()
|
||||
@@ -120,11 +134,17 @@ func _ready():
|
||||
|
||||
if !Engine.is_editor_hint():
|
||||
escoria.register_object(self)
|
||||
connect("mouse_entered_item", escoria.inputs_manager, "_on_mouse_entered_item")
|
||||
connect("mouse_exited_item", escoria.inputs_manager, "_on_mouse_exited_item")
|
||||
connect("mouse_left_clicked_item", escoria.inputs_manager, "_on_mouse_left_clicked_item")
|
||||
connect("mouse_double_left_clicked_item", escoria.inputs_manager, "_on_mouse_left_double_clicked_item")
|
||||
connect("mouse_right_clicked_item", escoria.inputs_manager, "_on_mouse_right_clicked_item")
|
||||
if !is_trigger:
|
||||
connect("mouse_entered_item", escoria.inputs_manager, "_on_mouse_entered_item")
|
||||
connect("mouse_exited_item", escoria.inputs_manager, "_on_mouse_exited_item")
|
||||
connect("mouse_left_clicked_item", escoria.inputs_manager, "_on_mouse_left_clicked_item")
|
||||
connect("mouse_double_left_clicked_item", escoria.inputs_manager, "_on_mouse_left_double_clicked_item")
|
||||
connect("mouse_right_clicked_item", escoria.inputs_manager, "_on_mouse_right_clicked_item")
|
||||
else:
|
||||
connect("area_entered", self, "element_entered")
|
||||
connect("area_exited", self, "element_exited")
|
||||
connect("body_entered", self, "element_entered")
|
||||
connect("body_exited", self, "element_exited")
|
||||
|
||||
if !is_exit:
|
||||
last_scale = scale
|
||||
@@ -184,12 +204,32 @@ func _on_mouse_exited():
|
||||
|
||||
################################################################################
|
||||
|
||||
# TRIGGER functions
|
||||
|
||||
func element_entered(body):
|
||||
if body is ESCBackground or body.get_parent() is ESCBackground:
|
||||
return
|
||||
escoria.do("trigger_in", [global_id, body.global_id, trigger_in_verb])
|
||||
|
||||
|
||||
func element_exited(body):
|
||||
if body is ESCBackground or body.get_parent() is ESCBackground:
|
||||
return
|
||||
escoria.do("trigger_out", [global_id, body.global_id, trigger_out_verb])
|
||||
|
||||
################################################################################
|
||||
|
||||
# MOVING OBJECT functions
|
||||
|
||||
func teleport(target, angle : Object = null) -> void:
|
||||
Movable.teleport(target, angle)
|
||||
|
||||
func walk_to(pos : Vector2, p_walk_context = null):
|
||||
Movable.walk_to(pos, p_walk_context)
|
||||
|
||||
################################################################################
|
||||
|
||||
# TALKATIVE object functions
|
||||
|
||||
func start_talking():
|
||||
# if animation_sprite.is_playing():
|
||||
|
||||
@@ -2,30 +2,30 @@ tool
|
||||
extends Area2D
|
||||
class_name ESCTriggerZone
|
||||
|
||||
signal left_click_on_trigger
|
||||
signal left_dblclick_on_trigger
|
||||
signal right_click_on_trigger
|
||||
signal mouse_enter_trigger
|
||||
signal mouse_exit_trigger
|
||||
func get_class():
|
||||
return "ESCTriggerZone"
|
||||
|
||||
func mouse_enter():
|
||||
emit_signal("mouse_enter_trigger", self)
|
||||
|
||||
func mouse_exit():
|
||||
emit_signal("mouse_exit_trigger", self)
|
||||
export(String) var global_id
|
||||
export(String, FILE, "*.esc") var esc_script
|
||||
|
||||
func body_entered(body):
|
||||
# if body is esc_type.PLAYER:
|
||||
# if self.visible:
|
||||
# run_event("enter")
|
||||
pass
|
||||
|
||||
func body_exited(body):
|
||||
# if body is esc_type.PLAYER:
|
||||
# if self.visible:
|
||||
# run_event("exit")
|
||||
pass
|
||||
func _ready():
|
||||
assert(!global_id.empty())
|
||||
escoria.register_object(self)
|
||||
connect("area_entered", self, "element_entered")
|
||||
connect("area_exited", self, "element_exited")
|
||||
connect("body_entered", self, "element_entered")
|
||||
connect("body_exited", self, "element_exited")
|
||||
|
||||
|
||||
func element_entered(body):
|
||||
if body is ESCBackground or body.get_parent() is ESCBackground:
|
||||
return
|
||||
escoria.do("trigger_in", [global_id, body.global_id])
|
||||
|
||||
|
||||
func element_exited(body):
|
||||
escoria.do("trigger_out", [global_id, body.global_id])
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user