v1.4.4.1 (Blood in the Water Update)

This commit is contained in:
Regalis11
2024-04-24 18:09:05 +03:00
parent 89b91d1c3e
commit ff1b8951a7
397 changed files with 15250 additions and 6479 deletions
@@ -405,25 +405,35 @@ namespace Barotrauma
}
}
public static bool CheckContactsForOtherFixtures(PhysicsBody triggerBody, Fixture otherFixture, Entity separatingEntity)
/// <summary>
/// Checks whether any fixture of the trigger body is in contact with any fixture belonging to the physics bodies of separatingEntity
/// </summary>
/// <param name="triggerBody">Physics body of the trigger</param>
/// <param name="separatingFixture">Fixture that got separated from the trigger</param>
/// <param name="separatingEntity">Entity that got separated from the trigger</param>
/// <returns></returns>
public static bool CheckContactsForOtherFixtures(PhysicsBody triggerBody, Fixture separatingFixture, Entity separatingEntity)
{
//check if there are contacts with any other fixture of the trigger
//(the OnSeparation callback happens when two fixtures separate,
//e.g. if a body stops touching the circular fixture at the end of a capsule-shaped body)
foreach (Fixture fixture in triggerBody.FarseerBody.FixtureList)
foreach (Fixture triggerFixture in triggerBody.FarseerBody.FixtureList)
{
ContactEdge contactEdge = fixture.Body.ContactList;
ContactEdge contactEdge = triggerFixture.Body.ContactList;
while (contactEdge != null)
{
if (contactEdge.Contact != null &&
contactEdge.Contact.Enabled &&
contactEdge.Contact.IsTouching)
{
if (contactEdge.Contact.FixtureA != fixture && contactEdge.Contact.FixtureB != fixture)
{
var otherEntity = GetEntity(contactEdge.Contact.FixtureB == otherFixture ?
//which fixture of this contact belongs to the "other" body (not the trigger itself)
Fixture otherFixture =
contactEdge.Contact.FixtureA == triggerFixture ?
contactEdge.Contact.FixtureB :
contactEdge.Contact.FixtureA);
contactEdge.Contact.FixtureA;
if (otherFixture != separatingFixture)
{
var otherEntity = GetEntity(otherFixture);
if (otherEntity == separatingEntity) { return true; }
}
}