]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add gas tanks throw damage (#20035)
authorVyacheslav Kovalevsky <40753025+Slava0135@users.noreply.github.com>
Mon, 4 Dec 2023 06:32:17 +0000 (09:32 +0300)
committerGitHub <noreply@github.com>
Mon, 4 Dec 2023 06:32:17 +0000 (17:32 +1100)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Server/Atmos/EntitySystems/GasTankSystem.cs
Content.Shared/Interaction/SharedInteractionSystem.cs
Content.Shared/Sound/SharedEmitSoundSystem.cs
Content.Shared/Throwing/IThrown.cs [deleted file]
Content.Shared/Throwing/ThrowingSystem.cs
Content.Shared/Throwing/ThrownEvent.cs [new file with mode: 0644]
Content.Shared/Throwing/ThrownItemSystem.cs
Resources/Prototypes/Entities/Objects/Tools/gas_tanks.yml

index 881d27c585247821b9f68afa4cddab6649e4349f..b476b906a9384a356d7d5d86b00739d5fbc61252 100644 (file)
@@ -1,3 +1,4 @@
+using System.Numerics;
 using Content.Server.Atmos.Components;
 using Content.Server.Body.Components;
 using Content.Server.Body.Systems;
@@ -8,6 +9,7 @@ using Content.Shared.Actions;
 using Content.Shared.Atmos;
 using Content.Shared.Atmos.Components;
 using Content.Shared.Examine;
+using Content.Shared.Throwing;
 using Content.Shared.Toggleable;
 using Content.Shared.Verbs;
 using JetBrains.Annotations;
@@ -33,6 +35,7 @@ namespace Content.Server.Atmos.EntitySystems
         [Dependency] private readonly UserInterfaceSystem _ui = default!;
         [Dependency] private readonly SharedPhysicsSystem _physics = default!;
         [Dependency] private readonly IRobustRandom _random = default!;
+        [Dependency] private readonly ThrowingSystem _throwing = default!;
 
         private const float TimerDelay = 0.5f;
         private float _timer = 0f;
@@ -172,9 +175,9 @@ namespace Content.Server.Atmos.EntitySystems
             {
                 _atmosphereSystem.Merge(environment, removed);
             }
-            var impulse = removed.TotalMoles * removed.Temperature;
-            _physics.ApplyLinearImpulse(gasTank, _random.NextAngle().ToWorldVec() * impulse);
-            _physics.ApplyAngularImpulse(gasTank, _random.NextFloat(-3f, 3f));
+            var strength = removed.TotalMoles * MathF.Sqrt(removed.Temperature);
+            var dir = _random.NextAngle().ToWorldVec();
+            _throwing.TryThrow(gasTank, dir * strength, strength);
             _audioSys.PlayPvs(gasTank.Comp.RuptureSound, gasTank);
         }
 
index 7981deaee66e6c03675643158a2723bd6e41f77f..44cf32556702195ef75b1d0dc53ff6d2bc93981e 100644 (file)
@@ -1044,25 +1044,6 @@ namespace Content.Shared.Interaction
         }
         #endregion
 
-        #region Throw
-        /// <summary>
-        ///     Calls Thrown on all components that implement the IThrown interface
-        ///     on an entity that has been thrown.
-        /// </summary>
-        public void ThrownInteraction(EntityUid user, EntityUid thrown)
-        {
-            var throwMsg = new ThrownEvent(user, thrown);
-            RaiseLocalEvent(thrown, throwMsg, true);
-            if (throwMsg.Handled)
-            {
-                _adminLogger.Add(LogType.Throw, LogImpact.Low,$"{ToPrettyString(user):user} threw {ToPrettyString(thrown):entity}");
-                return;
-            }
-
-            _adminLogger.Add(LogType.Throw, LogImpact.Low,$"{ToPrettyString(user):user} threw {ToPrettyString(thrown):entity}");
-        }
-        #endregion
-
         public void DroppedInteraction(EntityUid user, EntityUid item)
         {
             var dropMsg = new DroppedEvent(user);
index c7fcfc64698158fc166ee129a866dd2fe196fcfa..5e131a13554350fb1cc7ca09a70b3c2fb121fb60 100644 (file)
@@ -79,7 +79,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
             args.Handled = true;
     }
 
-    private void OnEmitSoundOnThrown(EntityUid uid, BaseEmitSoundComponent component, ThrownEvent args)
+    private void OnEmitSoundOnThrown(EntityUid uid, BaseEmitSoundComponent component, ref ThrownEvent args)
     {
         TryEmitSound(uid, component, args.User, false);
     }
