-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters