Exemplo n.º 1
0
        public void AddCallback(TDelegate dlg)
        {
            if (m_CannotMutateCallbacksArray)
            {
                if (m_CallbacksToAdd.Contains(dlg))
                {
                    return;
                }
                var removeIndex = m_CallbacksToRemove.IndexOf(dlg);
                if (removeIndex != -1)
                {
                    m_CallbacksToRemove.RemoveAtByMovingTailWithCapacity(removeIndex);
                }
                m_CallbacksToAdd.AppendWithCapacity(dlg);
                return;
            }

            if (!m_Callbacks.Contains(dlg))
            {
                m_Callbacks.AppendWithCapacity(dlg, capacityIncrement: 4);
            }
        }
Exemplo n.º 2
0
        public void RemoveCallback(TDelegate dlg)
        {
            if (m_CannotMutateCallbacksArray)
            {
                if (m_CallbacksToRemove.Contains(dlg))
                {
                    return;
                }
                var addIndex = m_CallbacksToAdd.IndexOf(dlg);
                if (addIndex != -1)
                {
                    m_CallbacksToAdd.RemoveAtByMovingTailWithCapacity(addIndex);
                }
                m_CallbacksToRemove.AppendWithCapacity(dlg);
                return;
            }

            var index = m_Callbacks.IndexOf(dlg);

            if (index >= 0)
            {
                m_Callbacks.RemoveAtWithCapacity(index);
            }
        }