]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix Assumption of Nullable to have value (#41220)
authorSir Warock <67167466+SirWarock@users.noreply.github.com>
Fri, 31 Oct 2025 17:17:58 +0000 (18:17 +0100)
committerGitHub <noreply@github.com>
Fri, 31 Oct 2025 17:17:58 +0000 (17:17 +0000)
* Fix Potential Test Fail

* Please the maintainer gods

Content.Shared/Projectiles/ProjectileEmbedEvent.cs
Content.Shared/Projectiles/SharedProjectileSystem.cs
Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs

index e7dd6df8e2962eeeeb9cfe5751ce74199a62a27f..675549c9d0870f7700863a12d0027ae3187a6d9b 100644 (file)
@@ -4,4 +4,4 @@ namespace Content.Shared.Projectiles;
 /// Raised directed on an entity when it embeds into something.
 /// </summary>
 [ByRefEvent]
-public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid Weapon, EntityUid Embedded);
+public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid? Weapon, EntityUid Embedded);
index f99950c8f1c09efad289939bd76749a5b46967a7..9a44ca545d00903a961eeb543a04ecec7da516d7 100644 (file)
@@ -90,11 +90,11 @@ public abstract partial class SharedProjectileSystem : EntitySystem
         EmbedAttach(embeddable, args.Target, args.Shooter, embeddable.Comp);
 
         // Raise a specific event for projectiles.
-        if (TryComp(embeddable, out ProjectileComponent? projectile))
-        {
-            var ev = new ProjectileEmbedEvent(projectile.Shooter!.Value, projectile.Weapon!.Value, args.Target);
-            RaiseLocalEvent(embeddable, ref ev);
-        }
+        if (!TryComp<ProjectileComponent>(embeddable, out var projectile))
+            return;
+
+        var ev = new ProjectileEmbedEvent(projectile.Shooter, projectile.Weapon, args.Target);
+        RaiseLocalEvent(embeddable, ref ev);
     }
 
     private void EmbedAttach(EntityUid uid, EntityUid target, EntityUid? user, EmbeddableProjectileComponent component)
index a3c5a322eee5e0b2e87b3fc0a8191cb9122efa4a..77af2e6543596c757f50797f86565534c59dab65 100644 (file)
@@ -225,11 +225,11 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
 
     private void OnGrappleCollide(EntityUid uid, GrapplingProjectileComponent component, ref ProjectileEmbedEvent args)
     {
-        if (!Timing.IsFirstTimePredicted)
+        if (!Timing.IsFirstTimePredicted || !args.Weapon.HasValue)
             return;
 
         var jointComp = EnsureComp<JointComponent>(uid);
-        var joint = _joints.CreateDistanceJoint(uid, args.Weapon, anchorA: new Vector2(0f, 0.5f), id: GrapplingJoint);
+        var joint = _joints.CreateDistanceJoint(uid, args.Weapon.Value, anchorA: new Vector2(0f, 0.5f), id: GrapplingJoint);
         joint.MaxLength = joint.Length + 0.2f;
         joint.Stiffness = 1f;
         joint.MinLength = 0.35f;