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()
+8 -7
View File
@@ -1123,17 +1123,18 @@ namespace Barotrauma
}
}
if (moveCam)
if (moveCam && needsAir)
{
float pressureEffect = 0.0f;
if (pressureProtection < 80.0f && AnimController.CurrentHull != null && AnimController.CurrentHull.LethalPressure > 50.0f)
if (pressureProtection < 80.0f &&
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 50.0f))
{
float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure;
cam.Zoom = MathHelper.Lerp(cam.Zoom,
(AnimController.CurrentHull.LethalPressure / 50.0f) * Rand.Range(1.0f, 1.05f),
(AnimController.CurrentHull.LethalPressure - 50.0f) / 50.0f);
(pressure / 50.0f) * Rand.Range(1.0f, 1.05f),
(pressure - 50.0f) / 50.0f);
}
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, (Submarine == null ? 400.0f : 250.0f)+pressureEffect, 0.05f);
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, 0.05f);
}
cursorPosition = cam.ScreenToWorld(PlayerInput.MousePosition);
+10 -10
View File
@@ -16,7 +16,7 @@ namespace Barotrauma
}
private TargetType targetTypes;
private string[] targetNames;
private HashSet<string> targetNames;
private List<RelatedItem> requiredItems;
@@ -26,8 +26,8 @@ namespace Barotrauma
private bool setValue;
private bool disableDeltaTime;
private string[] onContainingNames;
private HashSet<string> onContainingNames;
private readonly float duration;
@@ -48,12 +48,12 @@ namespace Barotrauma
get { return targetTypes; }
}
public string[] TargetNames
public HashSet<string> TargetNames
{
get { return targetNames; }
}
public string[] OnContainingNames
public HashSet<string> OnContainingNames
{
get { return onContainingNames; }
}
@@ -92,10 +92,10 @@ namespace Barotrauma
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
string[] containingNames = split[1].Split(',');
onContainingNames = new string[containingNames.Length];
for (int i =0; i < containingNames.Length; i++)
onContainingNames = new HashSet<string>();
for (int i = 0; i < containingNames.Length; i++)
{
onContainingNames[i] = containingNames[i].Trim();
onContainingNames.Add(containingNames[i].Trim());
}
}
@@ -116,10 +116,10 @@ namespace Barotrauma
break;
case "targetnames":
string[] names = attribute.Value.Split(',');
targetNames = new string[names.Length];
targetNames = new HashSet<string>();
for (int i=0; i < names.Length; i++ )
{
targetNames[i] = names[i].Trim();
targetNames.Add(names[i].Trim());
}
break;
case "sound":