public static EntitiesIndexedByNavigationNodes build(NavigationEngine p_navigationEngine) { EntitiesIndexedByNavigationNodes l_instance = new EntitiesIndexedByNavigationNodes(); l_instance.Entities = new Dictionary <NavigationNode, List <Entity> >(); return(l_instance); }
/// <summary> /// Returns true if <paramref name="p_entitiesIndexedByNavigationNodes"/> has any <see cref="Entity"/> that has a component of type COMPONENT /// and is satisfying the <paramref name="p_filterCondition"/> condition. /// </summary> public static bool isThereAtLeastOfComponentOfType <COMPONENT>( ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes, NavigationNode p_requestedNode, Func <COMPONENT, bool> p_filterCondition = null) where COMPONENT : AEntityComponent { if (p_entitiesIndexedByNavigationNodes.Entities.ContainsKey(p_requestedNode)) { List <Entity> l_entities = p_entitiesIndexedByNavigationNodes.Entities[p_requestedNode]; for (int i = 0; i < l_entities.Count; i++) { COMPONENT l_component = EntityComponent.get_component <COMPONENT>(l_entities[i]); if (l_component != null) { if (p_filterCondition != null) { if (p_filterCondition.Invoke(l_component)) { return(true); } } else { return(true); } } } } return(false); }
private static void removeEntityToNavigationNode(ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes, Entity p_entity, NavigationNode p_navigationNode) { if (p_entitiesIndexedByNavigationNodes.Entities.ContainsKey(p_navigationNode)) { p_entitiesIndexedByNavigationNodes.Entities[p_navigationNode].Remove(p_entity); } }
private static void addEntityToNavigationNode(ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes, Entity p_entity, NavigationNode p_navigationNode) { if (!p_entitiesIndexedByNavigationNodes.Entities.ContainsKey(p_navigationNode)) { p_entitiesIndexedByNavigationNodes.Entities.Add(p_navigationNode, new List <Entity>()); } List <Entity> l_navigationNodeEntities = p_entitiesIndexedByNavigationNodes.Entities[p_navigationNode]; if (!l_navigationNodeEntities.Contains(p_entity)) { l_navigationNodeEntities.Add(p_entity); } }
public static void onNavigationNodeChange(ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes, Entity p_entity, NavigationNode p_oldNavigationNode, NavigationNode p_newNavigationNode) { if (p_entity != null) { if (p_newNavigationNode != null) { addEntityToNavigationNode(ref p_entitiesIndexedByNavigationNodes, p_entity, p_newNavigationNode); } if (p_oldNavigationNode != null) { removeEntityToNavigationNode(ref p_entitiesIndexedByNavigationNodes, p_entity, p_oldNavigationNode); } } }
public static void free(ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes) { p_entitiesIndexedByNavigationNodes.Entities.Clear(); }