mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
<!-- 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>   </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)
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using System.Linq;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Shared.BarSign;
|
|
|
|
public sealed class BarSignSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly MetaDataSystem _metaData = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<BarSignComponent, MapInitEvent>(OnMapInit);
|
|
Subs.BuiEvents<BarSignComponent>(BarSignUiKey.Key,
|
|
subs =>
|
|
{
|
|
subs.Event<SetBarSignMessage>(OnSetBarSignMessage);
|
|
});
|
|
}
|
|
|
|
private void OnMapInit(Entity<BarSignComponent> ent, ref MapInitEvent args)
|
|
{
|
|
if (ent.Comp.Current != null)
|
|
return;
|
|
|
|
var newPrototype = _random.Pick(GetAllBarSigns(_prototypeManager));
|
|
SetBarSign(ent, newPrototype);
|
|
}
|
|
|
|
private void OnSetBarSignMessage(Entity<BarSignComponent> ent, ref SetBarSignMessage args)
|
|
{
|
|
if (!_prototypeManager.TryIndex(args.Sign, out var signPrototype))
|
|
return;
|
|
|
|
SetBarSign(ent, signPrototype);
|
|
}
|
|
|
|
public void SetBarSign(Entity<BarSignComponent> ent, BarSignPrototype newPrototype)
|
|
{
|
|
var meta = MetaData(ent);
|
|
var name = Loc.GetString(newPrototype.Name);
|
|
_metaData.SetEntityName(ent, name, meta);
|
|
_metaData.SetEntityDescription(ent, Loc.GetString(newPrototype.Description), meta);
|
|
|
|
ent.Comp.Current = newPrototype.ID;
|
|
Dirty(ent);
|
|
}
|
|
|
|
public static List<BarSignPrototype> GetAllBarSigns(IPrototypeManager prototypeManager)
|
|
{
|
|
return prototypeManager
|
|
.EnumeratePrototypes<BarSignPrototype>()
|
|
.Where(p => !p.Hidden)
|
|
.ToList();
|
|
}
|
|
}
|