Update content vectors to numerics (#17759)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Numerics;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Climbing.Components;
|
||||
using Content.Server.Interaction;
|
||||
@@ -384,21 +385,22 @@ public sealed class ClimbSystem : SharedClimbSystem
|
||||
|
||||
var from = Transform(uid).WorldPosition;
|
||||
var to = Transform(target).WorldPosition;
|
||||
var (x, y) = (to - from).Normalized;
|
||||
var (x, y) = (to - from).Normalized();
|
||||
|
||||
if (MathF.Abs(x) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line
|
||||
to = new Vector2(from.X, to.Y);
|
||||
else if (MathF.Abs(y) < 0.6f) // user climbed mostly horizontally so lets make it a clean straight line
|
||||
to = new Vector2(to.X, from.Y);
|
||||
|
||||
var velocity = (to - from).Length;
|
||||
var velocity = (to - from).Length();
|
||||
|
||||
if (velocity <= 0.0f) return;
|
||||
if (velocity <= 0.0f)
|
||||
return;
|
||||
|
||||
// Since there are bodies with different masses:
|
||||
// mass * 10 seems enough to move entity
|
||||
// instead of launching cats like rockets against the walls with constant impulse value.
|
||||
_physics.ApplyLinearImpulse(uid, (to - from).Normalized * velocity * physics.Mass * 10, body: physics);
|
||||
_physics.ApplyLinearImpulse(uid, (to - from).Normalized() * velocity * physics.Mass * 10, body: physics);
|
||||
_physics.SetBodyType(uid, BodyType.Dynamic, body: physics);
|
||||
climbing.OwnerIsTransitioning = true;
|
||||
_actionBlockerSystem.UpdateCanMove(uid);
|
||||
|
||||
Reference in New Issue
Block a user