Rename tag compontents to make it obvious they're for tagging
This commit is contained in:
parent
f4508fa0da
commit
84a353cfd2
@ -2,9 +2,9 @@ package com.me.asteroids;
|
|||||||
|
|
||||||
import com.me.asteroids.components.AccelerationComponent;
|
import com.me.asteroids.components.AccelerationComponent;
|
||||||
import com.me.asteroids.components.AsteroidComponent;
|
import com.me.asteroids.components.AsteroidComponent;
|
||||||
import com.me.asteroids.components.BulletComponent;
|
import com.me.asteroids.components.BulletTagComponent;
|
||||||
import com.me.asteroids.components.ColliderComponent;
|
import com.me.asteroids.components.ColliderTagComponent;
|
||||||
import com.me.asteroids.components.DebrisComponent;
|
import com.me.asteroids.components.DebrisTagComponent;
|
||||||
import com.me.asteroids.components.DecayComponent;
|
import com.me.asteroids.components.DecayComponent;
|
||||||
import com.me.asteroids.components.GameDataComponent;
|
import com.me.asteroids.components.GameDataComponent;
|
||||||
import com.me.asteroids.components.ModelComponent;
|
import com.me.asteroids.components.ModelComponent;
|
||||||
@ -17,9 +17,9 @@ public class Components {
|
|||||||
|
|
||||||
public static final ComponentMapper<AccelerationComponent> ACCELERATION;
|
public static final ComponentMapper<AccelerationComponent> ACCELERATION;
|
||||||
public static final ComponentMapper<AsteroidComponent> ASTEROID;
|
public static final ComponentMapper<AsteroidComponent> ASTEROID;
|
||||||
public static final ComponentMapper<BulletComponent> BULLET;
|
public static final ComponentMapper<BulletTagComponent> BULLET;
|
||||||
public static final ComponentMapper<ColliderComponent> COLLIDER;
|
public static final ComponentMapper<ColliderTagComponent> COLLIDER;
|
||||||
public static final ComponentMapper<DebrisComponent> DEBRIS;
|
public static final ComponentMapper<DebrisTagComponent> DEBRIS;
|
||||||
public static final ComponentMapper<DecayComponent> DECAY;
|
public static final ComponentMapper<DecayComponent> DECAY;
|
||||||
public static final ComponentMapper<GameDataComponent> GAME_DATA;
|
public static final ComponentMapper<GameDataComponent> GAME_DATA;
|
||||||
public static final ComponentMapper<ModelComponent> MODEL;
|
public static final ComponentMapper<ModelComponent> MODEL;
|
||||||
@ -31,9 +31,9 @@ public class Components {
|
|||||||
static {
|
static {
|
||||||
ACCELERATION = ComponentMapper.getFor(AccelerationComponent.class);
|
ACCELERATION = ComponentMapper.getFor(AccelerationComponent.class);
|
||||||
ASTEROID = ComponentMapper.getFor(AsteroidComponent.class);
|
ASTEROID = ComponentMapper.getFor(AsteroidComponent.class);
|
||||||
BULLET = ComponentMapper.getFor(BulletComponent.class);
|
BULLET = ComponentMapper.getFor(BulletTagComponent.class);
|
||||||
COLLIDER = ComponentMapper.getFor(ColliderComponent.class);
|
COLLIDER = ComponentMapper.getFor(ColliderTagComponent.class);
|
||||||
DEBRIS = ComponentMapper.getFor(DebrisComponent.class);
|
DEBRIS = ComponentMapper.getFor(DebrisTagComponent.class);
|
||||||
DECAY = ComponentMapper.getFor(DecayComponent.class);
|
DECAY = ComponentMapper.getFor(DecayComponent.class);
|
||||||
GAME_DATA = ComponentMapper.getFor(GameDataComponent.class);
|
GAME_DATA = ComponentMapper.getFor(GameDataComponent.class);
|
||||||
MODEL = ComponentMapper.getFor(ModelComponent.class);
|
MODEL = ComponentMapper.getFor(ModelComponent.class);
|
||||||
|
@ -5,9 +5,9 @@ import com.badlogic.gdx.math.MathUtils;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.me.asteroids.components.AccelerationComponent;
|
import com.me.asteroids.components.AccelerationComponent;
|
||||||
import com.me.asteroids.components.AsteroidComponent;
|
import com.me.asteroids.components.AsteroidComponent;
|
||||||
import com.me.asteroids.components.BulletComponent;
|
import com.me.asteroids.components.BulletTagComponent;
|
||||||
import com.me.asteroids.components.ColliderComponent;
|
import com.me.asteroids.components.ColliderTagComponent;
|
||||||
import com.me.asteroids.components.DebrisComponent;
|
import com.me.asteroids.components.DebrisTagComponent;
|
||||||
import com.me.asteroids.components.DecayComponent;
|
import com.me.asteroids.components.DecayComponent;
|
||||||
import com.me.asteroids.components.ModelComponent;
|
import com.me.asteroids.components.ModelComponent;
|
||||||
import com.me.asteroids.components.PlayerComponent;
|
import com.me.asteroids.components.PlayerComponent;
|
||||||
@ -34,8 +34,9 @@ public class EntityFactory {
|
|||||||
private static final Vector2 tmpA = new Vector2();
|
private static final Vector2 tmpA = new Vector2();
|
||||||
private static final Vector2 tmpB = new Vector2();
|
private static final Vector2 tmpB = new Vector2();
|
||||||
|
|
||||||
private static final ColliderComponent COLLIDER = new ColliderComponent();
|
private static final ColliderTagComponent COLLIDER_TAG = new ColliderTagComponent();
|
||||||
private static final DebrisComponent DEBRIS = new DebrisComponent();
|
private static final DebrisTagComponent DEBRIS_TAG = new DebrisTagComponent();
|
||||||
|
private static final BulletTagComponent BULLET_TAG = new BulletTagComponent();
|
||||||
|
|
||||||
private static Entity createEntity(Engine engine) {
|
private static Entity createEntity(Engine engine) {
|
||||||
Entity entity = engine.createEntity();
|
Entity entity = engine.createEntity();
|
||||||
@ -71,7 +72,7 @@ public class EntityFactory {
|
|||||||
player.addComponent(velocity);
|
player.addComponent(velocity);
|
||||||
player.addComponent(playerModel);
|
player.addComponent(playerModel);
|
||||||
player.addComponent(new AccelerationComponent(0f, 1f));
|
player.addComponent(new AccelerationComponent(0f, 1f));
|
||||||
player.addComponent(COLLIDER);
|
player.addComponent(COLLIDER_TAG);
|
||||||
player.addComponent(new PlayerComponent(afterBurner));
|
player.addComponent(new PlayerComponent(afterBurner));
|
||||||
player.setTag("PLAYER");
|
player.setTag("PLAYER");
|
||||||
|
|
||||||
@ -135,7 +136,7 @@ public class EntityFactory {
|
|||||||
debris.addComponent(new PositionComponent(new Vector2(model.getPosition()), 90));
|
debris.addComponent(new PositionComponent(new Vector2(model.getPosition()), 90));
|
||||||
debris.addComponent(velocity);
|
debris.addComponent(velocity);
|
||||||
debris.addComponent(model);
|
debris.addComponent(model);
|
||||||
debris.addComponent(DEBRIS);
|
debris.addComponent(DEBRIS_TAG);
|
||||||
debris.addComponent(new DecayComponent(rand.nextFloat(0.5f, 2.5f)));
|
debris.addComponent(new DecayComponent(rand.nextFloat(0.5f, 2.5f)));
|
||||||
entities[i] = debris;
|
entities[i] = debris;
|
||||||
}
|
}
|
||||||
@ -164,8 +165,8 @@ public class EntityFactory {
|
|||||||
bullet.addComponent(position);
|
bullet.addComponent(position);
|
||||||
bullet.addComponent(new VelocityComponent(new Vector2(direction).scl(12.5f)));
|
bullet.addComponent(new VelocityComponent(new Vector2(direction).scl(12.5f)));
|
||||||
bullet.addComponent(model);
|
bullet.addComponent(model);
|
||||||
bullet.addComponent(COLLIDER);
|
bullet.addComponent(COLLIDER_TAG);
|
||||||
bullet.addComponent(new BulletComponent());
|
bullet.addComponent(BULLET_TAG);
|
||||||
return bullet;
|
return bullet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ public class EntityFactory {
|
|||||||
asteroid.addComponent(new PositionComponent());
|
asteroid.addComponent(new PositionComponent());
|
||||||
asteroid.addComponent(new VelocityComponent());
|
asteroid.addComponent(new VelocityComponent());
|
||||||
asteroid.addComponent(model);
|
asteroid.addComponent(model);
|
||||||
asteroid.addComponent(COLLIDER);
|
asteroid.addComponent(COLLIDER_TAG);
|
||||||
asteroid.addComponent(new AsteroidComponent());
|
asteroid.addComponent(new AsteroidComponent());
|
||||||
asteroid.addGroup("ASTEROIDS");
|
asteroid.addGroup("ASTEROIDS");
|
||||||
return asteroid;
|
return asteroid;
|
||||||
@ -231,7 +232,7 @@ public class EntityFactory {
|
|||||||
split.addComponent(new PositionComponent(new Vector2(chunkPosition), 90));
|
split.addComponent(new PositionComponent(new Vector2(chunkPosition), 90));
|
||||||
split.addComponent(velocity);
|
split.addComponent(velocity);
|
||||||
split.addComponent(new AsteroidComponent(ASTEROID.get(asteroid).generation + 1));
|
split.addComponent(new AsteroidComponent(ASTEROID.get(asteroid).generation + 1));
|
||||||
split.addComponent(COLLIDER);
|
split.addComponent(COLLIDER_TAG);
|
||||||
split.addGroup("ASTEROIDS");
|
split.addGroup("ASTEROIDS");
|
||||||
entities[i] = split;
|
entities[i] = split;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.me.asteroids;
|
package com.me.asteroids;
|
||||||
|
|
||||||
import com.me.asteroids.components.AsteroidComponent;
|
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.components.PlayerComponent;
|
||||||
import com.me.asteroids.events.BulletAsteroidCollisionEvent;
|
import com.me.asteroids.events.BulletAsteroidCollisionEvent;
|
||||||
import com.me.asteroids.events.CollisionEvent;
|
import com.me.asteroids.events.CollisionEvent;
|
||||||
@ -13,8 +13,8 @@ public class EventFactory {
|
|||||||
public static CollisionEvent getNewCollisionEvent(Entity a, Entity b) {
|
public static CollisionEvent getNewCollisionEvent(Entity a, Entity b) {
|
||||||
boolean isEntityAPlayer = a.hasComponent(PlayerComponent.class);
|
boolean isEntityAPlayer = a.hasComponent(PlayerComponent.class);
|
||||||
boolean isEntityBPlayer = b.hasComponent(PlayerComponent.class);
|
boolean isEntityBPlayer = b.hasComponent(PlayerComponent.class);
|
||||||
boolean isEntityABullet = !isEntityAPlayer && a.hasComponent(BulletComponent.class);
|
boolean isEntityABullet = !isEntityAPlayer && a.hasComponent(BulletTagComponent.class);
|
||||||
boolean isEntityBBullet = !isEntityBPlayer && b.hasComponent(BulletComponent.class);
|
boolean isEntityBBullet = !isEntityBPlayer && b.hasComponent(BulletTagComponent.class);
|
||||||
boolean isEntityAAsteroid = !isEntityAPlayer && !isEntityABullet && a.hasComponent(AsteroidComponent.class);
|
boolean isEntityAAsteroid = !isEntityAPlayer && !isEntityABullet && a.hasComponent(AsteroidComponent.class);
|
||||||
boolean isEntityBAsteroid = !isEntityBPlayer && !isEntityBBullet && b.hasComponent(AsteroidComponent.class);
|
boolean isEntityBAsteroid = !isEntityBPlayer && !isEntityBBullet && b.hasComponent(AsteroidComponent.class);
|
||||||
|
|
||||||
|
@ -2,6 +2,6 @@ package com.me.asteroids.components;
|
|||||||
|
|
||||||
import com.me.common.ecs.Component;
|
import com.me.common.ecs.Component;
|
||||||
|
|
||||||
public class BulletComponent implements Component {
|
public class BulletTagComponent implements Component {
|
||||||
// TODO: See PlayerComponent's TODO
|
// TODO: See PlayerComponent's TODO
|
||||||
}
|
}
|
@ -5,5 +5,5 @@ import com.me.common.ecs.Component;
|
|||||||
/**
|
/**
|
||||||
* Add this to Entities that should be checked for collisions with other entities.
|
* Add this to Entities that should be checked for collisions with other entities.
|
||||||
*/
|
*/
|
||||||
public class ColliderComponent implements Component {
|
public class ColliderTagComponent implements Component {
|
||||||
}
|
}
|
@ -2,6 +2,6 @@ package com.me.asteroids.components;
|
|||||||
|
|
||||||
import com.me.common.ecs.Component;
|
import com.me.common.ecs.Component;
|
||||||
|
|
||||||
public class DebrisComponent implements Component {
|
public class DebrisTagComponent implements Component {
|
||||||
// TODO: See PlayerComponent's TODO
|
// TODO: See PlayerComponent's TODO
|
||||||
}
|
}
|
@ -10,9 +10,9 @@ import com.me.asteroids.EntityFactory;
|
|||||||
import com.me.asteroids.Graphics;
|
import com.me.asteroids.Graphics;
|
||||||
import com.me.asteroids.components.AccelerationComponent;
|
import com.me.asteroids.components.AccelerationComponent;
|
||||||
import com.me.asteroids.components.AsteroidComponent;
|
import com.me.asteroids.components.AsteroidComponent;
|
||||||
import com.me.asteroids.components.BulletComponent;
|
import com.me.asteroids.components.BulletTagComponent;
|
||||||
import com.me.asteroids.components.ColliderComponent;
|
import com.me.asteroids.components.ColliderTagComponent;
|
||||||
import com.me.asteroids.components.DebrisComponent;
|
import com.me.asteroids.components.DebrisTagComponent;
|
||||||
import com.me.asteroids.components.DecayComponent;
|
import com.me.asteroids.components.DecayComponent;
|
||||||
import com.me.asteroids.components.GameDataComponent;
|
import com.me.asteroids.components.GameDataComponent;
|
||||||
import com.me.asteroids.components.ModelComponent;
|
import com.me.asteroids.components.ModelComponent;
|
||||||
@ -67,17 +67,18 @@ public class GameScreen extends Screen implements Listener {
|
|||||||
|
|
||||||
engine = new Engine();
|
engine = new Engine();
|
||||||
|
|
||||||
engine.registerComponentClass(GameDataComponent.class);
|
engine.registerComponentClass(BulletTagComponent.class);
|
||||||
engine.registerComponentClass(PlayerComponent.class);
|
engine.registerComponentClass(ColliderTagComponent.class);
|
||||||
engine.registerComponentClass(BulletComponent.class);
|
engine.registerComponentClass(DebrisTagComponent.class);
|
||||||
|
|
||||||
|
engine.registerComponentClass(AccelerationComponent.class);
|
||||||
engine.registerComponentClass(AsteroidComponent.class);
|
engine.registerComponentClass(AsteroidComponent.class);
|
||||||
engine.registerComponentClass(DebrisComponent.class);
|
|
||||||
engine.registerComponentClass(DecayComponent.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(PositionComponent.class);
|
||||||
engine.registerComponentClass(VelocityComponent.class);
|
engine.registerComponentClass(VelocityComponent.class);
|
||||||
engine.registerComponentClass(AccelerationComponent.class);
|
|
||||||
engine.registerComponentClass(ModelComponent.class);
|
|
||||||
|
|
||||||
GameDataSystem system = new GameDataSystem(engine);
|
GameDataSystem system = new GameDataSystem(engine);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package com.me.asteroids.systems;
|
|||||||
|
|
||||||
import com.badlogic.gdx.math.Rectangle;
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
import com.me.asteroids.EventFactory;
|
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.asteroids.components.ModelComponent;
|
||||||
import com.me.common.ecs.Engine;
|
import com.me.common.ecs.Engine;
|
||||||
import com.me.common.ecs.Entity;
|
import com.me.common.ecs.Entity;
|
||||||
@ -13,7 +13,7 @@ import static com.me.asteroids.Components.MODEL;
|
|||||||
public class CollisionSystem extends EntitySystem {
|
public class CollisionSystem extends EntitySystem {
|
||||||
|
|
||||||
public CollisionSystem(Engine engine) {
|
public CollisionSystem(Engine engine) {
|
||||||
super(engine, ColliderComponent.class, ModelComponent.class);
|
super(engine, ColliderTagComponent.class, ModelComponent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user