diff --git a/core/src/com/me/asteroids/Components.java b/core/src/com/me/asteroids/Components.java index cd5d845..02c1dd4 100644 --- a/core/src/com/me/asteroids/Components.java +++ b/core/src/com/me/asteroids/Components.java @@ -2,9 +2,9 @@ package com.me.asteroids; import com.me.asteroids.components.AccelerationComponent; import com.me.asteroids.components.AsteroidComponent; -import com.me.asteroids.components.BulletComponent; -import com.me.asteroids.components.ColliderComponent; -import com.me.asteroids.components.DebrisComponent; +import com.me.asteroids.components.BulletTagComponent; +import com.me.asteroids.components.ColliderTagComponent; +import com.me.asteroids.components.DebrisTagComponent; import com.me.asteroids.components.DecayComponent; import com.me.asteroids.components.GameDataComponent; import com.me.asteroids.components.ModelComponent; @@ -17,9 +17,9 @@ public class Components { public static final ComponentMapper ACCELERATION; public static final ComponentMapper ASTEROID; - public static final ComponentMapper BULLET; - public static final ComponentMapper COLLIDER; - public static final ComponentMapper DEBRIS; + public static final ComponentMapper BULLET; + public static final ComponentMapper COLLIDER; + public static final ComponentMapper DEBRIS; public static final ComponentMapper DECAY; public static final ComponentMapper GAME_DATA; public static final ComponentMapper MODEL; @@ -31,9 +31,9 @@ public class Components { static { ACCELERATION = ComponentMapper.getFor(AccelerationComponent.class); ASTEROID = ComponentMapper.getFor(AsteroidComponent.class); - BULLET = ComponentMapper.getFor(BulletComponent.class); - COLLIDER = ComponentMapper.getFor(ColliderComponent.class); - DEBRIS = ComponentMapper.getFor(DebrisComponent.class); + BULLET = ComponentMapper.getFor(BulletTagComponent.class); + COLLIDER = ComponentMapper.getFor(ColliderTagComponent.class); + DEBRIS = ComponentMapper.getFor(DebrisTagComponent.class); DECAY = ComponentMapper.getFor(DecayComponent.class); GAME_DATA = ComponentMapper.getFor(GameDataComponent.class); MODEL = ComponentMapper.getFor(ModelComponent.class); diff --git a/core/src/com/me/asteroids/EntityFactory.java b/core/src/com/me/asteroids/EntityFactory.java index 9be54d7..7ff780d 100644 --- a/core/src/com/me/asteroids/EntityFactory.java +++ b/core/src/com/me/asteroids/EntityFactory.java @@ -5,9 +5,9 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.me.asteroids.components.AccelerationComponent; import com.me.asteroids.components.AsteroidComponent; -import com.me.asteroids.components.BulletComponent; -import com.me.asteroids.components.ColliderComponent; -import com.me.asteroids.components.DebrisComponent; +import com.me.asteroids.components.BulletTagComponent; +import com.me.asteroids.components.ColliderTagComponent; +import com.me.asteroids.components.DebrisTagComponent; import com.me.asteroids.components.DecayComponent; import com.me.asteroids.components.ModelComponent; import com.me.asteroids.components.PlayerComponent; @@ -34,8 +34,9 @@ public class EntityFactory { private static final Vector2 tmpA = new Vector2(); private static final Vector2 tmpB = new Vector2(); - private static final ColliderComponent COLLIDER = new ColliderComponent(); - private static final DebrisComponent DEBRIS = new DebrisComponent(); + private static final ColliderTagComponent COLLIDER_TAG = new ColliderTagComponent(); + private static final DebrisTagComponent DEBRIS_TAG = new DebrisTagComponent(); + private static final BulletTagComponent BULLET_TAG = new BulletTagComponent(); private static Entity createEntity(Engine engine) { Entity entity = engine.createEntity(); @@ -71,7 +72,7 @@ public class EntityFactory { player.addComponent(velocity); player.addComponent(playerModel); player.addComponent(new AccelerationComponent(0f, 1f)); - player.addComponent(COLLIDER); + player.addComponent(COLLIDER_TAG); player.addComponent(new PlayerComponent(afterBurner)); player.setTag("PLAYER"); @@ -135,7 +136,7 @@ public class EntityFactory { debris.addComponent(new PositionComponent(new Vector2(model.getPosition()), 90)); debris.addComponent(velocity); debris.addComponent(model); - debris.addComponent(DEBRIS); + debris.addComponent(DEBRIS_TAG); debris.addComponent(new DecayComponent(rand.nextFloat(0.5f, 2.5f))); entities[i] = debris; } @@ -164,8 +165,8 @@ public class EntityFactory { bullet.addComponent(position); bullet.addComponent(new VelocityComponent(new Vector2(direction).scl(12.5f))); bullet.addComponent(model); - bullet.addComponent(COLLIDER); - bullet.addComponent(new BulletComponent()); + bullet.addComponent(COLLIDER_TAG); + bullet.addComponent(BULLET_TAG); return bullet; } @@ -185,7 +186,7 @@ public class EntityFactory { asteroid.addComponent(new PositionComponent()); asteroid.addComponent(new VelocityComponent()); asteroid.addComponent(model); - asteroid.addComponent(COLLIDER); + asteroid.addComponent(COLLIDER_TAG); asteroid.addComponent(new AsteroidComponent()); asteroid.addGroup("ASTEROIDS"); return asteroid; @@ -231,7 +232,7 @@ public class EntityFactory { split.addComponent(new PositionComponent(new Vector2(chunkPosition), 90)); split.addComponent(velocity); split.addComponent(new AsteroidComponent(ASTEROID.get(asteroid).generation + 1)); - split.addComponent(COLLIDER); + split.addComponent(COLLIDER_TAG); split.addGroup("ASTEROIDS"); entities[i] = split; } diff --git a/core/src/com/me/asteroids/EventFactory.java b/core/src/com/me/asteroids/EventFactory.java index 3fd4f41..4f08b9d 100644 --- a/core/src/com/me/asteroids/EventFactory.java +++ b/core/src/com/me/asteroids/EventFactory.java @@ -1,7 +1,7 @@ package com.me.asteroids; import com.me.asteroids.components.AsteroidComponent; -import com.me.asteroids.components.BulletComponent; +import com.me.asteroids.components.BulletTagComponent; import com.me.asteroids.components.PlayerComponent; import com.me.asteroids.events.BulletAsteroidCollisionEvent; import com.me.asteroids.events.CollisionEvent; @@ -13,8 +13,8 @@ public class EventFactory { public static CollisionEvent getNewCollisionEvent(Entity a, Entity b) { boolean isEntityAPlayer = a.hasComponent(PlayerComponent.class); boolean isEntityBPlayer = b.hasComponent(PlayerComponent.class); - boolean isEntityABullet = !isEntityAPlayer && a.hasComponent(BulletComponent.class); - boolean isEntityBBullet = !isEntityBPlayer && b.hasComponent(BulletComponent.class); + boolean isEntityABullet = !isEntityAPlayer && a.hasComponent(BulletTagComponent.class); + boolean isEntityBBullet = !isEntityBPlayer && b.hasComponent(BulletTagComponent.class); boolean isEntityAAsteroid = !isEntityAPlayer && !isEntityABullet && a.hasComponent(AsteroidComponent.class); boolean isEntityBAsteroid = !isEntityBPlayer && !isEntityBBullet && b.hasComponent(AsteroidComponent.class); diff --git a/core/src/com/me/asteroids/components/BulletComponent.java b/core/src/com/me/asteroids/components/BulletTagComponent.java similarity index 68% rename from core/src/com/me/asteroids/components/BulletComponent.java rename to core/src/com/me/asteroids/components/BulletTagComponent.java index bc28109..8d8fe7c 100644 --- a/core/src/com/me/asteroids/components/BulletComponent.java +++ b/core/src/com/me/asteroids/components/BulletTagComponent.java @@ -2,6 +2,6 @@ package com.me.asteroids.components; import com.me.common.ecs.Component; -public class BulletComponent implements Component { +public class BulletTagComponent implements Component { // TODO: See PlayerComponent's TODO } diff --git a/core/src/com/me/asteroids/components/ColliderComponent.java b/core/src/com/me/asteroids/components/ColliderTagComponent.java similarity index 74% rename from core/src/com/me/asteroids/components/ColliderComponent.java rename to core/src/com/me/asteroids/components/ColliderTagComponent.java index c61d3af..814e0e3 100644 --- a/core/src/com/me/asteroids/components/ColliderComponent.java +++ b/core/src/com/me/asteroids/components/ColliderTagComponent.java @@ -5,5 +5,5 @@ import com.me.common.ecs.Component; /** * Add this to Entities that should be checked for collisions with other entities. */ -public class ColliderComponent implements Component { +public class ColliderTagComponent implements Component { } diff --git a/core/src/com/me/asteroids/components/DebrisComponent.java b/core/src/com/me/asteroids/components/DebrisTagComponent.java similarity index 68% rename from core/src/com/me/asteroids/components/DebrisComponent.java rename to core/src/com/me/asteroids/components/DebrisTagComponent.java index 50744c5..1e3b27c 100644 --- a/core/src/com/me/asteroids/components/DebrisComponent.java +++ b/core/src/com/me/asteroids/components/DebrisTagComponent.java @@ -2,6 +2,6 @@ package com.me.asteroids.components; import com.me.common.ecs.Component; -public class DebrisComponent implements Component { +public class DebrisTagComponent implements Component { // TODO: See PlayerComponent's TODO } diff --git a/core/src/com/me/asteroids/screens/GameScreen.java b/core/src/com/me/asteroids/screens/GameScreen.java index 50b9b86..8de2dc4 100644 --- a/core/src/com/me/asteroids/screens/GameScreen.java +++ b/core/src/com/me/asteroids/screens/GameScreen.java @@ -10,9 +10,9 @@ import com.me.asteroids.EntityFactory; import com.me.asteroids.Graphics; import com.me.asteroids.components.AccelerationComponent; import com.me.asteroids.components.AsteroidComponent; -import com.me.asteroids.components.BulletComponent; -import com.me.asteroids.components.ColliderComponent; -import com.me.asteroids.components.DebrisComponent; +import com.me.asteroids.components.BulletTagComponent; +import com.me.asteroids.components.ColliderTagComponent; +import com.me.asteroids.components.DebrisTagComponent; import com.me.asteroids.components.DecayComponent; import com.me.asteroids.components.GameDataComponent; import com.me.asteroids.components.ModelComponent; @@ -67,17 +67,18 @@ public class GameScreen extends Screen implements Listener { engine = new Engine(); - engine.registerComponentClass(GameDataComponent.class); - engine.registerComponentClass(PlayerComponent.class); - engine.registerComponentClass(BulletComponent.class); + engine.registerComponentClass(BulletTagComponent.class); + engine.registerComponentClass(ColliderTagComponent.class); + engine.registerComponentClass(DebrisTagComponent.class); + + engine.registerComponentClass(AccelerationComponent.class); engine.registerComponentClass(AsteroidComponent.class); - engine.registerComponentClass(DebrisComponent.class); engine.registerComponentClass(DecayComponent.class); - engine.registerComponentClass(ColliderComponent.class); + engine.registerComponentClass(GameDataComponent.class); + engine.registerComponentClass(ModelComponent.class); + engine.registerComponentClass(PlayerComponent.class); engine.registerComponentClass(PositionComponent.class); engine.registerComponentClass(VelocityComponent.class); - engine.registerComponentClass(AccelerationComponent.class); - engine.registerComponentClass(ModelComponent.class); GameDataSystem system = new GameDataSystem(engine); diff --git a/core/src/com/me/asteroids/systems/CollisionSystem.java b/core/src/com/me/asteroids/systems/CollisionSystem.java index 70afbf4..e6378ae 100644 --- a/core/src/com/me/asteroids/systems/CollisionSystem.java +++ b/core/src/com/me/asteroids/systems/CollisionSystem.java @@ -2,7 +2,7 @@ package com.me.asteroids.systems; import com.badlogic.gdx.math.Rectangle; import com.me.asteroids.EventFactory; -import com.me.asteroids.components.ColliderComponent; +import com.me.asteroids.components.ColliderTagComponent; import com.me.asteroids.components.ModelComponent; import com.me.common.ecs.Engine; import com.me.common.ecs.Entity; @@ -13,7 +13,7 @@ import static com.me.asteroids.Components.MODEL; public class CollisionSystem extends EntitySystem { public CollisionSystem(Engine engine) { - super(engine, ColliderComponent.class, ModelComponent.class); + super(engine, ColliderTagComponent.class, ModelComponent.class); } @Override