Fixed a bunch of bugs when dragging characters up ladders (see e0504042). The dragging logic didn't take into account that the characters are not necessarily in the same sub, which caused the dragged character to launch away at a high speed when climbing from a sub to another (for example when climbing down to the shuttle in Aegir). The pull joint on the target's torso was never disabled, so the character stayed floating mid-air after getting off the ladders.
+ Made Limb.pullJoint private. Now it can only be accessed by properties of the Limb, and there's some error checks in place to prevent WorldAnchorB from being set to an invalid value.
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Barotrauma
|
||||
|
||||
public bool inWater;
|
||||
|
||||
public FixedMouseJoint pullJoint;
|
||||
private readonly FixedMouseJoint pullJoint;
|
||||
|
||||
public readonly LimbType type;
|
||||
|
||||
@@ -145,7 +145,48 @@ namespace Barotrauma
|
||||
{
|
||||
get { return stepOffset; }
|
||||
}
|
||||
|
||||
public bool PullJointEnabled
|
||||
{
|
||||
get { return pullJoint.Enabled; }
|
||||
set { pullJoint.Enabled = value; }
|
||||
}
|
||||
|
||||
public float PullJointMaxForce
|
||||
{
|
||||
get { return pullJoint.MaxForce; }
|
||||
set { pullJoint.MaxForce = value; }
|
||||
}
|
||||
|
||||
public Vector2 PullJointWorldAnchorA
|
||||
{
|
||||
get { return pullJoint.WorldAnchorA; }
|
||||
}
|
||||
|
||||
public Vector2 PullJointWorldAnchorB
|
||||
{
|
||||
get { return pullJoint.WorldAnchorB; }
|
||||
set
|
||||
{
|
||||
if (!MathUtils.IsValid(value))
|
||||
{
|
||||
string errorMsg = "Attempted to set the anchor of a limb's pull joint to an invalid value (" + value + ")\n" + Environment.StackTrace;
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Limb.SetPullJointAnchor:InvalidValue", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Vector2.DistanceSquared(pullJoint.WorldAnchorA, value) > 50.0f * 50.0f)
|
||||
{
|
||||
string errorMsg = "Attempted to move the anchor of a limb's pull joint extremely far from the limb (" + value + ")\n" + Environment.StackTrace;
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Limb.SetPullJointAnchor:ExcessiveValue", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
pullJoint.WorldAnchorB = value;
|
||||
}
|
||||
}
|
||||
public List<WearableSprite> WearingItems { get; private set; }
|
||||
|
||||
public Limb (Character character, XElement element, float scale = 1.0f)
|
||||
@@ -208,9 +249,11 @@ namespace Barotrauma
|
||||
type = LimbType.None;
|
||||
}
|
||||
|
||||
pullJoint = new FixedMouseJoint(body.FarseerBody, pullJointPos);
|
||||
pullJoint.Enabled = false;
|
||||
pullJoint.MaxForce = ((type == LimbType.LeftHand || type == LimbType.RightHand) ? 400.0f : 150.0f) * body.Mass;
|
||||
pullJoint = new FixedMouseJoint(body.FarseerBody, pullJointPos)
|
||||
{
|
||||
Enabled = false,
|
||||
MaxForce = ((type == LimbType.LeftHand || type == LimbType.RightHand) ? 400.0f : 150.0f) * body.Mass
|
||||
};
|
||||
|
||||
GameMain.World.AddJoint(pullJoint);
|
||||
|
||||
@@ -286,10 +329,10 @@ namespace Barotrauma
|
||||
}
|
||||
partial void InitProjSpecific(XElement element);
|
||||
|
||||
public void MoveToPos(Vector2 pos, float force, bool pullFromCenter=false)
|
||||
public void MoveToPos(Vector2 pos, float force, bool pullFromCenter = false)
|
||||
{
|
||||
Vector2 pullPos = body.SimPosition;
|
||||
if (pullJoint != null && !pullFromCenter)
|
||||
if (!pullFromCenter)
|
||||
{
|
||||
pullPos = pullJoint.WorldAnchorA;
|
||||
}
|
||||
@@ -299,6 +342,11 @@ namespace Barotrauma
|
||||
body.MoveToPos(pos, force, pullPos);
|
||||
}
|
||||
|
||||
public void MirrorPullJoint()
|
||||
{
|
||||
pullJoint.LocalAnchorA = new Vector2(-pullJoint.LocalAnchorA.X, pullJoint.LocalAnchorA.Y);
|
||||
}
|
||||
|
||||
public AttackResult AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, bool playSound)
|
||||
{
|
||||
List<DamageModifier> appliedDamageModifiers = new List<DamageModifier>();
|
||||
|
||||
Reference in New Issue
Block a user