Files
przygody-pana-cegly/scripts/Resources/LevelResource.cs
Gabriel Kaszewski f85c16c641 fix(levels): ScenePath must be a string, not a PackedScene
slice 7 regression. level_village_2..5.tscn each reference their own
LevelResource for the death screen label, so pointing the resource back
at the scene forms a cycle Godot cannot resolve - "Parse Error: Busy"
and the level fails to load entirely.

ScenePath was a string for exactly this reason. Reverted, and the rot it
allowed (forest_1 aimed at a nonexistent scene) is now caught by
LevelCatalogue.Validate checking every path resolves, plus a repo-level
structural check - fixed by validation rather than by typing.

project.godot: restores the C# feature flag and dialogue_manager
uses_dotnet, which `godot --headless --import` strips on every run.
2026-07-28 19:40:02 +02:00

45 lines
1.8 KiB
C#

using Godot;
namespace Mr.BrickAdventures.scripts.Resources;
/// <summary>
/// One authored Level: its stable id, its display name key, and where its scene lives.
/// </summary>
/// <remarks>
/// <para>
/// <see cref="Id"/> is what Playthroughs and Best Times reference, so it must never change once a
/// build has shipped — unlike position in a list, which is what the old <c>GameManager.LevelScenes</c>
/// array used and which every save depended on.
/// </para>
/// <para>
/// <see cref="ScenePath"/> is deliberately a path string and not an exported <c>PackedScene</c>.
/// Several level scenes reference their own <c>LevelResource</c> (for the death screen's label), so a
/// typed reference back to the scene forms a cycle that Godot cannot resolve — it fails with
/// "Parse Error: Busy" and the level will not load at all.
/// </para>
/// <para>
/// The trade-off is that a path can rot: this field previously pointed at
/// <c>res://scenes/level_forest_5.tscn</c>, which does not exist. That is fixed by validation rather
/// than by typing — <c>LevelCatalogue.Validate</c> checks every path resolves, so a bad one fails
/// loudly at boot instead of silently.
/// </para>
/// </remarks>
[GlobalClass]
public partial class LevelResource : Resource
{
/// <summary>Stable identity. Referenced by saves — do not change after shipping.</summary>
[Export]
public string Id { get; set; } = string.Empty;
/// <summary>Translation key for the player-facing name. Labels auto-translate it.</summary>
[Export]
public string LevelName { get; set; } = string.Empty;
/// <summary>
/// <c>res://</c> or <c>uid://</c> path to the scene. Loaded on demand, never held as a typed
/// reference — see the remarks above.
/// </summary>
[Export(PropertyHint.File, "*.tscn")]
public string ScenePath { get; set; } = string.Empty;
}