-using Content.Shared.Interaction.Events;\r
using Content.Shared.Examine;\r
using Content.Shared.Coordinates.Helpers;\r
using Content.Server.Power.Components;\r
using Content.Server.PowerCell;\r
+using Content.Shared.Interaction;\r
\r
namespace Content.Server.Holosign;\r
\r
public sealed class HolosignSystem : EntitySystem\r
{\r
[Dependency] private readonly PowerCellSystem _powerCell = default!;\r
+ [Dependency] private readonly SharedTransformSystem _transform = default!;\r
+\r
\r
public override void Initialize()\r
{\r
base.Initialize();\r
- SubscribeLocalEvent<HolosignProjectorComponent, UseInHandEvent>(OnUse);\r
+ SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);\r
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);\r
}\r
\r
}\r
}\r
\r
- private void OnUse(EntityUid uid, HolosignProjectorComponent component, UseInHandEvent args)\r
+ private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)\r
{\r
- if (args.Handled ||\r
- !_powerCell.TryGetBatteryFromSlot(uid, out var battery) ||\r
- !battery.TryUseCharge(component.ChargeUse))\r
+\r
+ if (args.Handled\r
+ || !args.CanReach // prevent placing out of range\r
+ || !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work\r
+ )\r
return;\r
\r
- // TODO: Too tired to deal\r
- var holo = EntityManager.SpawnEntity(component.SignProto, Transform(args.User).Coordinates.SnapToGrid(EntityManager));\r
- Transform(holo).Anchored = true;\r
+ // places the holographic sign at the click location, snapped to grid.\r
+ // overlapping of the same holo on one tile remains allowed to allow holofan refreshes\r
+ var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));\r
+ var xform = Transform(holoUid);\r
+ if (!xform.Anchored)\r
+ _transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)\r
\r
args.Handled = true;\r
}\r