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) {
      bulletsToBeRemoved.add((Projectile) actorA);
    } else if (actorB instanceof Projectile && actorA instanceof Map) {
      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) {

  }
}

@@ -784,28 +784,37 @@
 f Projectile
+%0A       
  && 
+(
 actorB insta
@@ -814,32 +814,63 @@
 B instanceof Map
+ %7C%7C actorB instanceof Obstacle)
 ) %7B%0A      bullet
@@ -951,20 +951,29 @@
 ojectile
+%0A       
  && 
+(
 actorA i
@@ -985,16 +985,47 @@
 ceof Map
+ %7C%7C actorA instanceof Obstacle)
 ) %7B%0A    

Add collision detection for Obstacle