Skip to content

Commit

Permalink
Smuggling Changes (#715)
Browse files Browse the repository at this point in the history
* smuggling admin logs and report change

* cleanup

* comments

* one more detail for admins
  • Loading branch information
Cheackraze authored Dec 17, 2023
1 parent ed58b43 commit 8f90e57
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Content.Server/_NF/Smuggling/DeadDropSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Text;
using Content.Server._NF.Smuggling.Components;
using Content.Server.Administration.Logs;
using Content.Server.Paper;
using Content.Server.Radio.EntitySystems;
using Content.Server.Shipyard.Systems;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Radio;
Expand All @@ -21,6 +23,7 @@ namespace Content.Server._NF.Smuggling;

public sealed class DeadDropSystem : EntitySystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly MapLoaderSystem _map = default!;
[Dependency] private readonly MetaDataSystem _meta = default!;
Expand All @@ -41,13 +44,16 @@ public override void Initialize()

private void OnStartup(EntityUid paintingUid, DeadDropComponent component, ComponentStartup _)
{
//set up the timing of the first activation
component.NextDrop = _timing.CurTime + TimeSpan.FromSeconds(_random.Next(component.MinimumCoolDown, component.MaximumCoolDown));
}

private void AddSearchVerb(EntityUid uid, DeadDropComponent component, GetVerbsEvent<InteractionVerb> args)
{
if (!args.CanInteract || !args.CanAccess || args.Hands == null || _timing.CurTime < component.NextDrop)
return;

//here we build our dynamic verb. Using the object's sprite for now to make it more dynamic for the moment.
InteractionVerb searchVerb = new()
{
IconEntity = GetNetEntity(uid),
Expand All @@ -59,12 +65,14 @@ private void AddSearchVerb(EntityUid uid, DeadDropComponent component, GetVerbsE
args.Verbs.Add(searchVerb);
}

//spawning the dead drop.
private void SendDeadDrop(EntityUid uid, DeadDropComponent component, EntityUid user, HandsComponent hands)
{
//simple check to make sure we dont allow multiple activations from a desynced verb window.
if (_timing.CurTime < component.NextDrop)
return;


//relying entirely on shipyard capabilities, including using the shipyard map to spawn the items and ftl to bring em in
if (_shipyard.ShipyardMap is not MapId shipyardMap)
return;

Expand All @@ -73,12 +81,16 @@ private void SendDeadDrop(EntityUid uid, DeadDropComponent component, EntityUid
LoadMap = false,
};

//load whatever grid was specified on the component, either a special dead drop or default
if (!_map.TryLoad(shipyardMap, component.DropGrid, out var gridUids, options))
return;

//setup the radar properties
_shuttle.SetIFFColor(gridUids[0], component.Color);
_shuttle.AddIFFFlag(gridUids[0], IFFFlags.HideLabel);

//this is where we set up all the information that FTL is going to need, including a new null entitiy as a destination target because FTL needs it for reasons?
//dont ask me im just fulfilling FTL requirements.
var dropLocation = _random.NextVector2(component.MinimumDistance, component.MaximumDistance);
var mapId = Transform(user).MapID;
var coords = new MapCoordinates(dropLocation, mapId);
Expand All @@ -89,23 +101,29 @@ private void SendDeadDrop(EntityUid uid, DeadDropComponent component, EntityUid
_shuttle.FTLTravel(gridUids[0], shuttle, location, 5.5f, 35f);
}

//tattle on the smuggler here, but obfuscate it a bit if possible to just the grid it was summoned from.
var channel = _prototypeManager.Index<RadioChannelPrototype>("Security");
_radio.SendRadioMessage(uid, Loc.GetString("deaddrop-security-report"), channel, uid);
var sender = Transform(user).GridUid ?? uid;

var dropHint = new StringBuilder();
_radio.SendRadioMessage(sender, Loc.GetString("deaddrop-security-report"), channel, uid);
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user)} sent a dead drop to {dropLocation.ToString()} from {ToPrettyString(uid)} at {Transform(uid).Coordinates.ToString()}");

// here we are just building a string for the hint paper so that it looks pretty and RP-like on the paper itself.
var dropHint = new StringBuilder();
dropHint.AppendLine(Loc.GetString("deaddrop-hint-pretext"));
dropHint.AppendLine();
dropHint.AppendLine(dropLocation.ToString());
dropHint.AppendLine();
dropHint.AppendLine(Loc.GetString("deaddrop-hint-posttext"));

var paper = EntityManager.SpawnEntity(component.HintPaper, Transform(uid).Coordinates);

_paper.SetContent(paper, dropHint.ToString());
_meta.SetEntityName(paper, Loc.GetString("deaddrop-hint-name"));
_meta.SetEntityDescription(paper, Loc.GetString("deaddrop-hint-desc"));
_hands.PickupOrDrop(user, paper, handsComp: hands);

//reset the timer
component.NextDrop = _timing.CurTime + TimeSpan.FromSeconds(_random.Next(component.MinimumCoolDown, component.MaximumCoolDown));
}
}

0 comments on commit 8f90e57

Please sign in to comment.