Package com.l2client.controller.entity

Examples of com.l2client.controller.entity.Entity


      Box b = new Box(.5f,1f,.5f);
      Geometry walker = new Geometry("wakler", b);
      Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Red);
        walker.setMaterial(mat);
        Entity e = placeObject(new Vector3f(257f,2.2f,0f), new Vector3f(389f,0f,0f));
        if(e != null){
          e.attachChild(walker);
          rootNode.attachChild(e);
          this.walker = e;
        }

     
View Full Code Here


        }
      }
    }
   
    private Entity placeObject(final Vector3f position, final Vector3f destination/*can be null*/){
      final Entity ent =  createEntity(position);

      try {
     
      Thread t = new Thread(new Runnable() {
       
        @Override
        public void run() {
              try {
            Thread.sleep(10000);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
         
          if(ent != null && destination != null){
                Path pa = new Path();
                PositioningComponent pc = (PositioningComponent) em.getComponent(ent.getId(), PositioningComponent.class);
                if(pc != null){
                boolean foundPath = enm.buildNavigationPath(pa, pc.position, destination);
                if(foundPath){
                  NavTestHelper.printPath(pa);
                  pc.initByWayPoint(pa);
View Full Code Here

    }
    static int id = 1;

  private Entity createEntity(Vector3f pos) {

    Entity e = EntityManager.get().createEntity(id++);
    if (e != null) {
      Cell c = Singleton.get().getNavManager().FindClosestCell(pos, false);
      pc = new PositioningComponent();
      if (c != null) {
        pc.cell = c.getId();
        c.MapVectorHeightToCell(pos);
      }
      pc.position.set(pos);
      pc.heightOffset = 1f;
     
      em.addComponent(e.getId(), pc);
      ps.addComponentForUpdate(pc);
      js.addComponentForUpdate(pc);
       
//        e.setLocalTranslation(pos);
       
View Full Code Here

      Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Red);
        walker.setMaterial(mat);
//        269.5173, -284.07605, 87.175156 to 476.54184, -171.21466, 454.62576
        //Entity e = placeObject(new Vector3f(-9969.057f, 15.097652f, 8429.296f), new Vector3f(-9979.581f, 28.097652f, 8420.083f));
        Entity e = placeObject(new Vector3f(-9890.341f, 14.610833f, 8302.891f), p.clone());
        if(e != null){
          e.attachChild(walker);
          rootNode.attachChild(e);
          this.walker = e;
        }
        System.out.println("Entity placed");
       
View Full Code Here

      }
      }
    }
   
    private Entity placeObject(final Vector3f position, final Vector3f destination/*can be null*/){
      final Entity ent =  createEntity(position);

          if(ent != null && destination != null){
                Path pa = new Path();
                PositioningComponent pc = (PositioningComponent) em.getComponent(ent.getId(), PositioningComponent.class);
                if(pc != null){
                  boolean foundPath = enm.buildNavigationPath(pa, pc.position, destination);
                  if(foundPath){
                    NavTestHelper.printPath(pa);
                    pc.initByWayPoint(pa);
                    pc.acc =0f;
                    pc.direction = Vector3f.ZERO;
                    pc.heading = 0f;
                    pc.maxAcc = 2f;
                    pc.maxDcc = 3f;
                    pc.maxSpeed = 4f;
                    pc.speed = 0f;
                    }
                  }
            } else
              System.out.println("No PosComp on Entity "+ent.getId());

    return ent;
     
    }
View Full Code Here

    }
    static int id = 1;

  private Entity createEntity(Vector3f pos) {

    Entity e = em.createEntity(id++);
    if (e != null) {
      Cell c = enm.FindClosestCell(pos, false);
      pc = new PositioningComponent();
      if (c != null) {
        pc.cell = c.getId();
        c.MapVectorHeightToCell(pos);
        System.out.println("Entity placed at "+pos);
      } else {
        System.out.println("No cell found near "+pos);
      }
      pc.position.set(pos);
      pc.heightOffset = 1f;
     
      em.addComponent(e.getId(), pc);
      ps.addComponentForUpdate(pc);
      js.addComponentForUpdate(pc);
       
//        e.setLocalTranslation(pos);
       
View Full Code Here

      Geometry walker = new Geometry("wakler", b);
      Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Red);
        walker.setMaterial(mat);
//        269.5173, -284.07605, 87.175156 to 476.54184, -171.21466, 454.62576
        Entity e = placeObject(new Vector3f(270f,-280f,90f), new Vector3f(375f,-170f,455f));
        if(e != null){
          e.attachChild(walker);
          rootNode.attachChild(e);
          this.walker = e;
        }

     
View Full Code Here

        }
      }
    }
   
    private Entity placeObject(final Vector3f position, final Vector3f destination/*can be null*/){
      final Entity ent =  createEntity(position);

      try {
     
      Thread t = new Thread(new Runnable() {
       
        @Override
        public void run() {
              try {
            Thread.sleep(10000);
          } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
         
          if(ent != null && destination != null){
                Path pa = new Path();
                PositioningComponent pc = (PositioningComponent) em.getComponent(ent.getId(), PositioningComponent.class);
                if(pc != null){
                boolean foundPath = enm.buildNavigationPath(pa, pc.position, destination);
                if(foundPath){
                  NavTestHelper.printPath(pa);
                  pc.initByWayPoint(pa);
View Full Code Here

    }
    static int id = 1;

  private Entity createEntity(Vector3f pos) {

    Entity e = em.createEntity(id++);
    if (e != null) {
      Cell c = enm.FindClosestCell(pos, false);
      pc = new PositioningComponent();
      if (c != null) {
        pc.cell = c.getId();
        c.MapVectorHeightToCell(pos);
      }
      pc.position.set(pos);
      pc.heightOffset = 1f;
     
      em.addComponent(e.getId(), pc);
      ps.addComponentForUpdate(pc);
      js.addComponentForUpdate(pc);
       
//        e.setLocalTranslation(pos);
       
View Full Code Here

            return;
          //TODO distance check only on client side? server still has our last target?
          IdentityComponent e = (IdentityComponent) em.getComponent(tgt.getCurrentTarget(), IdentityComponent.class);
          if(e != null){
            IdentityComponent me = em.getEntity(tgt);
            Entity i = me.getEntity();
            Entity them = e.getEntity();
            if(them != null && i != null){
              //update our target positin (ev. used by others), ev. rotation to target in positioning system
              tgt.pos = them.getLocalTranslation().clone();
            }
          }
        }
        //
        // ENDOF NPC UPDATE
      } else {
        //----------- target changed to new target -----------
        if(tgt.getCurrentTarget() != tgt.getLastTarget()){ 
          //
          // PLAYER UPDATE
            //----------- remove last marked -----------
            if(tgt.getLastTarget() != TargetComponent.NO_TARGET){
              log.fine("Player target changed, removing Selection on:"+tgt.getLastTarget());
              //target was set to a new entity
              //get visual and REMOVE selection from it
              VisualComponent vis = (VisualComponent) em
                .getComponent(tgt.getLastTarget(), VisualComponent.class);
              if(vis!=null){
                if (vis.vis != null) {
                  ((VisibleModel) vis.vis).removeSelectionMarker();
                  log.finest("Player target changed, Selection removed:"+tgt.getLastTarget());
                } else {
                  log.severe("Player target changed, Selection VIS not found on:"+tgt.getLastTarget());
                }
              } else
                log.severe("Player target changed, Selection NO VIS not found on:"+tgt.getLastTarget());

//FIXME this causes side effects with entity deletion, it seems, l2j deletes dead entities quite fast
//              LoggingComponent l = (LoggingComponent) em.getComponent(tgt.getLastTarget(), LoggingComponent.class);
//              if(l != null) {
//                Singleton.get().getPosSystem().removeComponentForUpdate(l);
//                em.removeComponent(tgt.getLastTarget(), l);
//              }
            }
            //----------- set current -----------
            if(tgt.hasTarget()){
              log.fine("Player target changed, adding Selection on:"+tgt.getCurrentTarget());
              //target was set to a new entity
              //get visual and add selection to it
              VisualComponent vis = (VisualComponent) em
                .getComponent(tgt.getCurrentTarget(), VisualComponent.class);
              if (vis != null && vis.vis != null) {
                ((VisibleModel) vis.vis).addSelectionMarker(tgt.color);
                log.fine("Player target changed, Selection added:"+tgt.getCurrentTarget());
              } else {
                log.severe("Player target changed, Selection VIS not found on on:"+tgt.getCurrentTarget());
              }

//FIXME this causes side effects with entity deletion, it seems, l2j deletes dead entities quite fast             
//              LoggingComponent l = (LoggingComponent) em.getComponent(tgt.getCurrentTarget(), LoggingComponent.class);
//              if(l == null){
//                l = new LoggingComponent();
//                em.addComponent(tgt.getCurrentTarget(), l);
//                Singleton.get().getPosSystem().addComponentForUpdate(l);
//              } else {
//                log.severe("Logging comp still on changed ent!!?");
//              }
            } else {
              //reset target creation by setting old target to current
              tgt.setNoTarget();
              tgt.pos = Vector3f.ZERO;
              log.fine("Player target changed, set to NOTARGET");
            }
          //----------- reset targeting creation changes by setting old target to current -----------
          tgt.setTarget(tgt.getCurrentTarget());
          log.fine("Player target changed, setting last to current, current to current target");
        } else {
          //check if target is set and moved out of distance
          if(!tgt.hasTarget())
            return;
          //TODO distance check only on client side? server still has our last target?
          IdentityComponent e = (IdentityComponent) em.getComponent(tgt.getCurrentTarget(), IdentityComponent.class);
          if(e != null){
            IdentityComponent me = em.getEntity(tgt);
            Entity i = me.getEntity();
            Entity them = e.getEntity();
            if(them != null && i != null){
              //update our target positin (ev. used by others)
              tgt.pos = them.getLocalTranslation();
//              if(tgt.pos.distance(i.getLocalTranslation()) > MAX_TARGETING_DISTANCE) {
//                //remove next time in above code
//                tgt.setNoTarget();
//              } else {
                //update health bar of highlighted target
                VisualComponent vis = (VisualComponent) em
                    .getComponent(tgt.getCurrentTarget(), VisualComponent.class);
                if (vis != null && vis.vis != null) {
                  ((VisibleModel) vis.vis).updateHealthbar((float)l2j.l2jEntity.getCurrentHp()/(float)l2j.l2jEntity.getMaxHp());
                }else
                  log.severe("Player target changed, VIS not found on :"+tgt.getCurrentTarget()+" for HealthBar update");
//              }
              //update target information for environment
              EnvironmentComponent env = (EnvironmentComponent) Singleton.get().getEntityManager().getComponent(i.getId(), EnvironmentComponent.class);
              if (env != null) {
                env.changed = true;
                log.finer("Should update stance");
              } else
                log.severe("No EnvironmentComponent found with entity id "
                        + i.getId() + ", perhaps just create one?");
            } else {
              //remove next time in above code
              tgt.setNoTarget();
            }
          } else {
            //remove next time in above code
            tgt.setNoTarget();
          }
        }
      }
      //
      // END OF PLAYER UPDATE
    } else
      if(c instanceof PositioningComponent){
        PositioningComponent com = (PositioningComponent) c;
        IdentityComponent e = em.getEntity(com);
        if(e != null)
        {
          Entity ent = e.getEntity();
          ent.setLocalTranslation(com.position.x, com.position.y+com.heightOffset, com.position.z);
          ent.setLocalRotation(new Quaternion().fromAngleNormalAxis(com.heading, Vector3f.UNIT_Y.negate()));
        } else {
          log.severe("Positioning component without identity component found! comp:"+
              c+" at "+ com.position.x+ ", "+(com.position.y+com.heightOffset)+", "+com.position.z);
          //FIXME this is a workaround, investigate why this can happen! was it added twice? should we better use a hasmap for components
          dumpComponents();
View Full Code Here

TOP

Related Classes of com.l2client.controller.entity.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.