Package com.l2client.controller.entity

Examples of com.l2client.controller.entity.Entity


 
  //FIXME this is a copy from NPCHandler move this out to the entity Manager !!
  public Entity createPCComponents(EntityData e, VisibleModel visible) {
   
    EntityManager em = Singleton.get().getEntityManager();
    final Entity ent = em.createEntity(e.getObjectId());
    PositioningComponent pos = new PositioningComponent();
    L2JComponent l2j = new L2JComponent();
    VisualComponent vis = new VisualComponent();
    EnvironmentComponent env = new EnvironmentComponent();
    TargetComponent tgt = new TargetComponent();
    LoggingComponent log = new LoggingComponent();
   
    em.addComponent(ent.getId(), env);
    em.addComponent(ent.getId(), l2j);
    em.addComponent(ent.getId(), pos);   
    em.addComponent(ent.getId(), vis);
    em.addComponent(ent.getId(), tgt);
    em.addComponent(ent.getId(), log);
       
    //done here extra as in update values will be left untouched
    pos.startPos.set(e.getX(), e.getY(), e.getZ());
    pos.position.set(pos.startPos);
    pos.goalPos.set(pos.position);
    pos.walkSpeed = e.getWalkSpeed();
    pos.runSpeed = e.getRunSpeed();
    pos.running = e.isRunning();
    pos.heading = e.getHeading();
    pos.targetHeading = pos.heading;
    pos.teleport = true;
   
    vis.vis = visible;
    visible.attachVisuals();
   
    l2j.isPlayer  = true;
    em.setPlayerId(ent.getId());
    l2j.l2jEntity = e;

    ent.setLocalTranslation(pos.position);
    ent.setLocalRotation(new Quaternion().fromAngleAxis(e.getHeading(), Vector3f.UNIT_Y));
    ent.attachChild(visible);
   
    //hook up of the terrain swapping @see SimpleTerrainManager
    ent.addControl(new AbstractControl(){

      @Override
      public Control cloneForSpatial(Spatial spatial) {
        return null;
      }

      @Override
      protected void controlUpdate(float tpf) {
        Singleton.get().getTerrainManager().update(ent.getLocalTranslation());
      }

      @Override
      protected void controlRender(RenderManager rm, ViewPort vp) {
      }}
View Full Code Here


    L2JComponent l2j = new L2JComponent();
    VisualComponent vis = new VisualComponent();
    EnvironmentComponent env = new EnvironmentComponent();
    //FIXME parallel create problems, synchronize creation and essential components or at least create/check of components
System.out.println("createNpc pre createEntity "+e.getObjectId());
    Entity ent = em.createEntity(e.getObjectId());
System.out.println("createNpc post createEntity "+e.getObjectId());
    em.addComponent(ent.getId(), pos);
System.out.println("createNpc post Add pos "+e.getObjectId());
    em.addComponent(ent.getId(), vis);
    System.out.println("createNpc post Add vis "+e.getObjectId());
    em.addComponent(ent.getId(), env);
    System.out.println("createNpc post Add env "+e.getObjectId());
    em.addComponent(ent.getId(), l2j);
    System.out.println("createNpc post Add l2j "+e.getObjectId());
   
    updateComponents(e, ent, pos, l2j, env, vis);//vis might take some time so we already added pos for updates
    System.out.println("createNpc end  "+e.getObjectId());
View Full Code Here

  public void remove(int obj) {
    Singleton s = Singleton.get();
    IdentityComponent id = (IdentityComponent) s.getEntityManager().getComponent(obj, IdentityComponent.class);
    if(id != null){
      Entity e = id.getEntity();
      if(e != null)
        s.getSceneManager().changeWalkerNode(e,Action.REMOVE);
System.out.println("Starting to remove comps of "+id);     
      //FIXME check this is working correctly, what if we delete one which is currently updated, better queue for removal.
      Component pos = s.getEntityManager().getComponent(obj, PositioningComponent.class);
View Full Code Here

      if (en.changed) {
        IdentityComponent e = Singleton.get().getEntityManager().getEntity(c);
        if (e != null) {
          // e.getEntity().setLocalTranslation(com.position.x,
          // com.position.y+com.heightOffset, com.position.z);
          Entity ent = e.getEntity();
          checkForDamageMessages(ent, en);
          // FIXME damn ugly Ent -> NPCModel -> Vis -> Controller WILL BLOW ON PURE VISMODEL
          try {
            JMEAnimationController con = null;
            if(ent.getChildren().size() > 0 && ((Node)ent.getChild(0)) != null && ((Node)ent.getChild(0)).getChildren().size() > 0)
              con = ((Node) ent.getChild(0)).getChild(0).getControl(JMEAnimationController.class);
            if (con != null) {
              InputProvider in = getInputFrom(en, ent);
              con.setInput(in);
//FIXME OEHAM twice done, see Attack sever packet
//            if(en.damageDealt > 0)
View Full Code Here

   */
  public void callAction(CallActions a, int entityId) {
    IdentityComponent idc = (IdentityComponent) Singleton.get().getEntityManager()
        .getComponent(entityId, IdentityComponent.class);
    if (idc != null) {
      Entity e = idc.getEntity();
      VisualComponent comp = (VisualComponent) Singleton.get().getEntityManager().getComponent(e.getId(), VisualComponent.class);
      if(comp != null){
        //FIXME this can blow up!
        if(e.getChildren().size()>0 && ((Node)e.getChild(0)).getChildren().size()>0 ){
          JMEAnimationController con = ((Node) e.getChild(0)).getChild(0)
              .getControl(JMEAnimationController.class);
          if (con != null) {
            EnvironmentComponent env = (EnvironmentComponent) Singleton.get().getEntityManager().getComponent(entityId,
                    EnvironmentComponent.class);
            if (env != null) {
              log.finest(e.getId()+" callAction "+a);
              con.callAction(a.toString(), getInputFrom(env, e));
            }
          }
        } else {
          log.warning("No proper spatial hierarchy on model "+e.getName());
        }
         
      }
    }

View Full Code Here

    new Thread(new Runnable() {
     
      @Override
      public void run() {
       
        Entity ent = Singleton.get().getEntityManager().createEntity(objId);
        ItemInstance item = new ItemInstance();
        item.charId = charId;
        item.objectId = objId;
        item.itemId = itemId;
        item.worldPosition =   ServerValues.getClientCoords(x, y, z);
        item.stackable = stackable;
        item.count = count;
       
        ItemModel i = new ItemModel(item);
        i.attachVisuals();
        Singleton.get().getNavManager().snapToGround(item.worldPosition);
        ent.setLocalTranslation(item.worldPosition);
        ent.setName(i.getName());
        ent.attachChild(i);
       
       
        Singleton.get().getSceneManager().changeItemNode(ent,Action.ADD);
      }
    }).start();
View Full Code Here

 
  public void removeItem(int obj) {
    Singleton s = Singleton.get();
    IdentityComponent id = (IdentityComponent) s.getEntityManager().getComponent(obj, IdentityComponent.class);
    if(id != null){
      Entity e = id.getEntity();
      if(e != null)
        s.getSceneManager().changeItemNode(e,Action.REMOVE);   
    } else {
System.out.println("ERROR!! Remove of "+id+" but no ID comp found!?! NO comps removed :-(");     
    }
View Full Code Here

    l.lastUpdate+=tpf;
    if(l.lastUpdate > l.debugTime){
      l.lastUpdate = 0f;
      IdentityComponent i = Singleton.get().getEntityManager().getEntity(l);
      //FIXME can be null this is baaad
      Entity ent = i.getEntity();
      if(ent != null){
        Vector3f v = i.getEntity().getWorldTranslation();
        log.fine("ENTITY:"+i.getId()+" at:"+v+" -> ("+ServerValues.getServerString(v.x, v.y, v.z)+")");
//System.out.println("ENTITY:"+i.getId()+" at JME:"+v+" -> L2J:("+ServerValues.getServerCoord(v.x)+
//    ","+ServerValues.getServerCoord(v.y)+","+ServerValues.getServerCoord(v.z)+")");
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.