From: keronshb <54602815+keronshb@users.noreply.github.com> Date: Sat, 20 Apr 2024 02:18:25 +0000 (-0400) Subject: Adds non randomized rod velocity (#27123) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6be204e3f4176fb6a1eb526b36bb8dc8bf49250f;p=space-station-14.git Adds non randomized rod velocity (#27123) * adds non randomized rod velocity * Adds despawn suffix to despawn rod --- diff --git a/Content.Server/ImmovableRod/ImmovableRodSystem.cs b/Content.Server/ImmovableRod/ImmovableRodSystem.cs index 4553dda095..ce74777b07 100644 --- a/Content.Server/ImmovableRod/ImmovableRodSystem.cs +++ b/Content.Server/ImmovableRod/ImmovableRodSystem.cs @@ -60,15 +60,18 @@ public sealed class ImmovableRodSystem : EntitySystem _physics.SetFriction(uid, phys, 0f); _physics.SetBodyStatus(uid, phys, BodyStatus.InAir); - if (!component.RandomizeVelocity) - return; - var xform = Transform(uid); - var vel = component.DirectionOverride.Degrees switch + var worldRot = _transform.GetWorldRotation(uid); + var vel = worldRot.ToWorldVec() * component.MaxSpeed; + + if (component.RandomizeVelocity) { - 0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed), - _ => _transform.GetWorldRotation(uid).RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed) - }; + vel = component.DirectionOverride.Degrees switch + { + 0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed), + _ => worldRot.RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed) + }; + } _physics.ApplyLinearImpulse(uid, vel, body: phys); xform.LocalRotation = (vel - _transform.GetWorldPosition(uid)).ToWorldAngle() + MathHelper.PiOver2; diff --git a/Resources/Prototypes/Entities/Objects/Fun/immovable_rod.yml b/Resources/Prototypes/Entities/Objects/Fun/immovable_rod.yml index aad12a5025..e52f66d39b 100644 --- a/Resources/Prototypes/Entities/Objects/Fun/immovable_rod.yml +++ b/Resources/Prototypes/Entities/Objects/Fun/immovable_rod.yml @@ -35,6 +35,7 @@ - type: entity id: ImmovableRodDespawn + suffix: Despawn parent: ImmovableRod components: - type: TimedDespawn