Formats
namespace Griff.Scenes;
public static class FormatsThe small text formats a field is typed in, each read one way: names (“Bullet, Enemy”), points (“4 0; 4 3”), numbers by kind (“0:20, 3:15”) and items (“150 Gold, Wood 50”, see Items). A field’s rows editor, its Problem and the game all read through here, so they can’t disagree about what a text says. Each text is read once, for as long as the very string is held (what a component keeps until its field is set again), and the result is shared, so it’s never changed. A part that doesn’t read is left out here and flagged by the field’s editor (the loader and a game’s start say so in Output, see NameChecks).
Methods
Section titled “Methods”KindCount
Section titled “KindCount”public static ValueTuple<int, int>? KindCount(string part)One “kind:count” pair, “3:15”; null if it isn’t two whole numbers around a colon.
KindCounts
Section titled “KindCounts”public static IReadOnlyDictionary<int, int> KindCounts(string? text)How many of each kind “0:20, 3:15” says (a kind named twice adds up). Shared: don’t change it; copy it to count on.
public static string[] Names(string? text)The names in “Bullet, Enemy” (commas or semicolons between them), blank ones left out. Shared: don’t change it.
public static Vector2? Point(string part)One point, “4 3” or “4,3”; null if it isn’t two finite numbers.
Points
Section titled “Points”public static IReadOnlyList<Vector2> Points(string? text)The points in “x y; x y” (commas work between the numbers too, and “|” or a new line between points). Shared: don’t change it.
WriteKindCounts
Section titled “WriteKindCounts”public static string WriteKindCounts(IEnumerable<KeyValuePair<int, int>> counts)“0:20, 3:15” written from counts, by kind.