Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into EMP_2
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Aug 3, 2023
2 parents 8ef9940 + c09481b commit 84369db
Show file tree
Hide file tree
Showing 81 changed files with 6,491 additions and 5,095 deletions.
4 changes: 4 additions & 0 deletions Content.Server/Nyanotrasen/Mail/Components/MailComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public sealed class MailComponent : SharedMailComponent
[DataField("recipientJob")]
public string RecipientJob = "None";

[ViewVariables(VVAccess.ReadWrite)]
[DataField("recipientStation")]
public string RecipientStation = "None";

// Why do we not use LockComponent?
// Because this can't be locked again,
// and we have special conditions for unlocking,
Expand Down
35 changes: 30 additions & 5 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationRecords.Systems;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Coordinates;
using Content.Shared.Damage;
using Content.Shared.Emag.Components;
using Content.Shared.Destructible;
Expand Down Expand Up @@ -60,6 +63,7 @@ public sealed class MailSystem : EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly StationRecordsSystem _recordsSystem = default!;

private ISawmill _sawmill = default!;

Expand Down Expand Up @@ -214,7 +218,7 @@ private void OnExamined(EntityUid uid, MailComponent component, ExaminedEvent ar
return;
}

args.PushMarkup(Loc.GetString("mail-desc-close", ("name", component.Recipient), ("job", component.RecipientJob)));
args.PushMarkup(Loc.GetString("mail-desc-close", ("name", component.Recipient), ("job", component.RecipientJob), ("station", component.RecipientStation)));

if (component.IsFragile)
args.PushMarkup(Loc.GetString("mail-desc-fragile"));
Expand Down Expand Up @@ -444,7 +448,7 @@ public void SetupMail(EntityUid uid, MailTeleporterComponent component, MailReci

mailComp.RecipientJob = recipient.Job;
mailComp.Recipient = recipient.Name;

mailComp.RecipientStation = recipient.Ship;
if (mailComp.IsFragile)
{
mailComp.Bounty += component.FragileBonus;
Expand Down Expand Up @@ -536,6 +540,20 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
HashSet<String> accessTags = access.Tags;

var mayReceivePriorityMail = true;
var stationUid = _stationSystem.GetOwningStation(receiver.Owner);
var stationName = string.Empty;
if (stationUid is EntityUid station
&& TryComp<StationDataComponent>(station, out var stationData)
&& _stationSystem.GetLargestGrid(stationData) is EntityUid stationGrid
&& TryName(stationGrid, out var gridName)
&& gridName != null)
{
stationName = gridName;
}
else
{
stationName = "Unknown";
}

if (TryComp<MindContainerComponent>(receiver.Owner, out MindContainerComponent? mind)
&& mind.Mind?.Session == null)
Expand All @@ -546,7 +564,8 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
recipient = new MailRecipient(idCard.FullName,
idCard.JobTitle,
accessTags,
mayReceivePriorityMail);
mayReceivePriorityMail,
stationName);

return true;
}
Expand All @@ -561,12 +580,16 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
public List<MailRecipient> GetMailRecipientCandidates(EntityUid uid)
{
List<MailRecipient> candidateList = new();

var mailLocation = Transform(uid);
foreach (var receiver in EntityQuery<MailReceiverComponent>())
{
// mail is mapwide now, dont need to check if they are on the same station
//if (_stationSystem.GetOwningStation(receiver.Owner) != _stationSystem.GetOwningStation(uid))
// continue;
var location = Transform(receiver.Owner);

if (location.MapID != mailLocation.MapID)
continue;

if (TryGetMailRecipientForReceiver(receiver, out MailRecipient? recipient))
candidateList.Add(recipient.Value);
Expand Down Expand Up @@ -700,13 +723,15 @@ public struct MailRecipient
public string Job;
public HashSet<String> AccessTags;
public bool MayReceivePriorityMail;
public string Ship;

public MailRecipient(string name, string job, HashSet<String> accessTags, bool mayReceivePriorityMail)
public MailRecipient(string name, string job, HashSet<String> accessTags, bool mayReceivePriorityMail, string ship)
{
Name = name;
Job = job;
AccessTags = accessTags;
MayReceivePriorityMail = mayReceivePriorityMail;
Ship = ship;
}
}
}
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/_Nyano/mail.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mail-recipient-mismatch = Recipient name or job does not match.
mail-invalid-access = Recipient name and job match, but access isn't as expected.
mail-locked = The anti-tamper lock hasn't been removed. Tap the recipient's ID.
mail-desc-far = A parcel of mail. You can't make out who it's addressed to from this distance.
mail-desc-close = A parcel of mail addressed to {CAPITALIZE($name)}, {$job}.
mail-desc-close = A parcel of mail addressed to {CAPITALIZE($name)}, {$job}. Last known location: {$station}.
mail-desc-fragile = It has a [color=red]red fragile label[/color].
mail-desc-priority = The anti-tamper lock's [color=yellow]yellow priority tape[/color] is active. Better deliver it on time!
mail-desc-priority-inactive = The anti-tamper lock's [color=#886600]yellow priority tape[/color] is inactive.
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/flavors/flavor-profiles.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ flavor-complex-tomato = like tomatoes
flavor-complex-corn = like corn
flavor-complex-banana = like bananas
flavor-complex-apple = like apples
flavor-complex-pear = like pears
flavor-complex-bungo = like bungo
flavor-complex-raisins = like dried grapes
flavor-complex-orange = like oranges
Expand Down
Loading

0 comments on commit 84369db

Please sign in to comment.