Using TrySetLimbPosition when flipping a character to prevent limbs from going through walls, changes to outside->inside teleportation logic
This commit is contained in:
@@ -1169,18 +1169,24 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
|
||||
Vector2 position = limb.SimPosition;
|
||||
|
||||
if (!limb.pullJoint.Enabled && mirror)
|
||||
{
|
||||
difference = limb.body.SimPosition - torso.SimPosition;
|
||||
difference = Vector2.Transform(difference, torsoTransform);
|
||||
difference.Y = -difference.Y;
|
||||
|
||||
TrySetLimbPosition(limb, limb.SimPosition, torso.SimPosition + Vector2.Transform(difference, -torsoTransform));
|
||||
position = torso.SimPosition + Vector2.Transform(difference, -torsoTransform);
|
||||
|
||||
//TrySetLimbPosition(limb, limb.SimPosition, );
|
||||
}
|
||||
|
||||
float angle = flipAngle ? -limb.body.Rotation : limb.body.Rotation;
|
||||
if (wrapAngle) angle = MathUtils.WrapAnglePi(angle);
|
||||
|
||||
TrySetLimbPosition(limb, RefLimb.SimPosition, position);
|
||||
|
||||
limb.body.SetTransform(limb.body.SimPosition, angle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,7 +503,17 @@ namespace Barotrauma
|
||||
|
||||
public virtual Hull FindHull()
|
||||
{
|
||||
if (parentInventory != null && (parentInventory.Owner as Character) != null)
|
||||
{
|
||||
CurrentHull = (parentInventory.Owner as Character).AnimController.CurrentHull;
|
||||
body.Submarine = (parentInventory.Owner as Character).Submarine;
|
||||
return CurrentHull;
|
||||
}
|
||||
|
||||
CurrentHull = Hull.FindHull(WorldPosition, CurrentHull);
|
||||
|
||||
|
||||
|
||||
if (body!=null)
|
||||
{
|
||||
body.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||
|
||||
@@ -435,7 +435,7 @@ namespace Barotrauma
|
||||
Vector2 normalizedVel = limb.character.AnimController.RefLimb.LinearVelocity == Vector2.Zero ?
|
||||
Vector2.Zero : Vector2.Normalize(limb.character.AnimController.RefLimb.LinearVelocity);
|
||||
|
||||
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + normalizedVel);
|
||||
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] - normal2);
|
||||
|
||||
Hull newHull = Hull.FindHull(targetPos, null);
|
||||
|
||||
@@ -453,7 +453,7 @@ namespace Barotrauma
|
||||
targetPos = limb.character.WorldPosition;
|
||||
|
||||
bool gapFound = false;
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
foreach (Gap gap in gaps)
|
||||
{
|
||||
if (gap.Open == 0.0f || gap.IsRoomToRoom) continue;
|
||||
|
||||
@@ -486,7 +486,7 @@ namespace Barotrauma
|
||||
if (!gapFound) return true;
|
||||
|
||||
var ragdoll = limb.character.AnimController;
|
||||
ragdoll.FindHull();
|
||||
ragdoll.FindHull(newHull.WorldPosition);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user