Disposals refactor (#17803)

This commit is contained in:
metalgearsloth
2023-07-06 13:39:34 +10:00
committed by GitHub
parent 0790f31f21
commit 3eb93988e5
21 changed files with 1321 additions and 1261 deletions

View File

@@ -1,6 +1,6 @@
using Content.Client.Disposal.Components;
using Content.Client.Disposal.Systems;
using Content.Shared.Disposal;
using Content.Shared.Disposal.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
@@ -16,7 +16,9 @@ namespace Content.Client.Disposal.UI
{
[Dependency] private readonly IEntityManager _entityManager = default!;
// What are you doing here
public MailingUnitWindow? MailingUnitWindow;
public DisposalUnitWindow? DisposalUnitWindow;
public DisposalUnitBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
@@ -76,41 +78,27 @@ namespace Content.Client.Disposal.UI
return;
}
var entityId = Owner.Owner;
if (!_entityManager.TryGetComponent(entityId, out DisposalUnitComponent? component))
return;
switch (state)
{
case MailingUnitBoundUserInterfaceState mailingUnitState:
MailingUnitWindow?.UpdateState(mailingUnitState);
component.UiState = mailingUnitState.DisposalState;
break;
case DisposalUnitBoundUserInterfaceState disposalUnitState:
DisposalUnitWindow?.UpdateState(disposalUnitState);
component.UiState = disposalUnitState;
break;
}
_entityManager.System<DisposalUnitSystem>().UpdateActive(entityId, true);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
if (!disposing)
return;
MailingUnitWindow?.Dispose();
DisposalUnitWindow?.Dispose();
}
public bool? UpdateWindowState(DisposalUnitBoundUserInterfaceState state)
{
return UiKey is DisposalUnitUiKey
? DisposalUnitWindow?.UpdateState(state)
: MailingUnitWindow?.UpdatePressure(state.FullPressureTime);
}
}
}