]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
move TriggerExplosion to shared (#30227)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Thu, 19 Sep 2024 00:01:40 +0000 (00:01 +0000)
committerGitHub <noreply@github.com>
Thu, 19 Sep 2024 00:01:40 +0000 (10:01 +1000)
* move component to shared

* add fake systems

* update server explosion system and remove duplicate transform query

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Client/Explosion/ExplosionSystem.cs
Content.Server/Destructible/Thresholds/Behaviors/SolutionExplosionBehavior.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.Airtight.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.CVars.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.TileFill.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.Visuals.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Content.Shared/Explosion/Components/ExplosiveComponent.cs [moved from Content.Server/Explosion/Components/ExplosiveComponent.cs with 76% similarity]
Content.Shared/Explosion/EntitySystems/SharedExplosionSystem.cs

index a2ed2d50e0d1efb14d5318791227636684e1fe8a..692782ded4b77b6ddad56bebf6b2940ea667ab86 100644 (file)
@@ -2,7 +2,4 @@ using Content.Shared.Explosion.EntitySystems;
 
 namespace Content.Client.Explosion.EntitySystems;
 
-public sealed class ExplosionSystem : SharedExplosionSystem
-{
-
-}
+public sealed class ExplosionSystem : SharedExplosionSystem;
index 5166aaccabba4137685b39c963696f4d544d34ac..08c7c8f068f81e81237431ff3353b299534b930e 100644 (file)
@@ -1,4 +1,4 @@
-using Content.Server.Explosion.Components;
+using Content.Shared.Explosion.Components;
 using JetBrains.Annotations;
 
 namespace Content.Server.Destructible.Thresholds.Behaviors
index 4b59c8f1c48f8f7a6e4cbd9d21be5704f0e54bf2..6fa553bc8b60d6d82c2aad6b73083854b70638f5 100644 (file)
@@ -6,9 +6,10 @@ using Content.Shared.Explosion;
 using Content.Shared.Explosion.EntitySystems;
 using Content.Shared.FixedPoint;
 using Robust.Shared.Map.Components;
+
 namespace Content.Server.Explosion.EntitySystems;
 
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     [Dependency] private readonly DestructibleSystem _destructibleSystem = default!;
 
index ce98f89de7af4a5bd3c835dcb9cfc2d276e507fc..5af06ef93684af5f9ef22887e205b69019139e03 100644 (file)
@@ -1,8 +1,8 @@
 using Content.Shared.CCVar;
-using Content.Shared.Explosion.EntitySystems;
+
 namespace Content.Server.Explosion.EntitySystems;
 
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     public int MaxIterations { get; private set; }
     public int MaxArea { get; private set; }
index 75bb606441a42437beb3f074cfaed93fcaa73992..29477c16b28e3303c5525b2759089f5cb148bfc5 100644 (file)
@@ -12,7 +12,7 @@ namespace Content.Server.Explosion.EntitySystems;
 // A good portion of it is focused around keeping track of what tile-indices on a grid correspond to tiles that border
 // space. AFAIK no other system currently needs to track these "edge-tiles". If they do, this should probably be a
 // property of the grid itself?
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     /// <summary>
     ///     Set of tiles of each grid that are directly adjacent to space, along with the directions that face space.
index 6d0cbcf2794c27357bf16b7c17c235963011ebcd..97d52e436a8f7eeafefa57f6f5cd1c4f73a5d611 100644 (file)
@@ -22,9 +22,10 @@ using Robust.Shared.Random;
 using Robust.Shared.Timing;
 using Robust.Shared.Utility;
 using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
+
 namespace Content.Server.Explosion.EntitySystems;
 
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     [Dependency] private readonly FlammableSystem _flammableSystem = default!;
 
@@ -218,7 +219,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
         // get the entities on a tile. Note that we cannot process them directly, or we get
         // enumerator-changed-while-enumerating errors.
         List<(EntityUid, TransformComponent)> list = new();
-        var state = (list, processed, _transformQuery);
+        var state = (list, processed, EntityManager.TransformQuery);
 
         // get entities:
         lookup.DynamicTree.QueryAabb(ref state, GridQueryCallback, gridBox, true);
@@ -317,7 +318,7 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
         var gridBox = Box2.FromDimensions(tile * DefaultTileSize, new Vector2(DefaultTileSize, DefaultTileSize));
         var worldBox = spaceMatrix.TransformBox(gridBox);
         var list = new List<(EntityUid, TransformComponent)>();
-        var state = (list, processed, invSpaceMatrix, lookup.Owner, _transformQuery, gridBox, _transformSystem);
+        var state = (list, processed, invSpaceMatrix, lookup.Owner, EntityManager.TransformQuery, gridBox, _transformSystem);
 
         // get entities:
         lookup.DynamicTree.QueryAabb(ref state, SpaceQueryCallback, worldBox, true);
index 8c3229e06eef532c4e8bc3d5d6b5756feef58bbc..7b73490d9467f59e2cd66904a2c376aa618b734e 100644 (file)
@@ -7,13 +7,13 @@ using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Components;
 using Robust.Shared.Timing;
-using Content.Shared.Explosion.EntitySystems;
+
 namespace Content.Server.Explosion.EntitySystems;
 
 // This partial part of the explosion system has all of the functions used to create the actual explosion map.
 // I.e, to get the sets of tiles & intensity values that describe an explosion.
 
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     /// <summary>
     ///     This is the main explosion generating function.
index 219dba4bdeb8f8e11418b6661f6cdb8fb5aace4a..57323e4de7093e2fddb73c50223fe7b46565cd3e 100644 (file)
@@ -5,10 +5,11 @@ using Content.Shared.Explosion.EntitySystems;
 using Robust.Server.GameObjects;
 using Robust.Shared.GameStates;
 using Robust.Shared.Map;
+
 namespace Content.Server.Explosion.EntitySystems;
 
 // This part of the system handled send visual / overlay data to clients.
-public sealed partial class ExplosionSystem : SharedExplosionSystem
+public sealed partial class ExplosionSystem
 {
     public void InitVisuals()
     {
index cd0ca1c22eb2faf1534dd188493e4ac556a16a46..818953ed4b478b6d3990365bc201297e93d17364 100644 (file)
@@ -12,6 +12,8 @@ using Content.Shared.CCVar;
 using Content.Shared.Damage;
 using Content.Shared.Database;
 using Content.Shared.Explosion;
+using Content.Shared.Explosion.Components;
+using Content.Shared.Explosion.EntitySystems;
 using Content.Shared.GameTicking;
 using Content.Shared.Inventory;
 using Content.Shared.Projectiles;
@@ -53,7 +55,6 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
     [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
     [Dependency] private readonly SharedMapSystem _map = default!;
 
-    private EntityQuery<TransformComponent> _transformQuery;
     private EntityQuery<FlammableComponent> _flammableQuery;
     private EntityQuery<PhysicsComponent> _physicsQuery;
     private EntityQuery<ProjectileComponent> _projectileQuery;
@@ -103,7 +104,6 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
         InitAirtightMap();
         InitVisuals();
 
-        _transformQuery = GetEntityQuery<TransformComponent>();
         _flammableQuery = GetEntityQuery<FlammableComponent>();
         _physicsQuery = GetEntityQuery<PhysicsComponent>();
         _projectileQuery = GetEntityQuery<ProjectileComponent>();
@@ -141,15 +141,8 @@ public sealed partial class ExplosionSystem : SharedExplosionSystem
             args.DamageCoefficient *= modifier;
     }
 
-    /// <summary>
-    ///     Given an entity with an explosive component, spawn the appropriate explosion.
-    /// </summary>
-    /// <remarks>
-    ///     Also accepts radius or intensity arguments. This is useful for explosives where the intensity is not
-    ///     specified in the yaml / by the component, but determined dynamically (e.g., by the quantity of a
-    ///     solution in a reaction).
-    /// </remarks>
-    public void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
+    /// <inheritdoc/>
+    public override void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
     {
         // log missing: false, because some entities (e.g. liquid tanks) attempt to trigger explosions when damaged,
         // but may not actually be explosive.
similarity index 76%
rename from Content.Server/Explosion/Components/ExplosiveComponent.cs
rename to Content.Shared/Explosion/Components/ExplosiveComponent.cs
index 2b27a89d9db78fb87d22a4fc5a85d61dbe16d358..bab7f5a7d6785c61ca61686e6896ae0235fa8bcd 100644 (file)
@@ -1,8 +1,7 @@
-using Content.Server.Explosion.EntitySystems;
-using Content.Shared.Explosion;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
+using Content.Shared.Explosion.EntitySystems;
+using Robust.Shared.Prototypes;
 
-namespace Content.Server.Explosion.Components;
+namespace Content.Shared.Explosion.Components;
 
 /// <summary>
 ///     Specifies an explosion that can be spawned by this entity. The explosion itself is spawned via <see
@@ -12,31 +11,27 @@ namespace Content.Server.Explosion.Components;
 ///      The total intensity may be overridden by whatever system actually calls TriggerExplosive(), but this
 ///      component still determines the explosion type and other properties.
 /// </remarks>
-[RegisterComponent]
+[RegisterComponent, Access(typeof(SharedExplosionSystem))]
 public sealed partial class ExplosiveComponent : Component
 {
-
     /// <summary>
     ///     The explosion prototype. This determines the damage types, the tile-break chance, and some visual
     ///     information (e.g., the light that the explosion gives off).
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("explosionType", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<ExplosionPrototype>))]
-    public string ExplosionType = default!;
+    [DataField(required: true)]
+    public ProtoId<ExplosionPrototype> ExplosionType = default!;
 
     /// <summary>
     ///     The maximum intensity the explosion can have on a single tile. This limits the maximum damage and tile
     ///     break chance the explosion can achieve at any given location.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("maxIntensity")]
+    [DataField]
     public float MaxIntensity = 4;
 
     /// <summary>
     ///     How quickly the intensity drops off as you move away from the epicenter.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("intensitySlope")]
+    [DataField]
     public float IntensitySlope = 1;
 
     /// <summary>
@@ -47,38 +42,34 @@ public sealed partial class ExplosiveComponent : Component
     ///     This number can be overridden by passing optional argument to <see
     ///     cref="ExplosionSystem.TriggerExplosive"/>.
     /// </remarks>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("totalIntensity")]
+    [DataField]
     public float TotalIntensity = 10;
 
     /// <summary>
     ///     Factor used to scale the explosion intensity when calculating tile break chances. Allows for stronger
     ///     explosives that don't space tiles, without having to create a new explosion-type prototype.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("tileBreakScale")]
+    [DataField]
     public float TileBreakScale = 1f;
 
     /// <summary>
     ///     Maximum number of times that an explosive can break a tile. Currently, for normal space stations breaking a
     ///     tile twice will generally result in a vacuum.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("maxTileBreak")]
+    [DataField]
     public int MaxTileBreak = int.MaxValue;
 
     /// <summary>
     ///     Whether this explosive should be able to create a vacuum by breaking tiles.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("canCreateVacuum")]
+    [DataField]
     public bool CanCreateVacuum = true;
 
     /// <summary>
     /// An override for whether or not the entity should be deleted after it explodes.
     /// If null, the system calling the explode method handles it.
     /// </summary>
-    [DataField("deleteAfterExplosion")]
+    [DataField]
     public bool? DeleteAfterExplosion;
 
     /// <summary>
index 1d926dd0b67d6b141dbef253a51ca1fcfee159f6..f29825580784b6d9ef25975442d73574fa6d5cf0 100644 (file)
@@ -1,25 +1,40 @@
-using Content.Shared.Explosion.Components;
 using Content.Shared.Armor;
+using Content.Shared.Explosion.Components;
 
 namespace Content.Shared.Explosion.EntitySystems;
 
+/// <summary>
+/// Lets code in shared trigger explosions and handles explosion resistance examining.
+/// All processing is still done clientside.
+/// </summary>
 public abstract class SharedExplosionSystem : EntitySystem
 {
-
     public override void Initialize()
     {
         base.Initialize();
         SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
     }
 
-    private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
+    private void OnArmorExamine(Entity<ExplosionResistanceComponent> ent, ref ArmorExamineEvent args)
     {
-        var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);
+        var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
 
         if (value == 0)
             return;
 
         args.Msg.PushNewline();
-        args.Msg.AddMarkupOrThrow(Loc.GetString(component.Examine, ("value", value)));
+        args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
+    }
+
+    /// <summary>
+    ///     Given an entity with an explosive component, spawn the appropriate explosion.
+    /// </summary>
+    /// <remarks>
+    ///     Also accepts radius or intensity arguments. This is useful for explosives where the intensity is not
+    ///     specified in the yaml / by the component, but determined dynamically (e.g., by the quantity of a
+    ///     solution in a reaction).
+    /// </remarks>
+    public virtual void TriggerExplosive(EntityUid uid, ExplosiveComponent? explosive = null, bool delete = true, float? totalIntensity = null, float? radius = null, EntityUid? user = null)
+    {
     }
 }