Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Mech.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.ActionBlocker;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
@@ -33,6 +34,7 @@ public sealed class MechSystem : SharedMechSystem
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly BatterySystem _batterySystem = default!;
private ISawmill _sawmill = default!;
@@ -69,7 +71,7 @@ public sealed class MechSystem : SharedMechSystem
#endregion
}
private void OnMechCanMoveEvent(EntityUid uid, MechComponent component , UpdateCanMoveEvent args)
private void OnMechCanMoveEvent(EntityUid uid, MechComponent component, UpdateCanMoveEvent args)
{
if (component.Broken || component.Integrity <= 0 || component.Energy <= 0)
args.Cancel();
@@ -300,7 +302,7 @@ public sealed class MechSystem : SharedMechSystem
EquipmentStates = ev.States
};
var ui = _ui.GetUi(uid, MechUiKey.Key);
_ui.SetUiState(ui, state);
UserInterfaceSystem.SetUiState(ui, state);
}
public override bool TryInsert(EntityUid uid, EntityUid? toInsert, MechComponent? component = null)
@@ -318,7 +320,7 @@ public sealed class MechSystem : SharedMechSystem
{
var tile = grid.GetTileRef(coordinates);
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is { } environment)
{
_atmosphere.Merge(mechAir.Air, environment.RemoveVolume(MechAirComponent.GasMixVolume));
}
@@ -342,7 +344,7 @@ public sealed class MechSystem : SharedMechSystem
{
var tile = grid.GetTileRef(coordinates);
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is {} environment)
if (_atmosphere.GetTileMixture(tile.GridUid, null, tile.GridIndices, true) is { } environment)
{
_atmosphere.Merge(environment, mechAir.Air);
mechAir.Air.Clear();
@@ -376,7 +378,7 @@ public sealed class MechSystem : SharedMechSystem
if (!TryComp<BatteryComponent>(battery, out var batteryComp))
return false;
batteryComp.CurrentCharge = batteryComp.CurrentCharge + delta.Float();
_batterySystem.SetCharge(battery!.Value, batteryComp.CurrentCharge + delta.Float(), batteryComp);
if (batteryComp.CurrentCharge != component.Energy) //if there's a discrepency, we have to resync them
{
_sawmill.Debug($"Battery charge was not equal to mech charge. Battery {batteryComp.CurrentCharge}. Mech {component.Energy}");