Update content for joints refactor (#4487)
* Update content for joints refactor * Fix tumbler * Fix pulling crash * Fixes
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Shared.Pulling.Components;
|
|||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Physics;
|
||||||
|
|
||||||
namespace Content.Client.Physics.Controllers
|
namespace Content.Client.Physics.Controllers
|
||||||
{
|
{
|
||||||
@@ -29,10 +30,14 @@ namespace Content.Client.Physics.Controllers
|
|||||||
|
|
||||||
// We set joints to predicted given these can affect how our mob moves.
|
// We set joints to predicted given these can affect how our mob moves.
|
||||||
// I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?)
|
// I would only recommend disabling this if you make pulling not use joints anymore (someday maybe?)
|
||||||
foreach (var joint in body.Joints)
|
|
||||||
|
if (player.TryGetComponent(out JointComponent? jointComponent))
|
||||||
{
|
{
|
||||||
joint.BodyA.Predict = true;
|
foreach (var joint in jointComponent.GetJoints)
|
||||||
joint.BodyB.Predict = true;
|
{
|
||||||
|
joint.BodyA.Predict = true;
|
||||||
|
joint.BodyB.Predict = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
|
// If we're being pulled then we won't predict anything and will receive server lerps so it looks way smoother.
|
||||||
|
|||||||
@@ -161,11 +161,13 @@ namespace Content.Shared.Pulling.Components
|
|||||||
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
|
||||||
|
|
||||||
_physics.WakeBody();
|
_physics.WakeBody();
|
||||||
_pullJoint = pullerPhysics.CreateDistanceJoint(_physics, $"pull-joint-{_physics.Owner.Uid}");
|
_pullJoint = EntitySystem.Get<SharedJointSystem>().CreateDistanceJoint(Owner.Uid, _puller.Uid, id:$"pull-joint-{_physics.Owner.Uid}");
|
||||||
// _physics.BodyType = BodyType.Kinematic; // TODO: Need to consider their original bodytype
|
// _physics.BodyType = BodyType.Kinematic; // TODO: Need to consider their original bodytype
|
||||||
_pullJoint.CollideConnected = false;
|
_pullJoint.CollideConnected = false;
|
||||||
_pullJoint.Length = length * 0.75f;
|
_pullJoint.Length = length * 0.75f;
|
||||||
|
_pullJoint.MinLength = 0f;
|
||||||
_pullJoint.MaxLength = length;
|
_pullJoint.MaxLength = length;
|
||||||
|
_pullJoint.Stiffness = 1f;
|
||||||
}
|
}
|
||||||
// Code here will not run if pulling a new object was attempted and failed because of the returns from the refactor.
|
// Code here will not run if pulling a new object was attempted and failed because of the returns from the refactor.
|
||||||
}
|
}
|
||||||
@@ -269,7 +271,7 @@ namespace Content.Shared.Pulling.Components
|
|||||||
|
|
||||||
if (_physics != null && _pullJoint != null)
|
if (_physics != null && _pullJoint != null)
|
||||||
{
|
{
|
||||||
_physics.RemoveJoint(_pullJoint);
|
EntitySystem.Get<SharedJointSystem>().RemoveJoint(_pullJoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user != null && user.TryGetComponent<SharedPullerComponent>(out var puller))
|
if (user != null && user.TryGetComponent<SharedPullerComponent>(out var puller))
|
||||||
|
|||||||
Reference in New Issue
Block a user