Fix debug assert when shooting guns (#21070)

This commit is contained in:
DrSmugleaf
2023-10-17 21:45:35 -07:00
committed by GitHub
parent 13cff0e89b
commit c72b95db6b
5 changed files with 10 additions and 16 deletions

View File

@@ -38,7 +38,7 @@ public sealed partial class ParticleAcceleratorSystem
} }
if (TryComp<ProjectileComponent>(emitted, out var proj)) if (TryComp<ProjectileComponent>(emitted, out var proj))
_projectileSystem.SetShooter(proj, uid); _projectileSystem.SetShooter(emitted, proj, uid);
if (TryComp<SinguloFoodComponent>(emitted, out var food)) if (TryComp<SinguloFoodComponent>(emitted, out var food))
{ {

View File

@@ -4,11 +4,10 @@ using Content.Server.Weapons.Ranged.Systems;
using Content.Shared.Camera; using Content.Shared.Camera;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Projectiles; using Content.Shared.Projectiles;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
namespace Content.Server.Projectiles; namespace Content.Server.Projectiles;
@@ -39,7 +38,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem
RaiseLocalEvent(target, ref attemptEv); RaiseLocalEvent(target, ref attemptEv);
if (attemptEv.Cancelled) if (attemptEv.Cancelled)
{ {
SetShooter(component, target); SetShooter(uid, component, target);
return; return;
} }

View File

@@ -291,7 +291,7 @@ namespace Content.Server.Singularity.EntitySystems
var xform = Transform(uid); var xform = Transform(uid);
var ent = Spawn(component.BoltType, xform.Coordinates); var ent = Spawn(component.BoltType, xform.Coordinates);
var proj = EnsureComp<ProjectileComponent>(ent); var proj = EnsureComp<ProjectileComponent>(ent);
_projectile.SetShooter(proj, uid); _projectile.SetShooter(ent, proj, uid);
var targetPos = new EntityCoordinates(uid, new Vector2(0, -1)); var targetPos = new EntityCoordinates(uid, new Vector2(0, -1));

View File

@@ -10,13 +10,13 @@ using Content.Shared.Damage;
using Content.Shared.Damage.Systems; using Content.Shared.Damage.Systems;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Effects; using Content.Shared.Effects;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction.Components; using Content.Shared.Interaction.Components;
using Content.Shared.Projectiles; using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged; using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Weapons.Ranged.Systems;
using Content.Shared.Weapons.Reflect; using Content.Shared.Weapons.Reflect;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
@@ -26,7 +26,6 @@ using Robust.Shared.Physics.Components;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using SharedGunSystem = Content.Shared.Weapons.Ranged.Systems.SharedGunSystem;
namespace Content.Server.Weapons.Ranged.Systems; namespace Content.Server.Weapons.Ranged.Systems;
@@ -305,7 +304,7 @@ public sealed partial class GunSystem : SharedGunSystem
if (user != null) if (user != null)
{ {
var projectile = EnsureComp<ProjectileComponent>(uid); var projectile = EnsureComp<ProjectileComponent>(uid);
Projectiles.SetShooter(projectile, user.Value); Projectiles.SetShooter(uid, projectile, user.Value);
projectile.Weapon = gunUid; projectile.Weapon = gunUid;
} }

View File

@@ -3,11 +3,7 @@ using Content.Shared.Damage;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Projectiles;
using Content.Shared.Sound.Components;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Components;
using Robust.Shared.Audio;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -139,13 +135,13 @@ public abstract partial class SharedProjectileSystem : EntitySystem
} }
} }
public void SetShooter(ProjectileComponent component, EntityUid uid) public void SetShooter(EntityUid id, ProjectileComponent component, EntityUid shooterId)
{ {
if (component.Shooter == uid) if (component.Shooter == shooterId)
return; return;
component.Shooter = uid; component.Shooter = shooterId;
Dirty(uid, component); Dirty(id, component);
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]