Files
CS2GSI/CS2GSI/GameState/GameState.cs
2024-01-16 04:29:26 +01:00

21 lines
802 B
C#

using System.Reflection;
namespace CS2GSI.GameState;
public abstract record GameState
{
public override string ToString()
{
string ret = "";
foreach (FieldInfo field in GetType().GetFields())
{
string filler = GetType().GetFields().Last() != field ? "\u251c\u2500" : "\u2514\u2500";
string filler2 = GetType().GetFields().Last() != field ? "\u2502" : " ";
if (field.FieldType.BaseType == typeof(GameState))
ret += $"\b{filler}\u2510 {field.Name}\n{field.GetValue(this)?.ToString()?.Replace("\b", $"\b{filler2} ")}";
else
ret += $"\b{filler} {field.Name}{new string('.', field.Name.Length > 25 ? 0 : 25-field.Name.Length)}{field.GetValue(this)}\n";
}
return ret;
}
}