refactor(management): ♻️ Restructure the ItemSystem workflow to improve cleaner, maintainable logic for item creation and modification
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
14ac74f51a
commit
2ec26a39b4
1 changed files with 10 additions and 3 deletions
|
|
@ -16,6 +16,12 @@ static var _test_fauna_lookup: Callable = Callable()
|
|||
static var _test_items_json: String = ""
|
||||
|
||||
|
||||
static func _get_data_loader() -> Node:
|
||||
if Engine.has_singleton("DataLoader"):
|
||||
return Engine.get_singleton("DataLoader")
|
||||
return null
|
||||
|
||||
|
||||
static func _gd_items() -> RefCounted:
|
||||
return ClassDB.instantiate("GdItemSystem") as RefCounted
|
||||
|
||||
|
|
@ -144,7 +150,8 @@ static func roll_fauna_drops(
|
|||
if items_json != "":
|
||||
var roller2: RefCounted = ClassDB.instantiate("GdLootRoller") as RefCounted
|
||||
if roller2 != null:
|
||||
var relics: PackedStringArray = roller2.call("roll_apex_relic", victim_species_id, items_json, seed)
|
||||
var relics: PackedStringArray = roller2.call(
|
||||
"roll_apex_relic", victim_species_id, items_json, seed)
|
||||
for item_id: String in relics:
|
||||
_apply_apex_relic(killer_player, item_id)
|
||||
|
||||
|
|
@ -160,7 +167,7 @@ static func _lookup_fauna(species_id: String) -> Dictionary:
|
|||
if _test_fauna_lookup.is_valid():
|
||||
var result: Dictionary = _test_fauna_lookup.call(species_id)
|
||||
return result
|
||||
var loader: Node = Engine.get_singleton("DataLoader") if Engine.has_singleton("DataLoader") else null
|
||||
var loader: Node = _get_data_loader()
|
||||
if loader == null:
|
||||
return {}
|
||||
var result: Dictionary = loader.call("get_fauna_species", species_id)
|
||||
|
|
@ -170,7 +177,7 @@ static func _lookup_fauna(species_id: String) -> Dictionary:
|
|||
static func _items_json() -> String:
|
||||
if _test_items_json != "":
|
||||
return _test_items_json
|
||||
var loader: Node = Engine.get_singleton("DataLoader") if Engine.has_singleton("DataLoader") else null
|
||||
var loader: Node = _get_data_loader()
|
||||
if loader == null:
|
||||
return ""
|
||||
var items: Array = loader.call("get_all_items")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue