Skip to content

Commit

Permalink
Merge pull request #1378 from hivehum/dogtag
Browse files Browse the repository at this point in the history
dogtag update from CD
  • Loading branch information
mqole authored Jan 16, 2025
2 parents 09335a0 + 41ce7b2 commit cbc5675
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 23 deletions.
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.AddMarkupPermissive(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);
}
}

0 comments on commit cbc5675

Please sign in to comment.