Skip to content

Commit

Permalink
Frontier Mail (#1652)
Browse files Browse the repository at this point in the history
* Does all the under the hood changes to mail components before I EVEN start thinking about MailSystem

* Mail Handheld Rapid Parcel Delivery System (#974)

* Mail RPDS

* removed sizes, more items go in capsules

* fixed error

* capsule resprite, added it to service techfab

* Update after upstream merge

* glass

* Update frontier.yml

* tag fix

---------

Co-authored-by: Dvir <dvirf01@gmail.com>

* Mail Buff (#1473)

* MailUp

* Update base_mail.yml

* Update base_mail.yml

* Update MailTeleporterComponent.cs

* Update MailComponent.cs

* Update base_mail.yml

* Update base_mail.yml

* Update Resources/Prototypes/Nyanotrasen/Entities/Objects/Specific/Mail/base_mail.yml

Sure

Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>

---------

Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>

* Mail table rework (#1477)

* Mail table, system for smoke prank

* Format mail messages

* DelayedItemSystem cleanup, more mail table entries

* More mail table entries

* Remove hoverbike from mail pool

* Add large mail.

FIXME: mail_large.rsi has no copyright info

* Default mail isLarge to false, comment cleanup

* More mail types

* Add optional large mail flag to admin mailto cmd

* mail_large copyright

* admin cmd fix, new mail types, const cleanup

* Mail: new components, weighting, a few new items

* Fix merge conflict, add placeholder pipebomb mail

* Format mail text, separate sword mail from knives

* Mail: fix exp. welder ID, split up Dan's cigs

* Fourth muffin, decrease captain's sabre chance

* yaml fixes

* Add ShowJobIcons component to mail hud

* Reorganize mail items, add build-a-buddy mail

* Build-a-Buddy fixes, slime & vulp versions, text

* Reptillian->Reptilian

* More signatures, label necrosol bottle, bigger emp

* lowercase i

* extra premium cigars, premium liquors

* Cleanup

* Fixups And Edits

* Remove kendo hakama, jabroni comment, fix cigars

* Platinum cigars, fix sprites

* fix premium absinthe ID

* Remove cyberpen, add BibleUserImplanter, ATV mail

Also adjusts weights for TacticalMaid (missing a zero), Restraints (cut
in half)

* kendo mail order, more mail comments

* Remove Nyano mail lists & parcels, move into _NF/

* True to true, cigars aren't fragile

---------

Co-authored-by: Dvir <dvirf01@gmail.com>
Co-authored-by: Whatstone <whatstone3@gmail.com>

* Kills accidentally cherrypicked platinum cig, makes mail be sorted into 5 ymls again

* THE MAIL TABLE!!!!! AHHHHHHHHHHHHHHHHHHHH

* NUKES two UNNECCESSARY RANDOMLY PASTED BRACKETS

FUCK YOU BUILD ERROR !!! EAT SHIT

* a semicolon for good measure

Adei versus the one silly

* Fuck is this? Why is it in my mail?

* Pro forgot values for two of the engineering mails

:skull:

* First pass to fix various mail bugs + editing of papers

* obliterates a random S in a C# file, also returns the mail teleporter to how it was

* Nukes the platinum cigar's YAML

Since there's no intent for it to spawn in the mail, might as well.

* Milon's Review

Does some shit to the mail / courierdrobe and gets rid of string keys. Thanks Milon

* Milon's Review 2, Electric Boogaloo

* Various YAML fixes as I try to satisfy the Linter and fail

* Fixes Mail.yml / If I get rid of the EMP china lake does it fix things? Let's find out!

* Cleans up more C# at Milon's behest

* TORTUGAAAAAAAAAAAAAAAAAAAA!!!!

Why is this mapped in?

* Revert "TORTUGAAAAAAAAAAAAAAAAAAAA!!!!"

This reverts commit b1d415a.

* Migrations

* Does a bit more fixing

* Update Resources/Locale/en-US/_NF/mail/mail.ftl

Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
Signed-off-by: Adeinitas <147965189+adeinitas@users.noreply.github.com>

* Update Resources/Locale/en-US/nyanotrasen/Mail/mail.ftl

Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
Signed-off-by: Adeinitas <147965189+adeinitas@users.noreply.github.com>

* Fixes Mail Capsule / Creates frontierMigrations

Blame Velcro for frontierMigrations.

* Update Resources/Migrations/deltaMigrations.yml

Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
Signed-off-by: Adeinitas <147965189+adeinitas@users.noreply.github.com>

* Rewords that one fucking comment I made 2 months ago about MIT / AGPL

* Just gives the delayed smoke prank and delayed EMP effects the instant effect sprites

* Where the fuck are these random curly braces from??

* An attempt to satisfy the Yaml Linter

* Revert "Update Resources/Locale/en-US/nyanotrasen/Mail/mail.ftl"

This reverts commit 0ee3869.

* Revert "Update Resources/Locale/en-US/_NF/mail/mail.ftl"

This reverts commit 29129df.

* Mail FTL fixes / I think I know what the linter wants

* will this sprite be valid pretty please?

* Does a first pass on noSpawn for all mails.

ANOTHER COMMIT FOR THE PILE.

* Unfucks noSpawn from the mail prototypes

---------

Signed-off-by: Adeinitas <147965189+adeinitas@users.noreply.github.com>
Co-authored-by: ErhardSteinhauer <65374927+ErhardSteinhauer@users.noreply.github.com>
Co-authored-by: Dvir <dvirf01@gmail.com>
Co-authored-by: Dvir <39403717+dvir001@users.noreply.github.com>
Co-authored-by: Whatstone <166147148+whatston3@users.noreply.github.com>
Co-authored-by: Whatstone <whatstone3@gmail.com>
Co-authored-by: Danger Revolution! <142105406+DangerRevolution@users.noreply.github.com>
  • Loading branch information
7 people authored Sep 2, 2024
1 parent 14e6342 commit 952f368
Show file tree
Hide file tree
Showing 57 changed files with 3,481 additions and 1,003 deletions.
35 changes: 20 additions & 15 deletions Content.Server/Nyanotrasen/Mail/Components/MailComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ namespace Content.Server.Mail.Components
[RegisterComponent]
public sealed partial class MailComponent : SharedMailComponent
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("recipient")]
[DataField]
public string Recipient = "None";

[ViewVariables(VVAccess.ReadWrite)]
[DataField("recipientJob")]
[DataField]
public string RecipientJob = "None";

// Why do we not use LockComponent?
// Because this can't be locked again,
// and we have special conditions for unlocking,
// and we don't want to add a verb.
[ViewVariables(VVAccess.ReadWrite)]
[DataField("isLocked")]
[DataField]
public bool IsLocked = true;

/// <summary>
Expand All @@ -32,7 +29,7 @@ public sealed partial class MailComponent : SharedMailComponent
/// This is useful for broken fragile packages and packages that were
/// not delivered in time.
/// </remarks>
[DataField("isProfitable")]
[DataField]
public bool IsProfitable = true;

/// <summary>
Expand All @@ -42,7 +39,7 @@ public sealed partial class MailComponent : SharedMailComponent
/// This can be set to true in the YAML files for a mail delivery to
/// always be Fragile, despite its contents.
/// </remarks>
[DataField("isFragile")]
[DataField]
public bool IsFragile = false;

/// <summary>
Expand All @@ -58,43 +55,51 @@ public sealed partial class MailComponent : SharedMailComponent
/// This can be set to true in the YAML files for a mail delivery to
/// always be Priority.
/// </remarks>
[DataField("isPriority")]
[DataField]
public bool IsPriority = false;

// Frontier Mail Port: large mail
/// <summary>
/// Whether this parcel is large.
/// </summary>
[DataField]
public bool IsLarge = false;
// End Frontier: large mail

/// <summary>
/// What will be packaged when the mail is spawned.
/// </summary>
[DataField("contents")]
[DataField]
public List<EntitySpawnEntry> Contents = new();

/// <summary>
/// The amount that cargo will be awarded for delivering this mail.
/// </summary>
[DataField("bounty")]
[DataField]
public int Bounty = 750;

/// <summary>
/// Penalty if the mail is destroyed.
/// </summary>
[DataField("penalty")]
[DataField]
public int Penalty = -250;

/// <summary>
/// The sound that's played when the mail's lock is broken.
/// </summary>
[DataField("penaltySound")]
[DataField]
public SoundSpecifier PenaltySound = new SoundPathSpecifier("/Audio/Machines/Nuke/angry_beep.ogg");

/// <summary>
/// The sound that's played when the mail's opened.
/// </summary>
[DataField("openSound")]
[DataField]
public SoundSpecifier OpenSound = new SoundPathSpecifier("/Audio/Effects/packetrip.ogg");

/// <summary>
/// The sound that's played when the mail's lock has been emagged.
/// </summary>
[DataField("emagSound")]
[DataField]
public SoundSpecifier EmagSound = new SoundCollectionSpecifier("sparks");

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public sealed partial class MailTeleporterComponent : Component
/// The MailDeliveryPoolPrototype that's used to select what mail this
/// teleporter can deliver.
/// </summary>
[DataField("mailPool")]
public string MailPool = "RandomMailDeliveryPool";
[DataField]
public string MailPool = "RandomDeltaVMailDeliveryPool"; // Frontier / DeltaV: Mail rework

/// <summary>
/// How many mail candidates do we need per actual delivery sent when
Expand Down Expand Up @@ -102,7 +102,21 @@ public sealed partial class MailTeleporterComponent : Component
/// <summary>
/// What's the malus for failing to deliver a priority package?
/// </summary>
[DataField("priorityMalus")]
[DataField]
public int PriorityMalus = -250;

// Frontier: Large mail
/// <summary>
/// What's the bonus for delivering a large package intact?
/// </summary>
[DataField]
public int LargeBonus = 1500; //DeltaV; 5000 to 1500

/// <summary>
/// What's the malus for failing to deliver a large package?
/// </summary>
[DataField]
public int LargeMalus = -500; //DeltaV; -250 to -500
// End Frontier: Large mail
}
}
20 changes: 16 additions & 4 deletions Content.Server/Nyanotrasen/Mail/MailCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public sealed class MailToCommand : IConsoleCommand
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;

private readonly string _blankMailPrototype = "MailAdminFun";
private readonly string _blankLargeMailPrototype = "MailLargeAdminFun"; // Frontier: large mail
private readonly string _container = "storagebase";
private readonly string _mailContainer = "contents";

Expand Down Expand Up @@ -56,6 +57,16 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

// Frontier: Large Mail
bool isLarge = false;
if (args.Length > 4 && !Boolean.TryParse(args[4], out isLarge))
{
shell.WriteError(Loc.GetString("shell-invalid-bool"));
return;
}
var mailPrototype = isLarge ? _blankLargeMailPrototype : _blankMailPrototype;
// End Frontier


var _mailSystem = _entitySystemManager.GetEntitySystem<MailSystem>();
var _containerSystem = _entitySystemManager.GetEntitySystem<SharedContainerSystem>();
Expand All @@ -66,9 +77,9 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

if (!_prototypeManager.HasIndex<EntityPrototype>(_blankMailPrototype))
if (!_prototypeManager.HasIndex<EntityPrototype>(mailPrototype)) // Frontier: _blankMailPrototype<mailPrototype
{
shell.WriteLine(Loc.GetString("command-mailto-no-blankmail", ("blankMail", _blankMailPrototype)));
shell.WriteLine(Loc.GetString("command-mailto-no-blankmail", ("blankMail", mailPrototype))); // Frontier: _blankMailPrototype<mailPrototype
return;
}

Expand All @@ -90,12 +101,12 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)
return;
}

