Package com.artemis

Examples of com.artemis.Entity


    assertEquals(1, gm.getEntities(GROUPIE).size());
  }
 
  @Test
  public void deleted_entities_should_be_removed() {
    Entity entity = world.createEntity();
    gm.add(entity, GROUPIE);

    assertEquals(1, gm.getEntities(GROUPIE).size());

    entity.deleteFromWorld();
    world.process();
    assertEquals(0, gm.getEntities(GROUPIE).size());
    assertFalse(gm.isInAnyGroup(entity));
  }
View Full Code Here


    assertFalse(gm.isInAnyGroup(entity));
  }
 
  @Test
  public void deleted_entities_should_be_removed_from_all_groups() {
    Entity entity = world.createEntity();
    gm.add(entity, GROUPIE);
    gm.add(entity, GROUPIE2);
   
    assertEquals(1, gm.getEntities(GROUPIE).size());
    assertEquals(1, gm.getEntities(GROUPIE2).size());
   
    entity.deleteFromWorld();
    world.process();
   
    assertEquals(0, gm.getEntities(GROUPIE).size());
    assertEquals(0, gm.getEntities(GROUPIE2).size());
    assertFalse(gm.isInAnyGroup(entity));
View Full Code Here

  @Test(expected=MundaneWireException.class)
  public void throw_exception_missing_uuid_manager() {
    World world = new World();
    world.initialize();
   
    Entity entity = world.createEntity();
   
    Assert.assertNotNull(entity.getUuid());
  }
View Full Code Here

  public void uuid_assigned() {
    World world = new World();
    world.setManager(new UuidEntityManager());
    world.initialize();
   
    Entity entity = world.createEntity();
   
    assertNotNull(entity.getUuid());
    UUID uuid1 = entity.getUuid();
    world.deleteEntity(entity);
   
    world.process();
    world.process();
   
    entity = world.createEntity();
   
    assertNotNull(entity.getUuid());
    UUID uuid2 = entity.getUuid();

    assertNotEquals(uuid1, uuid2);
  }
View Full Code Here

  public void uuid_updates_work() {
    World world = new World();
    UuidEntityManager uuidManager = world.setManager(new UuidEntityManager());
    world.initialize();
   
    Entity entity = world.createEntity();
   
    UUID uuid0 = entity.getUuid();
    Assert.assertNotNull(uuid0);
   
    UUID uuid1 = UUID.randomUUID();
   
    assertEquals(uuid0, entity.getUuid());
    entity.setUuid(uuid1);
    assertEquals(uuid1, entity.getUuid());
   
   
    assertNotEquals(uuid0, uuid1);
    assertNull(uuidManager.getEntity(uuid0));
    assertEquals(entity, uuidManager.getEntity(uuid1));
View Full Code Here

    UUID[] uuids = new UUID[3];
    uuids[0] = UUID.randomUUID();
    uuids[1] = UUID.randomUUID();
    uuids[2] = UUID.randomUUID();
   
    Entity e1 = world.createEntity(uuids[0]);
    Entity e2 = world.createEntity(uuids[1]);
    Entity e3 = world.createEntity(uuids[2]);
   
    assertEquals(uuids[0], e1.getUuid());
    assertEquals(uuids[1], e2.getUuid());
    assertEquals(uuids[2], e3.getUuid());
  }
View Full Code Here

  @Override
  public Entity create() {
    _sealed = true;
   
    Entity e = world.createEntity(archetype);
    if (_position) {
      Position c = positionMapper.get(e);
      c.x = _position_x;
      c.y = _position_y;
      _position = false;
View Full Code Here

    world.initialize();
  }
 
  @Test @SuppressWarnings("unused")
  public void pooled_component_scanning() throws Exception {
    Entity e1 = world.createEntity();
    ComponentToWeave c1a = e1.createComponent(ComponentToWeave.class);
    PooledComponentWithReset c1b = e1.createComponent(PooledComponentWithReset.class);
    PooledComponentNotScanned c1c = e1.createComponent(PooledComponentNotScanned.class);
    e1.addToWorld();
   
    ClassMetadata scan1 = scan(ComponentToWeave.class);
    ClassMetadata scan2 = scan(PooledComponentWithReset.class);
    ClassMetadata scan3 = scan(PooledComponentNotScanned.class);
   
View Full Code Here

import com.tankz.components.TurnFactor;
import com.tankz.components.Velocity;

public class EntityFactory {
  public static Entity createExplosion(World world, float x, float y) {
    Entity e = world.createEntity();
    e.addComponent(new Transform(x, y));
    e.addComponent(new SpatialForm("explosion"));
    e.addComponent(new Expiration(200));
    e.addToWorld();
    return e;
  }
View Full Code Here

    e.addToWorld();
    return e;
  }

  public static Entity createBullet(World world, float x, float y, float angle, Entity shooter) {
    Entity e = world.createEntity();
    world.getManager(GroupManager.class).add(e, "bullets");
    Transform transform = new Transform(x, y, angle);
    e.addComponent(transform);
    e.addComponent(new SpatialForm("bullet"));
    e.addComponent(new Expiration(1500));

    Body b = new Body(new Box(10, 10), 0.2f);
    b.setUserData(e);
    b.addExcludedBody(shooter.getComponent(Physics.class).getBody());
    b.setBitmask(1);
    b.setPosition(x, y);
    b.setRestitution(0);
    b.setDamping(0.002f);
    b.setFriction(10);
    b.setRotation(angle);
    // b.setForce(10000f*TrigLUT.cosDeg(angle),
    // 10000f*TrigLUT.sinDeg(angle));
    b.adjustVelocity(new Vector2f(1000f * TrigLUT.cosDeg(angle), 1000f * TrigLUT.sinDeg(angle)));

    // b.setDensity(100);
    // b.setFriction(1.1f);
    // b.setDamping(0.002f);
    // b.setRestitution(0);

    e.addComponent(new Physics(b));

    e.addToWorld();

    return e;
  }
View Full Code Here

TOP

Related Classes of com.artemis.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.