ActivatableUI tweaks (#27448)

* ActivatableUI tweaks

* EntGotRemovedFromContainerMessage

* A
This commit is contained in:
Leon Friedrich
2024-04-29 16:06:43 +12:00
committed by GitHub
parent cd90c05ce5
commit 7c7d8eb645
17 changed files with 244 additions and 99 deletions

View File

@@ -20,12 +20,19 @@ public sealed partial class ActivatableUISystem
{
_cell.SetPowerCellDrawEnabled(uid, false);
if (HasComp<ActivatableUIRequiresPowerCellComponent>(uid) &&
TryComp<ActivatableUIComponent>(uid, out var activatable) &&
activatable.Key != null)
if (!HasComp<ActivatableUIRequiresPowerCellComponent>(uid) ||
!TryComp(uid, out ActivatableUIComponent? activatable))
{
_uiSystem.CloseUi(uid, activatable.Key);
return;
}
if (activatable.Key == null)
{
Log.Error($"Encountered null key in activatable ui on entity {ToPrettyString(uid)}");
return;
}
_uiSystem.CloseUi(uid, activatable.Key);
}
private void OnBatteryOpened(EntityUid uid, ActivatableUIRequiresPowerCellComponent component, BoundUIOpenedEvent args)
@@ -55,9 +62,15 @@ public sealed partial class ActivatableUISystem
/// </summary>
public void CheckUsage(EntityUid uid, ActivatableUIComponent? active = null, ActivatableUIRequiresPowerCellComponent? component = null, PowerCellDrawComponent? draw = null)
{
if (!Resolve(uid, ref component, ref draw, ref active, false) || active.Key == null)
if (!Resolve(uid, ref component, ref draw, ref active, false))
return;
if (active.Key == null)
{
Log.Error($"Encountered null key in activatable ui on entity {ToPrettyString(uid)}");
return;
}
if (_cell.HasActivatableCharge(uid))
return;