mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Check the changelog for the full list. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Added Holopads (unmapped) - add: Intellicards are now useful for removing/adding a Station AI's brain. - add: Added the Communications Console to Station AI actions. - add: AI now has a warp point. - add: Added more things for the AI to press. - add: More AI laws have been added. - fix: Fixed the mail system - fix: Fixed AI actions - fix: Fixed invalid spawns for station AI breaking and ruining your ability to play it. - fix: The Station AI's name will now properly send in "arrived to the station" announcements. - fix: Changed the CPR sound to simply not loop until fixed. - fix: Fixed unlocalized messages being sent for the random sentience event. --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Zachary Higgs <compgeek223@gmail.com> Co-authored-by: MendaxxDev <153332064+MendaxxDev@users.noreply.github.com> Co-authored-by: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> (cherry picked from commit 3e8a7d9b00e19e160321eb81d69a884189dfa4e6)
150 lines
5.8 KiB
C#
150 lines
5.8 KiB
C#
using System.Linq;
|
|
using Robust.Shared.Console;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.Prototypes;
|
|
using Content.Shared.Administration;
|
|
using Content.Server.Administration;
|
|
using Content.Server.Mail.Components;
|
|
using Content.Server.Mail.Systems;
|
|
|
|
namespace Content.Server.Mail;
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
public sealed class MailToCommand : IConsoleCommand
|
|
{
|
|
public string Command => "mailto";
|
|
public string Description => Loc.GetString("command-mailto-description", ("requiredComponent", nameof(MailReceiverComponent)));
|
|
public string Help => Loc.GetString("command-mailto-help", ("command", Command));
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
|
|
|
private const string BlankMailPrototype = "MailAdminFun";
|
|
private const string BlankLargeMailPrototype = "MailLargeAdminFun"; // Frontier: large mail
|
|
private const string Container = "storagebase";
|
|
private const string MailContainer = "contents";
|
|
|
|
|
|
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length < 4)
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
|
return;
|
|
}
|
|
|
|
if (!EntityUid.TryParse(args[0], out var recipientUid))
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
return;
|
|
}
|
|
|
|
if (!EntityUid.TryParse(args[1], out var containerUid))
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
|
return;
|
|
}
|
|
|
|
if (!bool.TryParse(args[2], out var isFragile))
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-invalid-bool"));
|
|
return;
|
|
}
|
|
|
|
if (!bool.TryParse(args[3], out var isPriority))
|
|
{
|
|
shell.WriteError(Loc.GetString("shell-invalid-bool"));
|
|
return;
|
|
}
|
|
|
|
// Frontier: Large Mail
|
|
var isLarge = false;
|
|
if (args.Length > 4 && !bool.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>();
|
|
|
|
if (!_entityManager.HasComponent<MailReceiverComponent>(recipientUid))
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-no-mailreceiver", ("requiredComponent", nameof(MailReceiverComponent))));
|
|
return;
|
|
}
|
|
|
|
if (!_prototypeManager.HasIndex<EntityPrototype>(mailPrototype)) // Frontier: _blankMailPrototype<mailPrototype
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-no-blankmail", ("blankMail", mailPrototype))); // Frontier: _blankMailPrototype<mailPrototype
|
|
return;
|
|
}
|
|
|
|
if (!containerSystem.TryGetContainer(containerUid, Container, out var targetContainer))
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-invalid-container", ("requiredContainer", Container)));
|
|
return;
|
|
}
|
|
|
|
if (!mailSystem.TryGetMailRecipientForReceiver(recipientUid, out var recipient))
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-unable-to-receive"));
|
|
return;
|
|
}
|
|
|
|
if (!mailSystem.TryGetMailTeleporterForReceiver(recipientUid, out var teleporterComponent, out var teleporterUid))
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-no-teleporter-found"));
|
|
return;
|
|
}
|
|
|
|
var mailUid = _entityManager.SpawnEntity(mailPrototype, _entityManager.GetComponent<TransformComponent>(containerUid).Coordinates); // Frontier: _blankMailPrototype<mailPrototype
|
|
var mailContents = containerSystem.EnsureContainer<Container>(mailUid, MailContainer);
|
|
|
|
if (!_entityManager.TryGetComponent<MailComponent>(mailUid, out var mailComponent))
|
|
{
|
|
shell.WriteLine(Loc.GetString("command-mailto-bogus-mail", ("blankMail", mailPrototype), ("requiredMailComponent", nameof(MailComponent)))); // Frontier: _blankMailPrototype<mailPrototype
|
|
return;
|
|
}
|
|
|
|
foreach (var entity in targetContainer.ContainedEntities.ToArray())
|
|
{
|
|
containerSystem.Insert(entity, mailContents);
|
|
}
|
|
|
|
mailComponent.IsFragile = isFragile;
|
|
mailComponent.IsPriority = isPriority;
|
|
mailComponent.IsLarge = isLarge; //Frontier Mail
|
|
|
|
mailSystem.SetupMail(mailUid, teleporterComponent, recipient.Value);
|
|
|
|
var teleporterQueue = containerSystem.EnsureContainer<Container>((EntityUid)teleporterUid, "queued");
|
|
containerSystem.Insert(mailUid, teleporterQueue);
|
|
shell.WriteLine(Loc.GetString("command-mailto-success", ("timeToTeleport", teleporterComponent.TeleportInterval.TotalSeconds - teleporterComponent.Accumulator)));
|
|
}
|
|
}
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
public sealed class MailNowCommand : IConsoleCommand
|
|
{
|
|
public string Command => "mailnow";
|
|
public string Description => Loc.GetString("command-mailnow");
|
|
public string Help => Loc.GetString("command-mailnow-help", ("command", Command));
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
foreach (var mailTeleporter in _entityManager.EntityQuery<MailTeleporterComponent>())
|
|
{
|
|
mailTeleporter.Accumulator += (float) mailTeleporter.TeleportInterval.TotalSeconds - mailTeleporter.Accumulator;
|
|
}
|
|
|
|
shell.WriteLine(Loc.GetString("command-mailnow-success"));
|
|
}
|
|
}
|