feat: give the player embodied hunger, energy, and starvation death
This commit is contained in:
@@ -2,7 +2,7 @@ class_name SimulationStateRecord
|
||||
extends RefCounted
|
||||
|
||||
const SCHEMA_NAME := "the_steward.simulation"
|
||||
const SCHEMA_VERSION := 12
|
||||
const SCHEMA_VERSION := 13
|
||||
const LEGACY_SCHEMA_VERSION := 1
|
||||
const EVENT_LEGACY_SCHEMA_VERSION := 2
|
||||
const RELATIONSHIP_LEGACY_SCHEMA_VERSION := 3
|
||||
@@ -14,6 +14,7 @@ const ANIMAL_LEGACY_SCHEMA_VERSION := 9
|
||||
const ROUTINE_LEGACY_SCHEMA_VERSION := 10
|
||||
const PREVIOUS_SCHEMA_VERSION := 7
|
||||
const PLAYER_LEGACY_SCHEMA_VERSION := 11
|
||||
const PLAYER_STATE_LEGACY_SCHEMA_VERSION := 12
|
||||
|
||||
var simulation: Dictionary
|
||||
var village: VillageStateRecord
|
||||
@@ -27,6 +28,7 @@ var event_knowledge: Array[KnownEventStateRecord] = []
|
||||
var opportunities: Array[OpportunityStateRecord] = []
|
||||
var player_standing: PlayerStandingRecord
|
||||
var player_quests: Array[PlayerQuestRecord] = []
|
||||
var player_state: PlayerStateRecord
|
||||
|
||||
|
||||
func to_dictionary() -> Dictionary:
|
||||
@@ -73,7 +75,8 @@ func to_dictionary() -> Dictionary:
|
||||
"event_knowledge": knowledge_data,
|
||||
"opportunities": opportunity_data,
|
||||
"player_standing": player_standing.to_dictionary(),
|
||||
"player_quests": player_quest_data
|
||||
"player_quests": player_quest_data,
|
||||
"player_state": player_state.to_dictionary()
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +109,7 @@ static func from_dictionary(record_data: Dictionary) -> SimulationStateRecord:
|
||||
ANIMAL_LEGACY_SCHEMA_VERSION,
|
||||
ROUTINE_LEGACY_SCHEMA_VERSION,
|
||||
PLAYER_LEGACY_SCHEMA_VERSION,
|
||||
PLAYER_STATE_LEGACY_SCHEMA_VERSION,
|
||||
]
|
||||
):
|
||||
record_data = _migrate_legacy(record_data, version)
|
||||
@@ -127,6 +131,7 @@ static func from_dictionary(record_data: Dictionary) -> SimulationStateRecord:
|
||||
"opportunities",
|
||||
"player_standing",
|
||||
"player_quests",
|
||||
"player_state",
|
||||
]
|
||||
)
|
||||
):
|
||||
@@ -530,6 +535,14 @@ static func from_dictionary(record_data: Dictionary) -> SimulationStateRecord:
|
||||
highest_quest_id = maxi(highest_quest_id, quest_id)
|
||||
record.player_quests.append(quest_record)
|
||||
|
||||
var player_state_data = record_data["player_state"]
|
||||
if not player_state_data is Dictionary:
|
||||
return null
|
||||
var player_state_record := PlayerStateRecord.from_dictionary(player_state_data)
|
||||
if player_state_record == null:
|
||||
return null
|
||||
record.player_state = player_state_record
|
||||
|
||||
return record
|
||||
|
||||
|
||||
@@ -850,6 +863,8 @@ static func _migrate_legacy(legacy_data: Dictionary, version: int) -> Dictionary
|
||||
var quest_simulation_data: Dictionary = migrated.get("simulation", {})
|
||||
quest_simulation_data["next_quest_id"] = 0
|
||||
migrated["simulation"] = quest_simulation_data
|
||||
if version <= PLAYER_STATE_LEGACY_SCHEMA_VERSION:
|
||||
migrated["player_state"] = PlayerStateRecord.create().to_dictionary()
|
||||
return migrated
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user