This commit is contained in:
Ed
2025-02-12 17:20:50 +03:00
committed by GitHub
parent 811104ada8
commit 73b4060c65
12 changed files with 127 additions and 10 deletions

View File

@@ -5,7 +5,6 @@ using Content.Shared._CP14.MagicSpell;
using Content.Shared._CP14.MagicSpell.Components;
using Content.Shared._CP14.MagicSpell.Events;
using Content.Shared._CP14.MagicSpell.Spells;
using Content.Shared.EntityEffects;
using Content.Shared.Whitelist;
using Robust.Server.GameObjects;

View File

@@ -0,0 +1,9 @@
namespace Content.Server._CP14.Passport;
/// <summary>
/// Generates a paper text confirming the identity of the player and stamps it.
/// </summary>
[RegisterComponent]
public sealed partial class CP14PassportComponent : Component
{
}

View File

@@ -0,0 +1,63 @@
using System.Text;
using Content.Shared.GameTicking;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Paper;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server._CP14.Passport;
public sealed partial class CP14PassportSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly PaperSystem _paper = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public readonly EntProtoId PassportProto = "CP14Passport";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawning);
}
private void OnPlayerSpawning(PlayerSpawnCompleteEvent ev)
{
var passport = Spawn(PassportProto, Transform(ev.Mob).Coordinates);
if (!TryComp<PaperComponent>(passport, out var paper))
return;
var text = GeneratePassportText(ev);
_paper.SetContent((passport, paper), text);
_paper.TryStamp((passport, paper),
new StampDisplayInfo
{
StampedColor = Color.FromHex("#0a332a"),
StampedName = Loc.GetString("cp14-passport-stamp")
},
"");
_hands.TryPickupAnyHand(ev.Mob, passport);
}
private string GeneratePassportText(PlayerSpawnCompleteEvent ev)
{
var sb = new StringBuilder();
//Name
sb.AppendLine(Loc.GetString("cp14-passport-name", ("name", ev.Profile.Name)));
//Species
if (_proto.TryIndex(ev.Profile.Species, out var indexedSpecies))
sb.AppendLine(Loc.GetString("cp14-passport-species", ("species", Loc.GetString(indexedSpecies.Name))));
//Birthday
var birthday = $"{_random.Next(40)}.{_random.Next(12)}.{225 - ev.Profile.Age}";
sb.AppendLine(Loc.GetString("cp14-passport-birth-date", ("birthday", birthday)));
//Job
if (ev.JobId is not null && _proto.TryIndex<JobPrototype>(ev.JobId, out var indexedJob))
sb.AppendLine(Loc.GetString("cp14-passport-job", ("job", Loc.GetString(indexedJob.Name))));
return sb.ToString();
}
}

View File

@@ -0,0 +1,6 @@
cp14-passport-name = Name: {$name}
cp14-passport-species = Race: {$species}
cp14-passport-birth-date = Date of Birth: {$birthday}
cp14-passport-job = Job: {$job}
cp14-passport-stamp = Passport approved

View File

@@ -0,0 +1,6 @@
cp14-passport-name = Имя: {$name}
cp14-passport-species = Раса: {$species}
cp14-passport-birth-date = Дата рождения: {$birthday}
cp14-passport-job = Профессия: {$job}
cp14-passport-stamp = Паспорт утвержден

View File

@@ -0,0 +1,37 @@
- type: entity
parent: BaseItem
id: CP14Passport
categories: [ ForkFiltered ]
name: passport
description: Identification document.
components:
- type: Paper
- type: PaperLabelType
- type: ActivatableUI
key: enum.PaperUiKey.Key
requiresComplex: false
- type: UserInterface
interfaces:
enum.PaperUiKey.Key:
type: PaperBoundUserInterface
- type: Item
size: Tiny
- type: Tag
tags:
- Document
- type: Sprite
sprite: _CP14/Objects/Bureaucracy/paper.rsi
layers:
- state: passport
- type: PaperVisuals
backgroundImagePath: "/Textures/Interface/Paper/paper_background_book.svg.96dpi.png"
headerImagePath: "/Textures/_CP14/Interface/Paper/paper_passport.png"
headerMargin: 0.0, 0.0, 0.0, 4.0
backgroundImageTile: false
backgroundPatchMargin: 23.0, 16.0, 14.0, 15.0
contentMargin: 12.0, 0.0, 6.0, 0.0
maxWritableArea: 300.0, 246.0
backgroundModulate: "#baa580"
backgroundScale: 2, 2
contentImagePath: "/Textures/Interface/Paper/paper_content_lined.svg.96dpi.png"
contentImageModulate: "#998665"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,2 @@
sample:
filter: true

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

View File

@@ -1,7 +1,7 @@
{
"version": 1,
"license": "CC-BY-SA-4.0",
"copyright": "Created by Max Gab, folders by TheShuEd, stamps on paper by viator1748",
"copyright": "Created by Max Gab, folders and passport by TheShuEd, stamps on paper by viator1748",
"size": {
"x": 32,
"y": 32
@@ -19,14 +19,6 @@
{
"name": "paper_filled"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
},
{
"name": "approved_on_paper"
},
@@ -50,6 +42,9 @@
},
{
"name": "magic"
},
{
"name": "passport"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B