28 lines
2.0 KiB
GDScript
28 lines
2.0 KiB
GDScript
extends RefCounted
|
|
# Every orb is consumed once. Further advancement requires another orb.
|
|
const IDS := ["piercing", "booster", "advancement"]
|
|
const NAMES := {"piercing":"Orb przebicia", "booster":"Orb dopalacza", "advancement":"Orb awansu"}
|
|
const DESCRIPTIONS := {"piercing":"50% obrażeń broni omija tarcze i trafia bezpośrednio w kadłub. Tylko broń.", "booster":"Dopalacz pod TAB nie zużywa energii i działa również przy pustym generatorze. Tylko silnik.", "advancement":"Awansuje przedmiot o 1 poziom i ponownie losuje jego parametry oraz wartości obecnych addonów. Zachowuje ich typy, liczbę i efekty orbów. Wyniki losowania mogą być niższe. Jedna sztuka daje jeden awans. Kolejny awans wymaga nowego orba (limit poziomu 1000). Nie działa na materiały zużywalne."}
|
|
static func icon(id: String) -> Texture2D:
|
|
return load("res://assets/icons/orbs/%s.png" % id) as Texture2D
|
|
static func accepts(item: ItemInstance, id: String) -> bool:
|
|
if id not in IDS or item == null or item.definition == null: return false
|
|
if id == "advancement": return preload("res://scripts/items/item_generator.gd").can_advance(item)
|
|
if id in item.special_orbs: return false
|
|
return item.definition.category == (ItemDefinition.Category.WEAPON if id == "piercing" else ItemDefinition.Category.ENGINE)
|
|
static func apply(progress: Resource, inventory: Node, item: ItemInstance, id: String) -> bool:
|
|
if not accepts(item,id) or int(progress.orbs.get(id,0)) <= 0: return false
|
|
if inventory == null or not bool(inventory.get_parent().get("is_docked")): return false
|
|
var owned: Array = inventory.cargo + inventory.weapon_slots + inventory.module_slots + progress.freighter_storage
|
|
if not owned.has(item): return false
|
|
if id == "advancement":
|
|
if not preload("res://scripts/items/item_generator.gd").advance(item): return false
|
|
else:
|
|
item.special_orbs.append(id)
|
|
progress.orbs[id] = int(progress.orbs[id])-1
|
|
item.emit_changed()
|
|
inventory.call("_recalculate_ship_stats")
|
|
inventory.inventory_changed.emit()
|
|
progress.emit_changed()
|
|
return true
|