(bc739e38f) Added impact sounds to items (e.g. when dropped to the ground). Closes #841
This commit is contained in:
@@ -579,13 +579,12 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
//containers need to handle collision events to notify items inside them about the impact
|
||||
var itemContainer = GetComponent<ItemContainer>();
|
||||
if (ImpactTolerance > 0.0f || itemContainer != null)
|
||||
if (body != null)
|
||||
{
|
||||
if (body != null) body.FarseerBody.OnCollision += OnCollision;
|
||||
body.FarseerBody.OnCollision += OnCollision;
|
||||
}
|
||||
|
||||
var itemContainer = GetComponent<ItemContainer>();
|
||||
if (itemContainer != null)
|
||||
{
|
||||
ownInventory = itemContainer.Inventory;
|
||||
@@ -1145,6 +1144,12 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
float forceFactor = 1.0f;
|
||||
if (CurrentHull != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float forceFactor = 1.0f;
|
||||
if (CurrentHull != null)
|
||||
{
|
||||
@@ -1166,19 +1171,18 @@ namespace Barotrauma
|
||||
body.ApplyForce((uplift - drag) * 10.0f, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
|
||||
//apply simple angular drag
|
||||
body.ApplyTorque(body.AngularVelocity * volume * -0.05f);
|
||||
body.ApplyTorque(body.AngularVelocity * volume * -0.05f);
|
||||
}
|
||||
|
||||
private bool OnCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
#if CLIENT
|
||||
if (GameMain.Client != null) return true;
|
||||
#endif
|
||||
|
||||
Vector2 normal = contact.Manifold.LocalNormal;
|
||||
|
||||
float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal);
|
||||
|
||||
OnCollisionProjSpecific(f1, f2, contact, impact);
|
||||
|
||||
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return true; }
|
||||
|
||||
if (ImpactTolerance > 0.0f && impact > ImpactTolerance)
|
||||
{
|
||||
ApplyStatusEffects(ActionType.OnImpact, 1.0f);
|
||||
@@ -1200,6 +1204,8 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
partial void OnCollisionProjSpecific(Fixture f1, Fixture f2, Contact contact, float impact);
|
||||
|
||||
public override void FlipX(bool relativeToSub)
|
||||
{
|
||||
base.FlipX(relativeToSub);
|
||||
|
||||
Reference in New Issue
Block a user