feat: add missing wood opportunities

This commit is contained in:
Rijad Zuzo
2026-07-16 01:50:19 +02:00
parent f82d9683de
commit 79dd503343
26 changed files with 1054 additions and 175 deletions
+22 -4
View File
@@ -1,7 +1,8 @@
class_name EconomicEventRecord
extends RefCounted
const SCHEMA_VERSION := 2
const SCHEMA_VERSION := 3
const POSITION_LEGACY_SCHEMA_VERSION := 2
const LEGACY_SCHEMA_VERSION := 1
var data: Dictionary
@@ -33,6 +34,8 @@ static func create(
"destination_id": String(destination_id),
"item_id": String(item_id),
"amount": amount,
"action_id": "",
"required_amount": 0.0,
"world_position": [world_position.x, world_position.y, world_position.z]
}
)
@@ -45,7 +48,10 @@ static func create_narrative(
actor_id: int,
source_id: StringName,
action_display: String = "",
world_position: Vector3 = Vector3.ZERO
world_position: Vector3 = Vector3.ZERO,
action_id: StringName = &"",
item_id: StringName = &"",
required_amount: float = 0.0
) -> EconomicEventRecord:
return EconomicEventRecord.new(
{
@@ -56,9 +62,11 @@ static func create_narrative(
"actor_id": actor_id,
"source_id": String(source_id),
"destination_id": "",
"item_id": "",
"item_id": String(item_id),
"amount": 0.0,
"action_name": action_display,
"action_id": String(action_id),
"required_amount": required_amount,
"world_position": [world_position.x, world_position.y, world_position.z]
}
)
@@ -66,7 +74,7 @@ static func create_narrative(
static func from_dictionary(record_data: Dictionary) -> EconomicEventRecord:
var version := int(record_data.get("schema_version", -1))
if version not in [LEGACY_SCHEMA_VERSION, SCHEMA_VERSION]:
if version not in [LEGACY_SCHEMA_VERSION, POSITION_LEGACY_SCHEMA_VERSION, SCHEMA_VERSION]:
return null
if not record_data.has_all(
[
@@ -93,6 +101,8 @@ static func from_dictionary(record_data: Dictionary) -> EconomicEventRecord:
normalized["destination_id"] = String(record_data["destination_id"])
normalized["item_id"] = String(record_data["item_id"])
normalized["amount"] = float(record_data["amount"])
normalized["action_id"] = String(record_data.get("action_id", ""))
normalized["required_amount"] = float(record_data.get("required_amount", 0.0))
var saved_position = record_data.get("world_position", [0.0, 0.0, 0.0])
if not saved_position is Array or saved_position.size() != 3:
return null
@@ -101,6 +111,14 @@ static func from_dictionary(record_data: Dictionary) -> EconomicEventRecord:
]
if normalized["event_id"] < 0 or normalized["tick"] < 0 or normalized["event_type"].is_empty():
return null
if StringName(normalized["event_type"]) == SimulationIds.EVENT_TASK_BLOCKED:
var has_stable_contract: bool = (
not normalized["action_id"].is_empty()
and not normalized["item_id"].is_empty()
and normalized["required_amount"] > 0.0
)
if version == SCHEMA_VERSION and not has_stable_contract:
return null
return EconomicEventRecord.new(normalized)