From c26382440569490cd36f78bd69b298a5b951ea4d Mon Sep 17 00:00:00 2001 From: Allexit Date: Sun, 10 May 2015 18:35:38 +0300 Subject: [PATCH] CollisionSide made more generic --- .../com/saltosion/gladiator/components/CPhysics.java | 2 +- .../saltosion/gladiator/physics/CollisionSide.java | 11 ----------- .../saltosion/gladiator/systems/PhysicsSystem.java | 10 +++++----- .../{physics => util}/CollisionListener.java | 4 ++-- core/src/com/saltosion/gladiator/util/Direction.java | 11 +++++++++++ 5 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 core/src/com/saltosion/gladiator/physics/CollisionSide.java rename core/src/com/saltosion/gladiator/{physics => util}/CollisionListener.java (80%) create mode 100644 core/src/com/saltosion/gladiator/util/Direction.java diff --git a/core/src/com/saltosion/gladiator/components/CPhysics.java b/core/src/com/saltosion/gladiator/components/CPhysics.java index 45790a5..cf6840b 100644 --- a/core/src/com/saltosion/gladiator/components/CPhysics.java +++ b/core/src/com/saltosion/gladiator/components/CPhysics.java @@ -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 { diff --git a/core/src/com/saltosion/gladiator/physics/CollisionSide.java b/core/src/com/saltosion/gladiator/physics/CollisionSide.java deleted file mode 100644 index a479307..0000000 --- a/core/src/com/saltosion/gladiator/physics/CollisionSide.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.saltosion.gladiator.physics; - -/** - * - * @author Jens "Jeasonfire" Pitkänen - */ -public enum CollisionSide { - - TOP, BOTTOM, LEFT, RIGHT - -} diff --git a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java index e92d59d..68a607c 100644 --- a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java +++ b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java @@ -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); } } } diff --git a/core/src/com/saltosion/gladiator/physics/CollisionListener.java b/core/src/com/saltosion/gladiator/util/CollisionListener.java similarity index 80% rename from core/src/com/saltosion/gladiator/physics/CollisionListener.java rename to core/src/com/saltosion/gladiator/util/CollisionListener.java index 286d35e..45b945f 100644 --- a/core/src/com/saltosion/gladiator/physics/CollisionListener.java +++ b/core/src/com/saltosion/gladiator/util/CollisionListener.java @@ -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); } diff --git a/core/src/com/saltosion/gladiator/util/Direction.java b/core/src/com/saltosion/gladiator/util/Direction.java new file mode 100644 index 0000000..27b41c3 --- /dev/null +++ b/core/src/com/saltosion/gladiator/util/Direction.java @@ -0,0 +1,11 @@ +package com.saltosion.gladiator.util; + +/** + * + * @author Jens "Jeasonfire" Pitkänen + */ +public enum Direction { + + UP, DOWN, LEFT, RIGHT + +}