private Set <EventHandlerInfo> selectEventHandlers(Type eventType, EntityRef entity) { Set <EventHandlerInfo> result = Sets.newHashSet(); result.addAll(generalHandlers.get(eventType)); SetMultimap <Type, EventHandlerInfo> handlers = componentSpecificHandlers[eventType]; if (handlers == null) { return(result); } foreach (Type compClass in handlers.Keys) { if (entity.hasComponent(compClass)) { foreach (EventHandlerInfo eventHandler in handlers.get(compClass)) { if (eventHandler.isValidFor(entity)) { result.add(eventHandler); } } } } return(result); }
public virtual bool isValidFor(EntityRef entity) { foreach (Type component in components) { if (!entity.hasComponent(component)) { return(false); } } return(true); }