CollisionSide made more generic

This commit is contained in:
Allexit 2015-05-10 18:35:38 +03:00
parent be0669a754
commit c263824405
5 changed files with 19 additions and 19 deletions

View File

@ -2,7 +2,7 @@ package com.saltosion.gladiator.components;
import com.badlogic.ashley.core.Component; import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.saltosion.gladiator.physics.CollisionListener; import com.saltosion.gladiator.util.CollisionListener;
public class CPhysics extends Component { public class CPhysics extends Component {

View File

@ -1,11 +0,0 @@
package com.saltosion.gladiator.physics;
/**
*
* @author Jens "Jeasonfire" Pitkänen <jeasonfire@gmail.com>
*/
public enum CollisionSide {
TOP, BOTTOM, LEFT, RIGHT
}

View File

@ -7,7 +7,7 @@ import com.badlogic.ashley.core.EntitySystem;
import com.badlogic.ashley.core.Family; import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableArray; import com.badlogic.ashley.utils.ImmutableArray;
import com.saltosion.gladiator.components.CPhysics; import com.saltosion.gladiator.components.CPhysics;
import com.saltosion.gladiator.physics.CollisionSide; import com.saltosion.gladiator.util.Direction;
/** /**
* *
@ -97,7 +97,7 @@ public class PhysicsSystem extends EntitySystem {
} }
if (cp0.getCollisionListener() != null) { if (cp0.getCollisionListener() != null) {
cp0.getCollisionListener().collision(CollisionSide.LEFT, entity0, entity1); cp0.getCollisionListener().collision(Direction.LEFT, entity0, entity1);
} }
} }
if (x01 > x10 && Math.abs(x01 - x10) < (cp0.getSize().x + cp1.getSize().x) / 16) { if (x01 > x10 && Math.abs(x01 - x10) < (cp0.getSize().x + cp1.getSize().x) / 16) {
@ -110,7 +110,7 @@ public class PhysicsSystem extends EntitySystem {
} }
if (cp0.getCollisionListener() != null) { if (cp0.getCollisionListener() != null) {
cp0.getCollisionListener().collision(CollisionSide.RIGHT, entity0, entity1); cp0.getCollisionListener().collision(Direction.RIGHT, entity0, entity1);
} }
} }
if (y00 <= y11 && Math.abs(y00 - y11) < (cp0.getSize().y + cp1.getSize().y) / 16) { if (y00 <= y11 && Math.abs(y00 - y11) < (cp0.getSize().y + cp1.getSize().y) / 16) {
@ -125,7 +125,7 @@ public class PhysicsSystem extends EntitySystem {
} }
if (cp0.getCollisionListener() != null) { if (cp0.getCollisionListener() != null) {
cp0.getCollisionListener().collision(CollisionSide.BOTTOM, entity0, entity1); cp0.getCollisionListener().collision(Direction.DOWN, entity0, entity1);
} }
} }
if (y01 > y10 && Math.abs(y01 - y10) < (cp0.getSize().y + cp1.getSize().y) / 16) { if (y01 > y10 && Math.abs(y01 - y10) < (cp0.getSize().y + cp1.getSize().y) / 16) {
@ -138,7 +138,7 @@ public class PhysicsSystem extends EntitySystem {
} }
if (cp0.getCollisionListener() != null) { if (cp0.getCollisionListener() != null) {
cp0.getCollisionListener().collision(CollisionSide.TOP, entity0, entity1); cp0.getCollisionListener().collision(Direction.UP, entity0, entity1);
} }
} }
} }

View File

@ -1,4 +1,4 @@
package com.saltosion.gladiator.physics; package com.saltosion.gladiator.util;
import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Entity;
@ -17,6 +17,6 @@ public interface CollisionListener {
* @param host * @param host
* @param other * @param other
*/ */
public void collision(CollisionSide side, Entity host, Entity other); public void collision(Direction side, Entity host, Entity other);
} }

View File

@ -0,0 +1,11 @@
package com.saltosion.gladiator.util;
/**
*
* @author Jens "Jeasonfire" Pitkänen <jeasonfire@gmail.com>
*/
public enum Direction {
UP, DOWN, LEFT, RIGHT
}