me corte con el cuchillo, XD

This commit is contained in:
2023-09-25 23:49:48 +02:00
parent c307f2e5c6
commit 6cbd466f76
9 changed files with 21 additions and 84 deletions

2
.gitignore vendored
View File

@@ -11,3 +11,5 @@ saves/
# Disable accidental changes to the default bus layout. If a change to this
# file is required, use git add --force
addons/escoria-core/default_bus_layout.tres
.idea/

View File

@@ -1,11 +0,0 @@
extends Node
class_name ESCCombinable
var _combinations:Array
func _init(combinations: Array)-> void:
_combinations = combinations
func check(action: String) -> bool:
return action in _combinations

View File

@@ -1,11 +0,0 @@
extends Node
class_name ESCTargetable
var _targets:Array
func _init(targets: Array)-> void:
_targets = targets
func check(action: String) -> bool:
return action in _targets

View File

@@ -23,10 +23,9 @@ func configure() -> ESCCommandArgumentDescriptor:
# Validate wether the given arguments match the command descriptor
func validate(arguments: Array):
if not escoria.object_manager.has(arguments[0]):
escoria.logger.error(
self,
"Object %s not registered"
% [arguments[0]]
escoria.logger.report_errors(
"item_count_add: invalid object",
["Object %s not registered" % arguments[0]]
)
return false

View File

@@ -297,8 +297,8 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
# Check if current_action and current_tool are already set
if current_action and current_tool:
# MODIFIED FOR RETURN TO MONKEY UI
if (not escoria.action_manager\
.current_tool.node.is_combinable(current_action) and not obj.node.is_targetable(current_action)):
if (not current_action in escoria.action_manager\
.current_tool.node.combine_when_selected_action_is_in and not current_action in obj.node.target_when_selected_action_is_in):
current_tool = obj
tool_just_set = true
elif default_action:
@@ -306,7 +306,7 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
current_action = obj.node.default_action_inventory
else:
current_action = obj.node.default_action
elif obj.node.is_combinable(current_action):
elif current_action in obj.node.combine_when_selected_action_is_in:
current_tool = obj
tool_just_set = true
return tool_just_set
@@ -320,6 +320,6 @@ func _set_tool_and_action(obj: ESCObject, default_action: bool):
func _check_item_needs_combine_obj(obj: ESCObject) -> bool:
return current_action \
and current_tool \
and (current_tool.node.is_combinable(current_action)
and (current_action in current_tool.node.combine_when_selected_action_is_in
# MODIFIED FOR RETURN TO MONKEY UI
or obj.node.is_targetable(current_action))
or current_action in obj.node.target_when_selected_action_is_in)

View File

@@ -5,19 +5,20 @@ class_name ESCItemCountManager
func add(global_id: String, value:= 1) -> void:
var item = get_item(global_id)
set(global_id, item.count + value)
item.count = item.count + value
updateSprite(item)
func remove(global_id: String, value:= 1) -> void:
var item = get_item(global_id)
set(global_id, item.count - value)
item.count = item.count - value
updateSprite(item)
func set(global_id: String, value: int) -> void:
var item = get_item(global_id)
item.count = value
updateSprite(item)
escoria.globals_manager.set_global(global_id, value)
func removeFromInventoryIfCountLessThan(global_id: String, value:= 1) -> void:
@@ -41,9 +42,9 @@ func get_item(global_id: String) -> ESCItem:
func updateSprite(item: ESCItemWithTooltip) -> void:
var child_node = item.get_node("Sprite") as Sprite
if not child_node is Sprite:
escoria.logger.error(
self,
"No Sprite node found"
escoria.logger.report_errors(
"item_count_add: invalid sprite",
["No Sprite node found"]
)
var texture_path = getCountTexturePath(item)

View File

@@ -46,27 +46,6 @@ var lastHighlightState: bool
var active: bool
# The targetable subnode
var _targetable: ESCTargetable = null
# Whether this item is targetable.
export(bool) var _is_targetable = false
func is_targetable(action: String) -> bool:
if !_is_targetable:
return false
return _targetable.check(action)
# The targetable subnode
var _combinable: ESCCombinable = null
# Whether this item is targetable.
export(bool) var _is_combinable = false
func is_combinable(action: String) -> bool:
if !_is_targetable:
return false
return _combinable.check(action)
# React to the mouse entering the item by emitting the respective signal
func mouse_entered():
active = true
@@ -89,14 +68,6 @@ func _ready():
##outline.offset = Vector2(1,1)
collision.add_child(outline)
outline.hide()
if _is_targetable:
_targetable = ESCTargetable.new(target_when_selected_action_is_in)
add_child(_targetable)
if _is_combinable:
_combinable = ESCCombinable.new(combine_when_selected_action_is_in)
add_child(_targetable)
func _process(_delta) -> void:
if(is_interactive == false):

View File

@@ -249,7 +249,7 @@ func left_double_click_on_bg(position: Vector2) -> void:
func element_focused(element_id: String) -> void:
var target_obj = escoria.object_manager.get_object(element_id).node
if target_obj is ESCItem:
if target_obj is ESCItem or ESCItemWithTooltip:
$tooltip_layer/tooltip.set_target(target_obj.tooltip_name)
$tooltip_layer/tooltip.set_target_object(target_obj)
target_obj.highlight(true)
@@ -310,9 +310,7 @@ func click_on_inventory_item(item_global_id: String, event: InputEvent, action:
# If item needs combination with this action, use the item texture as mouse cursor
if action in target_obj.combine_when_selected_action_is_in:
var texture = target_obj.inventory_texture
var middleOfTheTexture = Vector2(texture.get_width() / 2, texture.get_height() / 2)
Input.set_custom_mouse_cursor(target_obj.inventory_texture, 0, middleOfTheTexture)
Input.set_custom_mouse_cursor(target_obj.inventory_texture)
escoria.action_manager.do(
escoria.action_manager.ACTION.ITEM_LEFT_CLICK,
@@ -334,7 +332,7 @@ func right_click_on_inventory_item(inventory_item_global_id: String, event: Inpu
func inventory_item_focused(inventory_item_global_id: String) -> void:
var target_obj = escoria.object_manager.get_object(inventory_item_global_id).node
if target_obj is ESCItem:
if target_obj is ESCItemWithTooltip:
$tooltip_layer/tooltip.set_target(target_obj.action3_text)
$tooltip_layer/tooltip.set_target_object(target_obj)
@@ -399,7 +397,7 @@ func apply_custom_settings(custom_settings: Dictionary):
func get_custom_data() -> Dictionary:
return {
"ui_type": "rtmi-ui"
"ui_type": "simplemouse"
}

View File

@@ -159,11 +159,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/escoria-core/game/scenes/camera_player/esc_camera_limits.gd"
}, {
"base": "Node",
"class": "ESCCombinable",
"language": "GDScript",
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island/behaviors/esc_combinable.gd"
}, {
"base": "ESCStatement",
"class": "ESCCommand",
"language": "GDScript",
@@ -439,11 +434,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_statement.gd"
}, {
"base": "Node",
"class": "ESCTargetable",
"language": "GDScript",
"path": "res://gymkhana/addons/escoria-ui-return-monkey-island/behaviors/esc_targetable.gd"
}, {
"base": "Navigation2D",
"class": "ESCTerrain",
"language": "GDScript",
@@ -760,7 +750,6 @@ _global_script_class_icons={
"ESCCamera": "",
"ESCCameraBaseCommand": "",
"ESCCameraLimits": "",
"ESCCombinable": "",
"ESCCommand": "",
"ESCCommandArgumentDescriptor": "",
"ESCCommandRegistry": "",
@@ -816,7 +805,6 @@ _global_script_class_icons={
"ESCSoundPlayer": "",
"ESCSpeechPlayer": "",
"ESCStatement": "",
"ESCTargetable": "",
"ESCTerrain": "res://addons/escoria-core/design/esc_terrain.svg",
"ESCTooltip": "",
"ESCTransitionPlayer": "",