]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix inconsistent borg flashlight state (#33027)
authoreoineoineoin <github@eoinrul.es>
Thu, 16 Jan 2025 10:34:11 +0000 (10:34 +0000)
committerGitHub <noreply@github.com>
Thu, 16 Jan 2025 10:34:11 +0000 (11:34 +0100)
* Fix borg light being stuck on if no cell is inserted

* Fix HandheldLightComponent.Activted becoming out of sync with SharedPointLightComponent.Enabled

* Fix for entities which don't have a handheld light component

Content.Server/Silicons/Borgs/BorgSystem.cs
Content.Shared/Light/EntitySystems/ItemTogglePointLightSystem.cs

index 5b4b0c08ca716a317e1220e662de82961e8b6bcf..99bd3813216211d613714114e96b204ca1fc349d 100644 (file)
@@ -293,8 +293,11 @@ public sealed partial class BorgSystem : SharedBorgSystem
     public void BorgActivate(EntityUid uid, BorgChassisComponent component)
     {
         Popup.PopupEntity(Loc.GetString("borg-mind-added", ("name", Identity.Name(uid, EntityManager))), uid);
-        Toggle.TryActivate(uid);
-        _powerCell.SetDrawEnabled(uid, _mobState.IsAlive(uid));
+        if (_powerCell.HasDrawCharge(uid))
+        {
+            Toggle.TryActivate(uid);
+            _powerCell.SetDrawEnabled(uid, _mobState.IsAlive(uid));
+        }
         _appearance.SetData(uid, BorgVisuals.HasPlayer, true);
     }
 
index 7030c538c1d6a49783e5624d9c3a761bbe979d7c..e2ed6cfcc2c117823783dd1f5664000f29e87d64 100644 (file)
@@ -1,4 +1,5 @@
 using Content.Shared.Item.ItemToggle.Components;
+using Content.Shared.Light.Components;
 using Content.Shared.Toggleable;
 using ItemTogglePointLightComponent = Content.Shared.Light.Components.ItemTogglePointLightComponent;
 
@@ -11,6 +12,7 @@ public sealed class ItemTogglePointLightSystem : EntitySystem
 {
     [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
     [Dependency] private readonly SharedPointLightSystem _light = default!;
+    [Dependency] private readonly SharedHandheldLightSystem _handheldLight = default!;
 
     public override void Initialize()
     {
@@ -25,5 +27,9 @@ public sealed class ItemTogglePointLightSystem : EntitySystem
 
         _appearance.SetData(ent, ToggleableLightVisuals.Enabled, args.Activated);
         _light.SetEnabled(ent.Owner, args.Activated, comp: light);
+        if (TryComp<HandheldLightComponent>(ent.Owner, out var handheldLight))
+        {
+            _handheldLight.SetActivated(ent.Owner, args.Activated, handheldLight);
+        }
     }
 }