Fixes taser bolts not moving when being shot

This commit is contained in:
Vera Aguilera Puerto
2021-03-19 19:32:22 +01:00
parent 2e65aaf1b2
commit 696fbcd506
3 changed files with 16 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower</param> /// <param name="pushbackRatio">The ratio of impulse applied to the thrower</param>
internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null, float pushbackRatio = 1.0f) 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; return;
} }

View File

@@ -10,6 +10,7 @@ using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Weapons.Ranged; using Content.Shared.GameObjects.Components.Weapons.Ranged;
using Content.Shared.GameObjects.EntitySystems; using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components; using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Asynchronous;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -364,9 +365,16 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
var projectileComponent = projectile.GetComponent<ProjectileComponent>(); var projectileComponent = projectile.GetComponent<ProjectileComponent>();
projectileComponent.IgnoreEntity(shooter); projectileComponent.IgnoreEntity(shooter);
projectile // FIXME: Work around issue where inserting and removing an entity from a container,
.GetComponent<IPhysBody>() // then setting its linear velocity in the same tick resets velocity back to zero.
.LinearVelocity = projectileAngle.ToVec() * velocity; // See SharedBroadPhaseSystem.HandleContainerInsert()... It sets Awake to false, which causes this.
projectile.SpawnTimer(TimeSpan.FromMilliseconds(25), () =>
{
projectile
.GetComponent<IPhysBody>()
.LinearVelocity = projectileAngle.ToVec() * velocity;
});
projectile.Transform.LocalRotation = projectileAngle + MathHelper.PiOver2; projectile.Transform.LocalRotation = projectileAngle + MathHelper.PiOver2;
} }

View File

@@ -0,0 +1,4 @@
author: Zumorica
changes:
- type: Fix
message: Fixes taser bolts not moving after being fired.