// Path: workspace/Angr/src/fi/hbp/angr/models/Destructible.java
// public interface Destructible {
//     /**
//      * Get damage model of this object
//      * @return Damage model
//      */
//     DamageModel getDatamageModel();
// 
//     /**
//      * Set body as destroyed
//      *
//      * This information can be used for sprite rendering.
//      */
//     void setDestroyed();
// 
//     /**
//      * Get destroyed status
//      */
//     boolean isDestroyed();
// 
//     /**
//      * Get Box2D body
//      *
//      * This is used to remove body from the world
//      * @return Body.
//      */
//     Body getBody();
// }


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 fi.hbp.angr.models.Destructible;
package fi.hbp.angr.logic;



/**
 * Model contact listener for damage modeling.
 */
public class ModelContactListener implements ContactListener
{
    protected final GameState gameState;

    /**
     * Contructor for ModelContactListerner.
     * @param gameState game state object.
     */
    public ModelContactListener(GameState gameState) {;
        this.gameState = gameState;
    }

    @Override
    public void beginContact(Contact arg0) {
    }

    @Override
    public void endContact(Contact arg0) {
    }

    @Override
    public void postSolve(Contact contact, ContactImpulse impulse) {
        if(impulse.getNormalImpulses()[0] > 0.01)
        {
            /* If body A was hit */
            if(contact.getFixtureA() != null)
            {
                if (Actor.class.isInstance(contact.getFixtureA().getBody().getUserData())) {
                    Actor a = (Actor) contact.getFixtureA().getBody().getUserData();
                    evalDamage(a, impulse);

                }
            }

            /* If body B was hit */
            if(contact.getFixtureB() != null)
            {
                if (Actor.class.isInstance(contact.getFixtureB().getBody().getUserData())) {
                    Actor b = (Actor) contact.getFixtureB().getBody().getUserData();
                    evalDamage(b, impulse);
                }
            }
        }
    }

    /**
     * Evaluate damage and score, and check if actor needs to be destroyed
     * @param actor Current actor
     * @param impulse Impulse
     */
    private void evalDamage(Actor actor, ContactImpulse impulse) {
// Path: workspace/Angr/src/fi/hbp/angr/models/Destructible.java
// public interface Destructible {
//     /**
//      * Get damage model of this object
//      * @return Damage model
//      */
//     DamageModel getDatamageModel();
// 
//     /**
//      * Set body as destroyed
//      *
//      * This information can be used for sprite rendering.
//      */
//     void setDestroyed();
// 
//     /**
//      * Get destroyed status
//      */
//     boolean isDestroyed();
// 
//     /**
//      * Get Box2D body
//      *
//      * This is used to remove body from the world
//      * @return Body.
//      */
//     Body getBody();
// }


// Path: workspace/Angr/src/fi/hbp/angr/logic/ModelContactListener.java
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 fi.hbp.angr.models.Destructible;

package fi.hbp.angr.logic;



/**
 * Model contact listener for damage modeling.
 */
public class ModelContactListener implements ContactListener
{
    protected final GameState gameState;

    /**
     * Contructor for ModelContactListerner.
     * @param gameState game state object.
     */
    public ModelContactListener(GameState gameState) {;
        this.gameState = gameState;
    }

    @Override
    public void beginContact(Contact arg0) {
    }

    @Override
    public void endContact(Contact arg0) {
    }

    @Override
    public void postSolve(Contact contact, ContactImpulse impulse) {
        if(impulse.getNormalImpulses()[0] > 0.01)
        {
            /* If body A was hit */
            if(contact.getFixtureA() != null)
            {
                if (Actor.class.isInstance(contact.getFixtureA().getBody().getUserData())) {
                    Actor a = (Actor) contact.getFixtureA().getBody().getUserData();
                    evalDamage(a, impulse);

                }
            }

            /* If body B was hit */
            if(contact.getFixtureB() != null)
            {
                if (Actor.class.isInstance(contact.getFixtureB().getBody().getUserData())) {
                    Actor b = (Actor) contact.getFixtureB().getBody().getUserData();
                    evalDamage(b, impulse);
                }
            }
        }
    }

    /**
     * Evaluate damage and score, and check if actor needs to be destroyed
     * @param actor Current actor
     * @param impulse Impulse
     */
    private void evalDamage(Actor actor, ContactImpulse impulse) {
        if (Destructible.class.isInstance(actor)) {