Fix Hissing & Another Airlock Error (#1596)

errors/test fail ops

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
(cherry picked from commit 7c5c4ba53b562720202937d19ae266b9e3c74f99)
This commit is contained in:
sleepyyapril
2025-01-19 02:04:17 -04:00
committed by Spatison
parent fd96c031b3
commit b271af64da
12 changed files with 131 additions and 166 deletions

View File

@@ -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);
}
}

View File

@@ -1,101 +0,0 @@
using Content.Shared.Electrocution;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Player;
namespace Content.Client.Electrocution;
/// <summary>
/// Shows the ElectrocutionOverlay to entities with the ElectrocutionOverlayComponent.
/// </summary>
public sealed class ElectrocutionOverlaySystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly IPlayerManager _playerMan = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<ElectrocutionOverlayComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ElectrocutionOverlayComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ElectrocutionOverlayComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<ElectrocutionOverlayComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<ElectrifiedComponent, AppearanceChangeEvent>(OnAppearanceChange);
}
private void OnPlayerAttached(Entity<ElectrocutionOverlayComponent> ent, ref LocalPlayerAttachedEvent args)
{
ShowOverlay();
}
private void OnPlayerDetached(Entity<ElectrocutionOverlayComponent> ent, ref LocalPlayerDetachedEvent args)
{
RemoveOverlay();
}
private void OnInit(Entity<ElectrocutionOverlayComponent> ent, ref ComponentInit args)
{
if (_playerMan.LocalEntity == ent)
{
ShowOverlay();
}
}
private void OnShutdown(Entity<ElectrocutionOverlayComponent> ent, ref ComponentShutdown args)
{
if (_playerMan.LocalEntity == ent)
{
RemoveOverlay();
}
}
private void ShowOverlay()
{
var electrifiedQuery = AllEntityQuery<ElectrifiedComponent, AppearanceComponent, SpriteComponent>();
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp))
{
if (!_appearance.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, appearanceComp))
continue;
if (!spriteComp.LayerMapTryGet(ElectrifiedLayers.Overlay, out var layer))
continue;
if (electrified)
spriteComp.LayerSetVisible(ElectrifiedLayers.Overlay, true);
else
spriteComp.LayerSetVisible(ElectrifiedLayers.Overlay, false);
}
}
private void RemoveOverlay()
{
var electrifiedQuery = AllEntityQuery<ElectrifiedComponent, AppearanceComponent, SpriteComponent>();
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp))
{
if (!spriteComp.LayerMapTryGet(ElectrifiedLayers.Overlay, out var layer))
continue;
spriteComp.LayerSetVisible(layer, false);
}
}
private void OnAppearanceChange(Entity<ElectrifiedComponent> ent, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (!_appearance.TryGetData<bool>(ent.Owner, ElectrifiedVisuals.IsElectrified, out var electrified, args.Component))
return;
if (!args.Sprite.LayerMapTryGet(ElectrifiedLayers.Overlay, out var layer))
return;
var player = _playerMan.LocalEntity;
if (electrified && HasComp<ElectrocutionOverlayComponent>(player))
args.Sprite.LayerSetVisible(layer, true);
else
args.Sprite.LayerSetVisible(layer, false);
}
}

View File

@@ -147,7 +147,7 @@ public sealed class SuicideSystem : EntitySystem
return;
}
args.DamageType ??= "Blunt";
args.DamageType ??= "Slash";
_suicide.ApplyLethalDamage(victim, args.DamageType);
args.Handled = true;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -6,7 +6,7 @@ namespace Content.Shared.Electrocution;
public enum ElectrifiedLayers : byte
{
Sparks,
Overlay,
HUD,
}
[Serializable, NetSerializable]

View File

@@ -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

View File

@@ -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
@@ -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

View File

@@ -59,7 +59,7 @@
skipChecks: true
- type: Ghost
- type: GhostHearing
- type: ElectrocutionOverlay
- type: ShowElectrocutionHUD
- type: IntrinsicRadioReceiver
- type: ActiveRadio
receiveAllChannels: true

View File

@@ -22,7 +22,7 @@
- type: IgnoreUIRange
- type: StationAiHeld
- type: StationAiOverlay
- type: ElectrocutionOverlay
- type: ShowElectrocutionHUD
- type: ActionGrant
actions:
- ActionJumpToCore

View File

@@ -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
@@ -77,6 +77,7 @@
- type: DoorBolt
- type: Appearance
- type: WiresVisuals
- type: ElectrocutionHUDVisuals
- type: ApcPowerReceiver
powerLoad: 20
- type: ExtensionCableReceiver

View File

@@ -31,22 +31,6 @@
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/shuttle.rsi
snapCardinals: false
layers:
- state: closed
map: ["enum.DoorVisualLayers.Base"]
- state: closed_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseUnlit"]
- state: welded
map: ["enum.WeldableLayers.BaseWelded"]
- state: bolted_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseBolted"]
- state: emergency_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseEmergencyAccess"]
- state: panel_open
map: ["enum.WiresVisualLayers.MaintenancePanel"]
- type: Wires
layoutId: Docking
- type: Door
@@ -63,6 +47,8 @@
path: /Audio/Machines/airlock_deny.ogg
- type: Airtight
noAirWhenFullyAirBlocked: false
airBlockedDirection:
- South
- type: Tag
tags:
- ForceNoFixRotations
@@ -72,6 +58,8 @@
- type: Construction
graph: AirlockShuttle
node: airlock
- type: StaticPrice
price: 350
- type: entity
id: AirlockGlassShuttle
@@ -82,29 +70,17 @@
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Glass/shuttle.rsi
snapCardinals: false
layers:
- state: closed
map: ["enum.DoorVisualLayers.Base"]
- state: closed_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseUnlit"]
- state: welded
map: ["enum.WeldableLayers.BaseWelded"]
- state: bolted_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseBolted"]
- state: emergency_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseEmergencyAccess"]
- state: panel_open
map: ["enum.WiresVisualLayers.MaintenancePanel"]
- type: Occluder
enabled: false
- type: PaintableAirlock
group: ShuttleGlass
- type: Door
occludes: false
- type: Fixtures
fixtures:
fix1:
layer: #removed opaque from the layer, allowing lasers to pass through glass airlocks
- GlassAirlockLayer
- type: entity
id: AirlockShuttleAssembly
@@ -120,42 +96,20 @@
- type: Sprite
sprite: Structures/Doors/Airlocks/Glass/shuttle.rsi
state: closed
snapCardinals: false
- type: Construction
graph: AirlockShuttle
node: assembly
- type: entity
id: AirlockGlassShuttleSyndicate
parent: AirlockShuttle
parent: AirlockGlassShuttle
name: external airlock
suffix: Glass, Docking
description: Necessary for connecting two space craft together.
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Glass/shuttle_syndicate.rsi
snapCardinals: false
layers:
- state: closed
map: ["enum.DoorVisualLayers.Base"]
- state: closed_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseUnlit"]
- state: welded
map: ["enum.WeldableLayers.BaseWelded"]
- state: bolted_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseBolted"]
- state: emergency_unlit
shader: unshaded
map: ["enum.DoorVisualLayers.BaseEmergencyAccess"]
- state: panel_open
map: ["enum.WiresVisualLayers.MaintenancePanel"]
- type: Occluder
enabled: false
- type: PaintableAirlock
group: ShuttleGlass
- type: Door
occludes: false
- type: entity
parent: AirlockShuttle
@@ -165,4 +119,4 @@
description: Necessary for connecting two space craft together.
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/shuttle_syndicate.rsi
sprite: Structures/Doors/Airlocks/Standard/shuttle_syndicate.rsi