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

Port Dogtags from CD and fix some minor issues with it. ( DeltaV #2301) #2628

Merged
merged 12 commits into from
Dec 28, 2024
32 changes: 32 additions & 0 deletions Content.Server/_CD/Engraving/EngraveableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Content.Server._CD.Engraving;

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

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

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

/// <summary>
/// The inspect text to use when there is an engraving. The message will be shown seperately afterwards.
/// </summary>
[DataField]
public LocId HasEngravingText = "engraving-generic-has-message"; // Frontier: "dogtags"<"generic"
}
83 changes: 83 additions & 0 deletions Content.Server/_CD/Engraving/EngraveableSystem.cs
Original file line number Diff line number Diff line change
@@ -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<EngraveableComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<EngraveableComponent, GetVerbsEvent<ActivationVerb>>(AddEngraveVerb);
}

private void OnExamined(Entity<EngraveableComponent> ent, ref ExaminedEvent args)
{
var msg = new FormattedMessage();
// Frontier: don't localize the message, use args in fluent entries
if (ent.Comp.EngravedMessage == string.Empty)
msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.NoEngravingText, ("object", ent)));
else
msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.HasEngravingText, ("object", ent), ("message", ent.Comp.EngravedMessage)));
// End Frontier

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))
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<EngraveableComponent>(ent))
return;

ent.Comp.EngravedMessage = message;
_popup.PopupEntity(Loc.GetString(ent.Comp.EngraveSuccessMessage, ("object", ent)), // Frontier: add object argument
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);
}
}
7 changes: 7 additions & 0 deletions Resources/Locale/en-US/_CD/engraving/engraving.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
engraving-verb-engrave = Engrave
engraving-popup-ui-message = Description
# Frontier: generic engraving messages
engraving-generic-no-message = There isn't anything engraved on {THE($object)}.
engraving-generic-has-message = There's a message engraved on {THE($object)}. It reads: {$message}
engraving-generic-succeed = You successfully engrave {THE($object)} with your message.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
Gold: 200 # 2 bars
- type: StaticPrice
price: 300
- type: Engraveable # Frontier - base rings may not be metallic

- type: entity
abstract: true
Expand All @@ -86,3 +87,4 @@
Silver: 200 # 2 bars
- type: StaticPrice
price: 275
- type: Engraveable # Frontier - base rings may not be metallic
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/shinyflask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand Down Expand Up @@ -46,6 +47,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/detflask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand All @@ -55,6 +57,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/hosflask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand All @@ -64,6 +67,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/flask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand All @@ -73,6 +77,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/barflask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand All @@ -82,6 +87,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/flask_old.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand All @@ -91,6 +97,7 @@
components:
- type: Sprite
sprite: Objects/Consumable/Drinks/lithiumflask.rsi
- type: Engraveable # Frontier

- type: entity
parent: FlaskBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@
sprite: Objects/Devices/goldwatch.rsi
- type: StaticPrice
price: 500 #if you ever increase the price of kidneys, increase this too.
- type: Engraveable # Frontier
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Objects/Tools/lighters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
- type: UseDelay
- type: IgnitionSource
ignited: false
- type: Engraveable # Frontier

- type: entity
name: flippo engraved lighter
Expand Down
14 changes: 14 additions & 0 deletions Resources/Prototypes/_CD/Entities/Objects/Misc/dogtags.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions Resources/Prototypes/_CD/Loadouts/Miscellaneous/trinkets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- type: loadout
id: CDDogtags
storage:
back:
- CDDogtags
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
ClothingOuterCoatNfsdLongCoat: 3
ClothingNeckCloakSheriff: 3
ClothingNeckMantleSheriff: 3
ClothingNeckPublicAffairsLiaisonBadge: 10
ClothingNeckNfsdBadgeSecurityCadet: 10
ClothingNeckNfsdBadgeSecurityBrigmedic: 10
ClothingNeckNfsdBadgeDetective: 10
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_NF/Loadouts/Jobs/Brigmedic/neck.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- type: loadout
id: BrigmedicClothingNeckMantleBrigmedic
id: BrigmedicClothingNeckNfsdBadgeSecurityBrigmedic
equipment:
neck: ClothingNeckNfsdBadgeSecurityBrigmedic
18 changes: 14 additions & 4 deletions Resources/Prototypes/_NF/Loadouts/Jobs/Contractor/neck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,22 @@
neck: ClothingNeckBellCollar

- type: loadout
id: ContractorClothingNeckStethoscope
id: ContractorCDDogtags
effects:
- !type:GroupLoadoutEffect
proto: ContractorT1
price: 500
equipment:
neck: ClothingNeckStethoscope
neck: CDDogtags

- type: loadout
id: ContractorClothingOuterPonchoClassic
id: ContractorClothingNeckStethoscope
effects:
- !type:GroupLoadoutEffect
proto: ContractorT1
price: 500
equipment:
neck: ClothingOuterPonchoClassic
neck: ClothingNeckStethoscope

- type: loadout
id: ContractorClothingOuterPoncho
Expand All @@ -124,6 +124,16 @@
price: 500
equipment:
neck: ClothingOuterPoncho

- type: loadout
id: ContractorClothingOuterPonchoClassic
effects:
- !type:GroupLoadoutEffect
proto: ContractorT1
price: 500
equipment:
neck: ClothingOuterPonchoClassic

#T2
- type: loadout
id: ContractorClothingNeckCloakCap
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/_NF/Loadouts/Jobs/NFDetective/neck.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#T0
- type: loadout
id: NFDetectiveClothingNeckBadgeNFDetective
id: NFDetectiveClothingNeckNfsdBadgeDetective
equipment:
neck: ClothingNeckNfsdBadgeSecurity
neck: ClothingNeckNfsdBadgeDetective
5 changes: 5 additions & 0 deletions Resources/Prototypes/_NF/Loadouts/Jobs/Pal/neck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#T0
- type: loadout
id: PalClothingNeckPublicAffairsLiaisonBadge
equipment:
neck: ClothingNeckPublicAffairsLiaisonBadge
10 changes: 10 additions & 0 deletions Resources/Prototypes/_NF/Loadouts/Jobs/Sheriff/neck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
id: SheriffClothingNeckMantleSheriff
equipment:
neck: ClothingNeckMantleSheriff

- type: loadout
id: SheriffClothingNeckCloakSheriff
equipment:
neck: ClothingNeckCloakSheriff

- type: loadout
id: SheriffClothingNeckNfsdBadgeSheriff
equipment:
neck: ClothingNeckNfsdBadgeSheriff
4 changes: 3 additions & 1 deletion Resources/Prototypes/_NF/Loadouts/bailiff_loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
- type: loadoutGroup
id: BailiffNeck
name: loadout-group-contractor-neck
minLimit: 0
hidden: true
loadouts:
- BailiffClothingNeckBadgeBailiff
fallbacks:
- BailiffClothingNeckBadgeBailiff

- type: loadoutGroup
id: BailiffPDA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
- type: loadoutGroup
id: BrigmedicNeck
name: loadout-group-contractor-neck
minLimit: 0
hidden: true
loadouts:
- BrigmedicClothingNeckMantleBrigmedic
- BrigmedicClothingNeckNfsdBadgeSecurityBrigmedic
fallbacks:
- BrigmedicClothingNeckNfsdBadgeSecurityBrigmedic

- type: loadoutGroup
id: BrigmedicPDA
Expand Down
4 changes: 3 additions & 1 deletion Resources/Prototypes/_NF/Loadouts/cadet_loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
- type: loadoutGroup
id: CadetNeck
name: loadout-group-contractor-neck
minLimit: 0
hidden: true
loadouts:
- CadetClothingNeckBadgeCadet
fallbacks:
- CadetClothingNeckBadgeCadet

- type: loadoutGroup
id: CadetPDA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
- ContractorClothingNeckHeadphones
- ContractorClothingNeckCrucifix
- ContractorClothingNeckBellCollar
- ContractorCDDogtags
- ContractorClothingNeckStethoscope
- ContractorClothingOuterPoncho
- ContractorClothingOuterPonchoClassic
Expand Down
4 changes: 3 additions & 1 deletion Resources/Prototypes/_NF/Loadouts/deputy_loadout_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
- type: loadoutGroup
id: DeputyNeck
name: loadout-group-contractor-neck
minLimit: 0
hidden: true # No point in showing this, it gets auto-selected.
loadouts:
- DeputyClothingNeckBadgeDeputy
fallbacks:
- DeputyClothingNeckBadgeDeputy

- type: loadoutGroup
id: DeputyPDA
Expand Down
Loading
Loading