]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix literally every single activatable UI bug (#27401)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 27 Apr 2024 16:32:57 +0000 (02:32 +1000)
committerGitHub <noreply@github.com>
Sat, 27 Apr 2024 16:32:57 +0000 (02:32 +1000)
* Fix all activatable bugs

Apparently this was a load-bearing nullable enum.

* build

Content.Shared/UserInterface/ActivatableUIComponent.cs
Content.Shared/UserInterface/ActivatableUISystem.Power.cs
Content.Shared/UserInterface/ActivatableUISystem.cs

index 74e613493288cd0e209097239451714e6cd5b7be..136a1f82cff3aecfe0b7492293618f6c839f74f0 100644 (file)
@@ -8,7 +8,7 @@ namespace Content.Shared.UserInterface
     public sealed partial class ActivatableUIComponent : Component
     {
         [DataField(required: true, customTypeSerializer: typeof(EnumSerializer))]
-        public Enum Key { get; set; } = default!;
+        public Enum? Key { get; set; } = default!;
 
         [ViewVariables(VVAccess.ReadWrite)]
         [DataField]
index c904224328181470caa1c6d494b0df9c685ea894..64099c9573edd240947ac88463815436b31b69dd 100644 (file)
@@ -21,7 +21,8 @@ public sealed partial class ActivatableUISystem
         _cell.SetPowerCellDrawEnabled(uid, false);
 
         if (HasComp<ActivatableUIRequiresPowerCellComponent>(uid) &&
-            TryComp<ActivatableUIComponent>(uid, out var activatable))
+            TryComp<ActivatableUIComponent>(uid, out var activatable) &&
+            activatable.Key != null)
         {
             _uiSystem.CloseUi(uid, activatable.Key);
         }
@@ -54,7 +55,7 @@ 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))
+        if (!Resolve(uid, ref component, ref draw, ref active, false) || active.Key == null)
             return;
 
         if (_cell.HasActivatableCharge(uid))
index 452f08c094b24eca829d1d335f8255aa3267f7a6..94271cc681200079fc44f66f5cb0f10e54195cd7 100644 (file)
@@ -136,7 +136,7 @@ public sealed partial class ActivatableUISystem : EntitySystem
 
     private bool InteractUI(EntityUid user, EntityUid uiEntity, ActivatableUIComponent aui)
     {
-        if (!_uiSystem.HasUi(uiEntity, aui.Key))
+        if (aui.Key == null || !_uiSystem.HasUi(uiEntity, aui.Key))
             return false;
 
         if (_uiSystem.IsUiOpen(uiEntity, aui.Key, user))
@@ -205,7 +205,7 @@ public sealed partial class ActivatableUISystem : EntitySystem
 
     public void CloseAll(EntityUid uid, ActivatableUIComponent? aui = null)
     {
-        if (!Resolve(uid, ref aui, false))
+        if (!Resolve(uid, ref aui, false) || aui.Key == null)
             return;
 
         _uiSystem.CloseUi(uid, aui.Key);