Esempio n. 1
0
 private void deleteComponentRemovedHandler(ListenerKey key, ComponentRemovedHandler handler)
 {
     if (componentRemovedHandlers.ContainsKey(key))
     {
         componentRemovedHandlers[key].Remove(handler);
         if (componentRemovedHandlers[key].Count == 0)
         {
             componentRemovedHandlers.Remove(key);
         }
     }
 }
Esempio n. 2
0
        private ComponentRemovedHandler createComponentRemovedHandler <T>(ListenerKey key, Action <T> onRemoved) where T : BaseData
        {
            if (!componentRemovedHandlers.ContainsKey(key))
            {
                componentRemovedHandlers.Add(key, new List <ComponentRemovedHandler>());
            }
            ComponentRemovedHandler <T> componentRemovedHandler = new ComponentRemovedHandler <T>();

            componentRemovedHandler.Removed = onRemoved;
            ComponentRemovedHandler <T> componentRemovedHandler2 = componentRemovedHandler;

            componentRemovedHandlers[key].Add(componentRemovedHandler2);
            return(componentRemovedHandler2);
        }
Esempio n. 3
0
        public void ComponentRemoved <T>(string entityName, T component) where T : BaseData
        {
            ListenerKey listenerKey = default(ListenerKey);

            listenerKey.EntityName = entityName;
            listenerKey.Type       = typeof(T);
            ListenerKey key = listenerKey;

            if (componentRemovedHandlers.ContainsKey(key))
            {
                List <ComponentRemovedHandler> list = componentRemovedHandlers[key];
                int count = list.Count;
                for (int i = 0; i < count; i++)
                {
                    ComponentRemovedHandler <T> componentRemovedHandler = (ComponentRemovedHandler <T>)list[i];
                    componentRemovedHandler.Removed.InvokeSafe(component);
                }
            }
        }
Esempio n. 4
0
 public static void SubscribeComponentRemoved <T>(ComponentRemovedHandler <T> handler)
 {
     World.SubscribeComponentRemoved(handler);
 }
 public void RemoveComponentRemovedListener <TComponent>(ComponentRemovedHandler <TScope, TComponent> handler)
 {
     ComponentData <TComponent> .OnComponentRemoved -= handler;
 }