Moved and split escoria._ev_left_click_on_item() function into ESCController (#371)
* Moved and split escoria._ev_left_click_on_item() function into ESCController. Added a boolean in ESCWalkContext to hold whether interact should happen after destination is reached. Co-authored-by: StraToN <StraToN@users.noreply.github.com>
This commit is contained in:
247
addons/escoria-core/game/core-scripts/esc_controller.gd
Normal file
247
addons/escoria-core/game/core-scripts/esc_controller.gd
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
# This script contains functions called by gamedev's game.gd.
|
||||||
|
# These functions convert input actions into game actions. For example:
|
||||||
|
# "click on background" -> player walks to position
|
||||||
|
# "click on item" -> player walks to item then performs the action defined
|
||||||
|
# by current verb
|
||||||
|
|
||||||
|
class_name ESCController
|
||||||
|
|
||||||
|
|
||||||
|
# Makes an object walk to a destination. This can be either a 2D position or
|
||||||
|
# another object.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - moving_obj_id: global id of the object that needs to move
|
||||||
|
# - destination: Position2D or ESCObject holding the moving object to head to
|
||||||
|
# - is_fast: if true, the walk is performed at fast speed (defined in the moving
|
||||||
|
# object.
|
||||||
|
func perform_walk(
|
||||||
|
moving_obj: ESCObject,
|
||||||
|
destination,
|
||||||
|
is_fast: bool = false
|
||||||
|
):
|
||||||
|
# Walk to Position2D.
|
||||||
|
if destination is Vector2:
|
||||||
|
var walk_context = ESCWalkContext.new(
|
||||||
|
null,
|
||||||
|
destination,
|
||||||
|
is_fast,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
moving_obj.node.walk_to(destination, walk_context)
|
||||||
|
|
||||||
|
# Walk to object
|
||||||
|
elif destination is ESCObject:
|
||||||
|
if destination.node:
|
||||||
|
var target_position: Vector2
|
||||||
|
if destination.node is ESCLocation:
|
||||||
|
target_position = destination.node.global_position
|
||||||
|
else:
|
||||||
|
target_position = destination.node.interact_position
|
||||||
|
|
||||||
|
var walk_context = ESCWalkContext.new(
|
||||||
|
destination.node,
|
||||||
|
Vector2(),
|
||||||
|
is_fast,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
moving_obj.node.walk_to(target_position, walk_context)
|
||||||
|
|
||||||
|
else:
|
||||||
|
escoria.logger.report_errors(
|
||||||
|
"esc_controller.gd:perform_walk()",
|
||||||
|
[
|
||||||
|
"Function expected either a Vector2 or ESCObject type " + \
|
||||||
|
"for destination parameter. Actual was: %s " % destination
|
||||||
|
]
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
# Event handler when an object/item was clicked
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - obj: Object that was left clicked
|
||||||
|
# - event: Input event that was received
|
||||||
|
# - default_action: if true, run the inventory default action
|
||||||
|
func perform_inputevent_on_object(
|
||||||
|
obj: ESCObject,
|
||||||
|
event: InputEvent,
|
||||||
|
default_action: bool = false
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
This algorithm:
|
||||||
|
- makes the player move to the clicked object location, if needed
|
||||||
|
(if it is located in the room for example) and wait for reaching.
|
||||||
|
- when reached, performs an action depending on current defined action
|
||||||
|
* no current action defined: do nothing else
|
||||||
|
* current action defined:
|
||||||
|
* item requires no combination: perform the current action
|
||||||
|
on the item
|
||||||
|
* item requires combination: check the status of the combination
|
||||||
|
A combination requires 3 elements to fulfill:
|
||||||
|
1/ a verb action
|
||||||
|
2/ a first "tool" (item to use)
|
||||||
|
3/ a second "tool" (item to use ON)
|
||||||
|
Whatever the user inputs to fulfill the combination (this is
|
||||||
|
determined by gamedev in his game.gd script)
|
||||||
|
- combination not fulfilled: no not perform until fulfilled
|
||||||
|
- combination fulfilled: perform the combination.
|
||||||
|
* else do nothing, except if default_action is requested.
|
||||||
|
In this case, perform the default_action on the item.
|
||||||
|
"""
|
||||||
|
|
||||||
|
escoria.logger.info("%s left-clicked with event " % obj.global_id, [event])
|
||||||
|
|
||||||
|
# Don't interact after player movement towards object
|
||||||
|
# (because object is inactive for example)
|
||||||
|
var dont_interact = false
|
||||||
|
|
||||||
|
var destination_position: Vector2 = escoria.main.current_scene.player.\
|
||||||
|
global_position
|
||||||
|
|
||||||
|
# If clicked object not in inventory, player walks towards it
|
||||||
|
if not escoria.inventory_manager.inventory_has(obj.global_id):
|
||||||
|
var context = _walk_towards_object(
|
||||||
|
obj,
|
||||||
|
event.position,
|
||||||
|
event.doubleclick
|
||||||
|
)
|
||||||
|
if context is GDScriptFunctionState:
|
||||||
|
context = yield(_walk_towards_object(
|
||||||
|
obj,
|
||||||
|
event.position,
|
||||||
|
event.doubleclick
|
||||||
|
), "completed")
|
||||||
|
destination_position = context.target_position
|
||||||
|
dont_interact = context.dont_interact_on_arrival
|
||||||
|
|
||||||
|
# If no interaction should happen after player has arrived, leave
|
||||||
|
# immediately.
|
||||||
|
if dont_interact:
|
||||||
|
return
|
||||||
|
|
||||||
|
var player_global_pos = escoria.main.current_scene.player.global_position
|
||||||
|
var clicked_position = event.position
|
||||||
|
|
||||||
|
# If player has arrived at the position he was supposed to reach
|
||||||
|
# so he can interact
|
||||||
|
if player_global_pos == destination_position:
|
||||||
|
# Manage exits
|
||||||
|
if obj.node.is_exit and escoria.action_manager.current_action \
|
||||||
|
in ["", "walk"]:
|
||||||
|
escoria.action_manager.activate("exit_scene", obj)
|
||||||
|
else:
|
||||||
|
# Manage movements towards object before activating it
|
||||||
|
if escoria.action_manager.current_action in ["", "walk"] and \
|
||||||
|
not escoria.inventory_manager.inventory_has(obj.global_id):
|
||||||
|
escoria.action_manager.activate("arrived", obj)
|
||||||
|
# Manage action on object
|
||||||
|
elif not escoria.action_manager.current_action in ["", "walk"]:
|
||||||
|
# Check if clicked item awaits a combination
|
||||||
|
var need_combine = _check_item_needs_combine(
|
||||||
|
obj,
|
||||||
|
default_action
|
||||||
|
)
|
||||||
|
|
||||||
|
# If apply_interact, perform combine between items
|
||||||
|
if need_combine:
|
||||||
|
escoria.action_manager.activate(
|
||||||
|
escoria.action_manager.current_action,
|
||||||
|
escoria.action_manager.current_tool,
|
||||||
|
obj
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
escoria.action_manager.activate(
|
||||||
|
escoria.action_manager.current_action,
|
||||||
|
obj
|
||||||
|
)
|
||||||
|
|
||||||
|
# Checks if object requires a combination with another, according to
|
||||||
|
# currently selected action verb (or check with default action of the item).
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - obj: the ESCObject to test
|
||||||
|
# - default_action: if true, the check is done on the object's default action
|
||||||
|
func _check_item_needs_combine(obj: ESCObject, default_action: bool) -> bool:
|
||||||
|
var need_combine = false
|
||||||
|
# Check if current_action and current_tool are already set
|
||||||
|
if escoria.action_manager.current_action and \
|
||||||
|
escoria.action_manager.current_tool:
|
||||||
|
if escoria.action_manager.current_action in escoria.action_manager\
|
||||||
|
.current_tool.node.combine_if_action_used_among:
|
||||||
|
need_combine = true
|
||||||
|
else:
|
||||||
|
escoria.action_manager.current_tool = obj
|
||||||
|
elif default_action:
|
||||||
|
if escoria.inventory_manager.inventory_has(obj.global_id):
|
||||||
|
escoria.action_manager.current_action = \
|
||||||
|
obj.node.default_action_inventory
|
||||||
|
else:
|
||||||
|
escoria.action_manager.current_action = \
|
||||||
|
obj.node.default_action
|
||||||
|
elif escoria.action_manager.current_action in \
|
||||||
|
obj.node.combine_if_action_used_among:
|
||||||
|
escoria.action_manager.current_tool = obj
|
||||||
|
return need_combine
|
||||||
|
|
||||||
|
|
||||||
|
# Makes the player character walk towards the clicked item.
|
||||||
|
# Returns the resulting walk context.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
#
|
||||||
|
# - obj: the object that was clicked
|
||||||
|
# - clicked_position: the Position2D of the input click
|
||||||
|
# - walk_fast: if true, the player will walk fast to the object
|
||||||
|
func _walk_towards_object(
|
||||||
|
obj: ESCObject,
|
||||||
|
clicked_position: Vector2,
|
||||||
|
walk_fast: bool
|
||||||
|
) -> ESCWalkContext:
|
||||||
|
var destination_position: Vector2
|
||||||
|
var dont_interact: bool = false
|
||||||
|
|
||||||
|
# If clicked object is interactive, get destination position from it.
|
||||||
|
if escoria.object_manager.get_object(obj.global_id).interactive:
|
||||||
|
if obj.node.get_interact_position() != null:
|
||||||
|
destination_position = obj.node.get_interact_position()
|
||||||
|
else:
|
||||||
|
destination_position = obj.node.position
|
||||||
|
else:
|
||||||
|
destination_position = clicked_position
|
||||||
|
dont_interact = true
|
||||||
|
|
||||||
|
# Create walk context
|
||||||
|
var walk_context = ESCWalkContext.new(
|
||||||
|
obj,
|
||||||
|
destination_position,
|
||||||
|
walk_fast,
|
||||||
|
dont_interact
|
||||||
|
)
|
||||||
|
|
||||||
|
# Walk towards the clicked object
|
||||||
|
escoria.main.current_scene.player.walk_to(destination_position,
|
||||||
|
walk_context)
|
||||||
|
|
||||||
|
# Wait for the player to arrive before continuing with action.
|
||||||
|
var context: ESCWalkContext = yield(
|
||||||
|
escoria.main.current_scene.player,
|
||||||
|
"arrived"
|
||||||
|
)
|
||||||
|
escoria.logger.info("Context arrived: %s" % context)
|
||||||
|
|
||||||
|
# Confirm that reached item was the one user clicked in the first place.
|
||||||
|
# Don't interact if that is not the case.
|
||||||
|
if (context.target_object and context.target_object.\
|
||||||
|
global_id != walk_context.\
|
||||||
|
target_object.global_id) or \
|
||||||
|
(context.target_position != walk_context.target_position):
|
||||||
|
walk_context.dont_interact_on_arrival = true
|
||||||
|
|
||||||
|
return context
|
||||||
@@ -10,15 +10,20 @@ var target_object: ESCObject = null
|
|||||||
# The target position
|
# The target position
|
||||||
var target_position: Vector2 = Vector2()
|
var target_position: Vector2 = Vector2()
|
||||||
|
|
||||||
# Wether to move fast
|
# Whether to move fast
|
||||||
var fast: bool
|
var fast: bool
|
||||||
|
|
||||||
|
# Whether an interaction should NOT happen after walk reaches destination
|
||||||
|
var dont_interact_on_arrival: bool
|
||||||
|
|
||||||
|
|
||||||
func _init(
|
func _init(
|
||||||
p_target_object: ESCObject,
|
p_target_object: ESCObject,
|
||||||
p_target_position: Vector2,
|
p_target_position: Vector2,
|
||||||
p_fast: bool
|
p_fast: bool,
|
||||||
|
p_dont_interact_on_arrival: bool
|
||||||
):
|
):
|
||||||
target_object = p_target_object
|
target_object = p_target_object
|
||||||
target_position = p_target_position
|
target_position = p_target_position
|
||||||
fast = p_fast
|
fast = p_fast
|
||||||
|
dont_interact_on_arrival = p_dont_interact_on_arrival
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ var inputs_manager: ESCInputsManager
|
|||||||
# Savegames and settings manager
|
# Savegames and settings manager
|
||||||
var save_manager: ESCSaveManager
|
var save_manager: ESCSaveManager
|
||||||
|
|
||||||
|
# The controller in charge of converting an action verb on a game object
|
||||||
|
# into an actual action
|
||||||
|
var controller: ESCController
|
||||||
|
|
||||||
|
|
||||||
# Initialize various objects
|
# Initialize various objects
|
||||||
func _init():
|
func _init():
|
||||||
@@ -97,6 +101,7 @@ func _init():
|
|||||||
self.resource_cache.start()
|
self.resource_cache.start()
|
||||||
self.save_manager = ESCSaveManager.new()
|
self.save_manager = ESCSaveManager.new()
|
||||||
self.inputs_manager = ESCInputsManager.new()
|
self.inputs_manager = ESCInputsManager.new()
|
||||||
|
self.controller = ESCController.new()
|
||||||
|
|
||||||
|
|
||||||
# Load settings
|
# Load settings
|
||||||
@@ -137,9 +142,13 @@ func do(action: String, params: Array = []) -> void:
|
|||||||
"walk":
|
"walk":
|
||||||
self.action_manager.clear_current_action()
|
self.action_manager.clear_current_action()
|
||||||
|
|
||||||
|
var walk_fast = false
|
||||||
|
if params.size() > 2:
|
||||||
|
walk_fast = true if params[2] else false
|
||||||
|
|
||||||
# Check moving object.
|
# Check moving object.
|
||||||
if not self.object_manager.has(params[0]):
|
if not escoria.object_manager.has(params[0]):
|
||||||
self.logger.report_errors(
|
escoria.logger.report_errors(
|
||||||
"escoria.gd:do()",
|
"escoria.gd:do()",
|
||||||
[
|
[
|
||||||
"Walk action requested on inexisting " + \
|
"Walk action requested on inexisting " + \
|
||||||
@@ -148,53 +157,26 @@ func do(action: String, params: Array = []) -> void:
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
var moving_obj = self.object_manager.get_object(params[0])\
|
var moving_obj = escoria.object_manager.get_object(params[0])
|
||||||
.node
|
var target
|
||||||
|
|
||||||
# Walk to Position2D.
|
if params[1] is String:
|
||||||
if params[1] is Vector2:
|
if not escoria.object_manager.has(params[1]):
|
||||||
var target_position = params[1]
|
escoria.logger.report_errors(
|
||||||
var is_fast: bool = false
|
|
||||||
if params.size() > 2 and params[2] == true:
|
|
||||||
is_fast = true
|
|
||||||
var walk_context = ESCWalkContext.new(
|
|
||||||
null,
|
|
||||||
target_position,
|
|
||||||
is_fast
|
|
||||||
)
|
|
||||||
moving_obj.walk_to(target_position, walk_context)
|
|
||||||
|
|
||||||
# Walk to object from its id
|
|
||||||
elif params[1] is String:
|
|
||||||
if not self.object_manager.has(params[1]):
|
|
||||||
self.logger.report_errors(
|
|
||||||
"escoria.gd:do()",
|
"escoria.gd:do()",
|
||||||
[
|
[
|
||||||
"Walk action requested TOWARDS " +\
|
"Walk action requested to inexisting " + \
|
||||||
"inexisting object: %s" % params[1]
|
"object: %s " % params[1]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
var object = self.object_manager.get_object(params[1])
|
|
||||||
if object:
|
|
||||||
var target_position: Vector2
|
|
||||||
if object.node is ESCLocation:
|
|
||||||
target_position = object.node.global_position
|
|
||||||
else:
|
|
||||||
target_position = object.node.interact_position
|
|
||||||
|
|
||||||
var is_fast: bool = false
|
|
||||||
if params.size() > 2 and params[2] == true:
|
|
||||||
is_fast = true
|
|
||||||
var walk_context = ESCWalkContext.new(
|
|
||||||
object,
|
|
||||||
Vector2(),
|
|
||||||
is_fast
|
|
||||||
)
|
|
||||||
|
|
||||||
moving_obj.walk_to(target_position, walk_context)
|
target = escoria.object_manager.get_object(params[1])
|
||||||
|
elif params[1] is Vector2:
|
||||||
|
target = params[1]
|
||||||
|
|
||||||
|
self.controller.perform_walk(moving_obj, target, walk_fast)
|
||||||
|
|
||||||
"item_left_click":
|
"item_left_click":
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
@@ -202,7 +184,7 @@ func do(action: String, params: Array = []) -> void:
|
|||||||
[params[0]]
|
[params[0]]
|
||||||
)
|
)
|
||||||
var item = self.object_manager.get_object(params[0])
|
var item = self.object_manager.get_object(params[0])
|
||||||
_ev_left_click_on_item(item, params[1])
|
self.controller.perform_inputevent_on_object(item, params[1])
|
||||||
|
|
||||||
"item_right_click":
|
"item_right_click":
|
||||||
if params[0] is String:
|
if params[0] is String:
|
||||||
@@ -211,7 +193,7 @@ func do(action: String, params: Array = []) -> void:
|
|||||||
[params[0]]
|
[params[0]]
|
||||||
)
|
)
|
||||||
var item = self.object_manager.get_object(params[0])
|
var item = self.object_manager.get_object(params[0])
|
||||||
_ev_left_click_on_item(item, params[1], true)
|
self.controller.perform_inputevent_on_object(item, params[1], true)
|
||||||
|
|
||||||
"trigger_in":
|
"trigger_in":
|
||||||
var trigger_id = params[0]
|
var trigger_id = params[0]
|
||||||
@@ -248,124 +230,6 @@ func do(action: String, params: Array = []) -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Event handler when an object/item was clicked
|
|
||||||
#
|
|
||||||
# #### Parameters
|
|
||||||
#
|
|
||||||
# - ob: Object that was left clicked
|
|
||||||
# - event: Input event that was received
|
|
||||||
# - default_action: Run the inventory default action
|
|
||||||
func _ev_left_click_on_item(obj, event, default_action = false):
|
|
||||||
if obj is String:
|
|
||||||
obj = object_manager.get_object(obj)
|
|
||||||
self.logger.info(obj.global_id + " left-clicked with event ", [event])
|
|
||||||
|
|
||||||
var need_combine = false
|
|
||||||
# Check if current_action and current_tool are already set
|
|
||||||
if self.action_manager.current_action:
|
|
||||||
if self.action_manager.current_tool:
|
|
||||||
if self.action_manager.current_action in self.action_manager\
|
|
||||||
.current_tool.node.combine_if_action_used_among:
|
|
||||||
need_combine = true
|
|
||||||
else:
|
|
||||||
self.action_manager.current_tool = obj
|
|
||||||
else:
|
|
||||||
if default_action:
|
|
||||||
if self.inventory_manager.inventory_has(obj.global_id):
|
|
||||||
self.action_manager.current_action = \
|
|
||||||
obj.node.default_action_inventory
|
|
||||||
else:
|
|
||||||
self.action_manager.current_action = \
|
|
||||||
obj.node.default_action
|
|
||||||
elif self.action_manager.current_action in \
|
|
||||||
obj.node.combine_if_action_used_among:
|
|
||||||
self.action_manager.current_tool = obj
|
|
||||||
|
|
||||||
|
|
||||||
# Don't interact after player movement towards object
|
|
||||||
# (because object is inactive for example)
|
|
||||||
var dont_interact = false
|
|
||||||
var destination_position: Vector2 = main.current_scene.player.\
|
|
||||||
global_position
|
|
||||||
|
|
||||||
# Create walk context
|
|
||||||
var walk_context = ESCWalkContext.new(
|
|
||||||
obj,
|
|
||||||
Vector2(),
|
|
||||||
event.doubleclick
|
|
||||||
)
|
|
||||||
|
|
||||||
# If object not in inventory, player walks towards it
|
|
||||||
if not inventory_manager.inventory_has(obj.global_id):
|
|
||||||
var clicked_object_has_interact_position = false
|
|
||||||
|
|
||||||
if object_manager.get_object(obj.global_id).interactive:
|
|
||||||
if obj.node.get_interact_position() != null:
|
|
||||||
destination_position = obj.node.get_interact_position()
|
|
||||||
clicked_object_has_interact_position = true
|
|
||||||
else:
|
|
||||||
destination_position = obj.node.position
|
|
||||||
else:
|
|
||||||
destination_position = event.position
|
|
||||||
dont_interact = true
|
|
||||||
|
|
||||||
main.current_scene.player.walk_to(
|
|
||||||
destination_position,
|
|
||||||
walk_context
|
|
||||||
)
|
|
||||||
|
|
||||||
# Wait for the player to arrive before continuing with action.
|
|
||||||
var context: ESCWalkContext = yield(
|
|
||||||
main.current_scene.player,
|
|
||||||
"arrived"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.logger.info("Context arrived: %s" % context)
|
|
||||||
|
|
||||||
if context.target_object and \
|
|
||||||
context.target_object.global_id != walk_context.\
|
|
||||||
target_object.global_id:
|
|
||||||
dont_interact = true
|
|
||||||
elif context.target_position != walk_context.target_position:
|
|
||||||
dont_interact = true
|
|
||||||
|
|
||||||
# If no interaction should happen after player has arrived, leave immediately.
|
|
||||||
if dont_interact:
|
|
||||||
return
|
|
||||||
|
|
||||||
var player_global_pos = main.current_scene.player.global_position
|
|
||||||
var clicked_position = event.position
|
|
||||||
|
|
||||||
# If player has arrived at the position he was supposed to reach so he can interact
|
|
||||||
if player_global_pos == destination_position:
|
|
||||||
# Manage exits
|
|
||||||
if obj.node.is_exit and self.action_manager.current_action == "" \
|
|
||||||
or self.action_manager.current_action == "walk":
|
|
||||||
self.action_manager.activate("exit_scene", obj)
|
|
||||||
else:
|
|
||||||
# Manage movements towards object before activating it
|
|
||||||
if self.action_manager.current_action == "" \
|
|
||||||
or self.action_manager.current_action == "walk":
|
|
||||||
if destination_position != clicked_position \
|
|
||||||
and not inventory_manager.inventory_has(obj.global_id):
|
|
||||||
self.action_manager.activate("arrived", obj)
|
|
||||||
# Manage action on object
|
|
||||||
elif self.action_manager.current_action != "" and \
|
|
||||||
self.action_manager.current_action != "walk":
|
|
||||||
# If apply_interact, perform combine between items
|
|
||||||
if need_combine:
|
|
||||||
self.action_manager.activate(
|
|
||||||
self.action_manager.current_action,
|
|
||||||
self.action_manager.current_tool,
|
|
||||||
obj
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
|
||||||
self.action_manager.activate(
|
|
||||||
self.action_manager.current_action,
|
|
||||||
obj
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Apply the loaded settings
|
# Apply the loaded settings
|
||||||
#
|
#
|
||||||
|
|||||||
18
docs/api/ESCController.md
Normal file
18
docs/api/ESCController.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!-- Auto-generated from JSON by GDScript docs maker. Do not edit this document directly. -->
|
||||||
|
|
||||||
|
# ESCController
|
||||||
|
|
||||||
|
## Method Descriptions
|
||||||
|
|
||||||
|
### perform\_walk
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func perform_walk(moving_obj: ESCObject, destination, is_fast: bool = false)
|
||||||
|
```
|
||||||
|
|
||||||
|
### perform\_inputevent\_on\_object
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func perform_inputevent_on_object(obj: ESCObject, event: InputEvent, default_action: bool = false)
|
||||||
|
```
|
||||||
|
|
||||||
@@ -57,6 +57,14 @@ The global id fo the topmost item from the hover_stack
|
|||||||
|
|
||||||
## Method Descriptions
|
## Method Descriptions
|
||||||
|
|
||||||
|
### register\_core
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
func register_core()
|
||||||
|
```
|
||||||
|
|
||||||
|
Register core signals (from escoria.gd)
|
||||||
|
|
||||||
### register\_inventory\_item
|
### register\_inventory\_item
|
||||||
|
|
||||||
```gdscript
|
```gdscript
|
||||||
|
|||||||
@@ -33,13 +33,21 @@ The target position
|
|||||||
var fast: bool
|
var fast: bool
|
||||||
```
|
```
|
||||||
|
|
||||||
Wether to move fast
|
Whether to move fast
|
||||||
|
|
||||||
|
### dont\_interact\_on\_arrival
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
var dont_interact_on_arrival: bool
|
||||||
|
```
|
||||||
|
|
||||||
|
Whether an interaction should NOT happen after walk reaches destination
|
||||||
|
|
||||||
## Method Descriptions
|
## Method Descriptions
|
||||||
|
|
||||||
### \_init
|
### \_init
|
||||||
|
|
||||||
```gdscript
|
```gdscript
|
||||||
func _init(p_target_object: ESCObject, p_target_position: Vector2, p_fast: bool)
|
func _init(p_target_object: ESCObject, p_target_position: Vector2, p_fast: bool, p_dont_interact_on_arrival: bool)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,15 @@ var save_manager: ESCSaveManager
|
|||||||
|
|
||||||
Savegames and settings manager
|
Savegames and settings manager
|
||||||
|
|
||||||
|
### controller
|
||||||
|
|
||||||
|
```gdscript
|
||||||
|
var controller: ESCController
|
||||||
|
```
|
||||||
|
|
||||||
|
The controller in charge of converting an action verb on a game object
|
||||||
|
into an actual action
|
||||||
|
|
||||||
## Method Descriptions
|
## Method Descriptions
|
||||||
|
|
||||||
### new\_game
|
### new\_game
|
||||||
@@ -219,12 +228,14 @@ Run a generic action
|
|||||||
### set\_game\_paused
|
### set\_game\_paused
|
||||||
|
|
||||||
```gdscript
|
```gdscript
|
||||||
func set_game_paused()
|
func set_game_paused(p_paused: bool)
|
||||||
```
|
```
|
||||||
|
|
||||||
### set\_game\_unpaused
|
Pauses or unpause the game
|
||||||
|
|
||||||
```gdscript
|
#### Parameters
|
||||||
func set_game_unpaused()
|
- p_paused: if true, pauses the game. If false, unpauses the game.
|
||||||
```
|
|
||||||
|
|
||||||
|
## Signals
|
||||||
|
|
||||||
|
- signal request_pause_menu(): Signal sent when pause menu has to be displayed
|
||||||
|
|||||||
@@ -9,202 +9,202 @@
|
|||||||
[ext_resource path="res://game/characters/mark/png/mark_talk_right.png" type="Texture" id=7]
|
[ext_resource path="res://game/characters/mark/png/mark_talk_right.png" type="Texture" id=7]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=1]
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 2 )
|
||||||
region = Rect2( 120, 0, 24, 70 )
|
region = Rect2( 0, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=2]
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
atlas = ExtResource( 2 )
|
atlas = ExtResource( 2 )
|
||||||
region = Rect2( 0, 0, 24, 70 )
|
region = Rect2( 24, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=3]
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
atlas = ExtResource( 2 )
|
atlas = ExtResource( 2 )
|
||||||
region = Rect2( 24, 0, 24, 70 )
|
region = Rect2( 48, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=4]
|
[sub_resource type="AtlasTexture" id=4]
|
||||||
atlas = ExtResource( 2 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 48, 0, 24, 70 )
|
region = Rect2( 48, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=5]
|
[sub_resource type="AtlasTexture" id=5]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 7 )
|
||||||
region = Rect2( 48, 0, 24, 70 )
|
region = Rect2( 0, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=6]
|
[sub_resource type="AtlasTexture" id=6]
|
||||||
atlas = ExtResource( 7 )
|
atlas = ExtResource( 7 )
|
||||||
region = Rect2( 0, 0, 24, 70 )
|
region = Rect2( 24, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=7]
|
[sub_resource type="AtlasTexture" id=7]
|
||||||
atlas = ExtResource( 7 )
|
atlas = ExtResource( 7 )
|
||||||
region = Rect2( 24, 0, 24, 70 )
|
region = Rect2( 48, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=8]
|
[sub_resource type="AtlasTexture" id=8]
|
||||||
atlas = ExtResource( 7 )
|
atlas = ExtResource( 7 )
|
||||||
region = Rect2( 48, 0, 24, 70 )
|
region = Rect2( 72, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=9]
|
[sub_resource type="AtlasTexture" id=9]
|
||||||
atlas = ExtResource( 7 )
|
atlas = ExtResource( 7 )
|
||||||
region = Rect2( 72, 0, 24, 70 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=10]
|
|
||||||
atlas = ExtResource( 7 )
|
|
||||||
region = Rect2( 96, 0, 24, 70 )
|
region = Rect2( 96, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=11]
|
[sub_resource type="AtlasTexture" id=10]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 144, 0, 24, 70 )
|
region = Rect2( 144, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=12]
|
[sub_resource type="AtlasTexture" id=11]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 168, 0, 24, 70 )
|
region = Rect2( 168, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=13]
|
[sub_resource type="AtlasTexture" id=12]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 192, 0, 24, 70 )
|
region = Rect2( 192, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=14]
|
[sub_resource type="AtlasTexture" id=13]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 216, 0, 24, 70 )
|
region = Rect2( 216, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=15]
|
[sub_resource type="AtlasTexture" id=14]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 240, 0, 24, 70 )
|
region = Rect2( 240, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=16]
|
[sub_resource type="AtlasTexture" id=15]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 264, 0, 24, 70 )
|
region = Rect2( 264, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=17]
|
[sub_resource type="AtlasTexture" id=16]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 288, 0, 24, 70 )
|
region = Rect2( 288, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=18]
|
[sub_resource type="AtlasTexture" id=17]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 312, 0, 24, 70 )
|
region = Rect2( 312, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=19]
|
[sub_resource type="AtlasTexture" id=18]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 0, 0, 24, 70 )
|
region = Rect2( 0, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=20]
|
[sub_resource type="AtlasTexture" id=19]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 336, 0, 24, 70 )
|
region = Rect2( 336, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=21]
|
[sub_resource type="AtlasTexture" id=20]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 360, 0, 24, 70 )
|
region = Rect2( 360, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=22]
|
[sub_resource type="AtlasTexture" id=21]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 384, 0, 24, 70 )
|
region = Rect2( 384, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=23]
|
[sub_resource type="AtlasTexture" id=22]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 72, 0, 24, 70 )
|
region = Rect2( 72, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=24]
|
[sub_resource type="AtlasTexture" id=23]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 96, 0, 24, 70 )
|
region = Rect2( 96, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=25]
|
[sub_resource type="AtlasTexture" id=24]
|
||||||
atlas = ExtResource( 4 )
|
atlas = ExtResource( 4 )
|
||||||
region = Rect2( 24, 0, 24, 70 )
|
region = Rect2( 24, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=26]
|
[sub_resource type="AtlasTexture" id=25]
|
||||||
atlas = ExtResource( 5 )
|
atlas = ExtResource( 5 )
|
||||||
region = Rect2( 0, 0, 24, 70 )
|
region = Rect2( 0, 0, 24, 70 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=26]
|
||||||
|
atlas = ExtResource( 5 )
|
||||||
|
region = Rect2( 24, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=27]
|
[sub_resource type="AtlasTexture" id=27]
|
||||||
atlas = ExtResource( 5 )
|
atlas = ExtResource( 5 )
|
||||||
region = Rect2( 24, 0, 24, 70 )
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=28]
|
|
||||||
atlas = ExtResource( 5 )
|
|
||||||
region = Rect2( 48, 0, 24, 70 )
|
region = Rect2( 48, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=29]
|
[sub_resource type="AtlasTexture" id=28]
|
||||||
atlas = ExtResource( 6 )
|
atlas = ExtResource( 6 )
|
||||||
region = Rect2( 0, 0, 24, 70 )
|
region = Rect2( 0, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id=30]
|
[sub_resource type="AtlasTexture" id=29]
|
||||||
atlas = ExtResource( 6 )
|
atlas = ExtResource( 6 )
|
||||||
region = Rect2( 24, 0, 24, 70 )
|
region = Rect2( 24, 0, 24, 70 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=30]
|
||||||
|
atlas = ExtResource( 4 )
|
||||||
|
region = Rect2( 120, 0, 24, 70 )
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=31]
|
[sub_resource type="SpriteFrames" id=31]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ SubResource( 1 ) ],
|
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 2 ), SubResource( 3 ) ],
|
||||||
"loop": true,
|
|
||||||
"name": "idle_down_left",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [ SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 3 ), SubResource( 4 ) ],
|
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "speak_down",
|
"name": "speak_down",
|
||||||
"speed": 6.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 5 ) ],
|
"frames": [ SubResource( 4 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "idle_right",
|
"name": "idle_right",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ],
|
"frames": [ SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "speak_right",
|
"name": "speak_right",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 12 ) ],
|
"frames": [ SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 11 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "walk_down",
|
"name": "walk_down",
|
||||||
"speed": 6.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ), SubResource( 18 ) ],
|
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 15 ), SubResource( 16 ), SubResource( 17 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "walk_right",
|
"name": "walk_right",
|
||||||
"speed": 6.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 19 ) ],
|
"frames": [ SubResource( 18 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "idle_down",
|
"name": "idle_down",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 21 ) ],
|
"frames": [ SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 20 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "walk_up",
|
"name": "walk_up",
|
||||||
"speed": 6.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 23 ) ],
|
"frames": [ SubResource( 22 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "idle_up",
|
"name": "idle_up",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 24 ) ],
|
"frames": [ SubResource( 23 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "idle_left",
|
"name": "idle_left",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 25 ) ],
|
"frames": [ SubResource( 24 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "idle_down_right",
|
"name": "idle_down_right",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 26 ), SubResource( 27 ), SubResource( 28 ) ],
|
"frames": [ SubResource( 25 ), SubResource( 26 ), SubResource( 27 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "speak_down_right",
|
"name": "speak_down_right",
|
||||||
"speed": 6.0
|
"speed": 6.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 29 ), SubResource( 30 ), SubResource( 29 ), SubResource( 30 ), SubResource( 30 ) ],
|
"frames": [ SubResource( 28 ), SubResource( 29 ), SubResource( 28 ), SubResource( 29 ), SubResource( 29 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "speak_up",
|
"name": "speak_up",
|
||||||
"speed": 3.0
|
"speed": 3.0
|
||||||
|
}, {
|
||||||
|
"frames": [ SubResource( 30 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "idle_down_left",
|
||||||
|
"speed": 5.0
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=32]
|
[sub_resource type="CapsuleShape2D" id=32]
|
||||||
height = 0.0
|
height = 0.0
|
||||||
|
|
||||||
[node name="mark" type="Area2D"]
|
[node name="mark" type="Area2D"]
|
||||||
|
pause_mode = 1
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
global_id = "player"
|
global_id = "player"
|
||||||
is_movable = true
|
is_movable = true
|
||||||
dialog_color = Color( 1, 1, 1, 1 )
|
dialog_color = Color( 1, 1, 1, 1 )
|
||||||
animation_player_node = NodePath("sprite")
|
|
||||||
animations = ExtResource( 3 )
|
animations = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="sprite" type="AnimatedSprite" parent="."]
|
[node name="sprite" type="AnimatedSprite" parent="."]
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -154,6 +154,11 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_condition.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_condition.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Reference",
|
||||||
|
"class": "ESCController",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/escoria-core/game/core-scripts/esc_controller.gd"
|
||||||
|
}, {
|
||||||
"base": "ESCStatement",
|
"base": "ESCStatement",
|
||||||
"class": "ESCDialog",
|
"class": "ESCDialog",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@@ -504,6 +509,7 @@ _global_script_class_icons={
|
|||||||
"ESCCommandRegistry": "",
|
"ESCCommandRegistry": "",
|
||||||
"ESCCompiler": "",
|
"ESCCompiler": "",
|
||||||
"ESCCondition": "",
|
"ESCCondition": "",
|
||||||
|
"ESCController": "",
|
||||||
"ESCDialog": "",
|
"ESCDialog": "",
|
||||||
"ESCDialogOption": "",
|
"ESCDialogOption": "",
|
||||||
"ESCDialogsPlayer": "",
|
"ESCDialogsPlayer": "",
|
||||||
@@ -648,6 +654,10 @@ switch_action_verb={
|
|||||||
|
|
||||||
translations=PoolStringArray( "res://game/translations/game.en.translation", "res://game/translations/game.fr.translation", "res://game/translations/main_menu.en.translation", "res://game/translations/main_menu.fr.translation" )
|
translations=PoolStringArray( "res://game/translations/game.en.translation", "res://game/translations/game.fr.translation", "res://game/translations/main_menu.en.translation", "res://game/translations/main_menu.fr.translation" )
|
||||||
|
|
||||||
|
[network]
|
||||||
|
|
||||||
|
limits/debugger_stdout/max_chars_per_second=99999999
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
|
|||||||
Reference in New Issue
Block a user