Merge branch 'master' into new-netcode

Conflicts:
	Subsurface/Properties/AssemblyInfo.cs
	Subsurface/Source/Items/Components/Signal/Wire.cs
	Subsurface/Source/Items/Item.cs
	Subsurface/Source/Items/ItemInventory.cs
	Subsurface/Source/Networking/GameServer.cs
This commit is contained in:
Regalis
2016-11-09 17:58:56 +02:00
25 changed files with 486 additions and 262 deletions
@@ -51,10 +51,20 @@ namespace Barotrauma
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
{
collider.PhysEnabled = false;
collider.SetTransform(MainLimb.SimPosition, 0.0f);
collider.FarseerBody.FixedRotation = false;
if (stunTimer > 0.0f)
if (character.IsRemotePlayer)
{
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
MainLimb.pullJoint.Enabled = true;
}
else
{
collider.LinearVelocity = (MainLimb.SimPosition - collider.SimPosition) * 60.0f;
collider.SmoothRotate(MainLimb.Rotation);
}
if (stunTimer > 0)
{
stunTimer -= deltaTime;
}
@@ -57,8 +57,18 @@ namespace Barotrauma
if (character.IsDead || character.IsUnconscious || stunTimer > 0.0f)
{
collider.PhysEnabled = false;
collider.SetTransform(GetLimb(LimbType.Torso).SimPosition, 0.0f);
collider.FarseerBody.FixedRotation = false;
if (character.IsRemotePlayer)
{
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
MainLimb.pullJoint.Enabled = true;
}
else
{
collider.LinearVelocity = (GetLimb(LimbType.Waist).SimPosition - collider.SimPosition) * 20.0f;
collider.SmoothRotate(GetLimb(LimbType.Torso).Rotation);
}
if (stunTimer > 0)
{
@@ -87,21 +97,21 @@ namespace Barotrauma
collider.SetTransform(new Vector2(
collider.SimPosition.X,
Math.Max(lowestLimb.SimPosition.Y + (collider.radius + collider.height / 2), collider.SimPosition.Y)),
0.0f);
collider.Rotation);
collider.FarseerBody.Enabled = true;
}
if (swimming)
{
collider.FarseerBody.FixedRotation = false;
collider.FarseerBody.FixedRotation = false;
}
else if (!collider.FarseerBody.FixedRotation)
{
if (Math.Abs(MathUtils.GetShortestAngle(collider.Rotation, 0.0f)) > 0.001f)
{
//rotate collider back upright
collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 60.0f;
collider.AngularVelocity = MathUtils.GetShortestAngle(collider.Rotation, 0.0f) * 10.0f;
collider.FarseerBody.FixedRotation = false;
}
else
@@ -297,8 +307,11 @@ namespace Barotrauma
if (onGround && (!character.IsRemotePlayer || GameMain.Server != null))
{
//move slower if collider isn't upright
float rotationFactor = (float)Math.Abs(Math.Cos(collider.Rotation));
collider.LinearVelocity = new Vector2(
movement.X,
movement.X * rotationFactor,
collider.LinearVelocity.Y > 0.0f ? collider.LinearVelocity.Y * 0.5f : collider.LinearVelocity.Y);
}
@@ -502,7 +515,8 @@ namespace Barotrauma
float colliderBottomY = GetColliderBottom().Y;
//the contact point should be higher than the bottom of the collider
if (((Vector2)handle).Y < colliderBottomY + 0.01f) return;
if (((Vector2)handle).Y < colliderBottomY + 0.01f ||
((Vector2)handle).Y > collider.SimPosition.Y) return;
//find the height of the floor below the torso
//(if moving towards towards an obstacle that's low enough to climb over, the torso should be above it)
@@ -511,7 +525,7 @@ namespace Barotrauma
if (obstacleY > colliderBottomY)
{
//higher vertical velocity for taller obstacles
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 10;
collider.LinearVelocity += Vector2.UnitY * (((Vector2)handle).Y - colliderBottomY + 0.01f) * 50;
onGround = true;
}
}
@@ -888,13 +902,22 @@ namespace Barotrauma
targetLimb.pullJoint.Enabled = true;
targetLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition - diff;
targetLimb.pullJoint.MaxForce = 10000.0f;
target.AnimController.movement -= diff;
}
}
float dist = Vector2.Distance(target.SimPosition, collider.SimPosition);
//limit movement if moving away from the target
if (Vector2.Dot(target.SimPosition - collider.SimPosition, targetMovement)<0)
{
targetMovement *= MathHelper.Clamp(2.0f - dist, 0.0f, 1.0f);
}
target.AnimController.IgnorePlatforms = IgnorePlatforms;
if (target.Stun > 0.0f || target.IsDead)
if (target.Stun > 0.0f || target.IsUnconscious || target.IsDead)
{
target.AnimController.TargetMovement = TargetMovement;
}
@@ -1140,7 +1140,10 @@ namespace Barotrauma
public Vector2 GetColliderBottom()
{
return collider.SimPosition - Vector2.UnitY * (collider.height / 2 + collider.radius);
float halfHeight = collider.height / 2 + collider.radius;
return collider.SimPosition +
new Vector2((float)Math.Sin(collider.Rotation), -(float)Math.Cos(collider.Rotation)) * halfHeight;
}
public Limb FindLowestLimb()