Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hissing & Another Airlock Error #1596

Merged
merged 11 commits into from
Jan 19, 2025
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using Content.Shared.Electrocution;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client.Electrocution;

/// <summary>
/// Shows the Electrocution HUD to entities with the ShowElectrocutionHUDComponent.
/// </summary>
public sealed class ElectrocutionHUDVisualizerSystem : VisualizerSystem<ElectrocutionHUDVisualsComponent>
{
[Dependency] private readonly IPlayerManager _playerMan = default!;

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

SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
}

private void OnPlayerAttached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerAttachedEvent args)
{
ShowHUD();
}

private void OnPlayerDetached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerDetachedEvent args)
{
RemoveHUD();
}

private void OnInit(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentInit args)
{
if (_playerMan.LocalEntity == ent)
{
ShowHUD();
}
}

private void OnShutdown(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentShutdown args)
{
if (_playerMan.LocalEntity == ent)
{
RemoveHUD();
}
}

// Show the HUD to the client.
// We have to look for all current entities that can be electrified and toggle the HUD layer on if they are.
private void ShowHUD()
{
var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, AppearanceComponent, SpriteComponent>();
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp))
{
if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, appearanceComp))
continue;

if (electrified)
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, true);
else
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false);
}
}

// Remove the HUD from the client.
// Find all current entities that can be electrified and hide the HUD layer.
private void RemoveHUD()
{
var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, AppearanceComponent, SpriteComponent>();
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp))
{
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false);
}
}

// Toggle the HUD layer if an entity becomes (de-)electrified
protected override void OnAppearanceChange(EntityUid uid, ElectrocutionHUDVisualsComponent comp, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, args.Component))
return;

var player = _playerMan.LocalEntity;
if (electrified && HasComp<ShowElectrocutionHUDComponent>(player))
args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, true);
else
args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, false);
}
}
101 changes: 0 additions & 101 deletions Content.Client/Electrocution/ElectrocutionOverlaySystem.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Content.Server/Chat/SuicideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void OnDamageableSuicide(Entity<DamageableComponent> victim, ref Suicide
return;
}

args.DamageType ??= "Blunt";
args.DamageType ??= "Slash";
_suicide.ApplyLethalDamage(victim, args.DamageType);
args.Handled = true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Shared.Electrocution;

/// <summary>
/// Handles toggling sprite layers for the electrocution HUD to show if an entity with the ElectrifiedComponent is electrified.
/// </summary>
[RegisterComponent]
public sealed partial class ElectrocutionHUDVisualsComponent : Component;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Electrocution;

/// <summary>
/// Allow an entity to see the Electrocution HUD showing electrocuted doors.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class ShowElectrocutionHUDComponent : Component;
2 changes: 1 addition & 1 deletion Content.Shared/Electrocution/SharedElectrocution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Content.Shared.Electrocution;
public enum ElectrifiedLayers : byte
{
Sparks,
Overlay,
HUD,
}

[Serializable, NetSerializable]
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/random-barks/hissing.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ bark-hissing-1 = Hsssss
bark-hissing-2 = Hssssssss
bark-hissing-3 = I sssee you
bark-hissing-4 = I will catch you
bark-hissing-5 = Meat...
bark-hissing-6 = I'm hhhungry!
bark-hissing-7 = Ssseek... food...
bark-hissing-8 = Hsss... Get there
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/DeltaV/Catalog/Shipyard/civilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
id: Helix
name: NTMC Helix
description: A large mobile health clinic for servicing distant outposts.
price: 46000
price: 47000
path: /Maps/Shuttles/DeltaV/helix.yml
categories:
- Civilian
Expand All @@ -36,7 +36,7 @@
id: Prospector
name: NT-7 Prospector
description: A small mining vessel designed to assist salvage operations.
price: 21000
price: 22000
path: /Maps/Shuttles/DeltaV/prospector.yml
categories:
- Civilian
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/Player/observer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
skipChecks: true
- type: Ghost
- type: GhostHearing
- type: ElectrocutionOverlay
- type: ShowElectrocutionHUD
- type: IntrinsicRadioReceiver
- type: ActiveRadio
receiveAllChannels: true
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- type: IgnoreUIRange
- type: StationAiHeld
- type: StationAiOverlay
- type: ElectrocutionOverlay
- type: ShowElectrocutionHUD
- type: ActionGrant
actions:
- ActionJumpToCore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
sprite: Interface/Misc/ai_hud.rsi
shader: unshaded
visible: false
map: ["enum.ElectrifiedLayers.Overlay"]
map: ["enum.ElectrifiedLayers.HUD"]
- type: AnimationPlayer
- type: Physics
- type: Fixtures
Expand Down Expand Up @@ -77,6 +77,7 @@
- type: DoorBolt
- type: Appearance
- type: WiresVisuals
- type: ElectrocutionHUDVisuals
- type: ApcPowerReceiver
powerLoad: 20
- type: ExtensionCableReceiver
Expand Down
Loading
Loading