Files
wwdpublic/Content.Server/Thief/Systems/ThiefBeaconSystem.cs
Lumminal 3aaaac7c06 [PORT] Thief Beacon (#2447)
# Description

Ports thieving beacon.

PRs ported:
https://github.com/space-wizards/space-station-14/pull/29997
https://github.com/space-wizards/space-station-14/pull/34430
https://github.com/space-wizards/space-station-14/pull/33750
https://github.com/space-wizards/space-station-14/pull/32764

<!--
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>



https://github.com/user-attachments/assets/a25836d0-7d1c-47fb-b284-762e20ce1299



</p>
</details>

---

# Changelog

🆑 TheShuEd, sporkyz, ReeZer2, Alpha-Two
- add: Ported thieving beacon from wizden. Have fun stealing pets now!

---------

Co-authored-by: Ed <96445749+TheShuEd@users.noreply.github.com>
Co-authored-by: John <35928781+sporkyz@users.noreply.github.com>
Co-authored-by: ReeZer2 <63300653+ReeZer2@users.noreply.github.com>
Co-authored-by: Alpha-Two <92269094+Alpha-Two@users.noreply.github.com>
2025-07-12 12:30:27 +10:00

98 lines
3.2 KiB
C#

using Content.Server.Mind;
using Content.Server.Objectives.Components;
using Content.Server.Roles;
using Content.Server.Thief.Components;
using Content.Shared.Examine;
using Content.Shared.Foldable;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Content.Shared.Roles;
using Robust.Shared.Audio.Systems;
namespace Content.Server.Thief.Systems;
/// <summary>
/// <see cref="ThiefBeaconComponent"/>
/// </summary>
public sealed class ThiefBeaconSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly SharedRoleSystem _roles = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ThiefBeaconComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
SubscribeLocalEvent<ThiefBeaconComponent, FoldedEvent>(OnFolded);
SubscribeLocalEvent<ThiefBeaconComponent, ExaminedEvent>(OnExamined);
}
private void OnGetInteractionVerbs(Entity<ThiefBeaconComponent> beacon, ref GetVerbsEvent<InteractionVerb> args)
{
if (!args.CanAccess || !args.CanInteract || args.Hands is null)
return;
if (TryComp<FoldableComponent>(beacon, out var foldable) && foldable.IsFolded)
return;
var mind = _mind.GetMind(args.User);
if (mind == null || !_roles.MindHasRole<ThiefRoleComponent>(mind.Value))
return;
var user = args.User;
args.Verbs.Add(new()
{
Act = () =>
{
SetCoordinate(beacon, mind.Value);
},
Message = Loc.GetString("thief-fulton-verb-message"),
Text = Loc.GetString("thief-fulton-verb-text"),
});
}
private void OnFolded(Entity<ThiefBeaconComponent> beacon, ref FoldedEvent args)
{
if (args.IsFolded)
ClearCoordinate(beacon);
}
private void OnExamined(Entity<ThiefBeaconComponent> beacon, ref ExaminedEvent args)
{
if (!TryComp<StealAreaComponent>(beacon, out var area))
return;
args.PushText(Loc.GetString(area.Owners.Count == 0
? "thief-fulton-examined-unset"
: "thief-fulton-examined-set"));
}
private void SetCoordinate(Entity<ThiefBeaconComponent> beacon, EntityUid mind)
{
if (!TryComp<StealAreaComponent>(beacon, out var area))
return;
_audio.PlayPvs(beacon.Comp.LinkSound, beacon);
_popup.PopupEntity(Loc.GetString("thief-fulton-set"), beacon);
area.Owners.Clear(); //We only reconfigure the beacon for ourselves, we don't need multiple thieves to steal from the same beacon.
area.Owners.Add(mind);
}
private void ClearCoordinate(Entity<ThiefBeaconComponent> beacon)
{
if (!TryComp<StealAreaComponent>(beacon, out var area))
return;
if (area.Owners.Count == 0)
return;
_audio.PlayPvs(beacon.Comp.UnlinkSound, beacon);
_popup.PopupEntity(Loc.GetString("thief-fulton-clear"), beacon);
area.Owners.Clear();
}
}