CollisionSide made more generic
This commit is contained in:
parent
be0669a754
commit
c263824405
@ -2,7 +2,7 @@ package com.saltosion.gladiator.components;
|
||||
|
||||
import com.badlogic.ashley.core.Component;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.saltosion.gladiator.physics.CollisionListener;
|
||||
import com.saltosion.gladiator.util.CollisionListener;
|
||||
|
||||
public class CPhysics extends Component {
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
package com.saltosion.gladiator.physics;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens "Jeasonfire" Pitkänen <jeasonfire@gmail.com>
|
||||
*/
|
||||
public enum CollisionSide {
|
||||
|
||||
TOP, BOTTOM, LEFT, RIGHT
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ import com.badlogic.ashley.core.EntitySystem;
|
||||
import com.badlogic.ashley.core.Family;
|
||||
import com.badlogic.ashley.utils.ImmutableArray;
|
||||
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) {
|
||||
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) {
|
||||
@ -110,7 +110,7 @@ public class PhysicsSystem extends EntitySystem {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -125,7 +125,7 @@ public class PhysicsSystem extends EntitySystem {
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -138,7 +138,7 @@ public class PhysicsSystem extends EntitySystem {
|
||||
}
|
||||
|
||||
if (cp0.getCollisionListener() != null) {
|
||||
cp0.getCollisionListener().collision(CollisionSide.TOP, entity0, entity1);
|
||||
cp0.getCollisionListener().collision(Direction.UP, entity0, entity1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.saltosion.gladiator.physics;
|
||||
package com.saltosion.gladiator.util;
|
||||
|
||||
import com.badlogic.ashley.core.Entity;
|
||||
|
||||
@ -17,6 +17,6 @@ public interface CollisionListener {
|
||||
* @param host
|
||||
* @param other
|
||||
*/
|
||||
public void collision(CollisionSide side, Entity host, Entity other);
|
||||
public void collision(Direction side, Entity host, Entity other);
|
||||
|
||||
}
|
11
core/src/com/saltosion/gladiator/util/Direction.java
Normal file
11
core/src/com/saltosion/gladiator/util/Direction.java
Normal 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
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user