]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix weather blocking in some instances (#14561)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sat, 11 Mar 2023 03:11:19 +0000 (14:11 +1100)
committerGitHub <noreply@github.com>
Sat, 11 Mar 2023 03:11:19 +0000 (14:11 +1100)
Content.Client/Weather/WeatherOverlay.cs
Content.Client/Weather/WeatherSystem.cs
Content.Shared/Weather/IgnoreWeatherComponent.cs [new file with mode: 0644]
Content.Shared/Weather/SharedWeatherSystem.cs
Resources/Prototypes/Entities/Objects/Decoration/flora.yml

index cfa745bf1e9d195bd7d56f2ecd745d3cdd4a170f..1c5fe4230a66186c335ebd42d45c2666a34f4605 100644 (file)
@@ -95,6 +95,7 @@ public sealed class WeatherOverlay : Overlay
         {
             var bodyQuery = _entManager.GetEntityQuery<PhysicsComponent>();
             var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
+            var weatherIgnoreQuery = _entManager.GetEntityQuery<IgnoreWeatherComponent>();
 
             foreach (var grid in _mapManager.FindGridsIntersecting(mapId, worldAABB))
             {
@@ -105,7 +106,7 @@ public sealed class WeatherOverlay : Overlay
                 foreach (var tile in grid.GetTilesIntersecting(worldAABB))
                 {
                     // Ignored tiles for stencil
-                    if (_weather.CanWeatherAffect(grid, tile, bodyQuery))
+                    if (_weather.CanWeatherAffect(grid, tile, weatherIgnoreQuery, bodyQuery))
                     {
                         continue;
                     }
index b94cad6253634408661f1fe8ed6e813d443ec20f..54e53e129364e02addb8b8736efde397d02a558d 100644 (file)
@@ -82,6 +82,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
             // If we don't have a nearest node don't play any sound.
             EntityCoordinates? nearestNode = null;
             var bodyQuery = GetEntityQuery<PhysicsComponent>();
+            var weatherIgnoreQuery = GetEntityQuery<IgnoreWeatherComponent>();
             var visited = new HashSet<Vector2i>();
 
             while (frontier.TryDequeue(out var node))
@@ -89,7 +90,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
                 if (!visited.Add(node.GridIndices))
                     continue;
 
-                if (!CanWeatherAffect(grid, node, bodyQuery))
+                if (!CanWeatherAffect(grid, node, weatherIgnoreQuery, bodyQuery))
                 {
                     // Add neighbors
                     // TODO: Ideally we pick some deterministically random direction and use that
diff --git a/Content.Shared/Weather/IgnoreWeatherComponent.cs b/Content.Shared/Weather/IgnoreWeatherComponent.cs
new file mode 100644 (file)
index 0000000..d3660f4
--- /dev/null
@@ -0,0 +1,12 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Weather;
+
+/// <summary>
+/// This entity will be ignored for considering weather on a tile
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed class IgnoreWeatherComponent : Component
+{
+
+}
index d0985961b512fdfa198bcfb2376b971faf51cf52..3aba97e92dfceff48101c77b6f2875bf0948af6e 100644 (file)
@@ -36,7 +36,11 @@ public abstract class SharedWeatherSystem : EntitySystem
         }
     }
 
-    public bool CanWeatherAffect(MapGridComponent grid, TileRef tileRef, EntityQuery<PhysicsComponent> bodyQuery)
+    public bool CanWeatherAffect(
+        MapGridComponent grid,
+        TileRef tileRef,
+        EntityQuery<IgnoreWeatherComponent> weatherIgnoreQuery,
+        EntityQuery<PhysicsComponent> bodyQuery)
     {
         if (tileRef.Tile.IsEmpty)
             return true;
@@ -50,7 +54,10 @@ public abstract class SharedWeatherSystem : EntitySystem
 
         while (anchoredEnts.MoveNext(out var ent))
         {
-            if (bodyQuery.TryGetComponent(ent, out var body) && body.CanCollide)
+            if (!weatherIgnoreQuery.HasComponent(ent.Value) &&
+                bodyQuery.TryGetComponent(ent, out var body) &&
+                body.Hard &&
+                body.CanCollide)
             {
                 return false;
             }
index 66b6d693e09552fd7c71e7945df9d212347b9345..44652af95565b8c9fecc436fa7fb17cebee6a54d 100644 (file)
@@ -37,6 +37,7 @@
   description: Yep, it's a tree.
   abstract: true
   components:
+  - type: IgnoreWeather
   - type: SpriteFade
   - type: Clickable
   - type: Sprite