public static float distance( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.xy.x, pa.xy.y).dst(pb.xy.x, pb.xy.y); }
public static float distance( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.x, pa.y).dst(pb.x, pb.y); }
public static float distance2( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.xy.x, pa.xy.y).dst2(pb.xy.x, pb.xy.y); }
public static float distance2( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.x, pa.y).dst2(pb.x, pb.y); }
public static float distance2( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.xy.x, pa.xy.y).dst2(pb.xy.x, pb.xy.y); }
public static float distance( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pa.xy.x, pa.xy.y).dst(pb.xy.x, pb.xy.y); }
public static float angle( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pb.x, pb.y).sub(pa.x, pa.y).angle(); }
public static float angle( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pb.xy.x, pb.xy.y).sub(pa.xy.x, pa.xy.y).angle(); }
public static float angle( final Entity a, final Entity b) { final Pos pa = (Pos)a.getComponent(Pos.class); final Pos pb = (Pos)b.getComponent(Pos.class); return tmp.set(pb.xy.x, pb.xy.y).sub(pa.xy.x, pa.xy.y).angle(); }
/** * Slower retrieval of components from this entity. * <p> * Minimize usage of this. Use {@link ComponentMapper} instead. * </p> * @param <T> * the expected return component class type * @param type * the expected return component class type * @return component that matches, or {@code null} if none is found */ @SuppressWarnings("unchecked") public <T extends Component> T getComponent(Class<T> type) { ComponentTypeFactory tf = world.getComponentManager().typeFactory; return (T) getComponent(tf.getTypeFor(type)); }
/** * Slower retrieval of components from this entity. * <p> * Minimize usage of this. Use {@link ComponentMapper} instead. * </p> * @param <T> * the expected return component class type * @param type * the expected return component class type * @return component that matches, or {@code null} if none is found */ @SuppressWarnings("unchecked") public <T extends Component> T getComponent(Class<T> type) { ComponentTypeFactory tf = world.getComponentManager().typeFactory; return (T) getComponent(tf.getTypeFor(type)); }
@Override public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) { if (fixture.getFilterData().categoryBits == GameManager.BOMB_BIT) { Entity bombEntity = (Entity) fixture.getBody().getUserData(); kickingBomb = bombEntity.getComponent(Bomb.class); return 0; } return 0; } };
private void readComponentsArchetype(Json json, Entity e, JsonValue component) { SaveFileFormat.ComponentIdentifiers identifiers = serializationState.componentIdentifiers; archetypeMapper.transmute(e, archetype); while (component != null) { assert (component.name() != null); Class<? extends Component> componentType = identifiers.getType(component.name); readComponent(json, component, e.getComponent(componentType)); component = component.next; } }
private void readComponentsArchetype(Json json, Entity e, JsonValue component) { SaveFileFormat.ComponentIdentifiers identifiers = serializationState.componentIdentifiers; archetypeMapper.transmute(e, archetype); while (component != null) { assert (component.name() != null); Class<? extends Component> componentType = identifiers.getType(component.name); readComponent(json, component, e.getComponent(componentType)); component = component.next; } }
private void readComponentsArchetype(Json json, Entity e, JsonValue component) { SaveFileFormat.ComponentIdentifiers identifiers = serializationState.componentIdentifiers; archetypeMapper.transmute(e, archetype); while (component != null) { assert (component.name() != null); Class<? extends Component> componentType = identifiers.getType(component.name); readComponent(json, component, e.getComponent(componentType)); component = component.next; } }
private boolean findReferences(int entityId, Field f, BitVector referencedIds) { Component c = world.getEntity(entityId).getComponent(f.getDeclaringClass()); if (c == null) return false; Class type = f.getType(); try { if (type.equals(int.class)) { return updateReferenced((Integer)f.get(c), referencedIds); } else if (type.equals(Entity.class)) { return updateReferenced((Entity)f.get(c), referencedIds); } else if (type.equals(IntBag.class)) { return updateReferenced((IntBag)f.get(c), referencedIds); } else if (type.equals(Bag.class)) { return updateReferenced((Bag)f.get(c), referencedIds); } else { throw new RuntimeException("unknown type: " + type); } } catch (ReflectionException e) { throw new RuntimeException(e); } }
private boolean findReferences(int entityId, Field f, BitVector referencedIds) { Component c = world.getEntity(entityId).getComponent(f.getDeclaringClass()); if (c == null) return false; Class type = f.getType(); try { if (type.equals(int.class)) { return updateReferenced((Integer)f.get(c), referencedIds); } else if (type.equals(Entity.class)) { return updateReferenced((Entity)f.get(c), referencedIds); } else if (type.equals(IntBag.class)) { return updateReferenced((IntBag)f.get(c), referencedIds); } else if (type.equals(Bag.class)) { return updateReferenced((Bag)f.get(c), referencedIds); } else { throw new RuntimeException("unknown type: " + type); } } catch (ReflectionException e) { throw new RuntimeException(e); } }
@Override public float reportRayFixture(Fixture fixture, Vector2 point, Vector2 normal, float fraction) { if (fixture.getFilterData().categoryBits == GameManager.INDESTRUCTIIBLE_BIT) { canExplodeThrough = false; return 0; } if (fixture.getFilterData().categoryBits == GameManager.BREAKABLE_BIT) { canExplodeThrough = false; Entity e = (Entity) fixture.getBody().getUserData(); Breakable breakable = e.getComponent(Breakable.class); breakable.state = Breakable.State.EXPLODING; return 0; } return 0; } };
Player player = e.getComponent(Player.class); player.receivedDamage++; } else if (fixtureB.getFilterData().categoryBits == GameManager.PLAYER_BIT) { Entity e = (Entity) fixtureB.getBody().getUserData(); Player player = e.getComponent(Player.class); player.receivedDamage++; Enemy enemy = e.getComponent(Enemy.class); enemy.receivedDamage++; } else if (fixtureB.getFilterData().categoryBits == GameManager.ENEMY_BIT) { Entity e = (Entity) fixtureB.getBody().getUserData(); Enemy enemy = e.getComponent(Enemy.class); enemy.receivedDamage++; Bomb bomb = e.getComponent(Bomb.class); bomb.countDown = 0; } else if (fixtureB.getFilterData().categoryBits == GameManager.BOMB_BIT) { Entity e = (Entity) fixtureB.getBody().getUserData(); Bomb bomb = e.getComponent(Bomb.class); bomb.countDown = 0; Breakable breakable = e.getComponent(Breakable.class); breakable.state = Breakable.State.EXPLODING; } else if (fixtureB.getFilterData().categoryBits == GameManager.BREAKABLE_BIT) { Entity e = (Entity) fixtureB.getBody().getUserData(); Breakable breakable = e.getComponent(Breakable.class); breakable.state = Breakable.State.EXPLODING; if (fixtureA.getFilterData().categoryBits == GameManager.PLAYER_BIT) {
while (!remoteBombQueue.isEmpty() && remoteBombQueue.peek().getComponent(Bomb.class) == null) { remoteBombQueue.remove(); Bomb remoteBomb = remoteBombEntity.getComponent(Bomb.class); remoteBomb.countDown = 0;