Skip to content

Commit

Permalink
Add Machine Incompatible Trait (#2395)
Browse files Browse the repository at this point in the history
* Mostly done, just needs some messaging added

Going to change the description for the unborgable brain and add a popup.

* Inspection says if brain has trait

* Comments

* Moved comment, removed body, localized, etc.

* move to shared, shitmed ready, add warning to health analyzer

* pro

* remove old component

* untroll brain system

* :trollface:

* :trollface:

* fix

---------

Signed-off-by: deltanedas <[email protected]>
Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: deltanedas <[email protected]>
  • Loading branch information
Emily9031 and deltanedas authored Jan 10, 2025
1 parent 2d6d852 commit d361ece
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Numerics;
using Content.Client.Message;
using Content.Shared._DV.Traits.Assorted; // DeltaV
using Content.Shared.Atmos;
using Content.Client.UserInterface.Controls;
using Content.Shared._Shitmed.Targeting; // Shitmed
Expand Down Expand Up @@ -36,6 +37,7 @@ public sealed partial class HealthAnalyzerWindow : FancyWindow
private readonly SpriteSystem _spriteSystem;
private readonly IPrototypeManager _prototypes;
private readonly IResourceCache _cache;
private readonly UnborgableSystem _unborgable; // DeltaV

// Shitmed Change Start
public event Action<TargetBodyPart?, EntityUid>? OnBodyPartSelected;
Expand All @@ -57,6 +59,7 @@ public HealthAnalyzerWindow()
_spriteSystem = _entityManager.System<SpriteSystem>();
_prototypes = dependencies.Resolve<IPrototypeManager>();
_cache = dependencies.Resolve<IResourceCache>();
_unborgable = _entityManager.System<UnborgableSystem>(); // DeltaV
// Shitmed Change Start
_bodyPartControls = new Dictionary<TargetBodyPart, TextureButton>
{
Expand Down Expand Up @@ -184,7 +187,8 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)

// Alerts

var showAlerts = msg.Unrevivable == true || msg.Bleeding == true;
var unborgable = _unborgable.IsUnborgable(_target.Value); // DeltaV
var showAlerts = msg.Unrevivable == true || msg.Bleeding == true || unborgable;

AlertsDivider.Visible = showAlerts;
AlertsContainer.Visible = showAlerts;
Expand All @@ -208,6 +212,14 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
MaxWidth = 300
});

if (unborgable) // DeltaV
AlertsContainer.AddChild(new RichTextLabel
{
Text = Loc.GetString("health-analyzer-window-entity-unborgable-text"),
Margin = new Thickness(0, 4),
MaxWidth = 300
});

// Damage Groups

var damageSortedGroups =
Expand Down
10 changes: 10 additions & 0 deletions Content.Shared/_DV/Traits/Assorted/UnborgableComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;

namespace Content.Shared._DV.Traits.Assorted;

/// <summary>
/// This is used for the unborgable trait, which blacklists a brain from MMIs.
/// If this is added to a body, it gets moved to its brain if it has one.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class UnborgableComponent : Component;
54 changes: 54 additions & 0 deletions Content.Shared/_DV/Traits/Assorted/UnborgableSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using Content.Shared.Body.Components;
using Content.Shared.Body.Organ;
using Content.Shared.Body.Systems;
using Content.Shared.Examine;
using Content.Shared.Movement.Components; // TODO: use BrainComponent instead of InputMover when shitmed is merged
using Robust.Shared.Utility;

namespace Content.Shared._DV.Traits.Assorted;

/// <summary>
/// Adds a warning examine message to brains with <see cref="UnborgableComponent"/>.
/// </summary>
public sealed class UnborgableSystem : EntitySystem
{
[Dependency] private readonly SharedBodySystem _body = default!;

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

SubscribeLocalEvent<UnborgableComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<UnborgableComponent, ExaminedEvent>(OnExamined);
}

/// <summary>
/// Returns true if a mob's brain has <see cref="UnborgableComponent"/>.
/// </summary>
public bool IsUnborgable(Entity<BodyComponent?> ent)
{
// technically this will apply for any organ not just brain, but assume nobody will be evil and do that
return _body.GetBodyOrganEntityComps<UnborgableComponent>(ent).Count > 0;
}

private void OnMapInit(Entity<UnborgableComponent> ent, ref MapInitEvent args)
{
if (!TryComp<BodyComponent>(ent, out var body))
return;

var brains = _body.GetBodyOrganEntityComps<InputMoverComponent>((ent.Owner, body));
foreach (var brain in brains)
{
EnsureComp<UnborgableComponent>(brain);
}
}

private void OnExamined(Entity<UnborgableComponent> ent, ref ExaminedEvent args)
{
// need a health analyzer to see if someone can't be borged, can't just look at them and know
if (!args.IsInDetailsRange || HasComp<BodyComponent>(ent))
return;

args.PushMarkup(Loc.GetString("brain-cannot-be-borged-message"));
}
}
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/_DV/borg/borg.ftl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
borg-type-security-name = Security
borg-type-security-desc = Assist security in the fight for justice by detaining dangerous criminals.
borg-type-security-transponder = security cyborg
brain-cannot-be-borged-message = [color=red]This brain is damaged beyond use.[/color]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
health-analyzer-window-entity-unborgable-text = [color=red]Patient's brain signatures are incompatible with MMI technology![/color]
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_DV/traits/traits.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ trait-inpain-desc = You’re constantly in discomfort. You need painkillers to f
trait-addicted-name = Addicted
trait-addicted-desc = You crave the substance, and your thoughts keep drifting back to it. Without it, you feel incomplete, anxious, and on edge.
trait-unborgable-name = Machine Incompatible
trait-unborgable-desc = Your brain cannot be put into a man-machine interface.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
whitelist:
components:
- Brain
blacklist: # DeltaV
components:
- Unborgable
- type: ContainerContainer
containers:
brain_slot: !type:ContainerSlot
Expand Down
8 changes: 8 additions & 0 deletions Resources/Prototypes/_DV/Traits/disabilities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@
category: Disabilities
components:
- type: Pain

- type: trait
id: Unborgable
name: trait-unborgable-name
description: trait-unborgable-desc
category: Disabilities
components:
- type: Unborgable # Automatically gets moved to the brain

0 comments on commit d361ece

Please sign in to comment.