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

dogtags but good #12

Merged
merged 2 commits into from
Jan 7, 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/_Emberfall/Engraving/EngravableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared._Emberfall.Engraving;

namespace Content.Client._Emberfall.Engraving;

public sealed class EngravableSystem : SharedEngravableSystem;
68 changes: 68 additions & 0 deletions Content.Server/_Emberfall/Engraving/EngravableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Content.Server.Administration;
using Content.Server.Administration.Logs;
using Content.Shared._Emberfall.Engraving;
using Content.Shared.Database;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Player;

namespace Content.Server._Emberfall.Engraving;

public sealed class EngravableSystem : SharedEngravableSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly QuickDialogSystem _dialog = default!;

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

SubscribeLocalEvent<EngravableComponent, GetVerbsEvent<ActivationVerb>>(AddEngraveVerb);
}

private void AddEngraveVerb(Entity<EngravableComponent> 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 (!TryComp<ActorComponent>(args.User, out var actor))
return;

// Make sure ghosts can't engrave stuff.
if (!args.CanInteract)
return;

var engraveVerb = new ActivationVerb
{
Text = Loc.GetString("engraving-verb-engrave"),
Act = () =>
{
_dialog.OpenDialog(actor.PlayerSession,
Loc.GetString("engraving-verb-engrave"),
Loc.GetString("engraving-popup-ui-message"),
(string message) =>
{
// If either the actor or comp have magically vanished
if (actor.PlayerSession.AttachedEntity == null || !HasComp<EngravableComponent>(ent))
return;

ent.Comp.EngravedMessage = message;
Dirty(ent);
_popup.PopupEntity(Loc.GetString(ent.Comp.EngraveSuccessMessage),
actor.PlayerSession.AttachedEntity.Value,
actor.PlayerSession,
PopupType.Medium);
_adminLogger.Add(LogType.Action,
LogImpact.Low,
$"{ToPrettyString(actor.PlayerSession.AttachedEntity):player} engraved an item with message: {message}");
});
},
Impact = LogImpact.Low,
};
engraveVerb.Impact = LogImpact.Low;
args.Verbs.Add(engraveVerb);
}
}
35 changes: 35 additions & 0 deletions Content.Shared/_Emberfall/Engraving/EngravableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Robust.Shared.GameStates;

namespace Content.Shared._Emberfall.Engraving;

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

/// <summary>
/// The inspect text to use when there is no engraving
/// </summary>
[DataField]
public LocId NoEngravingText = "engraving-dogtags-no-message";

/// <summary>
/// The message to use when successfully engraving the item
/// </summary>
[DataField]
public LocId EngraveSuccessMessage = "engraving-dogtags-succeed";

/// <summary>
/// The inspect text to use when there is an engraving. The message will be shown seperately afterwards.
/// </summary>
[DataField]
public LocId HasEngravingText = "engraving-dogtags-has-message";
}
31 changes: 31 additions & 0 deletions Content.Shared/_Emberfall/Engraving/SharedEngravableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using Robust.Shared.Utility;

namespace Content.Shared._Emberfall.Engraving;

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

SubscribeLocalEvent<EngravableComponent, ExaminedEvent>(OnExamined);
}

private void OnExamined(Entity<EngravableComponent> 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);
}
}
6 changes: 6 additions & 0 deletions Resources/Locale/en-US/_emberfall/engravable/engravable.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
engraving-verb-engrave = Engrave
engraving-popup-ui-message = Description

engraving-dogtags-no-message = The dogtags don't seem to have any kind of engraving.
engraving-dogtags-has-message = The dogtags are engraved with a message that reads:{" "}
engraving-dogtags-succeed = You successfully engrave the dogtags with your message.
1 change: 1 addition & 0 deletions Resources/Prototypes/Loadouts/loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- TowelColorSilver
- TowelColorWhite
- TowelColorYellow
- DogTags # Emberfall

- type: loadoutGroup
id: Glasses
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- type: entity
parent: ClothingNeckBase
id: DogTags
name: dogtags
description: A set of dogtags, hanging from a small piece of cord for wearing and carrying.
components:
- type: Sprite
sprite: _Emberfall/Objects/Misc/dogtags.rsi
layers:
- state: dogtag
- type: Clothing
sprite: _Emberfall/Objects/Misc/dogtags.rsi
- type: Appearance
- type: Engravable
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: loadout
id: DogTags
storage:
back:
- DogTags
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from cmss13 at https://github.com/cmss13-devs/cmss13/blob/a2d5ca6e69725341f0fa261a4a3f89c737e843b3/icons/obj/items/card.dmi",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "dogtag"
},
{
"name": "equipped-NECK",
"directions": 4
}
]
}
Loading