Fix Assumption of Nullable to have value (#41220)
* Fix Potential Test Fail * Please the maintainer gods
This commit is contained in:
@@ -4,4 +4,4 @@ namespace Content.Shared.Projectiles;
|
|||||||
/// Raised directed on an entity when it embeds into something.
|
/// Raised directed on an entity when it embeds into something.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid Weapon, EntityUid Embedded);
|
public readonly record struct ProjectileEmbedEvent(EntityUid? Shooter, EntityUid? Weapon, EntityUid Embedded);
|
||||||
|
|||||||
@@ -90,11 +90,11 @@ public abstract partial class SharedProjectileSystem : EntitySystem
|
|||||||
EmbedAttach(embeddable, args.Target, args.Shooter, embeddable.Comp);
|
EmbedAttach(embeddable, args.Target, args.Shooter, embeddable.Comp);
|
||||||
|
|
||||||
// Raise a specific event for projectiles.
|
// Raise a specific event for projectiles.
|
||||||
if (TryComp(embeddable, out ProjectileComponent? projectile))
|
if (!TryComp<ProjectileComponent>(embeddable, out var projectile))
|
||||||
{
|
return;
|
||||||
var ev = new ProjectileEmbedEvent(projectile.Shooter!.Value, projectile.Weapon!.Value, args.Target);
|
|
||||||
RaiseLocalEvent(embeddable, ref ev);
|
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)
|
private void EmbedAttach(EntityUid uid, EntityUid target, EntityUid? user, EmbeddableProjectileComponent component)
|
||||||
|
|||||||
@@ -225,11 +225,11 @@ public abstract class SharedGrapplingGunSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnGrappleCollide(EntityUid uid, GrapplingProjectileComponent component, ref ProjectileEmbedEvent args)
|
private void OnGrappleCollide(EntityUid uid, GrapplingProjectileComponent component, ref ProjectileEmbedEvent args)
|
||||||
{
|
{
|
||||||
if (!Timing.IsFirstTimePredicted)
|
if (!Timing.IsFirstTimePredicted || !args.Weapon.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var jointComp = EnsureComp<JointComponent>(uid);
|
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.MaxLength = joint.Length + 0.2f;
|
||||||
joint.Stiffness = 1f;
|
joint.Stiffness = 1f;
|
||||||
joint.MinLength = 0.35f;
|
joint.MinLength = 0.35f;
|
||||||
|
|||||||
Reference in New Issue
Block a user