var mailUid = _entityManager.SpawnEntity(_blankMailPrototype, _entityManager.GetComponent<TransformComponent>(containerUid).Coordinates);
var mailUid = _entityManager.SpawnEntity(mailPrototype, _entityManager.GetComponent<TransformComponent>(containerUid).Coordinates); // Frontier: _blankMailPrototype<mailPrototype
var mailContents = _containerSystem.EnsureContainer<Container>(mailUid, _mailContainer);

if (!_entityManager.TryGetComponent(mailUid, out MailComponent? mailComponent))
{
shell.WriteLine(Loc.GetString("command-mailto-bogus-mail", ("blankMail", _blankMailPrototype), ("requiredMailComponent", nameof(MailComponent))));
shell.WriteLine(Loc.GetString("command-mailto-bogus-mail", ("blankMail", mailPrototype), ("requiredMailComponent", nameof(MailComponent)))); // Frontier: _blankMailPrototype<mailPrototype
return;
}

Expand All @@ -104,6 +115,7 @@ public async void Execute(IConsoleShell shell, string argStr, string[] args)

mailComponent.IsFragile = isFragile;
mailComponent.IsPriority = isPriority;
mailComponent.IsLarge = isLarge; //Frontier Mail

_mailSystem.SetupMail(mailUid, teleporterComponent, recipient.Value);

