Adds non randomized rod velocity (#27123)

* adds non randomized rod velocity

* Adds despawn suffix to despawn rod
This commit is contained in:
keronshb
2024-04-19 22:18:25 -04:00
committed by GitHub
parent 533453eb81
commit 6be204e3f4
2 changed files with 11 additions and 7 deletions

View File

@@ -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;

View File

@@ -35,6 +35,7 @@
- type: entity
id: ImmovableRodDespawn
suffix: Despawn
parent: ImmovableRod
components:
- type: TimedDespawn