feat: add physical animal care delivery
This commit is contained in:
@@ -98,6 +98,21 @@ static func from_dictionary(record_data: Dictionary) -> NPCStateRecord:
|
||||
return null
|
||||
if not record_data["inventory"] is Dictionary:
|
||||
return null
|
||||
var normalized_inventory := {}
|
||||
for raw_item_id in record_data["inventory"]:
|
||||
var item_id := str(raw_item_id)
|
||||
var raw_amount = record_data["inventory"][raw_item_id]
|
||||
if typeof(raw_amount) not in [TYPE_INT, TYPE_FLOAT]:
|
||||
return null
|
||||
var amount := float(raw_amount)
|
||||
if (
|
||||
item_id.is_empty()
|
||||
or normalized_inventory.has(item_id)
|
||||
or not is_finite(amount)
|
||||
or amount < 0.0
|
||||
):
|
||||
return null
|
||||
normalized_inventory[item_id] = amount
|
||||
var profession_id := StringName(record_data["profession"])
|
||||
if SimulationDefinitions.get_profession(profession_id) == null:
|
||||
return null
|
||||
@@ -110,7 +125,9 @@ static func from_dictionary(record_data: Dictionary) -> NPCStateRecord:
|
||||
var last_action_id := StringName(record_data["last_task"])
|
||||
if not last_action_id.is_empty() and SimulationDefinitions.get_action(last_action_id) == null:
|
||||
return null
|
||||
return NPCStateRecord.new(record_data)
|
||||
var normalized := record_data.duplicate(true)
|
||||
normalized["inventory"] = normalized_inventory
|
||||
return NPCStateRecord.new(normalized)
|
||||
|
||||
|
||||
static func _migrate_legacy(legacy_data: Dictionary, version: int) -> Dictionary:
|
||||
|
||||
Reference in New Issue
Block a user