package com.pqbyte.coherence;


import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array;

public class CollisionListener implements ContactListener {

  private Array<Projectile> bulletsToBeRemoved;

  public CollisionListener(Array<Projectile> bulletsToBeRemoved) {
    this.bulletsToBeRemoved = bulletsToBeRemoved;
  }

  @Override
  public void beginContact(Contact contact) {
    Actor actorA = (Actor) contact.getFixtureA().getBody().getUserData();
    Actor actorB = (Actor) contact.getFixtureB().getBody().getUserData();

    if (actorA instanceof Projectile
        && (actorB instanceof Map || actorB instanceof Obstacle)) {
      bulletsToBeRemoved.add((Projectile) actorA);
    } else if (actorB instanceof Projectile
        && (actorA instanceof Map || actorA instanceof Obstacle)) {
      bulletsToBeRemoved.add((Projectile) actorB);
    }
  }

  @Override
  public void endContact(Contact contact) {

  }

  @Override
  public void preSolve(Contact contact, Manifold oldManifold) {

  }

  @Override
  public void postSolve(Contact contact, ContactImpulse impulse) {

  }
}

@@ -25,16 +25,45 @@
 ence;%0A%0A%0A
+import com.badlogic.gdx.Gdx;%0A
 import c
@@ -210,16 +210,109 @@
 stener;%0A
+import com.badlogic.gdx.physics.box2d.Filter;%0Aimport com.badlogic.gdx.physics.box2d.Fixture;%0A
 import c
@@ -733,52 +733,119 @@
     
-Actor actorA = (Actor) contact.getFixtureA()
+Fixture fixA = contact.getFixtureA();%0A    Fixture fixB = contact.getFixtureB();%0A    Actor actorA = (Actor) fixA
 .get
@@ -893,37 +893,20 @@
 (Actor) 
-contact.getFixtureB()
+fixB
 .getBody
@@ -922,16 +922,59 @@
 rData();
+%0A    Filter filterA = fixA.getFilterData();
 %0A%0A    if
@@ -976,25 +976,25 @@
    if (actor
-A
+B
  instanceof 
@@ -1019,61 +1019,54 @@
  && 
-(actorB instanceof Map %7C%7C actorB instanceof Obstacle)
+filterA.categoryBits == Constants.WORLD_ENTITY
 ) %7B%0A
@@ -1112,17 +1112,17 @@
 e) actor
-A
+B
 );%0A    %7D
@@ -1171,17 +1171,16 @@
      && 
-(
 actorA i
@@ -1193,96 +1193,293 @@
 eof 
-Map %7C%7C actorA instanceof Obstacle)) %7B%0A      bulletsToBeRemoved.add((Projectile) actorB);
+Player) %7B%0A      Player target = (Player) actorA;%0A      Projectile bullet = (Projectile) actorB;%0A      if (!bullet.getShooter().equals(actorA)) %7B%0A        // The player isn't shooting themselves, take damage.%0A        bulletsToBeRemoved.add(bullet);%0A        target.takeDamage(10);%0A      %7D
 %0A   
@@ -1620,25 +1620,24 @@
 Manifold) %7B%0A
-%0A
   %7D%0A%0A  @Over

Add bullet to player collision detection