Skip to content

Commit

Permalink
new bullshit comes
Browse files Browse the repository at this point in the history
  • Loading branch information
MilonPL committed Sep 21, 2024
1 parent 3fd5287 commit 6afc235
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 1 deletion.
76 changes: 76 additions & 0 deletions Content.Server/DeltaV/MedSecHud/MedSecHudSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Content.Shared.Actions;
using Content.Shared.DeltaV.MedSecHud;
using Content.Shared.Clothing;
using Content.Shared.Overlays;
using Robust.Shared.GameStates;

namespace Content.Server.DeltaV.MedSecHud
{
public sealed class MedSecHudSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly IEntityManager _entities = default!;

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

SubscribeLocalEvent<MedSecHudComponent, ClothingGotEquippedEvent>(OnEquip);
SubscribeLocalEvent<MedSecHudComponent, ClothingGotUnequippedEvent>(OnUnequip);
SubscribeLocalEvent<MedSecHudComponent, ToggleMedSecHudEvent>(OnToggle);
}

private void OnEquip(EntityUid uid, MedSecHudComponent component, ClothingGotEquippedEvent args)
{
_actions.AddAction(args.Wearer, ref component.ActionEntity, component.ActionId, uid);
UpdateVisuals(uid, component);
}

private void OnUnequip(EntityUid uid, MedSecHudComponent component, ClothingGotUnequippedEvent args)
{
_actions.RemoveAction(args.Wearer, component.ActionEntity);
}

private void OnToggle(EntityUid uid, MedSecHudComponent component, ToggleMedSecHudEvent args)
{

component.MedicalMode = !component.MedicalMode;
UpdateVisuals(uid, component);
}

private void UpdateVisuals(EntityUid uid, MedSecHudComponent component)
{
if (component.MedicalMode)
{
// We can't use EnsureComp<T> because the overlay doesn't update
// It sucks, I know
var healthBarsComponent = new ShowHealthBarsComponent
{
DamageContainers = new List<string> { "Biological" },
};

_entities.AddComponent(uid, healthBarsComponent, true);

var healthIconsComponent = new ShowHealthIconsComponent
{
DamageContainers = new List<string> { "Biological" },
};

_entities.AddComponent(uid, healthIconsComponent, true);

RemComp<ShowJobIconsComponent>(uid);
RemComp<ShowMindShieldIconsComponent>(uid);
RemComp<ShowCriminalRecordIconsComponent>(uid);
}
else
{
EnsureComp<ShowJobIconsComponent>(uid);
EnsureComp<ShowMindShieldIconsComponent>(uid);
EnsureComp<ShowCriminalRecordIconsComponent>(uid);
RemComp<ShowHealthIconsComponent>(uid);
RemComp<ShowHealthBarsComponent>(uid);
}
Dirty(uid, component);
}
}
}
22 changes: 22 additions & 0 deletions Content.Shared/DeltaV/MedSecHud/MedSecHudComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Content.Shared.Actions;
using Robust.Shared.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;

namespace Content.Shared.DeltaV.MedSecHud
{
[RegisterComponent, NetworkedComponent]
public sealed partial class MedSecHudComponent : Component, ISerializationHooks
{
[DataField]
public bool MedicalMode = true;

[DataField]
public string ActionId = "ActionToggleMedSecHud";

[DataField]
public EntityUid? ActionEntity;
}
}

public sealed partial class ToggleMedSecHudEvent : InstantActionEvent { }
2 changes: 2 additions & 0 deletions Content.Shared/Overlays/ShowHealthBarsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ namespace Content.Shared.Overlays;
/// This component allows you to see health bars above damageable mobs.
/// </summary>
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState] // DeltaV - This should probably get reworked to use ProtoId but upstream
public sealed partial class ShowHealthBarsComponent : Component
{
/// <summary>
/// Displays health bars of the damage containers.
/// </summary>
[DataField("damageContainers", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageContainerPrototype>))]
[AutoNetworkedField] // DeltaV
public List<string> DamageContainers = new();

[DataField]
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Overlays/ShowHealthIconsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ namespace Content.Shared.Overlays;
/// This component allows you to see health status icons above damageable mobs.
/// </summary>
[RegisterComponent, NetworkedComponent]
[AutoGenerateComponentState] // DeltaV - This should probably get reworked to use ProtoId but upstream
public sealed partial class ShowHealthIconsComponent : Component
{
/// <summary>
/// Displays health status icons of the damage containers.
/// </summary>
[DataField("damageContainers", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageContainerPrototype>))]
[AutoNetworkedField] // DeltaV
public List<string> DamageContainers = new();
}
13 changes: 13 additions & 0 deletions Resources/Prototypes/DeltaV/Actions/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@
sprite: Structures/Furniture/Tables/generic.rsi
state: full
event: !type:ToggleCrawlingStateEvent

- type: entity
id: ActionToggleMedSecHud
name: Toggle medsec hud mode
description: Switch between medical and security icons.
components:
- type: InstantAction
itemIconStyle: BigAction
useDelay: 30 # Prevent people from spamming it
icon:
sprite: Clothing/Eyes/Hud/medsec.rsi
state: icon
event: !type:ToggleMedSecHudEvent
3 changes: 2 additions & 1 deletion Resources/Prototypes/Entities/Clothing/Eyes/hud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
- type: ShowThirstIcons

- type: entity
parent: [ClothingEyesBase, ShowSecurityIcons, ShowMedicalIcons, BaseSecurityCommandContraband]
parent: [ClothingEyesBase, BaseSecurityCommandContraband]
id: ClothingEyesHudMedSec
name: medsec hud
description: An eye display that looks like a mixture of medical and security huds.
Expand All @@ -167,6 +167,7 @@
- type: Tag
tags:
- HudMedicalSecurity
- type: MedSecHud

- type: entity
parent: [ClothingEyesBase, ShowSecurityIcons, ShowMedicalIcons]
Expand Down

0 comments on commit 6afc235

Please sign in to comment.