Files
wwdpublic/Content.Client/BarSign/BarSignSystem.cs
Will-Oliver-Br e30bdfc1de Port Bar Signs Selection (#1971)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

port bar sings selection, as well as corrections for the same from
wizards.
prs:
https://github.com/space-wizards/space-station-14/pull/29068
https://github.com/space-wizards/space-station-14/pull/33467
https://github.com/space-wizards/space-station-14/pull/35490
https://github.com/space-wizards/space-station-14/pull/31517
https://github.com/space-wizards/space-station-14/pull/35296

---

# TODO

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [x] Task
- [x] Completed Task

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

![Captura de tela 2025-03-15
172158](https://github.com/user-attachments/assets/5285d9fd-ccc8-4b1a-95bd-c81a740d2458)
![Captura de tela 2025-03-15
172211](https://github.com/user-attachments/assets/86155504-e909-4055-9502-3b1550664475)

</p>
</details>

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑 EmoGarbage404, Winkarst-cpu, robinthedragon, spderman3333, lzk228
and Will-Oliver-Br
- add: The design on the bar sign can now be changed via a menu.
- add: Bar signs now have a maintenance panel and AI can interact with
them.
- add: New barsign Maltroach (based on sign by MoffNyan, from tgstation)
- tweak: Electronic bar signs can now be destroyed.
- fix: Fix stray pixel in officer beersky barsign

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.com>
Co-authored-by: Winkarst <74284083+Winkarst-cpu@users.noreply.github.co>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: spderman3333 <118777573+spderman3333@users.noreply.github.com>
Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com>
Co-authored-by: robinthedragon <92946919+robinthedragon@users.noreply.github.com>
(cherry picked from commit 7f00e12904dee186ca356c8df3a8577b6c8d8ceb)
2025-03-21 16:56:33 +03:00

54 lines
1.8 KiB
C#

using Content.Client.BarSign.Ui;
using Content.Shared.BarSign;
using Content.Shared.Power;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client.BarSign;
public sealed class BarSignSystem : VisualizerSystem<BarSignComponent>
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BarSignComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState);
}
private void OnAfterAutoHandleState(EntityUid uid, BarSignComponent component, ref AfterAutoHandleStateEvent args)
{
if (_ui.TryGetOpenUi<BarSignBoundUserInterface>(uid, BarSignUiKey.Key, out var bui))
bui.Update(component.Current);
UpdateAppearance(uid, component);
}
protected override void OnAppearanceChange(EntityUid uid, BarSignComponent component, ref AppearanceChangeEvent args)
{
UpdateAppearance(uid, component, args.Component, args.Sprite);
}
private void UpdateAppearance(EntityUid id, BarSignComponent sign, AppearanceComponent? appearance = null, SpriteComponent? sprite = null)
{
if (!Resolve(id, ref appearance, ref sprite))
return;
AppearanceSystem.TryGetData<bool>(id, PowerDeviceVisuals.Powered, out var powered, appearance);
if (powered
&& sign.Current != null
&& _prototypeManager.TryIndex(sign.Current, out var proto))
{
sprite.LayerSetSprite(0, proto.Icon);
sprite.LayerSetShader(0, "unshaded");
}
else
{
sprite.LayerSetState(0, "empty");
sprite.LayerSetShader(0, null, null);
}
}
}