Skip to content
Draft
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: 4 additions & 1 deletion Content.Shared/Body/Systems/SharedBloodstreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";

Expand Down Expand Up @@ -55,6 +56,8 @@ public override void Initialize()
SubscribeLocalEvent<BloodstreamComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
SubscribeLocalEvent<BloodstreamComponent, RejuvenateEvent>(OnRejuvenate);
SubscribeLocalEvent<BloodstreamComponent, MetabolismExclusionEvent>(OnMetabolismExclusion);

SubscribeLocalEvent<BloodstreamComponent, ExaminedEvent>(OnExamined); // DEN
}

public override void Update(float frameTime)
Expand Down
18 changes: 18 additions & 0 deletions Content.Shared/_DEN/Body/Components/BloodExaminerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Shared.Body.Systems;

namespace Content.Shared._DEN.Body.Systems;

/// <summary>
/// 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.
/// </summary>
[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";
}
66 changes: 66 additions & 0 deletions Content.Shared/_DEN/Body/EntitySystems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
@@ -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<BloodstreamComponent> target, ref ExaminedEvent args)
{
if (TryComp<BloodExaminerComponent>(args.Examiner, out var bloodExaminer))
BloodExaminerExamined((args.Examiner, bloodExaminer), target, ref args);
}

private void BloodExaminerExamined(Entity<BloodExaminerComponent> examiner,
Entity<BloodstreamComponent> 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<string> LocalizeBloodReagentNames(Entity<BloodstreamComponent> ent, string suffix)
{
var reference = ent.Comp.BloodReferenceSolution;
var names = new List<string>();
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;
}
}
Original file line number Diff line number Diff line change
@@ -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]
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_DEN/traits/categories.ftl
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
trait-category-perks = Perks
trait-category-species-morphs = Morphotypes
trait-category-species-specific = Species-specific
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/_DEN/traits/perks.ftl
Original file line number Diff line number Diff line change
@@ -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].
4 changes: 4 additions & 0 deletions Resources/Prototypes/_DEN/EntityTraits/categories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
id: SpeciesSpecific
priority: -10
name: trait-category-species-specific

- type: traitCategory
id: Perks
name: trait-category-perks
9 changes: 9 additions & 0 deletions Resources/Prototypes/_DEN/EntityTraits/perks.yml
Original file line number Diff line number Diff line change
@@ -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
Loading