Documentation and Optimization Part 1 (#2)

Authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
Dennis Ploeger
2021-06-16 10:12:51 +02:00
committed by GitHub
parent a22805d0e6
commit 4e09f522ff
109 changed files with 3556 additions and 2043 deletions

View File

@@ -177,7 +177,7 @@ func _process(_delta):
if typeof(target) == TYPE_VECTOR2 or typeof(target) == TYPE_ARRAY:
self.global_position = resolve_target_pos()
elif "moved" in target and target.moved \
or "moved" in target.Movable and target.Movable.moved:
or "moved" in target.movable and target.movable.moved:
self.global_position = resolve_target_pos()
func _ready():

View File

@@ -46,23 +46,30 @@ func add_new_item_by_id(item_id : String) -> void:
item_id = item_id.rsplit("i/", false)[0]
if not items_ids_in_inventory.has(item_id):
if not escoria.object_manager.has(item_id):
escoria.logger.report_errors(
"inventory_ui.gd:add_new_item_by_id()",
[
"Item global id '%s' does not exist." % item_id,
"Check item's id in ESCORIA_ALL_ITEMS scene."
]
)
if not all_items.get_inventory_item(item_id):
escoria.logger.report_errors(
"inventory_ui.gd:add_new_item_by_id()",
[
"Item global id '%s' doesn't have a " +\
"corresponding inventory item." % item_id,
"Check item's id in ESCORIA_ALL_ITEMS scene."
]
)
var item_inventory_button = all_items.get_inventory_item(item_id).duplicate()
var inventory_file = "%s/%s.tscn" % [
ProjectSettings.get_setting(
"escoria/ui/items_autoregister_path"
).trim_suffix("/"),
item_id
]
if ResourceLoader.exists(inventory_file):
escoria.object_manager.register_object(
ESCObject.new(
item_id,
ResourceLoader.load(inventory_file).instance()
)
)
else:
escoria.logger.report_errors(
"inventory_ui.gd:add_new_item_by_id()",
[
"Item global id '%s' does not exist." % item_id,
"Check item's id in ESCORIA_ALL_ITEMS scene."
]
)
var item_inventory_button = (
escoria.object_manager.get_object(item_id).node as ESCItem
).inventory_item.duplicate()
items_ids_in_inventory[item_id] = item_inventory_button
get_node(inventory_ui_container).add_item(item_inventory_button)