From: Plykiya <58439124+Plykiya@users.noreply.github.com> Date: Wed, 14 Feb 2024 05:25:59 +0000 (-0800) Subject: Ranged Holosigns (#25120) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=e6c21d66fae707bb3e31663e57ca0901fc200130;p=space-station-14.git Ranged Holosigns (#25120) * Changed holo signs to be ranged and used on click rather than Z. * Updated comments * Failed attempt at ignoring walls * Getting rid of unused libraries --------- Co-authored-by: Plykiya --- diff --git a/Content.Server/Holosign/HolosignSystem.cs b/Content.Server/Holosign/HolosignSystem.cs index f0fc3bbe14..c52272e957 100644 --- a/Content.Server/Holosign/HolosignSystem.cs +++ b/Content.Server/Holosign/HolosignSystem.cs @@ -1,19 +1,21 @@ -using Content.Shared.Interaction.Events; using Content.Shared.Examine; using Content.Shared.Coordinates.Helpers; using Content.Server.Power.Components; using Content.Server.PowerCell; +using Content.Shared.Interaction; namespace Content.Server.Holosign; public sealed class HolosignSystem : EntitySystem { [Dependency] private readonly PowerCellSystem _powerCell = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnUse); + SubscribeLocalEvent(OnBeforeInteract); SubscribeLocalEvent(OnExamine); } @@ -36,16 +38,21 @@ public sealed class HolosignSystem : EntitySystem } } - private void OnUse(EntityUid uid, HolosignProjectorComponent component, UseInHandEvent args) + private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args) { - if (args.Handled || - !_powerCell.TryGetBatteryFromSlot(uid, out var battery) || - !battery.TryUseCharge(component.ChargeUse)) + + if (args.Handled + || !args.CanReach // prevent placing out of range + || !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work + ) return; - // TODO: Too tired to deal - var holo = EntityManager.SpawnEntity(component.SignProto, Transform(args.User).Coordinates.SnapToGrid(EntityManager)); - Transform(holo).Anchored = true; + // places the holographic sign at the click location, snapped to grid. + // overlapping of the same holo on one tile remains allowed to allow holofan refreshes + var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager)); + var xform = Transform(holoUid); + if (!xform.Anchored) + _transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it) args.Handled = true; }