using System.Numerics; using System.Text; using Content.Shared.FixedPoint; using Content.Shared.Botany; using Robust.Client.AutoGenerated; //probably useless using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; using Content.Shared.Chemistry.Reagent; namespace Content.Client.SeedAnalyzer.UI { [GenerateTypedNameReferences] public sealed partial class SeedAnalyzerWindow : DefaultWindow { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public SeedAnalyzerWindow() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); } public void Populate(SeedAnalyzerScannedUserMessage msg) { var text = new StringBuilder(); var entities = IoCManager.Resolve(); // maybe bad if (msg.TargetEntity != null) // this may be bad, maybe && entities.TryGetComponent(msg.TargetEntity, out var seed) { string entityName = "Unknown"; // без этой строки все ломается и я не знаю почему if (msg.Viable == false) { text.Append($"{Loc.GetString("seed-analyzer-window-entity-viable-text")}\n"); } if (msg.TurnIntoKudzu == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-turnintokudzu-text")}\n"); } text.Append($"{Loc.GetString("seed-analyzer-window-entity-endurance-text", ("endurance", msg.Endurance!))}"); text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-yield-text", ("yield", msg.Yield!))}"); //maybe msg.Yield.HasValue ? "N/A" : $"{msg.Yield}" text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-maturation-text", ("maturation", msg.Maturation!))}"); text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-production-text", ("production", msg.Production!))}"); text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-lifespan-text", ("lifespan", msg.Lifespan!))}"); text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-potency-text", ("potency", msg.Potency!))}"); int zero = 0; var zero2 = FixedPoint2.New(zero); Dictionary nodic = new Dictionary(); nodic.Add("\nNo chemicals", zero2); if (msg.Chemicals != nodic && msg.Chemicals != null) { //text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-chemicals-text")}"); foreach (var (chemical, amount) in msg.Chemicals!) { var localizedName = _prototypeManager.TryIndex(chemical, out ReagentPrototype? p) ? p.LocalizedName : Loc.GetString("seed-analyzer-window-reagent-name-not-found-text"); //maybe Loc.GetString("seed-analyzer-window-reagent-name-not-found-text") text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-chemical-text", ("localizedName", localizedName))}"); text.Append($" {Loc.GetString("seed-analyzer-window-entity-amount-text", ("amount", amount))}"); } } if (msg.Ligneous == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-ligneous-text")}"); } if (msg.CanScream == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-canscream-text")}"); } if (msg.Slip == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-slip-text")}"); } if (msg.Bioluminescent == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-bioluminescent-text")}"); } if (msg.Sentient == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-sentient-text")}"); } if (msg.Seedless == true) { text.Append($"\n{Loc.GetString("seed-analyzer-window-entity-seedless-text")}"); } Diagnostics.Text = text.ToString(); SetSize = new Vector2(250, 600); } else { Diagnostics.Text = Loc.GetString("seed-analyzer-window-no-plant-data-text"); SetSize = new Vector2(250, 100); } } } }