Use ComponentMappers everywhere else
This commit is contained in:
parent
84a353cfd2
commit
3cf1d19c4d
@ -145,8 +145,8 @@ public class EntityFactory {
|
|||||||
|
|
||||||
|
|
||||||
public static Entity createBullet(Engine engine, Entity player) {
|
public static Entity createBullet(Engine engine, Entity player) {
|
||||||
float[] modelVertices = player.getComponent(ModelComponent.class).model.getVertices();
|
float[] modelVertices = MODEL.get(player).model.getVertices();
|
||||||
float rotation = player.getComponent(PositionComponent.class).rotation;
|
float rotation = POSITION.get(player).rotation;
|
||||||
|
|
||||||
PositionComponent position = new PositionComponent(modelVertices[0], modelVertices[1], rotation);
|
PositionComponent position = new PositionComponent(modelVertices[0], modelVertices[1], rotation);
|
||||||
ModelComponent model = new ModelComponent(new PolygonModel(Color.YELLOW));
|
ModelComponent model = new ModelComponent(new PolygonModel(Color.YELLOW));
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
package com.me.asteroids;
|
package com.me.asteroids;
|
||||||
|
|
||||||
import com.me.asteroids.components.AsteroidComponent;
|
|
||||||
import com.me.asteroids.components.BulletTagComponent;
|
|
||||||
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;
|
||||||
import com.me.asteroids.events.PlayerASteroidCollisionEvent;
|
import com.me.asteroids.events.PlayerASteroidCollisionEvent;
|
||||||
import com.me.common.ecs.Entity;
|
import com.me.common.ecs.Entity;
|
||||||
|
|
||||||
|
import static com.me.asteroids.Components.ASTEROID;
|
||||||
|
import static com.me.asteroids.Components.BULLET;
|
||||||
|
import static com.me.asteroids.Components.PLAYER;
|
||||||
|
|
||||||
public class EventFactory {
|
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 = PLAYER.has(a);
|
||||||
boolean isEntityBPlayer = b.hasComponent(PlayerComponent.class);
|
boolean isEntityBPlayer = PLAYER.has(b);
|
||||||
boolean isEntityABullet = !isEntityAPlayer && a.hasComponent(BulletTagComponent.class);
|
boolean isEntityABullet = !isEntityAPlayer && BULLET.has(a);
|
||||||
boolean isEntityBBullet = !isEntityBPlayer && b.hasComponent(BulletTagComponent.class);
|
boolean isEntityBBullet = !isEntityBPlayer && BULLET.has(b);
|
||||||
boolean isEntityAAsteroid = !isEntityAPlayer && !isEntityABullet && a.hasComponent(AsteroidComponent.class);
|
boolean isEntityAAsteroid = !isEntityAPlayer && !isEntityABullet && ASTEROID.has(a);
|
||||||
boolean isEntityBAsteroid = !isEntityBPlayer && !isEntityBBullet && b.hasComponent(AsteroidComponent.class);
|
boolean isEntityBAsteroid = !isEntityBPlayer && !isEntityBBullet && ASTEROID.has(b);
|
||||||
|
|
||||||
if (isEntityAAsteroid || isEntityBAsteroid) {
|
if (isEntityAAsteroid || isEntityBAsteroid) {
|
||||||
if (isEntityAPlayer && isEntityBAsteroid) {
|
if (isEntityAPlayer && isEntityBAsteroid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user