From 79035cd023c629743b30367abdabaa123ec92f57 Mon Sep 17 00:00:00 2001 From: Sir Warock <67167466+SirWarock@users.noreply.github.com> Date: Fri, 31 Oct 2025 18:17:58 +0100 Subject: [PATCH] Fix Assumption of Nullable to have value (#41220) * Fix Potential Test Fail * Please the maintainer gods --- Content.Shared/Projectiles/ProjectileEmbedEvent.cs | 2 +- Content.Shared/Projectiles/SharedProjectileSystem.cs | 10 +++++----- .../Weapons/Misc/SharedGrapplingGunSystem.cs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Content.Shared/Projectiles/ProjectileEmbedEvent.cs b/Content.Shared/Projectiles/ProjectileEmbedEvent.cs index e7dd6df8e2..675549c9d0 100644 --- a/Content.Shared/Projectiles/ProjectileEmbedEvent.cs +++ b/Content.Shared/Projectiles/ProjectileEmbedEvent.cs @@ -4,4 +4,4 @@ namespace Content.Shared.Projectiles; /// Raised directed on an entity when it embeds into something. /// [ByRefEvent] -public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid Weapon, EntityUid Embedded); +public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid? Weapon, EntityUid Embedded); diff --git a/Content.Shared/Projectiles/SharedProjectileSystem.cs b/Content.Shared/Projectiles/SharedProjectileSystem.cs index f99950c8f1..9a44ca545d 100644 --- a/Content.Shared/Projectiles/SharedProjectileSystem.cs +++ b/Content.Shared/Projectiles/SharedProjectileSystem.cs @@ -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(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) diff --git a/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs b/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs index a3c5a322ee..77af2e6543 100644 --- a/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedGrapplingGunSystem.cs @@ -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(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; -- 2.51.2