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

make dogtags text predicted #529

Merged
merged 3 commits into from
Jan 8, 2025
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
5 changes: 5 additions & 0 deletions Content.Client/_CD/Engraving/EngraveableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared._CD.Engraving;

namespace Content.Client._CD.Engraving;

public sealed class EngraveableSystem : SharedEngraveableSystem;
25 changes: 5 additions & 20 deletions Content.Server/_CD/Engraving/EngraveableSystem.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,34 @@
using Content.Server.Administration;
using Content.Server.Administration.Logs;
using Content.Server.Popups;
using Content.Shared._CD.Engraving;
using Content.Shared.Database;
using Content.Shared.Popups;
using Content.Shared.Examine;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Server._CD.Engraving;

public sealed class EngraveableSystem : EntitySystem
public sealed class EngraveableSystem : SharedEngraveableSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly QuickDialogSystem _dialog = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<EngraveableComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<EngraveableComponent, GetVerbsEvent<ActivationVerb>>(AddEngraveVerb);
}

private void OnExamined(Entity<EngraveableComponent> ent, ref ExaminedEvent args)
{
var msg = new FormattedMessage();
msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.EngravedMessage == string.Empty
? ent.Comp.NoEngravingText
: ent.Comp.HasEngravingText));

if (ent.Comp.EngravedMessage != string.Empty)
msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.EngravedMessage));

args.PushMessage(msg, 1);
}

private void AddEngraveVerb(Entity<EngraveableComponent> ent, ref GetVerbsEvent<ActivationVerb> args)
{
// First check if it's already been engraved. If it has, don't let them do it again.
if (ent.Comp.EngravedMessage != string.Empty)
return;

// We need an actor to give the verb.
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
if (!TryComp<ActorComponent>(args.User, out var actor))
return;

// Make sure ghosts can't engrave stuff.
Expand All @@ -66,6 +50,7 @@ private void AddEngraveVerb(Entity<EngraveableComponent> ent, ref GetVerbsEvent<
return;

ent.Comp.EngravedMessage = message;
Dirty(ent);
_popup.PopupEntity(Loc.GetString(ent.Comp.EngraveSuccessMessage),
actor.PlayerSession.AttachedEntity.Value,
actor.PlayerSession,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
namespace Content.Server._CD.Engraving;
using Robust.Shared.GameStates;

namespace Content.Shared._CD.Engraving;

/// <summary>
/// Allows an items' description to be modified with an engraving
/// </summary>
[RegisterComponent, Access(typeof(EngraveableSystem))]
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[Access(typeof(SharedEngraveableSystem))]
public sealed partial class EngraveableComponent : Component
{
/// <summary>
/// Message given to user to notify them a message was sent
/// </summary>
[DataField]
[DataField, AutoNetworkedField]
public string EngravedMessage = string.Empty;

/// <summary>
Expand Down
27 changes: 27 additions & 0 deletions Content.Shared/_CD/Engraving/SharedEngraveableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Shared.Examine;
using Robust.Shared.Utility;

namespace Content.Shared._CD.Engraving;

public abstract class SharedEngraveableSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<EngraveableComponent, ExaminedEvent>(OnExamined);
}

private void OnExamined(Entity<EngraveableComponent> ent, ref ExaminedEvent args)
{
var msg = new FormattedMessage();
msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.EngravedMessage == string.Empty
? ent.Comp.NoEngravingText
: ent.Comp.HasEngravingText));

if (ent.Comp.EngravedMessage != string.Empty)
msg.AddMarkupPermissive(Loc.GetString(ent.Comp.EngravedMessage));

args.PushMessage(msg, 1);
}
}
Loading