Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail table rework #1477

Merged
merged 38 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
af08dd9
Mail table, system for smoke prank
whatston3 Jun 4, 2024
e12821c
Format mail messages
whatston3 Jun 4, 2024
474af17
DelayedItemSystem cleanup, more mail table entries
whatston3 Jun 5, 2024
8871940
More mail table entries
whatston3 Jun 5, 2024
1ac6480
Remove hoverbike from mail pool
whatston3 Jun 6, 2024
77482c3
Add large mail.
whatston3 Jun 6, 2024
5aad04b
Default mail isLarge to false, comment cleanup
whatston3 Jun 6, 2024
8e5cf5b
More mail types
whatston3 Jun 7, 2024
d80711b
Add optional large mail flag to admin mailto cmd
whatston3 Jun 7, 2024
1f3e9a7
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Jun 7, 2024
0248975
mail_large copyright
whatston3 Jun 8, 2024
e956cbb
admin cmd fix, new mail types, const cleanup
whatston3 Jun 8, 2024
9d36fdd
Mail: new components, weighting, a few new items
whatston3 Jun 11, 2024
c0ac4e3
Fix merge conflict, add placeholder pipebomb mail
whatston3 Jun 11, 2024
07f9539
Format mail text, separate sword mail from knives
whatston3 Jun 11, 2024
821589b
Mail: fix exp. welder ID, split up Dan's cigs
whatston3 Jun 11, 2024
2f4d812
Fourth muffin, decrease captain's sabre chance
whatston3 Jun 11, 2024
2e259ba
yaml fixes
whatston3 Jun 11, 2024
89cb636
Add ShowJobIcons component to mail hud
whatston3 Jun 11, 2024
6f17b4a
Reorganize mail items, add build-a-buddy mail
whatston3 Jun 12, 2024
1b33f6f
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
whatston3 Jun 12, 2024
16242c0
Build-a-Buddy fixes, slime & vulp versions, text
whatston3 Jun 12, 2024
efa1cc6
Reptillian->Reptilian
whatston3 Jun 12, 2024
0ca452d
More signatures, label necrosol bottle, bigger emp
whatston3 Jun 12, 2024
9453b88
lowercase i
whatston3 Jun 12, 2024
a19aff2
extra premium cigars, premium liquors
whatston3 Jun 13, 2024
87ff4d2
Cleanup
dvir001 Jun 14, 2024
f95865f
Merge branch '2024-06-03_mail-table' of https://github.com/whatston3/…
dvir001 Jun 14, 2024
cad1b3c
Fixups And Edits
dvir001 Jun 14, 2024
ad23d9d
Merge branch '2024-06-03_mail-table' of https://github.com/whatston3/…
whatston3 Jun 14, 2024
c881627
Remove kendo hakama, jabroni comment, fix cigars
whatston3 Jun 14, 2024
1e8193f
Platinum cigars, fix sprites
whatston3 Jun 14, 2024
eaeb7cf
fix premium absinthe ID
whatston3 Jun 14, 2024
fa3848f
Merge branch 'master' of https://github.com/new-frontiers-14/frontier…
Jun 14, 2024
02eafa2
Remove cyberpen, add BibleUserImplanter, ATV mail
Jun 14, 2024
177c606
kendo mail order, more mail comments
Jun 14, 2024
ae1ead4
Remove Nyano mail lists & parcels, move into _NF/
Jun 14, 2024
4bb2cdd
True to true, cigars aren't fragile
Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Content.Server/Nyanotrasen/Mail/Components/MailComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public sealed partial class MailComponent : SharedMailComponent
[DataField("isPriority")]
public bool IsPriority = false;

// Frontier: large mail
/// <summary>
/// Whether this parcel is large.
/// </summary>
[DataField("isLarge")]
dvir001 marked this conversation as resolved.
Show resolved Hide resolved
public bool IsLarge = false;
// End Frontier: large mail

