Example #1
0
  public void addMotionHandler(MotionHandler mh) {
    if (motionHandlers.containsKey(mh.getID())) {
      LambdaLib.log.error("Duplicate MotionHandler ID");
      return;
    }

    mh.target = target;
    mh.entityX = this;
    motionHandlers.put(mh.getID(), mh);
    if (updated) {
      mh.onStart();
    }
  }
Example #2
0
  public void update() {
    Iterator<MotionHandler> iter = motionHandlers.values().iterator();
    while (iter.hasNext()) {
      MotionHandler mh = iter.next();
      if (mh.isDead) {
        iter.remove();
      } else if (mh.isActive) {
        mh.onUpdate();
      }
    }

    List<EntityCallback> ecList = callbacks.remove(target.ticksExisted);
    if (ecList != null) {
      for (EntityCallback ec : ecList) {
        ec.execute(target);
      }
    }
  }
Example #3
0
 public <U extends MotionHandler> U getMotionHandler(Class<? extends U> klass) {
   for (MotionHandler mo : motionHandlers.values()) {
     if (klass.isAssignableFrom(mo.getClass())) return (U) mo;
   }
   return null;
 }
Example #4
0
 public void startUpdate() {
   updated = true;
   for (MotionHandler mh : motionHandlers.values()) {
     mh.onStart();
   }
 }