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

Frankenstein update 2 #260

Merged
merged 10 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions Content.Server/SS220/AutoEngrave/AutoEngravingComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server.SS220.AutoEngrave;

[RegisterComponent]
public sealed class AutoEngravingComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("autoEngraveLocKey")]
public string? AutoEngraveLocKey;
[ViewVariables(VVAccess.ReadWrite), DataField("engravedText")]
public string EngravedText = "";
}
21 changes: 21 additions & 0 deletions Content.Server/SS220/AutoEngrave/AutoEngravingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.Examine;

namespace Content.Server.SS220.AutoEngrave;

public sealed class AutoEngravingSystem : EntitySystem
{
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<AutoEngravingComponent, ExaminedEvent>(OnExamine);
}

private void OnExamine(EntityUid uid, AutoEngravingComponent component, ExaminedEvent args)
{
if (component.AutoEngraveLocKey is null)
return;

args.PushMarkup(Loc.GetString(component.AutoEngraveLocKey, ("engraved", component.EngravedText)));
}
}
14 changes: 14 additions & 0 deletions Content.Server/SS220/AutoEngrave/EngraveNameOnOpenComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Content.Server.SS220.AutoEngrave;

[RegisterComponent]
public sealed class EngraveNameOnOpenComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("activated")]
public bool Activated;

[ViewVariables(VVAccess.ReadWrite), DataField("autoEngraveLocKey")]
public string? AutoEngraveLocKey;

[ViewVariables(VVAccess.ReadWrite), DataField("toEngrave")]
public HashSet<string> ToEngrave = new();
}
55 changes: 55 additions & 0 deletions Content.Server/SS220/AutoEngrave/EngraveNameOnOpenSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Server.Storage.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Interaction;

namespace Content.Server.SS220.AutoEngrave;

public sealed class EngraveNameOnOpenSystem : EntitySystem
{
[Dependency] private readonly AccessReaderSystem _accessReader = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<EngraveNameOnOpenComponent, ActivateInWorldEvent>(OnActivate);
}

private void OnActivate(EntityUid uid, EngraveNameOnOpenComponent component, ActivateInWorldEvent args)
{
if (!TryComp<ServerStorageComponent>(uid, out var storageComp))
return;

var character = args.User;

if (!_accessReader.IsAllowed(character, uid))
return;

TryEngrave(character, storageComp, component);
}

private void TryEngrave(EntityUid user, ServerStorageComponent storageComp, EngraveNameOnOpenComponent engraveComp)
{
if (engraveComp.Activated)
return;

if (storageComp.StoredEntities is null)
return;

foreach (var item in storageComp.StoredEntities)
{
var id = MetaData(item).EntityPrototype?.ID;
if (id is null)
continue;

if (!engraveComp.ToEngrave.Contains(id))
continue;

var engraving = AddComp<AutoEngravingComponent>(item);
engraving.AutoEngraveLocKey = engraveComp.AutoEngraveLocKey;
engraving.EngravedText = MetaData(user).EntityName;

engraveComp.Activated = true;
}
}
}
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/ss220/auto-engravings.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mateba-name-engraving = [italic]На стволе револьвера выгравировано: "{$engraved}".[/italic]
Loading
Loading