Package com.l2client.app

Examples of com.l2client.app.Singleton


        addEntityIdToGeoms(id, n);
    }
  }

  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);
      s.getPosSystem().removeComponentForUpdate(pos);
      s.getJmeSystem().removeComponentForUpdate(pos);
      Component env = s.getEntityManager().getComponent(obj, EnvironmentComponent.class);
      s.getAnimSystem().removeComponentForUpdate(env);
System.out.println("Removed comps of "+id+" pos:"+pos+" env"+env);     
    } else {
System.out.println("ERROR!! Remove of "+id+" but no ID comp found!?! NO comps removed :-(");     
    }
    s.getEntityManager().deleteEntity(obj);
System.out.println("REMOVE of "+id+" finished");     
   
  }
View Full Code Here


  @Override
  public void handlePacket() {
    log.finer("Read from Server "+this.getClass().getSimpleName());
    int obj = readD();
    Singleton s = Singleton.get();
    L2JComponent l2j = (L2JComponent) s.getEntityManager().getComponent(obj, L2JComponent.class);
    if(l2j != null){
      //TODO refactor item/npc handling, only components which should themselves know where to remove from, also refactor item/npc/pc instancing
      if(l2j.l2jItem != null) {
        _client.getItemHandler().removeItem(obj);
        log.fine("Delete of item id "+obj);
      } else {
        _client.getNpcHandler().remove(obj);
        log.fine("Delete of npc id "+obj);
      }
    } else {
      log.severe("Delete of objectid not possible no L2JComponent for:"+obj);
      s.getEntityManager().dumpComponents(obj);
    }

  }
View Full Code Here

   */
  @Override
  public void onAction(String name, boolean isPressed, float tpf) {
    // only execute on button/key release
    if (!isPressed) {
      Singleton sin = Singleton.get();
      Vector3f origin = camera.getWorldCoordinates(
          inputManager.getCursorPosition(), 0.0f);
      Vector3f direction = camera.getWorldCoordinates(
          inputManager.getCursorPosition(), 0.3f);
      direction.subtractLocal(origin).normalizeLocal();

      Ray ray = new Ray(origin, direction);
      CollisionResults results = new CollisionResults();

      sin.getSceneManager().getRoot().collideWith(ray, results);

      if (results.size() > 0) {
        Geometry geom = null;
        for (CollisionResult res : results) {
          geom = res.getGeometry();
          if (geom != null) {
            log.fine("picked " + geom.getName());
            Integer id = geom.getUserData(Entity.ENTITY_ID);
            if (id != null) {
              //Just create a target component rest is done in the jmeupdatesystem
              Node n = res.getGeometry().getParent();
              String na = n.getName();
              log.fine("picked " + na + " id:"+ id);
              Vector3f loc = n.getLocalTranslation();
              sin.getClientFacade().sendAction(id, loc.x, loc.y, loc.z, false, true);
              results.clear();
              return;
            } else {//FIXME click on anything, check nav, then send request
              // this is the one
              Vector3f location = res.getContactPoint();
              if(location != null){
                Path p = new Path();
                PositioningComponent pos = (PositioningComponent) sin.getEntityManager().getComponent(handler.getSelectedObjectId(), PositioningComponent.class);
                if(pos != null){
                  if(sin.getNavManager().buildNavigationPath(p, pos.position, location.clone())) {
                    log.fine("new loc:" + location
                        + " sent:"+ ServerValues.getServerCoordX(location.x)
                        + ","+ ServerValues.getServerCoordY(location.z)
                        + ","+ ServerValues.getServerCoordZ(location.y));
                    sin.getClientFacade().sendMoveToAction(handler.getSelectedObjectId(), pos.position.x, pos.position.y, pos.position.z, location.x, location.y,
                        location.z);
                    results.clear();
                    return;
                  } else {
                    log.fine("Unable to build path from "+pos.position+" to "+location);
View Full Code Here

    //test for very large update window, no more than the 5 passed should be processed (each once)
    sys.timeBudget = 1f;
    sys.update(0.01f);
    assertEquals(5, count);
   
    Singleton single = Singleton.get();
    single.init(null);
    PositioningSystem ps = Singleton.get().getPosSystem();
    PositioningComponent pos = new PositioningComponent();
    pos.position = new Vector3f(10,0,0);
    pos.startPos.set(pos.position);
    pos.goalPos = new Vector3f(0,0,0);
View Full Code Here

    }).start();
   
  }
 
  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 :-(");     
    }
    s.getEntityManager().deleteEntity(obj);
System.out.println("REMOVE of "+id+" finished");     
   
  }
View Full Code Here

TOP

Related Classes of com.l2client.app.Singleton

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.