Exemplo n.º 1
0
 public static void AddComponent(MonoComponent component, int prio)
 {
     if (component.GetType() == typeof(RenderComponent) || component.GetType().IsSubclassOf(typeof(RenderComponent)))
     {
         if (!renderComps.ContainsKey(prio))
         {
             renderComps[prio] = new List <RenderComponent>();
         }
         renderComps[prio].Add((RenderComponent)component);
     }
     else if (component.GetType() == typeof(CircleCollider))
     {
         if (!colliderComps.ContainsKey(prio))
         {
             colliderComps[prio] = new List <CircleCollider>();
         }
         colliderComps[prio].Add((CircleCollider)component);
     }
     else
     {
         if (!comps.ContainsKey(prio))
         {
             comps[prio] = new List <MonoComponent>();
         }
         comps[prio].Add(component);
     }
 }
Exemplo n.º 2
0
 public static void RemoveComponent(MonoComponent component)
 {
     if (component.GetType() == typeof(RenderComponent) || component.GetType().IsSubclassOf(typeof(RenderComponent)))
     {
         if (renderComps.ContainsKey(component.Priority))
         {
             if (renderComps[component.Priority].Contains(component))
             {
                 renderComps[component.Priority].Remove((RenderComponent)component);
                 if (renderComps[component.Priority].Count == 0)
                 {
                     renderComps.Remove(component.Priority);
                 }
             }
         }
     }
     else if (component.GetType() == typeof(CircleCollider))
     {
         if (colliderComps.ContainsKey(component.Priority))
         {
             if (colliderComps[component.Priority].Contains(component))
             {
                 colliderComps[component.Priority].Remove((CircleCollider)component);
                 if (colliderComps[component.Priority].Count == 0)
                 {
                     colliderComps.Remove(component.Priority);
                 }
             }
         }
     }
     else
     {
         if (comps.ContainsKey(component.Priority))
         {
             if (comps[component.Priority].Contains(component))
             {
                 comps[component.Priority].Remove(component);
                 if (comps[component.Priority].Count == 0)
                 {
                     comps.Remove(component.Priority);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public IEnumerable <MonoComponent> GetComponents(MonoComponent c)
 {
     return(comps.Where(x => x.GetType() == c.GetType()));
 }