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(); } }
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); } } }
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; }
public void startUpdate() { updated = true; for (MotionHandler mh : motionHandlers.values()) { mh.onStart(); } }