* mechs * interaction relay * atmos handling * fuck around with interaction events SPAGHETTI CODE OH MY GOD * more sprites and whatever the hell * more mech shit * more shit for equipment * starting equipment (for nukie mechs and such) * equipment cycling * starting with some of the ui * a fat chunk of ui prototyping * done tinkering with ui * a bunch of ui stuff and what have yous * cleaning up grabber and state handling * make the ui actually functional + watch me port a million icons I swear i'll prune the sprites later blease * start on construction * construction yo mamma * remove some unused files * fix a silly * make the graph sane * make it actually constructible. * print the boards as well, bozo * rebalance part prices * eject action also i appease the russians by remembering to localize * Punch Shit * make mech integrity and repairs work * Make the UI more based STOMP STOMP STOMP STOMP * make equipment even more based * batteries and other such delights * make the ui look pimpin af * make the construction mega based * UI but so epic * equipment * some sweat tweaks * damage rebalancing * restructure tech * fix some shit * mechs inherit access * make icons actually use sprite specifiers * TRAILING COMMAA!!!!! * fix a mild indentation sin * undo this change because it isn't needed * actually fix this * secret webeditting shhhh * place this tech here * comments * foo
73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
using Content.Client.UserInterface.Controls;
|
|
using Content.Client.UserInterface.Fragments;
|
|
using Content.Shared.Mech.Components;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Mech.Ui;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class MechMenu : FancyWindow
|
|
{
|
|
[Dependency] private readonly IEntityManager _ent = default!;
|
|
|
|
private readonly EntityUid _mech;
|
|
|
|
public event Action<EntityUid>? OnRemoveButtonPressed;
|
|
|
|
public MechMenu(EntityUid mech)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_mech = mech;
|
|
|
|
if (!_ent.TryGetComponent<SpriteComponent>(mech, out var sprite))
|
|
return;
|
|
|
|
MechView.Sprite = sprite;
|
|
}
|
|
|
|
public void UpdateMechStats()
|
|
{
|
|
if (!_ent.TryGetComponent<SharedMechComponent>(_mech, out var mechComp))
|
|
return;
|
|
|
|
var integrityPercent = mechComp.Integrity / mechComp.MaxIntegrity;
|
|
IntegrityDisplayBar.Value = integrityPercent.Float();
|
|
IntegrityDisplay.Text = Loc.GetString("mech-integrity-display", ("amount", (integrityPercent*100).Int()));
|
|
|
|
var energyPercent = mechComp.Energy / mechComp.MaxEnergy;
|
|
EnergyDisplayBar.Value = energyPercent.Float();
|
|
EnergyDisplay.Text = Loc.GetString("mech-energy-display", ("amount", (energyPercent*100).Int()));
|
|
|
|
SlotDisplay.Text = Loc.GetString("mech-slot-display",
|
|
("amount", mechComp.MaxEquipmentAmount - mechComp.EquipmentContainer.ContainedEntities.Count));
|
|
}
|
|
|
|
public void UpdateEquipmentView()
|
|
{
|
|
if (!_ent.TryGetComponent<MechComponent>(_mech, out var mechComp))
|
|
return;
|
|
|
|
EquipmentControlContainer.Children.Clear();
|
|
foreach (var ent in mechComp.EquipmentContainer.ContainedEntities)
|
|
{
|
|
if (!_ent.TryGetComponent<SpriteComponent>(ent, out var sprite) ||
|
|
!_ent.TryGetComponent<MetaDataComponent>(ent, out var metaData))
|
|
continue;
|
|
|
|
var uicomp = _ent.GetComponentOrNull<UIFragmentComponent>(ent);
|
|
var ui = uicomp?.Ui?.GetUIFragmentRoot();
|
|
|
|
var control = new MechEquipmentControl(metaData.EntityName, sprite, ui);
|
|
|
|
control.OnRemoveButtonPressed += () => OnRemoveButtonPressed?.Invoke(ent);
|
|
|
|
EquipmentControlContainer.AddChild(control);
|
|
}
|
|
}
|
|
}
|
|
|