コード例 #1
0
ファイル: AudioManager.java プロジェクト: Altrazar/Terasology
 private static Vector3f getEntityPosition(EntityRef entity) {
   LocationComponent loc = entity.getComponent(LocationComponent.class);
   if (loc != null) {
     return loc.getWorldPosition();
   }
   return null;
 }
コード例 #2
0
ファイル: AudioManager.java プロジェクト: Altrazar/Terasology
 private static Vector3f getEntityDirection(EntityRef entity) {
   LocationComponent loc = entity.getComponent(LocationComponent.class);
   if (loc != null) {
     Quat4f rot = loc.getWorldRotation();
     Vector3f dir = new Vector3f(0, 0, -1);
     QuaternionUtil.quatRotate(rot, dir, dir);
     return dir;
   }
   return new Vector3f();
 }
コード例 #3
0
  public EntityRef newInstance(Vector3f spawnPosition) {
    EntityRef player = entityManager.create("core:player");
    LocationComponent location = player.getComponent(LocationComponent.class);
    location.setWorldPosition(spawnPosition);
    player.saveComponent(location);
    PlayerComponent playerComponent = player.getComponent(PlayerComponent.class);
    playerComponent.spawnPosition.set(spawnPosition);
    player.saveComponent(playerComponent);
    player.addComponent(new LocalPlayerComponent());

    // Goodie chest
    EntityRef chest =
        blockFactory.newInstance(BlockManager.getInstance().getBlockFamily("core:chest"));
    BlockItemComponent blockItem = chest.getComponent(BlockItemComponent.class);
    EntityRef chestContents = blockItem.placedEntity;

    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("core:companion"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:brick:engine:stair"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(BlockManager.getInstance().getBlockFamily("core:Tnt"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("books:Bookcase"), 1)));

    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:clay:engine:slope"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:clay:engine:steepslope"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:StoneStair"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:marble:engine:stair"), 99)));

    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Marble"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:marble:engine:testsphere"),
                99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:marble:engine:slope"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:marble:engine:steepslope"),
                99)));

    chestContents.send(new ReceiveItemEvent(entityManager.create("potions:purplepotion")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("potions:greenpotion")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("potions:orangepotion")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("potions:redpotion")));

    chestContents.send(new ReceiveItemEvent(entityManager.create("books:book")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("books:bluebook")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("books:redbook")));
    chestContents.send(new ReceiveItemEvent(entityManager.create("core:railgunTool")));

    chestContents.send(new ReceiveItemEvent(entityManager.create("core:mrbarsack")));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Cobaltite"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:NativeGoldOre"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Microcline"), 99)));

    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Brick"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(BlockManager.getInstance().getBlockFamily("engine:Ice"), 99)));
    chestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Plank"), 99)));

    EntityRef doorItem = entityManager.create("core:door");
    ItemComponent doorItemComp = doorItem.getComponent(ItemComponent.class);
    doorItemComp.stackCount = 20;
    doorItem.saveComponent(doorItemComp);
    chestContents.send(new ReceiveItemEvent(doorItem));

    // Inner goodie chest
    EntityRef innerChest =
        blockFactory.newInstance(BlockManager.getInstance().getBlockFamily("core:Chest"));
    BlockItemComponent innerBlockItem = innerChest.getComponent(BlockItemComponent.class);
    EntityRef innerChestContents = innerBlockItem.placedEntity;

    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Alabaster"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Basalt"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Gabbro"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Hornblende"), 99)));

    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:OrangeSandStone"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Phyllite"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Schist"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Cinnabar"), 99)));

    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Lava"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Water"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Rutile"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("minerals:Kaolinite"), 99)));

    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Iris"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Dandelion"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Tulip"), 99)));
    innerChestContents.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:YellowFlower"), 99)));

    // Place inner chest into outer chest
    chestContents.send(new ReceiveItemEvent(innerChest));

    player.send(new ReceiveItemEvent(entityManager.create("core:pickaxe")));
    player.send(new ReceiveItemEvent(entityManager.create("core:axe")));
    player.send(
        new ReceiveItemEvent(
            blockFactory.newInstance(
                BlockManager.getInstance().getBlockFamily("engine:Torch"), 99)));
    player.send(new ReceiveItemEvent(entityManager.create("core:explodeTool")));
    player.send(new ReceiveItemEvent(entityManager.create("core:railgunTool")));
    player.send(new ReceiveItemEvent(entityManager.create("core:miniaturizer")));
    player.send(new ReceiveItemEvent(chest));

    return player;
  }