feat: complete playtest parity improvements

This commit is contained in:
goose
2026-10-08 19:06:19 -04:00
parent cce25a1908
commit eca098b4b9
139 changed files with 3001 additions and 982 deletions
@@ -12,6 +12,11 @@ const AMBIENCE_CONTEXTS := [&"exploration", &"combat", &"danger"]
const SFX_EVENTS := [&"attack_given", &"attack_received", &"menu_select", &"menu_cancel", &"item_use", &"death"]
const USER_AUDIO_DIRECTORY := "user://audio"
const USER_MANIFEST_PATH := "user://audio/audio_import_manifest.tres"
const BUNDLED_AMBIENCE_PATHS := {
&"exploration": "res://assets/audio/dungeon_exploration.wav",
&"combat": "res://assets/audio/dungeon_combat.wav",
&"danger": "res://assets/audio/dungeon_danger.wav",
}
var ambience_streams: Dictionary = {}
var sfx_streams: Dictionary = {}
@@ -46,9 +51,23 @@ static func save_user_manifest(manifest: AudioImportManifest) -> Error:
return ResourceSaver.save(manifest, USER_MANIFEST_PATH)
static func load_user_manifest() -> AudioImportManifest:
var manifest := load_bundled_manifest()
if not FileAccess.file_exists(USER_MANIFEST_PATH):
return AudioImportManifest.new()
return manifest
var resource := ResourceLoader.load(USER_MANIFEST_PATH, "AudioImportManifest", ResourceLoader.CACHE_MODE_IGNORE)
if resource is AudioImportManifest:
return resource as AudioImportManifest
return AudioImportManifest.new()
if not resource is AudioImportManifest:
return manifest
var user_manifest := resource as AudioImportManifest
for context: StringName in user_manifest.ambience_streams:
manifest.register_ambience(context, user_manifest.ambience_for(context))
for event: StringName in user_manifest.sfx_streams:
manifest.register_sfx(event, user_manifest.sfx_for(event))
return manifest
static func load_bundled_manifest() -> AudioImportManifest:
var manifest := AudioImportManifest.new()
for context: StringName in BUNDLED_AMBIENCE_PATHS:
var stream := ResourceLoader.load(String(BUNDLED_AMBIENCE_PATHS[context])) as AudioStream
if stream != null:
manifest.register_ambience(context, stream)
return manifest
+12 -5
View File
@@ -20,12 +20,16 @@ var _last_ambience_path := ""
var _last_sfx_path := ""
func _init(manifest_or_legacy_root: Variant = null) -> void:
# The former API accepted an external directory override. Intentionally ignore
# it for compatibility: external paths are not a safe playback source.
if manifest_or_legacy_root is AudioImportManifest:
_manifest = manifest_or_legacy_root as AudioImportManifest
else:
elif manifest_or_legacy_root == null:
# Production instances load bundled music and optionally overlay the safe
# Godot-native user manifest.
_manifest = AudioImportManifestType.load_user_manifest()
else:
# The former API accepted an external directory override. Keep explicit
# legacy instances isolated and silent: arbitrary files are never decoded.
_manifest = AudioImportManifestType.new()
func _ready() -> void:
_ensure_players()
@@ -40,9 +44,12 @@ func set_manifest(manifest: AudioImportManifest) -> void:
func set_ambience_context(context: String) -> void:
if not context in AMBIENCE_CONTEXTS:
return
var stream := _manifest.ambience_for(StringName(context))
if current_ambience_context == context and _ambience_player != null and _ambience_player.stream == stream and _ambience_player.playing:
return
current_ambience_context = context
_last_ambience_path = ""
_set_ambience_stream(_manifest.ambience_for(StringName(context)))
_last_ambience_path = stream.resource_path if stream != null else ""
_set_ambience_stream(stream)
func play_sfx(event: String) -> void:
_last_sfx_path = ""
+29 -5
View File
@@ -116,7 +116,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
identified.append(String(id))
return {
"version": SCHEMA_VERSION,
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
"run": {"seed": run.seed, "settings": {"seed": run.settings.seed, "difficulty_id": String(run.settings.difficulty_id), "permadeath": run.settings.permadeath, "pet_enabled": run.settings.pet_enabled, "pet_name": run.settings.pet_name, "pet_species": run.settings.pet_species}, "player_name": run.player_name, "base_archetype": String(run.base_archetype), "current_floor": run.current_floor, "current_turn": run.current_turn, "gold": run.gold, "floors": floors, "floor_deadlines": deadlines, "inventory": run.inventory.to_dict(), "equipment": equipment, "identified_instance_ids": identified, "quest_records": run.quest_records, "achievement_state": run.achievement_state, "audience_state": run.audience_state, "recap_state": run.recap_state, "faction_war_state": run.faction_war_state, "moderation_state": run.moderation_state, "endgame_state": {"victory": run.endgame_state.victory}, "is_game_over": run.is_game_over, "death_outcome": String(run.death_outcome), "slot_policy": String(run.slot_policy), "log": _events_to_data(run.log), "meta": {}},
"runtime": {"player": _actor_to_data(game.player), "companion": _companion_to_data(game.companion), "party": _actors_to_data(game.party.members), "dialogue_player": _dialogue_to_data(dialogue_player)},
"metadata": {"updated_at": Time.get_unix_time_from_system(), "source": "godot"},
}
@@ -124,7 +124,7 @@ func _serialize(run: RunState, game: GameState, dialogue_player) -> Dictionary:
func _deserialize(data: Dictionary, catalog: ContentCatalog) -> Dictionary:
var run_data: Dictionary = data.get("run", {})
var settings_data: Dictionary = run_data.get("settings", {})
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false))))
var run := RunStateType.new(String(run_data.get("seed", "")), RunSettingsType.new(String(settings_data.get("seed", run_data.get("seed", ""))), StringName(settings_data.get("difficulty_id", "crawler")), bool(settings_data.get("permadeath", false)), bool(settings_data.get("pet_enabled", false)), String(settings_data.get("pet_name", "Familier")), String(settings_data.get("pet_species", "Animal"))))
run.player_name = String(run_data.get("player_name", "Sans-Nom")); run.base_archetype = StringName(run_data.get("base_archetype", "vanguard")); run.current_floor = int(run_data.get("current_floor", 0)); run.current_turn = int(run_data.get("current_turn", 0)); run.gold = int(run_data.get("gold", 0))
for key in (run_data.get("floors", {}) as Dictionary):
var floor := _floor_from_data(run_data.floors[key], catalog)
@@ -200,12 +200,36 @@ static func _actors_from_data(data: Array) -> Array[ActorState]:
static func _companion_to_data(companion: CompanionState):
if companion == null: return null
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "actor": _actor_to_data(companion.actor)}
return {"choice_id": String(companion.choice_id), "stance": String(companion.stance), "name": companion.name, "species": companion.species, "endurance": companion.endurance, "regeneration_skill": companion.regeneration_skill, "regeneration_perk_bonus": companion.regeneration_perk_bonus, "actor": _actor_to_data(companion.actor)}
static func _companion_from_data(data) -> CompanionState:
if not data is Dictionary or data.is_empty(): return null
var actor := _actor_from_data(data.get("actor", {})); if actor == null: return null
var companion := CompanionStateType.new(StringName(data.get("choice_id", "moth")), actor); companion.stance = StringName(data.get("stance", "follow")); return companion
var actor_data: Dictionary = data.get("actor", {})
if actor_data.is_empty() and data.has("id"):
actor_data = {
"id": String(data.get("id", "companion")),
"cell": [int(data.get("x", 0)), int(data.get("y", 0))],
"hit_points": int(data.get("hp", 1)),
"max_hit_points": int(data.get("max_hp", data.get("hp", 1))),
"attack_damage": int(data.get("attack_damage", 3)),
"xp": int(data.get("xp", 0)),
}
var actor := _actor_from_data(actor_data); if actor == null: return null
var companion := CompanionStateType.new(StringName(data.get("choice_id", data.get("id", "moth"))), actor)
companion.stance = _legacy_companion_stance(StringName(data.get("stance", data.get("behavior", "stay_back"))))
companion.name = String(data.get("name", "Familier"))
companion.species = String(data.get("species", "Animal"))
var attributes: Dictionary = data.get("attributes", {})
var skills: Dictionary = data.get("skills", {})
var perks: Dictionary = data.get("perks", {})
companion.endurance = int(data.get("endurance", attributes.get("end", 4)))
companion.regeneration_skill = int(data.get("regeneration_skill", skills.get("regeneration", 1)))
companion.regeneration_perk_bonus = int(data.get("regeneration_perk_bonus", perks.get("regen_bonus", 0)))
return companion
static func _legacy_companion_stance(value: StringName) -> StringName:
var normalized := CompanionStateType.normalize_stance(value)
return normalized if normalized in CompanionStateType.VALID_STANCES else CompanionStateType.Stance.STAY_BACK
static func _events_to_data(events: Array[GameEvent]) -> Array:
var data: Array = []