mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-05 21:29:09 +01:00
Cut the comments from the refactored code
Three survive: why AppServices is hand-wired, the cp1250 registration trap, and the IsDieselEngine note carried over from Physics.cs.
This commit is contained in:
@@ -9,43 +9,22 @@ using StarterNG.Domain;
|
||||
|
||||
namespace StarterNG.Domain.Sceneries;
|
||||
|
||||
/// <summary>A file the scenery offers to open alongside it (map, manual, ...).</summary>
|
||||
public sealed class SceneryAttachment
|
||||
{
|
||||
public string FilePath = "";
|
||||
public string Label = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An <c>include</c> the scenery marks as optional, so the user can decide
|
||||
/// whether it ends up in the exported scenario.
|
||||
/// </summary>
|
||||
public sealed class SceneryInclude
|
||||
{
|
||||
public string FilePath = "";
|
||||
public string Desc = "";
|
||||
|
||||
/// <summary>1 = on by default, 2 = only when no companion timetable exists.</summary>
|
||||
public int Kind;
|
||||
|
||||
public bool Selected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A scenario the user can start: its consists, loose vehicles, optional
|
||||
/// includes and weather, plus the ability to render all of that back into a .scn
|
||||
/// the simulator can load.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The aggregate is pure: it never reads or writes files. Parsing lives in
|
||||
/// <c>Infrastructure.Sceneries.SceneryParser</c> and loading in
|
||||
/// <c>SceneryRepository</c>, which is what lets the export rules be tested from
|
||||
/// a string rather than an installation.
|
||||
///
|
||||
/// <see cref="Template"/> is the .scn text with every trainset replaced by a
|
||||
/// <c>{{index}}</c> placeholder and the optional includes stripped, so
|
||||
/// <see cref="BuildExportContent"/> only has to substitute rather than re-parse.
|
||||
/// </remarks>
|
||||
public sealed class Scenery
|
||||
{
|
||||
public Scenery(string path, string template)
|
||||
@@ -54,13 +33,10 @@ public sealed class Scenery
|
||||
Template = template;
|
||||
}
|
||||
|
||||
/// <summary>Path of the .scn this was parsed from; the aggregate's identity.</summary>
|
||||
public string Path { get; }
|
||||
|
||||
/// <summary>The .scn body with trainset placeholders, used for export.</summary>
|
||||
public string Template { get; }
|
||||
|
||||
/// <summary>True when a companion .sbt timetable sits next to the .scn.</summary>
|
||||
public bool HasCompanionTimetable { get; set; }
|
||||
|
||||
public string? Group { get; set; }
|
||||
@@ -71,7 +47,6 @@ public sealed class Scenery
|
||||
|
||||
public string? ImageName { get; set; }
|
||||
|
||||
/// <summary>Scenery kept for historical interest; hidden unless asked for.</summary>
|
||||
public bool Archival { get; set; }
|
||||
|
||||
public List<Trainset> Trainsets { get; } = new();
|
||||
@@ -80,38 +55,21 @@ public sealed class Scenery
|
||||
|
||||
public List<SceneryInclude> Includes { get; } = new();
|
||||
|
||||
/// <summary>Vehicles placed directly as nodes rather than inside a trainset.</summary>
|
||||
public List<Dynamic> LooseVehicles { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Names of every loose vehicle, including those whose node failed to parse
|
||||
/// and therefore has no <see cref="Dynamic"/>.
|
||||
/// </summary>
|
||||
public List<string> LooseVehicleNames { get; } = new();
|
||||
|
||||
/// <summary>Parse problems worth showing on the scenario's fault list.</summary>
|
||||
public List<string> Faults { get; } = new();
|
||||
|
||||
public SceneryWeather Weather { get; } = new();
|
||||
|
||||
public string DisplayName => System.IO.Path.GetFileNameWithoutExtension(Path);
|
||||
|
||||
/// <summary>
|
||||
/// The description with any "@key" references resolved against the scenery's
|
||||
/// own translation files.
|
||||
/// </summary>
|
||||
public string LocalizedDescription(ISceneryTranslations translations) =>
|
||||
string.IsNullOrEmpty(Description)
|
||||
? ""
|
||||
: string.Join("\n", Description.Split('\n').Select(translations.Translate));
|
||||
|
||||
/// <summary>
|
||||
/// Renders the scenario the simulator should load: the original file with the
|
||||
/// user's consists, weather and optional includes applied.
|
||||
/// </summary>
|
||||
/// <param name="skipDecorTrainsets">
|
||||
/// Drops AI trainsets the user marked irrelevant, which shortens loading.
|
||||
/// </param>
|
||||
public string BuildExportContent(bool skipDecorTrainsets, IRandomSource random)
|
||||
{
|
||||
string result = Template;
|
||||
@@ -154,8 +112,6 @@ public sealed class Scenery
|
||||
var sb = new StringBuilder();
|
||||
foreach (var include in Includes)
|
||||
{
|
||||
// Kind 2 is the scenery's own timetable stand-in: it is only wanted
|
||||
// when the user has not supplied a companion .sbt.
|
||||
if (include.Kind == 2)
|
||||
{
|
||||
if (!HasCompanionTimetable)
|
||||
@@ -172,10 +128,6 @@ public sealed class Scenery
|
||||
return InsertBeforeFirstInit(text, sb.ToString(), fallbackAtEnd: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Places generated content ahead of <c>FirstInit</c>, which the simulator
|
||||
/// treats as the end of the definition section.
|
||||
/// </summary>
|
||||
private static string InsertBeforeFirstInit(string text, string addition, bool fallbackAtEnd)
|
||||
{
|
||||
var firstInit = Regex.Match(text, @"\bFirstInit\b", RegexOptions.IgnoreCase);
|
||||
|
||||
Reference in New Issue
Block a user