/** Returns this actor or the first ascendant of this actor that is assignable with the specified type, or null if none were * found. */ public <T extends Actor> T firstAscendant (Class<T> type) { if (type == null) throw new IllegalArgumentException("actor cannot be null."); Actor actor = this; do { if (ClassReflection.isInstance(type, actor)) return (T)actor; actor = actor.parent; } while (actor != null); return null; }
/** Returns this actor or the first ascendant of this actor that is assignable with the specified type, or null if none were * found. */ public <T extends Actor> T firstAscendant (Class<T> type) { if (type == null) throw new IllegalArgumentException("actor cannot be null."); Actor actor = this; do { if (ClassReflection.isInstance(type, actor)) return (T)actor; actor = actor.parent; } while (actor != null); return null; }
public boolean handle (Event event) { if (!active || !ClassReflection.isInstance(eventClass, event)) return false; result = EventAction.this.handle((T)event); return result; } };
public boolean handle (Event event) { if (!active || !ClassReflection.isInstance(eventClass, event)) return false; result = EventAction.this.handle((T)event); return result; } };
/** @param type * @param fill array to be filled with the matching layers * @return array with all the layers matching type */ public <T extends MapLayer> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = layers.size; i < n; i++) { MapLayer layer = layers.get(i); if (ClassReflection.isInstance(type, layer)) { fill.add((T)layer); } } return fill; }
/** @param type * @param fill array to be filled with the matching layers * @return array with all the layers matching type */ public <T extends MapLayer> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = layers.size; i < n; i++) { MapLayer layer = layers.get(i); if (ClassReflection.isInstance(type, layer)) { fill.add((T)layer); } } return fill; }
/** @param type class of the objects we want to retrieve * @param fill collection to put the returned objects in * @return array filled with all the objects in the collection matching type */ public <T extends MapObject> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = objects.size; i < n; i++) { MapObject object = objects.get(i); if (ClassReflection.isInstance(type, object)) { fill.add((T)object); } } return fill; }
/** @param type class of the objects we want to retrieve * @param fill collection to put the returned objects in * @return array filled with all the objects in the collection matching type */ public <T extends MapObject> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = objects.size; i < n; i++) { MapObject object = objects.get(i); if (ClassReflection.isInstance(type, object)) { fill.add((T)object); } } return fill; }
@SuppressWarnings("unchecked") public synchronized <T extends Buff> T buff( Class<T> c ) { for (Buff b : buffs) { if (ClassReflection.isInstance( c, b )) { return (T)b; } } return null; }
/** Registers a listener for the specified message code. Messages without an explicit receiver are broadcasted to all its * registered listeners. * @param listener the listener to add * @param msg the message code */ public void addListener (Telegraph listener, int msg) { Array<Telegraph> listeners = msgListeners.get(msg); if (listeners == null) { // Associate an empty unordered array with the message code listeners = new Array<Telegraph>(false, 16); msgListeners.put(msg, listeners); } listeners.add(listener); // Dispatch messages from registered providers Array<TelegramProvider> providers = msgProviders.get(msg); if (providers != null) { for (int i = 0, n = providers.size; i < n; i++) { TelegramProvider provider = providers.get(i); Object info = provider.provideMessageInfo(msg, listener); if (info != null) { Telegraph sender = ClassReflection.isInstance(Telegraph.class, provider) ? (Telegraph)provider : null; dispatchMessage(0, sender, listener, msg, info, false); } } } }
/** Returns this actor or the first ascendant of this actor that is assignable with the specified type, or null if none were * found. */ public <T extends Actor> T firstAscendant (Class<T> type) { if (type == null) throw new IllegalArgumentException("actor cannot be null."); Actor actor = this; do { if (ClassReflection.isInstance(type, actor)) return (T)actor; actor = actor.parent; } while (actor != null); return null; }
@SuppressWarnings("unchecked") public synchronized <T extends Buff> HashSet<T> buffs( Class<T> c ) { HashSet<T> filtered = new HashSet<>(); for (Buff b : buffs) { if (ClassReflection.isInstance( c, b )) { filtered.add( (T)b ); } } return filtered; }
public boolean handle (Event event) { if (!active || !ClassReflection.isInstance(eventClass, event)) return false; result = EventAction.this.handle((T)event); return result; } };
/** @param type class of the objects we want to retrieve * @param fill collection to put the returned objects in * @return array filled with all the objects in the collection matching type */ public <T extends MapObject> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = objects.size; i < n; i++) { MapObject object = objects.get(i); if (ClassReflection.isInstance(type, object)) { fill.add((T)object); } } return fill; }
/** @param type * @param fill array to be filled with the matching layers * @return array with all the layers matching type */ public <T extends MapLayer> Array<T> getByType (Class<T> type, Array<T> fill) { fill.clear(); for (int i = 0, n = layers.size; i < n; i++) { MapLayer layer = layers.get(i); if (ClassReflection.isInstance(type, layer)) { fill.add((T)layer); } } return fill; }
/** Registers a listener for the specified message code. Messages without an explicit receiver are broadcasted to all its * registered listeners. * @param listener the listener to add * @param msg the message code */ public void addListener (Telegraph listener, int msg) { Array<Telegraph> listeners = msgListeners.get(msg); if (listeners == null) { // Associate an empty unordered array with the message code listeners = new Array<Telegraph>(false, 16); msgListeners.put(msg, listeners); } listeners.add(listener); // Dispatch messages from registered providers Array<TelegramProvider> providers = msgProviders.get(msg); if (providers != null) { for (int i = 0, n = providers.size; i < n; i++) { TelegramProvider provider = providers.get(i); Object info = provider.provideMessageInfo(msg, listener); if (info != null) { Telegraph sender = ClassReflection.isInstance(Telegraph.class, provider) ? (Telegraph)provider : null; dispatchMessage(0, sender, listener, msg, info, false); } } } }