diff --git a/Content.Server/GameObjects/Components/Items/ThrowHelper.cs b/Content.Server/GameObjects/Components/Items/ThrowHelper.cs index b1b641f34d..dfdbed4413 100644 --- a/Content.Server/GameObjects/Components/Items/ThrowHelper.cs +++ b/Content.Server/GameObjects/Components/Items/ThrowHelper.cs @@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items /// The ratio of impulse applied to the thrower internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null, float pushbackRatio = 1.0f) { - if (direction == Vector2.Zero || !entity.TryGetComponent(out PhysicsComponent? physicsComponent)) + if (entity.Deleted || direction == Vector2.Zero || !entity.TryGetComponent(out PhysicsComponent? physicsComponent)) { return; } diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index 1b8e9b5d4f..a5fbc8b7ee 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -10,6 +10,7 @@ using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces.GameObjects.Components; +using Robust.Shared.Asynchronous; using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; @@ -364,9 +365,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels var projectileComponent = projectile.GetComponent(); projectileComponent.IgnoreEntity(shooter); - projectile - .GetComponent() - .LinearVelocity = projectileAngle.ToVec() * velocity; + // FIXME: Work around issue where inserting and removing an entity from a container, + // then setting its linear velocity in the same tick resets velocity back to zero. + // See SharedBroadPhaseSystem.HandleContainerInsert()... It sets Awake to false, which causes this. + projectile.SpawnTimer(TimeSpan.FromMilliseconds(25), () => + { + projectile + .GetComponent() + .LinearVelocity = projectileAngle.ToVec() * velocity; + }); + projectile.Transform.LocalRotation = projectileAngle + MathHelper.PiOver2; } diff --git a/Resources/Changelog/Parts/taser.yml b/Resources/Changelog/Parts/taser.yml new file mode 100644 index 0000000000..7106075806 --- /dev/null +++ b/Resources/Changelog/Parts/taser.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix + message: Fixes taser bolts not moving after being fired.