- 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

View File

@@ -915,22 +915,31 @@ namespace Barotrauma
Limb leftHand = GetLimb(LimbType.LeftHand);
Limb rightHand = GetLimb(LimbType.RightHand);
//only grab with one hand when swimming
leftHand.Disabled = true;
rightHand.Disabled = true;
if (!inWater) rightHand.Disabled = true;
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 pullLimb = GetLimb(i == 0 ? LimbType.RightHand : LimbType.LeftHand);
Limb pullLimb = GetLimb(i == 0 ?LimbType.LeftHand: LimbType.RightHand);
pullLimb.pullJoint.Enabled = true;
pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition;
pullLimb.pullJoint.MaxForce = 500.0f;
if (i==1 && inWater)
{
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.RightHand:
case LimbType.RightArm:
mirror = true;
flipAngle = true;
mirror = !inWater;
flipAngle = !inWater;
break;
case LimbType.LeftThigh:
case LimbType.LeftLeg:

View File

@@ -706,7 +706,7 @@ namespace Barotrauma
limbHull.WaveVel[n] = Math.Min(impulse.Y * 1.0f, 5.0f);
StrongestImpact = ((impulse.Length() * 0.5f) - limb.impactTolerance);
}
}
}
}
limb.Update(deltaTime);
@@ -719,46 +719,35 @@ namespace Barotrauma
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
Vector2 movePos = limb.SimPosition + moveAmount;
TrySetLimbPosition(limb, simPosition, movePos, lerp);
}
}
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;
//if there's something in between the limbs
if (body != null)
if (original != simPosition)
{
//move the limb close to the position where the raycast hit something
movePos = original + ((simPosition - original) * Submarine.LastPickedFraction * 0.9f);
Body body = Submarine.CheckVisibility(original, simPosition);
//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.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f);
}
else
{
@@ -868,21 +857,7 @@ namespace Barotrauma
{
System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions");
if (this is HumanoidAnimController)
{
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);
}
SetPosition(refLimb.body.TargetPosition, true);
}
}

View File

@@ -99,7 +99,7 @@ namespace Barotrauma
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;
};

View File

@@ -747,11 +747,17 @@ namespace Barotrauma
private bool OnCollision(Fixture f1, Fixture f2, Contact contact)
{
if (GameMain.Client != null) return true;
Vector2 normal = contact.Manifold.LocalNormal;
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;
if (containedItems != null)
@@ -1566,6 +1572,12 @@ namespace Barotrauma
bool sent = components[componentIndex].FillNetworkData(type, message);
if (sent) components[componentIndex].NetworkUpdateSent = true;
return sent;
case NetworkEventType.ApplyStatusEffect:
ActionType actionType = (ActionType)data;
message.WriteRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length, (int)actionType);
return true;
case NetworkEventType.UpdateProperty:
var allProperties = GetProperties<InGameEditable>();
@@ -1658,6 +1670,15 @@ namespace Barotrauma
components[componentIndex].NetworkUpdateSent = true;
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;
case NetworkEventType.UpdateProperty:
string propertyName = "";

View File

@@ -340,6 +340,8 @@ namespace Barotrauma
//couldn't find a place for a cave -> abort
if (tries >= maxTries) break;
if (!caveCells.Any()) continue;
usedCaveCells.AddRange(caveCells);
List<VoronoiCell> caveSolidCells;