Ragdoll.SetPosition takes platforms into account if the character isn't ignoring platforms (i.e. forcing a character on top of a platform won't make it fall through it), reaching the top/bottom of a ladder won't make networkplayers fall off, server ignores position updates from dead/unconscious characters, smaller ResetRagdollDistance

This commit is contained in:
Regalis
2016-08-10 19:16:18 +03:00
parent 70dd90f0f8
commit 69933188d6
6 changed files with 33 additions and 22 deletions

View File

@@ -814,15 +814,12 @@ namespace Barotrauma
}
else
{
notClimbing = Math.Abs(targetMovement.X) > 0.05f;
notClimbing = Math.Abs(targetMovement.X) > 0.05f ||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition) ||
(TargetMovement.Y > 0.0f && handPos.Y > 0.1f);
}
//stop climbing if:
// - moving sideways
// - reached the top or bottom of the ladder
if (notClimbing ||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition) ||
(TargetMovement.Y > 0.0f && handPos.Y > 0.1f))
if (notClimbing)
{
Anim = Animation.None;
character.SelectedConstruction = null;

View File

@@ -793,7 +793,10 @@ namespace Barotrauma
if (original != simPosition)
{
Body body = Submarine.CheckVisibility(original, simPosition);
Category collisionCategory = Physics.CollisionWall | Physics.CollisionLevel;
if (!ignorePlatforms) collisionCategory |= Physics.CollisionPlatform;
Body body = Submarine.PickBody(original, simPosition, null, collisionCategory);
//if there's something in between the limbs
if (body != null)
@@ -803,13 +806,10 @@ namespace Barotrauma
}
}
if (lerp)
{
limb.body.TargetPosition = movePos;
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
}
else
{

View File

@@ -1602,6 +1602,7 @@ namespace Barotrauma
GameServer.Log(Name + " selected " + pickedItem.Name, Color.Orange);
}
pickedItem.Pick(this, false, pickHit, actionHit);
}
return;
@@ -1732,6 +1733,8 @@ namespace Barotrauma
return;
}
if (GameMain.Server != null && (isDead || IsUnconscious)) return;
keys[(int)InputType.Use].Held = actionKeyState;
keys[(int)InputType.Use].SetState(false, actionKeyState);

View File

@@ -1301,14 +1301,19 @@ namespace Barotrauma
System.Diagnostics.Debug.WriteLine("Item.Pick(" + picker + ", " + forceSelectKey + ")");
if (picker.SelectedConstruction == this)
if (selected)
{
if (picker.IsKeyHit(InputType.Select)) picker.SelectedConstruction = null;
}
else if (selected)
{
picker.SelectedConstruction = this;
if (picker.SelectedConstruction == this)
{
picker.SelectedConstruction = null;
}
else
{
picker.SelectedConstruction = this;
}
}
if (!hasRequiredSkills && Character.Controlled==picker && Screen.Selected != GameMain.EditMapScreen)
{

View File

@@ -383,12 +383,18 @@ namespace Barotrauma
fixture.CollisionCategories == Category.None ||
fixture.CollisionCategories == Physics.CollisionItem) return -1;
if (collisionCategory != null && !fixture.CollisionCategories.HasFlag((Category)collisionCategory)) return -1;
if (collisionCategory != null &&
!fixture.CollisionCategories.HasFlag((Category)collisionCategory) &&
!((Category)collisionCategory).HasFlag(fixture.CollisionCategories)) return -1;
if (ignoredBodies != null && ignoredBodies.Contains(fixture.Body)) return -1;
Structure structure = fixture.Body.UserData as Structure;
if (structure != null && (structure.IsPlatform || !structure.HasBody)) return -1;
if (structure != null)
{
if (!structure.HasBody) return -1;
if (structure.IsPlatform && collisionCategory != null && !((Category)collisionCategory).HasFlag(Physics.CollisionPlatform)) return -1;
}
if (fraction < closestFraction)
{

View File

@@ -17,7 +17,7 @@
//if a ragdoll is further than this from the correct position, teleport it there
//(in sim units)
public const float ResetRagdollDistance = 2.0f;
public const float ResetRagdollDistance = 1.0f;
//if the ragdoll is closer than this, don't try to correct its position
public const float AllowedRagdollDistance = 0.1f;