/// <summary>
/// What will be packaged when the mail is spawned.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed partial class MailTeleporterComponent : Component
/// teleporter can deliver.
/// </summary>
[DataField("mailPool")]
public string MailPool = "RandomMailDeliveryPool";
public string MailPool = "RandomNFMailDeliveryPool"; // Frontier: use our own mail pool (TODO: migrate to frontier.yml instance?)

/// <summary>
/// How many mail candidates do we need per actual delivery sent when
Expand Down Expand Up @@ -104,5 +104,19 @@ public sealed partial class MailTeleporterComponent : Component
/// </summary>
[DataField("priorityMalus")]
public int PriorityMalus = -250;

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

/// <summary>
/// What's the malus for failing to deliver a large package?
/// </summary>
[DataField("largeMalus")]
public int LargeMalus = -250;
// 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;

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

Expand Down
16 changes: 13 additions & 3 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,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), ("station", component.RecipientStation)));
args.PushMarkup(Loc.GetString(mailEntityStrings.DescClose, ("name", component.Recipient), ("job", component.RecipientJob), ("station", component.RecipientStation))); // Frontier: mail constants struct

if (component.IsFragile)
args.PushMarkup(Loc.GetString("mail-desc-fragile"));
Expand Down Expand Up @@ -469,6 +470,15 @@ public void SetupMail(EntityUid uid, MailTeleporterComponent component, MailReci
mailComp.Recipient = recipient.Name;
mailComp.RecipientStation = recipient.Ship; // Frontier

// 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 All @@ -491,7 +501,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
17 changes: 17 additions & 0 deletions Content.Server/_NF/Mail/DelayedItemComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("item")]
dvir001 marked this conversation as resolved.
Show resolved Hide resolved
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"
};
}
}
4 changes: 4 additions & 0 deletions Resources/Locale/en-US/_NF/mail/mail.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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}.
8 changes: 7 additions & 1 deletion Resources/Locale/en-US/nyanotrasen/mail.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ 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 All @@ -29,3 +30,8 @@ command-mailto-success = Success! Mail parcel has been queued for next teleport
command-mailnow = Force all mail teleporters to deliver another round of mail as soon as possible. This will not bypass the undelivered mail limit.
command-mailnow-help = Usage: {$command}
command-mailnow-success = Success! All mail teleporters will be delivering another round of mail soon.

# 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.
1 change: 1 addition & 0 deletions Resources/Prototypes/Nyanotrasen/mailDeliveries.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Frontier: no longer used, look for RandomNFMailDeliveryPool
- type: mailDeliveryPool
id: RandomMailDeliveryPool
everyone:
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/_NF/Entities/Clothing/Eyes/hud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
sprite: _NF/Clothing/Eyes/Hud/mail.rsi
- type: Clothing
sprite: _NF/Clothing/Eyes/Hud/mail.rsi
- type: ShowJobIcons

- type: entity
parent: [ClothingEyesHudMedical, ClothingEyesHudNfsd]
Expand Down
28 changes: 28 additions & 0 deletions Resources/Prototypes/_NF/Entities/Objects/Fun/toys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,31 @@
- type: Sprite
sprite: _NF/Objects/Fun/catplushie.rsi
state: white

# Rubber Throngler.
# Essentially a rubber hammer but with explosion noises and RSI
- type: entity
name: The Throngler
parent: BaseItem
id: ThronglerToy
suffix: Toy
description: Why would you make this?
components:
- type: Sprite
sprite: Objects/Weapons/Melee/Throngler2.rsi
state: icon
- type: StaminaDamageOnHit
damage: 0.8
- type: Appearance
- type: DisarmMalus
malus: 0
- type: MeleeWeapon
wideAnimationRotation: -135
attackRate: 10
damage:
types:
Blunt: 0
soundHit:
path: /Audio/Effects/explosion_small1.ogg
soundNoDamage:
path: /Audio/Effects/explosion_small1.ogg
Loading
Loading