mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-02-15 03:31:38 +01:00
Автоматизация бюрократии (#3402)
Co-authored-by: Lomcastar <Lomcastar@gmail.com>
This commit is contained in:
64
Content.Server/Corvax/Documents/DocumentPrinterSystem.cs
Normal file
64
Content.Server/Corvax/Documents/DocumentPrinterSystem.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Corvax.Documents;
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Paper;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Corvax.Documents;
|
||||
|
||||
public sealed partial class DocumentPrinterSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
||||
[Dependency] private readonly PaperSystem _paper = default!;
|
||||
[Dependency] private readonly SharedStationSystem _station = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<DocumentPrinterComponent, LatheGetResultEvent>(SetContentDocument);
|
||||
}
|
||||
|
||||
private void SetContentDocument(Entity<DocumentPrinterComponent> ent, ref LatheGetResultEvent result)
|
||||
{
|
||||
var paperComp = EnsureComp<PaperComponent>(result.ResultItem);
|
||||
|
||||
var station = _station.GetOwningStation(result.ResultItem);
|
||||
var stationName = station != null ? Name(station.Value) : null;
|
||||
|
||||
if (_itemSlots.TryGetSlot(ent.Owner, ent.Comp.SlotName, out var slot) && slot.Item is { Valid: true } idCardEntity
|
||||
&& TryComp<IdCardComponent>(idCardEntity, out var idCard))
|
||||
{
|
||||
_paper.SetContent(result.ResultItem, FormatString(Loc.GetString(paperComp.Content), stationName, idCard));
|
||||
}
|
||||
else
|
||||
{
|
||||
_paper.SetContent(result.ResultItem, FormatString(Loc.GetString(paperComp.Content), stationName));
|
||||
}
|
||||
}
|
||||
|
||||
public string FormatString(string content, string? station, IdCardComponent? idCard = null)
|
||||
{
|
||||
var stationTime = GetTimeStation();
|
||||
|
||||
content = content
|
||||
.Replace(Loc.GetString("doc-var-date"), stationTime)
|
||||
.Replace(Loc.GetString("doc-var-station"), station ?? Loc.GetString("doc-text-printer-default-station"));
|
||||
|
||||
content = content
|
||||
.Replace(Loc.GetString("doc-var-name"), idCard?.FullName ?? Loc.GetString("doc-text-printer-default-name"))
|
||||
.Replace(Loc.GetString("doc-var-job"), idCard?.LocalizedJobTitle ?? Loc.GetString("doc-text-printer-default-job"));
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
private string GetTimeStation()
|
||||
{
|
||||
var curTime = _timing.CurTime;
|
||||
var formattedTime = $"{(int)curTime.TotalHours:D2}:{curTime.Minutes:D2}:{curTime.Seconds:D2}";
|
||||
return formattedTime + " " + DateTime.UtcNow.AddYears(1000).ToShortDateString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -245,6 +245,9 @@ namespace Content.Server.Lathe
|
||||
if (currentRecipe.Result is { } resultProto)
|
||||
{
|
||||
var result = Spawn(resultProto, Transform(uid).Coordinates);
|
||||
//Corvax
|
||||
RaiseLocalEvent(uid, new LatheGetResultEvent(result));
|
||||
//Corvax
|
||||
_stack.TryMergeToContacts(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Shared.Corvax.Documents;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class DocumentPrinterComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public string SlotName = "id";
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Research.Prototypes;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Lathe
|
||||
{
|
||||
@@ -116,6 +117,19 @@ namespace Content.Shared.Lathe
|
||||
}
|
||||
}
|
||||
|
||||
//Corvax
|
||||
[Serializable]
|
||||
public sealed partial class LatheGetResultEvent : EntityEventArgs
|
||||
{
|
||||
public readonly EntityUid ResultItem;
|
||||
|
||||
public LatheGetResultEvent(EntityUid result)
|
||||
{
|
||||
ResultItem = result;
|
||||
}
|
||||
}
|
||||
//Corvax
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on a lathe when it starts producing a recipe.
|
||||
/// </summary>
|
||||
|
||||
4
Resources/Locale/en-US/corvax/paper/doc-printer-tags.ftl
Normal file
4
Resources/Locale/en-US/corvax/paper/doc-printer-tags.ftl
Normal file
@@ -0,0 +1,4 @@
|
||||
doc-var-station = :STATION:
|
||||
doc-var-date = :DATE:
|
||||
doc-var-name = :NAME:
|
||||
doc-var-job = :JOB:
|
||||
@@ -1,2 +1,2 @@
|
||||
ent-PrinterDoc = document printer
|
||||
.desc = Bureaucratic perfection. Stores a database of all Nanotrasen documents, and lets you print them as long as you have paper.
|
||||
.desc = Bureaucratic perfection. Stores the database of all Nanotrasen documents. For rapid pre-filling of documents with your personal details, use the ID card slot. Printing is available provided paper is supplied.
|
||||
|
||||
7
Resources/Locale/ru-RU/corvax/paper/doc-printer-tags.ftl
Normal file
7
Resources/Locale/ru-RU/corvax/paper/doc-printer-tags.ftl
Normal file
@@ -0,0 +1,7 @@
|
||||
doc-text-printer-default-station = Station XX-000
|
||||
doc-text-printer-default-name = (ФИО)
|
||||
doc-text-printer-default-job = (полное наименование должности)
|
||||
doc-var-station = :СТАНЦИЯ:
|
||||
doc-var-date = :ДАТА:
|
||||
doc-var-name = :ФИО:
|
||||
doc-var-job = :ДОЛЖНОСТЬ:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
ent-PrinterDoc = принтер документов
|
||||
.desc = Бюрократическое совершенство. Хранит базу данных всех документов Nanotrasen и позволяет печатать их, пока хватает бумаги.
|
||||
.desc = Бюрократическое совершенство. Хранит базу данных всех документов Nanotrasen. Для быстрого заполнения документов вашими личными данными используйте слот для ID-карты. Печать доступна при наличии бумаги.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
parent: BaseLathe
|
||||
id: PrinterDoc
|
||||
name: document printer
|
||||
description: Bureaucratic perfection. Stores a database of all Nanotrasen documents, and lets you print them as long as you have paper.
|
||||
description: Bureaucratic perfection. Stores the database of all Nanotrasen documents. For rapid pre-filling of documents with your personal details, use the ID card slot. Printing is available provided paper is supplied.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Corvax/Structures/Machines/printer.rsi
|
||||
@@ -47,3 +47,17 @@
|
||||
- Document
|
||||
storage:
|
||||
PrinterPaper: 0
|
||||
- type: DocumentPrinter
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
machine_board: !type:Container
|
||||
machine_parts: !type:Container
|
||||
blueprint: !type:Container
|
||||
id: !type:ContainerSlot
|
||||
- type: ItemSlots
|
||||
slots:
|
||||
id:
|
||||
name: IdSlot
|
||||
whitelist:
|
||||
components:
|
||||
- IdCard
|
||||
|
||||
Reference in New Issue
Block a user