* 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
85 lines
2.0 KiB
C#
85 lines
2.0 KiB
C#
using Content.Client.UserInterface.Fragments;
|
|
using Content.Shared.Mech;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Mech.Ui;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class MechBoundUserInterface : BoundUserInterface
|
|
{
|
|
[Dependency] private readonly IEntityManager _ent = default!;
|
|
|
|
private readonly EntityUid _mech;
|
|
|
|
private MechMenu? _menu;
|
|
|
|
public MechBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
_mech = owner.Owner;
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_menu = new(_mech);
|
|
|
|
_menu.OnClose += Close;
|
|
_menu.OpenCenteredLeft();
|
|
|
|
_menu.OnRemoveButtonPressed += uid =>
|
|
{
|
|
SendMessage(new MechEquipmentRemoveMessage(uid));
|
|
};
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (state is not MechBoundUiState msg)
|
|
return;
|
|
UpdateEquipmentControls(msg);
|
|
_menu?.UpdateMechStats();
|
|
_menu?.UpdateEquipmentView();
|
|
}
|
|
|
|
public void UpdateEquipmentControls(MechBoundUiState state)
|
|
{
|
|
if (!_ent.TryGetComponent<MechComponent>(_mech, out var mechComp))
|
|
return;
|
|
|
|
foreach (var ent in mechComp.EquipmentContainer.ContainedEntities)
|
|
{
|
|
var ui = GetEquipmentUi(ent);
|
|
if (ui == null)
|
|
continue;
|
|
foreach (var (attached, estate) in state.EquipmentStates)
|
|
{
|
|
if (ent == attached)
|
|
ui.UpdateState(estate);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
base.Dispose(disposing);
|
|
|
|
if (!disposing)
|
|
return;
|
|
|
|
_menu?.Close();
|
|
}
|
|
|
|
public UIFragment? GetEquipmentUi(EntityUid? uid)
|
|
{
|
|
var component = _ent.GetComponentOrNull<UIFragmentComponent>(uid);
|
|
component?.Ui?.Setup(this, uid);
|
|
return component?.Ui;
|
|
}
|
|
}
|
|
|