From 04b923958118dc0decd82c898976bbcffd8d8f51 Mon Sep 17 00:00:00 2001 From: Kr8art Date: Thu, 28 Nov 2024 13:04:17 +0100 Subject: [PATCH] Port Dogtags from CD and fix some minor issues with it. (#2301) * Port Dogtags from CD and fix some minor issues with it. * Addressing reviews --- .../_CD/Engraving/EngraveableComponent.cs | 32 +++++++ .../_CD/Engraving/EngraveableSystem.cs | 83 ++++++++++++++++++ .../Locale/en-US/_CD/engraving/engraving.ftl | 6 ++ .../Prototypes/Loadouts/loadout_groups.yml | 1 + .../_CD/Entities/Objects/Misc/dogtags.yml | 14 +++ .../_CD/Loadouts/Miscellaneous/trinkets.yml | 5 ++ .../_CD/Objects/Misc/dogtags.rsi/dogtag.png | Bin 0 -> 862 bytes .../Misc/dogtags.rsi/equipped-NECK.png | Bin 0 -> 332 bytes .../_CD/Objects/Misc/dogtags.rsi/meta.json | 18 ++++ 9 files changed, 159 insertions(+) create mode 100644 Content.Server/_CD/Engraving/EngraveableComponent.cs create mode 100644 Content.Server/_CD/Engraving/EngraveableSystem.cs create mode 100644 Resources/Locale/en-US/_CD/engraving/engraving.ftl create mode 100644 Resources/Prototypes/_CD/Entities/Objects/Misc/dogtags.yml create mode 100644 Resources/Prototypes/_CD/Loadouts/Miscellaneous/trinkets.yml create mode 100644 Resources/Textures/_CD/Objects/Misc/dogtags.rsi/dogtag.png create mode 100644 Resources/Textures/_CD/Objects/Misc/dogtags.rsi/equipped-NECK.png create mode 100644 Resources/Textures/_CD/Objects/Misc/dogtags.rsi/meta.json diff --git a/Content.Server/_CD/Engraving/EngraveableComponent.cs b/Content.Server/_CD/Engraving/EngraveableComponent.cs new file mode 100644 index 0000000000..f60ee3f584 --- /dev/null +++ b/Content.Server/_CD/Engraving/EngraveableComponent.cs @@ -0,0 +1,32 @@ +namespace Content.Server._CD.Engraving; + +/// +/// Allows an items' description to be modified with an engraving +/// +[RegisterComponent, Access(typeof(EngraveableSystem))] +public sealed partial class EngraveableComponent : Component +{ + /// + /// Message given to user to notify them a message was sent + /// + [DataField] + public string EngravedMessage = string.Empty; + + /// + /// The inspect text to use when there is no engraving + /// + [DataField] + public LocId NoEngravingText = "engraving-dogtags-no-message"; + + /// + /// The message to use when successfully engraving the item + /// + [DataField] + public LocId EngraveSuccessMessage = "engraving-dogtags-succeed"; + + /// + /// The inspect text to use when there is an engraving. The message will be shown seperately afterwards. + /// + [DataField] + public LocId HasEngravingText = "engraving-dogtags-has-message"; +} diff --git a/Content.Server/_CD/Engraving/EngraveableSystem.cs b/Content.Server/_CD/Engraving/EngraveableSystem.cs new file mode 100644 index 0000000000..370929511a --- /dev/null +++ b/Content.Server/_CD/Engraving/EngraveableSystem.cs @@ -0,0 +1,83 @@ +using Content.Server.Administration; +using Content.Server.Administration.Logs; +using Content.Server.Popups; +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 +{ + [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly PopupSystem _popup = default!; + [Dependency] private readonly QuickDialogSystem _dialog = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamined); + SubscribeLocalEvent>(AddEngraveVerb); + } + + private void OnExamined(Entity 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 ent, ref GetVerbsEvent 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)) + 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(ent)) + return; + + ent.Comp.EngravedMessage = message; + _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); + } +} diff --git a/Resources/Locale/en-US/_CD/engraving/engraving.ftl b/Resources/Locale/en-US/_CD/engraving/engraving.ftl new file mode 100644 index 0000000000..fc6ca919ea --- /dev/null +++ b/Resources/Locale/en-US/_CD/engraving/engraving.ftl @@ -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. diff --git a/Resources/Prototypes/Loadouts/loadout_groups.yml b/Resources/Prototypes/Loadouts/loadout_groups.yml index ccf1bd50d3..d81dd6c611 100644 --- a/Resources/Prototypes/Loadouts/loadout_groups.yml +++ b/Resources/Prototypes/Loadouts/loadout_groups.yml @@ -50,6 +50,7 @@ - SilverRing # DeltaV - Cane # DeltaV - WhiteCane #DeltaV + - CDDogtags # _CD - type: loadoutGroup id: Glasses diff --git a/Resources/Prototypes/_CD/Entities/Objects/Misc/dogtags.yml b/Resources/Prototypes/_CD/Entities/Objects/Misc/dogtags.yml new file mode 100644 index 0000000000..22a1b22a72 --- /dev/null +++ b/Resources/Prototypes/_CD/Entities/Objects/Misc/dogtags.yml @@ -0,0 +1,14 @@ +- type: entity + id: CDDogtags + parent: ClothingNeckBase + name: dogtags + description: A set of dogtags, hanging from a small piece of cord for wearing and carrying. + components: + - type: Sprite + sprite: _CD/Objects/Misc/dogtags.rsi + layers: + - state: dogtag + - type: Clothing + sprite: _CD/Objects/Misc/dogtags.rsi + - type: Appearance + - type: Engraveable diff --git a/Resources/Prototypes/_CD/Loadouts/Miscellaneous/trinkets.yml b/Resources/Prototypes/_CD/Loadouts/Miscellaneous/trinkets.yml new file mode 100644 index 0000000000..5c04fc51da --- /dev/null +++ b/Resources/Prototypes/_CD/Loadouts/Miscellaneous/trinkets.yml @@ -0,0 +1,5 @@ +- type: loadout + id: CDDogtags + storage: + back: + - CDDogtags diff --git a/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/dogtag.png b/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/dogtag.png new file mode 100644 index 0000000000000000000000000000000000000000..05a5b71bc5e592a13cc8c0b45052d0e4c89cc6ff GIT binary patch literal 862 zcmV-k1EKthP)WkkWy!otv^A+k_H7&Avp#)(OcT)ggg$Md=~-S@YK zHhr6S-+lMJ?|06<=ge%Rf2{uio&b*R-(~3LpJk?NstUlyi9p*;sv%!ER5NinA3@jDC z$!oA?mG-ThkG`G?*uB#fs+a3(8=EPU$pqrD<~2JAEdZiNB=``b2Y?#^4q3pN;cau0 zt14g^r|4N~g!QLOwgH_-s@afU5u%psNy{ECEzvD|#;q)@||z zz(P5VJfEcQqwO+6%vBynp4UZ>XLuJ?;kpd5P;@f`FQO4;#0R;&aKhP;r8XY`pE%tu zpXcZ2L<#H9gsTjwY2zBl7#&jmD0e-WhodcYV>l)6FZU#AJAIMQr)L+vbwa#w_sJ{c z?8$>NVgPXJQP=8P7(=Q#1oJn!AG9UhfbVI2Y%{i(lMa-_?-Pv+Xj$hI=`+dT>D z8&1pdxkQ(xhvOjx#EAI42L#fNY6wKy%FK{zD|6^hdK3_b_-$}^2(2J6MoW!fxTIb8 zcx;@)!FtpDK`KROl1URnfErI9J@nR!RS5h@eWcCQcchah-oBIbV}rf4LHrSc`6)54 z3g%eXv3HNWN0urfJas~p=kZ9J%mjb5Ly2}mM9=daJ?_;^RO*jfF-MIn3~(0c%2jEK zdw$O5oVC9Ou#%l25(e0J2q~5){??F$fH_AG^LvBW$oCo0sV>$kuleGyri5}Fx_F-Q z*KeB9!yI$ItH7(I(LldJ0s^`}(62T31%T$md&{SuubAiNWJ2)RLY@KC=y>lTY(r(F ocE-K|${=*}9_9NC_%YMzCk2ncdtHU?2LJ#707*qoM6N<$g5*V)a{vGU literal 0 HcmV?d00001 diff --git a/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/equipped-NECK.png b/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/equipped-NECK.png new file mode 100644 index 0000000000000000000000000000000000000000..4d837168da6041b3a170104ef7d44a1f417fc70e GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=oCO|{#S9F5M?jcysy3fAQ1G9p zi(^Q|oVT|&@-{h0v^~7u(yJ37EPGs3&nF?`plw8hQ_h{EyaGucIXMr+i+}D@H}qh9 z68AuAox>bvg>#Go&lx(38ID*UnA7}<`Flz7_gs7R%}hPbw)s2b<=^M7YnDG-$9nAG z^P1=C-On1H8%|xm==JSwcPD82H+l2zyHdKXyzY@YLm^*-1v{#N43A_`gvEs($j5gs zUMDH^pm;BXc1O%)fp1)Ew#F&^l1gM;HRac`*KPH>`>%*B-{ke%?$zln>IYW{uiYA! k5Yub)=g_(5IP8e~EbSmIyg_3#FeDf}UHx3vIVCg!08}-9(f|Me literal 0 HcmV?d00001 diff --git a/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/meta.json b/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/meta.json new file mode 100644 index 0000000000..da1b490e53 --- /dev/null +++ b/Resources/Textures/_CD/Objects/Misc/dogtags.rsi/meta.json @@ -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 + } + ] +}