Expand Down
18 changes: 15 additions & 3 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,14 @@ private void OnAfterInteractUsing(EntityUid uid, MailComponent component, AfterI

private void OnExamined(EntityUid uid, MailComponent component, ExaminedEvent args)
{
MailEntityStrings mailEntityStrings = component.IsLarge ? MailConstants.MailLarge : MailConstants.Mail; //Frontier: mail types stored per type (large mail)
if (!args.IsInDetailsRange)
{
args.PushMarkup(Loc.GetString("mail-desc-far"));
args.PushMarkup(Loc.GetString(mailEntityStrings.DescFar)); // Frontier: mail constants struct
return;
}

args.PushMarkup(Loc.GetString("mail-desc-close", ("name", component.Recipient), ("job", component.RecipientJob)));
args.PushMarkup(Loc.GetString(mailEntityStrings.DescClose, ("name", component.Recipient), ("job", component.RecipientJob))); // Frontier: mail constants struct

if (component.IsFragile)
args.PushMarkup(Loc.GetString("mail-desc-fragile"));
Expand Down Expand Up @@ -501,6 +502,15 @@ public void SetupMail(EntityUid uid, MailTeleporterComponent component, MailReci
mailComp.RecipientJob = recipient.Job;
mailComp.Recipient = recipient.Name;

// Frontier: Large mail bonus
MailEntityStrings mailEntityStrings = mailComp.IsLarge ? MailConstants.MailLarge : MailConstants.Mail;
if (mailComp.IsLarge)
{
mailComp.Bounty += component.LargeBonus;
mailComp.Penalty += component.LargeMalus;
}
// End Frontier

if (mailComp.IsFragile)
{
mailComp.Bounty += component.FragileBonus;
Expand Down Expand Up @@ -534,7 +544,7 @@ public void SetupMail(EntityUid uid, MailTeleporterComponent component, MailReci

_appearanceSystem.SetData(uid, MailVisuals.JobIcon, recipient.JobIcon);

_metaDataSystem.SetEntityName(uid, Loc.GetString("mail-item-name-addressed",
_metaDataSystem.SetEntityName(uid, Loc.GetString(mailEntityStrings.NameAddressed, // Frontier: move constant to MailEntityString
("recipient", recipient.Name)));

var accessReader = EnsureComp<AccessReaderComponent>(uid);
Expand Down Expand Up @@ -713,6 +723,8 @@ public void SpawnMail(EntityUid uid, MailTeleporterComponent? component = null)

var mail = EntityManager.SpawnEntity(chosenParcel, Transform(uid).Coordinates);
SetupMail(mail, component, candidate);

_tagSystem.AddTag(mail, "Mail"); // Frontier
}

if (_containerSystem.TryGetContainer(uid, "queued", out var queued))
Expand Down
16 changes: 16 additions & 0 deletions Content.Server/_NF/Mail/DelayedItemComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Content.Server.Mail
{
/// <summary>
/// A placeholder for another entity, spawned when dropped or placed in someone's hands.
/// Useful for storing instant effect entities, e.g. smoke, in the mail.
/// </summary>
[RegisterComponent]
public sealed partial class DelayedItemComponent : Component
{
/// <summary>
/// The entity to replace this when opened or dropped.
/// </summary>
[DataField]
public string Item = "None";
}
}
56 changes: 56 additions & 0 deletions Content.Server/_NF/Mail/DelayedItemSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared.Damage;
using Content.Shared.Hands;
using Robust.Shared.Containers;

namespace Content.Server.Mail
{
/// <summary>
/// A placeholder for another entity, spawned when taken out of a container, with the placeholder deleted shortly after.
/// Useful for storing instant effect entities, e.g. smoke, in the mail.
/// </summary>
public sealed class DelayedItemSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DelayedItemComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<DelayedItemComponent, GotEquippedHandEvent>(OnHandEquipped);
SubscribeLocalEvent<DelayedItemComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<DelayedItemComponent, EntGotRemovedFromContainerMessage>(OnRemovedFromContainer);
}

/// <summary>
/// EntGotRemovedFromContainerMessage handler - spawn the intended entity after removed from a container.
/// </summary>
private void OnRemovedFromContainer(EntityUid uid, DelayedItemComponent component, ContainerModifiedMessage args)
{
Spawn(component.Item, Transform(uid).Coordinates);
}

/// <summary>
/// GotEquippedHandEvent handler - destroy the placeholder.
/// </summary>
private void OnHandEquipped(EntityUid uid, DelayedItemComponent component, EquippedHandEvent args)
{
EntityManager.DeleteEntity(uid);
}

/// <summary>
/// OnDropAttempt handler - destroy the placeholder.
/// </summary>
private void OnDropAttempt(EntityUid uid, DelayedItemComponent component, DropAttemptEvent args)
{
EntityManager.DeleteEntity(uid);
}

/// <summary>
/// OnDamageChanged handler - item has taken damage (e.g. inside the envelope), spawn the intended entity outside of any container and delete the placeholder.
/// </summary>
private void OnDamageChanged(EntityUid uid, DelayedItemComponent component, DamageChangedEvent args)
{
Spawn(component.Item, Transform(uid).Coordinates);
EntityManager.DeleteEntity(uid);
}
}
}
38 changes: 38 additions & 0 deletions Content.Server/_NF/Mail/MailConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Content.Server.Mail
{
/// <summary>
/// A set of localized strings related to mail entities
/// </summary>
public struct MailEntityStrings
{
public string NameAddressed;
public string DescClose;
public string DescFar;
}

/// <summary>
/// Constants related to mail.
/// </summary>
public sealed class MailConstants : EntitySystem
{
/// <summary>
/// Locale strings related to small parcels.
/// <summary>
public static readonly MailEntityStrings Mail = new()
{
NameAddressed = "mail-item-name-addressed",
DescClose = "mail-desc-close",
DescFar = "mail-desc-far"
};

/// <summary>
/// Locale strings related to large packages.
/// <summary>
public static readonly MailEntityStrings MailLarge = new()
{
NameAddressed = "mail-large-item-name-addressed",
DescClose = "mail-large-desc-close",
DescFar = "mail-large-desc-far"
};
}
}
9 changes: 9 additions & 0 deletions Resources/Locale/en-US/_NF/mail/mail.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mail-large-item-name-unaddressed = package
mail-large-item-name-addressed = package ({$recipient})
mail-large-desc-far = A large package.
mail-large-desc-close = A large package addressed to {CAPITALIZE($name)}, {$job}. Last known location: {$station}.
### Frontier: mailtestbulk
command-mailtestbulk = Sends one of each type of parcel to a given mail teleporter. Implicitly calls mailnow.
command-mailtestbulk-help = Usage: {$command} <teleporter_id>
command-mailtestbulk-success = Success! All mail teleporters will be delivering another round of mail soon.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ mail-desc-priority = The anti-tamper lock's [color=yellow]yellow priority tape[/
mail-desc-priority-inactive = The anti-tamper lock's [color=#886600]yellow priority tape[/color] is inactive.
mail-unlocked = Anti-tamper system unlocked.
mail-unlocked-by-emag = Anti-tamper system *BZZT*.
mail-unlocked-reward = Anti-tamper system unlocked. {$bounty} spesos have been added to logistics's account.
mail-penalty-lock = ANTI-TAMPER LOCK BROKEN. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} CREDITS.
mail-penalty-fragile = INTEGRITY COMPROMISED. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} CREDITS.
mail-penalty-expired = DELIVERY PAST DUE. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} CREDITS.
mail-unlocked-reward = Anti-tamper system unlocked. {$bounty} spesos have been added to logistics' account.
mail-penalty-lock = ANTI-TAMPER LOCK BROKEN. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} SPESOS.
mail-penalty-fragile = INTEGRITY COMPROMISED. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} SPESOS.
mail-penalty-expired = DELIVERY PAST DUE. LOGISTICS BANK ACCOUNT PENALIZED BY {$credits} SPESOS.
mail-item-name-unaddressed = mail
mail-item-name-addressed = mail ({$recipient})
command-mailto-description = Queue a parcel to be delivered to an entity. Example usage: `mailto 1234 5678 false false`. The target container's contents will be transferred to an actual mail parcel.
command-mailto-help = Usage: {$command} <recipient entityUid> <container entityUid> [is-fragile: true or false] [is-priority: true or false]
### Frontier: add is-large description
command-mailto-help = Usage: {$command} <recipient entityUid> <container entityUid> [is-fragile: true or false] [is-priority: true or false] [is-large: true or false, optional]
command-mailto-no-mailreceiver = Target recipient entity does not have a {$requiredComponent}.
command-mailto-no-blankmail = The {$blankMail} prototype doesn't exist. Something is very wrong. Contact a programmer.
command-mailto-bogus-mail = {$blankMail} did not have {$requiredMailComponent}. Something is very wrong. Contact a programmer.
Expand Down
2 changes: 2 additions & 0 deletions Resources/Migrations/frontierMigrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 2024-08-22 - Frontier Mail - Add more to these when they come up as mapped. Part of the Frontier Mail port, blame Tortuga.
MailPAI: MailNFPAI
Loading

0 comments on commit 952f368

Please sign in to comment.