- clients only apply OnImpact statuseffects on items when the server says so

- fixed characters occasionally teleporting partially inside walls in mp
- made it easier to drag characters while swimming
This commit is contained in:
Regalis
2016-04-16 21:00:21 +03:00
parent 204d1333d1
commit 17d499d70a
5 changed files with 59 additions and 52 deletions
@@ -915,22 +915,31 @@ namespace Barotrauma
Limb leftHand = GetLimb(LimbType.LeftHand); Limb leftHand = GetLimb(LimbType.LeftHand);
Limb rightHand = GetLimb(LimbType.RightHand); Limb rightHand = GetLimb(LimbType.RightHand);
//only grab with one hand when swimming
leftHand.Disabled = true; leftHand.Disabled = true;
rightHand.Disabled = true; if (!inWater) rightHand.Disabled = true;
for (int i = 0; i < 2; i++ ) for (int i = 0; i < 2; i++ )
{ {
LimbType type = i == 0 ? rightHandTarget : leftHandTarget; LimbType type = i == 0 ? leftHandTarget: rightHandTarget;
Limb targetLimb = target.AnimController.GetLimb(type); Limb targetLimb = target.AnimController.GetLimb(type);
Limb pullLimb = GetLimb(i == 0 ? LimbType.RightHand : LimbType.LeftHand); Limb pullLimb = GetLimb(i == 0 ?LimbType.LeftHand: LimbType.RightHand);
pullLimb.pullJoint.Enabled = true; if (i==1 && inWater)
pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition; {
pullLimb.pullJoint.MaxForce = 500.0f; targetLimb.pullJoint.Enabled = false;
}
else
{
pullLimb.pullJoint.Enabled = true;
pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition;
pullLimb.pullJoint.MaxForce = 100.0f;
targetLimb.pullJoint.Enabled = true;
targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition;
}
targetLimb.pullJoint.Enabled = true;
targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition;
} }
@@ -1142,8 +1151,8 @@ namespace Barotrauma
case LimbType.LeftArm: case LimbType.LeftArm:
case LimbType.RightHand: case LimbType.RightHand:
case LimbType.RightArm: case LimbType.RightArm:
mirror = true; mirror = !inWater;
flipAngle = true; flipAngle = !inWater;
break; break;
case LimbType.LeftThigh: case LimbType.LeftThigh:
case LimbType.LeftLeg: case LimbType.LeftLeg:
@@ -719,46 +719,35 @@ namespace Barotrauma
foreach (Limb limb in Limbs) foreach (Limb limb in Limbs)
{ {
if (limb==refLimb)
{
if (lerp)
{
limb.body.TargetPosition = simPosition;
}
else
{
limb.body.SetTransform(simPosition, limb.Rotation);
}
continue;
}
//check visibility from the new position of RefLimb to the new position of this limb //check visibility from the new position of RefLimb to the new position of this limb
Vector2 movePos = limb.SimPosition + moveAmount; Vector2 movePos = limb.SimPosition + moveAmount;
TrySetLimbPosition(limb, simPosition, movePos, lerp); TrySetLimbPosition(limb, simPosition, movePos, lerp);
} }
} }
protected void TrySetLimbPosition(Limb limb, Vector2 original, Vector2 simPosition, bool lerp = false) protected void TrySetLimbPosition(Limb limb, Vector2 original, Vector2 simPosition, bool lerp = false)
{ {
if (original == simPosition) return;
Body body = Submarine.CheckVisibility(original, simPosition);
Vector2 movePos = simPosition; Vector2 movePos = simPosition;
//if there's something in between the limbs if (original != simPosition)
if (body != null)
{ {
//move the limb close to the position where the raycast hit something Body body = Submarine.CheckVisibility(original, simPosition);
movePos = original + ((simPosition - original) * Submarine.LastPickedFraction * 0.9f);
//if there's something in between the limbs
if (body != null)
{
//move the limb close to the position where the raycast hit something
movePos = original + ((simPosition - original) * Submarine.LastPickedFraction * 0.9f);
}
} }
if (lerp) if (lerp)
{ {
limb.body.TargetPosition = movePos; limb.body.TargetPosition = movePos;
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
} }
else else
{ {
@@ -868,21 +857,7 @@ namespace Barotrauma
{ {
System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions"); System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions");
if (this is HumanoidAnimController) SetPosition(refLimb.body.TargetPosition, true);
{
foreach (Limb limb in Limbs)
{
if (limb != refLimb) limb.body.TargetPosition = limb.body.SimPosition + diff;
limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, limb.body.TargetPosition) < 10.0f);
limb.body.LinearVelocity = Vector2.Zero;
limb.body.AngularVelocity = 0.0f;
}
}
else
{
SetPosition(refLimb.body.TargetPosition);
}
} }
} }
+1 -1
View File
@@ -99,7 +99,7 @@ namespace Barotrauma
limb.pullJoint.Enabled = false; limb.pullJoint.Enabled = false;
} }
new NetworkEvent(NetworkEventType.SelectCharacter, Character.Controlled.ID, true, Character.Controlled.SelectedCharacter); new NetworkEvent(NetworkEventType.SelectCharacter, Character.Controlled.ID, true, Character.Controlled.SelectedCharacter.ID);
return true; return true;
}; };
+22 -1
View File
@@ -747,11 +747,17 @@ namespace Barotrauma
private bool OnCollision(Fixture f1, Fixture f2, Contact contact) private bool OnCollision(Fixture f1, Fixture f2, Contact contact)
{ {
if (GameMain.Client != null) return true;
Vector2 normal = contact.Manifold.LocalNormal; Vector2 normal = contact.Manifold.LocalNormal;
float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal); float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal);
if (ImpactTolerance > 0.0f && impact > ImpactTolerance) ApplyStatusEffects(ActionType.OnImpact, 1.0f); if (ImpactTolerance > 0.0f && impact > ImpactTolerance)
{
ApplyStatusEffects(ActionType.OnImpact, 1.0f);
new NetworkEvent(NetworkEventType.ApplyStatusEffect, this.ID, false, ActionType.OnImpact);
}
var containedItems = ContainedItems; var containedItems = ContainedItems;
if (containedItems != null) if (containedItems != null)
@@ -1566,6 +1572,12 @@ namespace Barotrauma
bool sent = components[componentIndex].FillNetworkData(type, message); bool sent = components[componentIndex].FillNetworkData(type, message);
if (sent) components[componentIndex].NetworkUpdateSent = true; if (sent) components[componentIndex].NetworkUpdateSent = true;
return sent; return sent;
case NetworkEventType.ApplyStatusEffect:
ActionType actionType = (ActionType)data;
message.WriteRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length, (int)actionType);
return true;
case NetworkEventType.UpdateProperty: case NetworkEventType.UpdateProperty:
var allProperties = GetProperties<InGameEditable>(); var allProperties = GetProperties<InGameEditable>();
@@ -1658,6 +1670,15 @@ namespace Barotrauma
components[componentIndex].NetworkUpdateSent = true; components[componentIndex].NetworkUpdateSent = true;
components[componentIndex].ReadNetworkData(type, message, sendingTime); components[componentIndex].ReadNetworkData(type, message, sendingTime);
break;
case NetworkEventType.ApplyStatusEffect:
ActionType actionType = (ActionType)message.ReadRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length);
data = actionType;
ApplyStatusEffects(actionType, 1.0f);
break; break;
case NetworkEventType.UpdateProperty: case NetworkEventType.UpdateProperty:
string propertyName = ""; string propertyName = "";
+2
View File
@@ -340,6 +340,8 @@ namespace Barotrauma
//couldn't find a place for a cave -> abort //couldn't find a place for a cave -> abort
if (tries >= maxTries) break; if (tries >= maxTries) break;
if (!caveCells.Any()) continue;
usedCaveCells.AddRange(caveCells); usedCaveCells.AddRange(caveCells);
List<VoronoiCell> caveSolidCells; List<VoronoiCell> caveSolidCells;