Characters receive damage when crushed between a sub and the level and are gibbed if the impact is hard enough. Closes #186

This commit is contained in:
Joonas Rikkonen
2017-12-30 02:17:08 +02:00
parent c3c16b53ac
commit 6777a039d5

View File

@@ -491,6 +491,22 @@ namespace Barotrauma
if (contactDot > 0.0f)
{
Body.LinearVelocity -= Vector2.Normalize(Body.LinearVelocity) * contactDot;
float damageAmount = contactDot * Body.Mass / limb.character.Mass;
Vector2 n;
FixedArray2<Vector2> contactPos;
contact.GetWorldManifold(out n, out contactPos);
limb.character.DamageLimb(ConvertUnits.ToDisplayUnits(contactPos[0]), limb, DamageType.Blunt, damageAmount, 0.0f, 0.0f, true, 0.0f);
if (limb.character.IsDead)
{
foreach (LimbJoint limbJoint in limb.character.AnimController.LimbJoints)
{
if (limbJoint.IsSevered || (limbJoint.LimbA != limb && limbJoint.LimbB != limb)) continue;
limb.character.AnimController.SeverLimbJoint(limbJoint);
}
}
}
}