diff --git a/Content.Shared/Throwing/IThrown.cs b/Content.Shared/Throwing/IThrown.cs
deleted file mode 100644 (file)
index 7946ac1..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-using JetBrains.Annotations;
-
-namespace Content.Shared.Throwing
-{
-    /// <summary>
-    ///     Raised when throwing the entity in your hands.
-    /// </summary>
-    [PublicAPI]
-    public sealed class ThrownEvent : HandledEntityEventArgs
-    {
-        /// <summary>
-        ///     Entity that threw the item.
-        /// </summary>
-        public EntityUid User { get; }
-
-        /// <summary>
-        ///     Item that was thrown.
-        /// </summary>
-        public EntityUid Thrown { get; }
-
-        public ThrownEvent(EntityUid user, EntityUid thrown)
-        {
-            User = user;
-            Thrown = thrown;
-        }
-    }
-}
index e47cdd5acc2c228881163c56b43ca6ecc987f66c..229d8a72b2495201ef4d9ff6d00718259bb7f81a 100644 (file)
@@ -1,4 +1,6 @@
 using System.Numerics;
+using Content.Shared.Administration.Logs;
+using Content.Shared.Database;
 using Content.Shared.Gravity;
 using Content.Shared.Interaction;
 using Content.Shared.Projectiles;
@@ -25,10 +27,10 @@ public sealed class ThrowingSystem : EntitySystem
 
     [Dependency] private readonly IGameTiming _gameTiming = default!;
     [Dependency] private readonly SharedGravitySystem _gravity = default!;
-    [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
     [Dependency] private readonly SharedPhysicsSystem _physics = default!;
     [Dependency] private readonly SharedTransformSystem _transform = default!;
     [Dependency] private readonly ThrownItemSystem _thrownSystem = default!;
+    [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
 
     public void TryThrow(
         EntityUid uid,
@@ -135,8 +137,10 @@ public sealed class ThrowingSystem : EntitySystem
             _transform.SetLocalRotation(uid, angle + offset);
         }
 
+        var throwEvent = new ThrownEvent(user, uid);
+        RaiseLocalEvent(uid, ref throwEvent, true);
         if (user != null)
-            _interactionSystem.ThrownInteraction(user.Value, uid);
+            _adminLogger.Add(LogType.Throw, LogImpact.Low, $"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity}");
 
         var impulseVector = direction.Normalized() * strength * physics.Mass;
         _physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
diff --git a/Content.Shared/Throwing/ThrownEvent.cs b/Content.Shared/Throwing/ThrownEvent.cs
new file mode 100644 (file)
index 0000000..70cb6ee
--- /dev/null
@@ -0,0 +1,10 @@
+using JetBrains.Annotations;
+
+namespace Content.Shared.Throwing;
+
+/// <summary>
+///     Raised on thrown entity.
+/// </summary>
+[PublicAPI]
+[ByRefEvent]
+public readonly record struct ThrownEvent(EntityUid? User, EntityUid Thrown);
index deda47bae6b80ba4cadc7a82ba2d075c2383f13a..fffde8c87ebfa659016ea841c48774694676b283 100644 (file)
@@ -43,7 +43,7 @@ namespace Content.Shared.Throwing
             component.ThrownTime ??= _gameTiming.CurTime;
         }
 
-        private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
+        private void ThrowItem(EntityUid uid, ThrownItemComponent component, ref ThrownEvent @event)
         {
             if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
                 fixturesComponent.Fixtures.Count != 1 ||
index 9887d8cdc01a13c72d08df947b9ec8ff20552875..624c99e64c6cb6fa3e7f721708ab9cd387ea4b29 100644 (file)
     damage:
       types:
         Blunt: 10
+  - type: DamageOtherOnHit
+    damage:
+      types:
+        Blunt: 10
   - type: PhysicalComposition
     materialComposition:
       Steel: 400
     damage:
       types:
         Blunt: 5
+  - type: DamageOtherOnHit
+    damage:
+      types:
+        Blunt: 5
   - type: PhysicalComposition
     materialComposition:
       Steel: 100
     damage:
       types:
         Blunt: 7.5
+  - type: DamageOtherOnHit
+    damage:
+      types:
+        Blunt: 7.5
 
 - type: entity
   parent: GasTankRoundBase