Exemplo n.º 1
0
        public static EntitiesIndexedByNavigationNodes build(NavigationEngine p_navigationEngine)
        {
            EntitiesIndexedByNavigationNodes l_instance = new EntitiesIndexedByNavigationNodes();

            l_instance.Entities = new Dictionary <NavigationNode, List <Entity> >();
            return(l_instance);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
 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);
         }
     }
 }
Exemplo n.º 6
0
 public static void free(ref EntitiesIndexedByNavigationNodes p_entitiesIndexedByNavigationNodes)
 {
     p_entitiesIndexedByNavigationNodes.Entities.Clear();
 }