Add portable RV homes and decor prototype
This commit is contained in:
parent
81decf2b71
commit
fe099f47dd
56 changed files with 5459 additions and 112 deletions
|
|
@ -34,8 +34,9 @@ const WorldWeatherServiceType = preload(
|
|||
const WorldLayoutType = preload("res://world/world_layout.gd")
|
||||
const PlayerJobServiceType = preload("res://jobs/player_job_service.gd")
|
||||
const PlayerType = preload("res://player/player.gd")
|
||||
const PlayerHomeStateType = preload("res://homes/player_home_state.gd")
|
||||
|
||||
const SAVE_VERSION: int = 10
|
||||
const SAVE_VERSION: int = 11
|
||||
const LEGACY_SAVE_FILENAME := "player_save.json"
|
||||
const ARCHIVE_EXTENSION := ".nfsave"
|
||||
const BASIC_ROD_ID: StringName = &"basic_fishing_rod"
|
||||
|
|
@ -76,6 +77,7 @@ class LoadSnapshot:
|
|||
WorldWeatherServiceType.SUNNY_DURATION_RANGE.x
|
||||
)
|
||||
var jobs_data: Dictionary = PlayerJobServiceType.default_save_data()
|
||||
var home_data: Dictionary = PlayerHomeStateType.default_save_data()
|
||||
|
||||
|
||||
@export_range(0.05, 5.0, 0.05) var autosave_delay: float = 0.5
|
||||
|
|
@ -96,6 +98,7 @@ var _world_time: WorldTimeServiceType
|
|||
var _world_weather: WorldWeatherServiceType
|
||||
var _jobs: PlayerJobServiceType
|
||||
var _player: PlayerType
|
||||
var _home_state: PlayerHomeStateType
|
||||
var _autosave_timer: Timer
|
||||
var _is_configured: bool = false
|
||||
var _is_restoring: bool = false
|
||||
|
|
@ -175,6 +178,7 @@ func setup(
|
|||
world_weather: WorldWeatherServiceType,
|
||||
jobs: PlayerJobServiceType,
|
||||
player: PlayerType,
|
||||
home_state: PlayerHomeStateType,
|
||||
) -> void:
|
||||
_inventory = inventory
|
||||
_collection_log = collection_log
|
||||
|
|
@ -192,6 +196,7 @@ func setup(
|
|||
_world_weather = world_weather
|
||||
_jobs = jobs
|
||||
_player = player
|
||||
_home_state = home_state
|
||||
_is_configured = (
|
||||
_inventory != null
|
||||
and _collection_log != null
|
||||
|
|
@ -209,6 +214,7 @@ func setup(
|
|||
and _world_weather != null
|
||||
and _jobs != null
|
||||
and _player != null
|
||||
and _home_state != null
|
||||
)
|
||||
if not _is_configured:
|
||||
push_error("PlayerSaveManager setup is missing required references.")
|
||||
|
|
@ -255,6 +261,8 @@ func setup(
|
|||
_player.active_bait_changed.connect(_on_active_tackle_changed)
|
||||
if not _player.active_lure_changed.is_connected(_on_active_tackle_changed):
|
||||
_player.active_lure_changed.connect(_on_active_tackle_changed)
|
||||
if not _home_state.changed.is_connected(_mark_dirty):
|
||||
_home_state.changed.connect(_mark_dirty)
|
||||
|
||||
|
||||
func load_player_data() -> bool:
|
||||
|
|
@ -360,6 +368,9 @@ func load_player_data() -> bool:
|
|||
snapshot.world_weather_seconds_remaining,
|
||||
)
|
||||
var jobs_restored: bool = _jobs.restore_from_save_data(snapshot.jobs_data)
|
||||
var home_restored: bool = _home_state.restore_from_save_data(
|
||||
snapshot.home_data
|
||||
)
|
||||
_is_restoring = false
|
||||
if (
|
||||
not inventory_restored
|
||||
|
|
@ -376,13 +387,14 @@ func load_player_data() -> bool:
|
|||
or not world_time_restored
|
||||
or not world_weather_restored
|
||||
or not jobs_restored
|
||||
or not home_restored
|
||||
):
|
||||
push_error(
|
||||
(
|
||||
"Validated player save could not be restored: "
|
||||
+ "inventory=%s collection=%s wallet=%s bag=%s tackle=%s hotbar=%s "
|
||||
+ "upgrades=%s cooler=%s layout=%s art=%s experience=%s "
|
||||
+ "time=%s weather=%s jobs=%s"
|
||||
+ "time=%s weather=%s jobs=%s home=%s"
|
||||
)
|
||||
% [
|
||||
inventory_restored,
|
||||
|
|
@ -399,6 +411,7 @@ func load_player_data() -> bool:
|
|||
world_time_restored,
|
||||
world_weather_restored,
|
||||
jobs_restored,
|
||||
home_restored,
|
||||
]
|
||||
)
|
||||
return false
|
||||
|
|
@ -899,6 +912,7 @@ func _build_save_dictionary() -> Dictionary:
|
|||
),
|
||||
},
|
||||
"jobs": _jobs.to_save_data(),
|
||||
"home": _home_state.to_save_data(),
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -913,6 +927,7 @@ func _build_load_snapshot(save_data: Dictionary) -> LoadSnapshot:
|
|||
or typeof(save_data.get("inventory_layout")) != TYPE_DICTIONARY
|
||||
or typeof(save_data.get("experience")) != TYPE_DICTIONARY
|
||||
or typeof(save_data.get("jobs")) != TYPE_DICTIONARY
|
||||
or typeof(save_data.get("home")) != TYPE_DICTIONARY
|
||||
):
|
||||
return null
|
||||
var wallet_data: Dictionary = save_data["wallet"]
|
||||
|
|
@ -924,6 +939,7 @@ func _build_load_snapshot(save_data: Dictionary) -> LoadSnapshot:
|
|||
var inventory_layout_data: Dictionary = save_data["inventory_layout"]
|
||||
var experience_data: Dictionary = save_data["experience"]
|
||||
var jobs_data: Dictionary = save_data["jobs"]
|
||||
var home_data: Dictionary = save_data["home"]
|
||||
var world_data: Dictionary = {}
|
||||
if typeof(save_data.get("world")) == TYPE_DICTIONARY:
|
||||
world_data = save_data["world"]
|
||||
|
|
@ -1006,6 +1022,12 @@ func _build_load_snapshot(save_data: Dictionary) -> LoadSnapshot:
|
|||
if not PlayerJobServiceType.validate_save_data(jobs_data):
|
||||
return null
|
||||
snapshot.jobs_data = jobs_data.duplicate(true)
|
||||
var sanitized_home: Dictionary = PlayerHomeStateType.sanitize_save_data(
|
||||
home_data
|
||||
)
|
||||
if sanitized_home.is_empty():
|
||||
return null
|
||||
snapshot.home_data = sanitized_home
|
||||
if world_data.has("time_hours"):
|
||||
snapshot.world_time_hours = _read_world_time_hours(
|
||||
world_data["time_hours"]
|
||||
|
|
@ -1340,6 +1362,8 @@ func _migrate_save(
|
|||
migrated = _migrate_version_8_to_9(migrated)
|
||||
9:
|
||||
migrated = _migrate_version_9_to_10(migrated)
|
||||
10:
|
||||
migrated = _migrate_version_10_to_11(migrated)
|
||||
_:
|
||||
return {}
|
||||
if migrated.is_empty():
|
||||
|
|
@ -1597,6 +1621,13 @@ func _migrate_version_9_to_10(data: Dictionary) -> Dictionary:
|
|||
return migrated
|
||||
|
||||
|
||||
func _migrate_version_10_to_11(data: Dictionary) -> Dictionary:
|
||||
var migrated: Dictionary = data.duplicate(true)
|
||||
migrated["home"] = PlayerHomeStateType.default_save_data()
|
||||
migrated["save_version"] = 11
|
||||
return migrated
|
||||
|
||||
|
||||
func _mark_dirty() -> void:
|
||||
if (
|
||||
_is_restoring
|
||||
|
|
@ -1866,6 +1897,7 @@ func _restore_defaults() -> void:
|
|||
_world_layout = WorldLayoutType.GENERATED
|
||||
_world_seed = DEFAULT_WORLD_SEED
|
||||
_jobs.reset_to_defaults()
|
||||
_home_state.reset_to_defaults()
|
||||
_is_restoring = false
|
||||
_is_dirty = false
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue