diff --git a/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs b/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs index 2bce22c045..9a4058baee 100644 --- a/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs +++ b/Content.Shared/Body/Systems/SharedBloodstreamSystem.cs @@ -8,6 +8,7 @@ using Content.Shared.Damage; using Content.Shared.Damage.Systems; using Content.Shared.EntityEffects.Effects.Solution; +using Content.Shared.Examine; using Content.Shared.FixedPoint; using Content.Shared.Fluids; using Content.Shared.Forensics.Components; @@ -26,7 +27,7 @@ namespace Content.Shared.Body.Systems; -public abstract class SharedBloodstreamSystem : EntitySystem +public abstract partial class SharedBloodstreamSystem : EntitySystem // DEN: Make partial { public static readonly EntProtoId Bloodloss = "StatusEffectBloodloss"; @@ -55,6 +56,8 @@ public override void Initialize() SubscribeLocalEvent(OnApplyMetabolicMultiplier); SubscribeLocalEvent(OnRejuvenate); SubscribeLocalEvent(OnMetabolismExclusion); + + SubscribeLocalEvent(OnExamined); // DEN } public override void Update(float frameTime) diff --git a/Content.Shared/_DEN/Body/Components/BloodExaminerComponent.cs b/Content.Shared/_DEN/Body/Components/BloodExaminerComponent.cs new file mode 100644 index 0000000000..b13f924119 --- /dev/null +++ b/Content.Shared/_DEN/Body/Components/BloodExaminerComponent.cs @@ -0,0 +1,18 @@ +using Content.Shared.Body.Systems; + +namespace Content.Shared._DEN.Body.Systems; + +/// +/// This entity can see the bloodstream reagents of other species. +/// Note that this does not detect all chemicals in the bloodstream - just whatever their +/// actual BloodstreamComponent blood is. +/// +[RegisterComponent, Access(typeof(SharedBloodstreamSystem))] +public sealed partial class BloodExaminerComponent : Component +{ + [DataField] + public LocId ExamineText = "blood-examiner-component-examine"; + + [DataField] + public LocId BloodSuffix = "blood-examiner-component-blood-suffix"; +} diff --git a/Content.Shared/_DEN/Body/EntitySystems/BloodstreamSystem.cs b/Content.Shared/_DEN/Body/EntitySystems/BloodstreamSystem.cs new file mode 100644 index 0000000000..0729182c83 --- /dev/null +++ b/Content.Shared/_DEN/Body/EntitySystems/BloodstreamSystem.cs @@ -0,0 +1,66 @@ +using System.Linq; +using Content.Shared._DEN.Body.Systems; +using Content.Shared.Body.Components; +using Content.Shared.Examine; +using Content.Shared.Interaction; +using Content.Shared.Localizations; + +namespace Content.Shared.Body.Systems; + +public abstract partial class SharedBloodstreamSystem +{ + [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + + private void OnExamined(Entity target, ref ExaminedEvent args) + { + if (TryComp(args.Examiner, out var bloodExaminer)) + BloodExaminerExamined((args.Examiner, bloodExaminer), target, ref args); + } + + private void BloodExaminerExamined(Entity examiner, + Entity target, + ref ExaminedEvent args) + { + if (examiner.Owner == target.Owner) + return; + + // Blood drinker range. + if (!_interactionSystem.InRangeUnobstructed(examiner.Owner, target.Owner)) + return; + + var bloodSuffix = Loc.GetString(examiner.Comp.BloodSuffix); + var bloodNames = LocalizeBloodReagentNames(target, bloodSuffix); + var bloodText = ContentLocalizationManager.FormatList(bloodNames); + + var examineText = Loc.GetString(examiner.Comp.ExamineText, ("target", target), ("blood", bloodText)); + args.PushMarkup(examineText); + } + + private List LocalizeBloodReagentNames(Entity ent, string suffix) + { + var reference = ent.Comp.BloodReferenceSolution; + var names = new List(); + var protos = reference.GetReagentPrototypes(PrototypeManager).Select(p => p.Key); + + foreach (var blood in protos) + { + var bloodName = blood.LocalizedName; + + // Blood reagent text is colored. + var bloodText = Loc.GetString("blood-examiner-component-chemical", + ("color", blood.SubstanceColor.ToHexNoAlpha()), + ("blood", bloodName)); + + // Add "blood" to the end if it doesn't already have it, to make the sentence make sense. + // E.g. "You can smell her apple juice." -> "You can smell her apple juice blood." + if (protos.Last() == blood && !bloodName.EndsWith(suffix)) + bloodText = Loc.GetString("blood-examiner-component-examine-not-blood", + ("chemical", bloodText), + ("suffix", suffix)); + + names.Add(bloodText); + } + + return names; + } +} diff --git a/Resources/Locale/en-US/_DEN/bloodstream/blood-examiner-component.ftl b/Resources/Locale/en-US/_DEN/bloodstream/blood-examiner-component.ftl new file mode 100644 index 0000000000..747fc67039 --- /dev/null +++ b/Resources/Locale/en-US/_DEN/bloodstream/blood-examiner-component.ftl @@ -0,0 +1,4 @@ +blood-examiner-component-examine = [color=lightgray]You can smell {POSS-ADJ($target)} {$blood}.[/color] +blood-examiner-component-examine-not-blood = {$chemical} {$suffix} +blood-examiner-component-blood-suffix = blood +blood-examiner-component-chemical = [color={$color}]{$blood}[/color] diff --git a/Resources/Locale/en-US/_DEN/traits/categories.ftl b/Resources/Locale/en-US/_DEN/traits/categories.ftl index ea2c28cb06..497bc06bf7 100644 --- a/Resources/Locale/en-US/_DEN/traits/categories.ftl +++ b/Resources/Locale/en-US/_DEN/traits/categories.ftl @@ -1,2 +1,3 @@ +trait-category-perks = Perks trait-category-species-morphs = Morphotypes trait-category-species-specific = Species-specific diff --git a/Resources/Locale/en-US/_DEN/traits/perks.ftl b/Resources/Locale/en-US/_DEN/traits/perks.ftl new file mode 100644 index 0000000000..c0a8231839 --- /dev/null +++ b/Resources/Locale/en-US/_DEN/traits/perks.ftl @@ -0,0 +1,5 @@ +trait-blood-examiner-name = Blood Smell +trait-blood-examiner-desc = + You can [color=yellow]identify the blood chemical of mobs[/color] when you stand close enough to them. + Note that this trait [color=orange]does not detect other chemicals in their blood stream[/color], only what + the mob's blood stream is actually made of - such as [color=lightblue]synth blood[/color] or [color=lightblue]insect blood[/color]. diff --git a/Resources/Prototypes/_DEN/EntityTraits/categories.yml b/Resources/Prototypes/_DEN/EntityTraits/categories.yml index 723ce83024..8b5e0b0d75 100644 --- a/Resources/Prototypes/_DEN/EntityTraits/categories.yml +++ b/Resources/Prototypes/_DEN/EntityTraits/categories.yml @@ -8,3 +8,7 @@ id: SpeciesSpecific priority: -10 name: trait-category-species-specific + +- type: traitCategory + id: Perks + name: trait-category-perks diff --git a/Resources/Prototypes/_DEN/EntityTraits/perks.yml b/Resources/Prototypes/_DEN/EntityTraits/perks.yml new file mode 100644 index 0000000000..c66e72f82a --- /dev/null +++ b/Resources/Prototypes/_DEN/EntityTraits/perks.yml @@ -0,0 +1,9 @@ +- type: entityTrait + id: BloodExaminer + name: trait-blood-examiner-name + description: trait-blood-examiner-desc + category: Perks + functions: + - !type:AddComponentTrait + components: + - type: BloodExaminer