]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Tweak for the visual coverage granted to station AIs by holopads (#38059)
authorchromiumboy <50505512+chromiumboy@users.noreply.github.com>
Thu, 5 Jun 2025 23:15:55 +0000 (18:15 -0500)
committerGitHub <noreply@github.com>
Thu, 5 Jun 2025 23:15:55 +0000 (19:15 -0400)
* Initial commit

* Added option to require anchoring

Content.Shared/Silicons/StationAi/StationAiVisionComponent.cs
Content.Shared/Silicons/StationAi/StationAiVisionSystem.cs
Resources/Prototypes/Entities/Structures/Machines/holopad.yml

index f047fe41e4db127710c573631e4d23d8770b6405..3c5f3896b0095114e5813f1bc2f3ebd85ec96684 100644 (file)
@@ -3,17 +3,38 @@ using Robust.Shared.GameStates;
 
 namespace Content.Shared.StationAi;
 
+/// <summary>
+/// Attached to entities that grant vision to the station AI, such as cameras.
+/// </summary>
 [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStationAiSystem))]
 public sealed partial class StationAiVisionComponent : Component
 {
+    /// <summary>
+    /// Determines whether the entity is actively providing vision to the station AI.
+    /// </summary>
     [DataField, AutoNetworkedField]
     public bool Enabled = true;
 
+    /// <summary>
+    /// Determines whether the entity's vision is blocked by walls.
+    /// </summary>
     [DataField, AutoNetworkedField]
     public bool Occluded = true;
 
     /// <summary>
-    /// Range in tiles
+    /// Determines whether the entity needs to be receiving power to provide vision to the station AI.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool NeedsPower = false;
+
+    /// <summary>
+    /// Determines whether the entity needs to be anchored to provide vision to the station AI.
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public bool NeedsAnchoring = false;
+
+    /// <summary>
+    /// Vision range in tiles.
     /// </summary>
     [DataField, AutoNetworkedField]
     public float Range = 7.5f;
index d3416949d536ff6f26504a80183300ba27bcc81f..7ae27da497efbb9945ea8b1123764a34587e2c45 100644 (file)
@@ -1,8 +1,8 @@
+using Content.Shared.Power.EntitySystems;
 using Content.Shared.StationAi;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics;
 using Robust.Shared.Threading;
-using Robust.Shared.Utility;
 
 namespace Content.Shared.Silicons.StationAi;
 
@@ -18,6 +18,7 @@ public sealed class StationAiVisionSystem : EntitySystem
     [Dependency] private readonly EntityLookupSystem _lookup = default!;
     [Dependency] private readonly SharedMapSystem _maps = default!;
     [Dependency] private readonly SharedTransformSystem _xforms = default!;
+    [Dependency] private readonly SharedPowerReceiverSystem _power = default!;
 
     private SeedJob _seedJob;
     private ViewJob _job;
@@ -83,6 +84,12 @@ public sealed class StationAiVisionSystem : EntitySystem
             if (!seed.Comp.Enabled)
                 continue;
 
+            if (seed.Comp.NeedsPower && !_power.IsPowered(seed.Owner))
+                continue;
+
+            if (seed.Comp.NeedsAnchoring && !Transform(seed.Owner).Anchored)
+                continue;
+
             _job.Data.Add(seed);
         }
 
@@ -164,6 +171,12 @@ public sealed class StationAiVisionSystem : EntitySystem
             if (!seed.Comp.Enabled)
                 continue;
 
+            if (seed.Comp.NeedsPower && !_power.IsPowered(seed.Owner))
+                continue;
+
+            if (seed.Comp.NeedsAnchoring && !Transform(seed.Owner).Anchored)
+                continue;
+
             _job.Data.Add(seed);
         }
 
index 1a1712991a8cd8ae354c5e93660ca61b12351bc6..95a1fba489631fa1bcee20edc2e2e64b21519a83 100644 (file)
@@ -17,6 +17,8 @@
   - type: ApcPowerReceiver
     powerLoad: 300
   - type: StationAiVision
+    range: 1
+    needsAnchoring: true
   - type: Sprite
     sprite: Structures/Machines/holopad.rsi
     drawdepth: HighFloorObjects