]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
cleanup
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Fri, 22 Nov 2024 22:02:59 +0000 (23:02 +0100)
committerslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Fri, 22 Nov 2024 22:02:59 +0000 (23:02 +0100)
Content.Client/Electrocution/ElectrocutionOverlaySystem.cs
Content.Shared/Electrocution/Components/ElectrocutionHUDVisualsComponent.cs [new file with mode: 0644]
Content.Shared/Electrocution/Components/ShowElectrocutionHUDComponent.cs [moved from Content.Shared/Electrocution/Components/ElectrocutionOverlayComponent.cs with 51% similarity]
Content.Shared/Electrocution/SharedElectrocution.cs
Resources/Prototypes/Entities/Mobs/Player/observer.yml
Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_structureairlocks.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml

index 2751c498de3f7ae96ae132853a51ccd95e13e2bd..bcfc51acc12620e4a48daf69e683b118ca782802 100644 (file)
@@ -6,96 +6,90 @@ using Robust.Shared.Player;
 namespace Content.Client.Electrocution;
 
 /// <summary>
-/// Shows the ElectrocutionOverlay to entities with the ElectrocutionOverlayComponent.
+/// Shows the Electrocution HUD to entities with the ShowElectrocutionHUDComponent.
 /// </summary>
-public sealed class ElectrocutionOverlaySystem : EntitySystem
+public sealed class ElectrifiedVisualizerSystem : VisualizerSystem<ElectrocutionHUDVisualsComponent>
 {
-
-    [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);
+        base.Initialize();
 
-        SubscribeLocalEvent<ElectrifiedComponent, AppearanceChangeEvent>(OnAppearanceChange);
+        SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentInit>(OnInit);
+        SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentShutdown>(OnShutdown);
+        SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
+        SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);
     }
 
-    private void OnPlayerAttached(Entity<ElectrocutionOverlayComponent> ent, ref LocalPlayerAttachedEvent args)
+    private void OnPlayerAttached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerAttachedEvent args)
     {
-        ShowOverlay();
+        ShowHUD();
     }
 
-    private void OnPlayerDetached(Entity<ElectrocutionOverlayComponent> ent, ref LocalPlayerDetachedEvent args)
+    private void OnPlayerDetached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerDetachedEvent args)
     {
-        RemoveOverlay();
+        RemoveHUD();
     }
 
-    private void OnInit(Entity<ElectrocutionOverlayComponent> ent, ref ComponentInit args)
+    private void OnInit(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentInit args)
     {
         if (_playerMan.LocalEntity == ent)
         {
-            ShowOverlay();
+            ShowHUD();
         }
     }
 
-    private void OnShutdown(Entity<ElectrocutionOverlayComponent> ent, ref ComponentShutdown args)
+    private void OnShutdown(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentShutdown args)
     {
         if (_playerMan.LocalEntity == ent)
         {
-            RemoveOverlay();
+            RemoveHUD();
         }
     }
 
-    private void ShowOverlay()
+    // 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<ElectrifiedComponent, AppearanceComponent, SpriteComponent>();
+        var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, 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))
+            if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, appearanceComp))
                 continue;
 
             if (electrified)
-                spriteComp.LayerSetVisible(ElectrifiedLayers.Overlay, true);
+                spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, true);
             else
-                spriteComp.LayerSetVisible(ElectrifiedLayers.Overlay, false);
+                spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false);
         }
     }
 
-    private void RemoveOverlay()
+    // 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<ElectrifiedComponent, AppearanceComponent, SpriteComponent>();
+        var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, 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);
+            spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false);
         }
     }
 
-    private void OnAppearanceChange(Entity<ElectrifiedComponent> ent, ref AppearanceChangeEvent args)
+    // 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 (!_appearance.TryGetData<bool>(ent.Owner, ElectrifiedVisuals.IsElectrified, out var electrified, args.Component))
-            return;
-
-        if (!args.Sprite.LayerMapTryGet(ElectrifiedLayers.Overlay, out var layer))
+        if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, args.Component))
             return;
 
         var player = _playerMan.LocalEntity;
-        if (electrified && HasComp<ElectrocutionOverlayComponent>(player))
-            args.Sprite.LayerSetVisible(layer, true);
+        if (electrified && HasComp<ShowElectrocutionHUDComponent>(player))
+            args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, true);
         else
-            args.Sprite.LayerSetVisible(layer, false);
+            args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, false);
     }
 }
diff --git a/Content.Shared/Electrocution/Components/ElectrocutionHUDVisualsComponent.cs b/Content.Shared/Electrocution/Components/ElectrocutionHUDVisualsComponent.cs
new file mode 100644 (file)
index 0000000..a48b1e3
--- /dev/null
@@ -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;
similarity index 51%
rename from Content.Shared/Electrocution/Components/ElectrocutionOverlayComponent.cs
rename to Content.Shared/Electrocution/Components/ShowElectrocutionHUDComponent.cs
index e03e8cb9344cb9f45d7a65beeaa1d98b87f51678..a6d9f380da3f5dd0baadd196b0e41a7eaaeccdc9 100644 (file)
@@ -3,7 +3,7 @@ using Robust.Shared.GameStates;
 namespace Content.Shared.Electrocution;
 
 /// <summary>
-/// Allow an entity to see the ElectrocutionOverlay showing electrocuted doors.
+/// Allow an entity to see the Electrocution HUD showing electrocuted doors.
 /// </summary>
 [RegisterComponent, NetworkedComponent]
-public sealed partial class ElectrocutionOverlayComponent : Component;
+public sealed partial class ShowElectrocutionHUDComponent : Component;
index b00fb1afdb7f1922c342a9e0ba808efe64ccf707..5422049874d92bb2d656211256e721cbb9eace78 100644 (file)
@@ -6,7 +6,7 @@ namespace Content.Shared.Electrocution;
 public enum ElectrifiedLayers : byte
 {
     Sparks,
-    Overlay,
+    HUD,
 }
 
 [Serializable, NetSerializable]
index dc89e635bf0019b83f1817bc2302a1e132878d0e..32a481491ce5e18d6d1f3580eed2bd6dc3f1e9cc 100644 (file)
@@ -55,7 +55,7 @@
     skipChecks: true
   - type: Ghost
   - type: GhostHearing
-  - type: ElectrocutionOverlay
+  - type: ShowElectrocutionHUD
   - type: IntrinsicRadioReceiver
   - type: ActiveRadio
     receiveAllChannels: true
index dee11f0451d4cf388b9b9ea462620b404c783535..b694b245b29ff7d6936417c4a4142bf0dbe6c94a 100644 (file)
@@ -30,7 +30,7 @@
   - type: IgnoreUIRange
   - type: StationAiHeld
   - type: StationAiOverlay
-  - type: ElectrocutionOverlay
+  - type: ShowElectrocutionHUD
   - type: ActionGrant
     actions:
     - ActionJumpToCore
index 8d8c69c6ad3531682a116bbee2be1224572ea16a..90224d3136e37f82bdea0d20af9f1115c7c9d305 100644 (file)
@@ -35,7 +35,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
@@ -78,6 +78,7 @@
   - type: DoorBolt
   - type: Appearance
   - type: WiresVisuals
+  - type: ElectrocutionHUDVisuals
   - type: ApcPowerReceiver
     powerLoad: 20
   - type: ExtensionCableReceiver
index e6905d61cc19bbc27153dade55404910d9337f00..630027384c94785656c4e3b2716adc46e9915f22 100644 (file)
         hard: false
   - 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"]
-      visible: false
-    - 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