Skip to content

Commit

Permalink
Fix inconsistent borg flashlight state (#33027)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
eoineoineoin authored Jan 16, 2025
1 parent 85b9f91 commit 820517e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Content.Server/Silicons/Borgs/BorgSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,11 @@ private void UpdateBatteryAlert(Entity<BorgChassisComponent> ent, PowerCellSlotC
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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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()
{
Expand All @@ -25,5 +27,9 @@ private void OnLightToggled(Entity<ItemTogglePointLightComponent> ent, ref ItemT

_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);
}
}
}

0 comments on commit 820517e

Please sign in to comment.