Exemplo n.º 1
0
        public void removeEntityListener(EntityListener listener)
        {
            for (int i = 0; i < entityListeners.size; i++)
            {
                EntityListenerData entityListenerData = entityListeners.get(i);
                if (entityListenerData.listener == listener)
                {
                    // Shift down bitmasks by one step
                    foreach (var mask in entityListenerMasks.Values)
                    {
                        //var mask = entry.value;
                        for (int k = i, n = mask.length(); k < n; k++)
                        {
                            if (mask.get(k + 1))
                            {
                                mask.set(k);
                            }
                            else
                            {
                                mask.clear(k);
                            }
                        }
                    }

                    entityListeners.removeIndex(i--);
                }
            }
        }
Exemplo n.º 2
0
        public void addEntityListener(Family family, int priority, EntityListener listener)
        {
            registerFamily(family);

            int insertionIndex = 0;

            while (insertionIndex < entityListeners.size)
            {
                if (entityListeners.get(insertionIndex).priority <= priority)
                {
                    insertionIndex++;
                }
                else
                {
                    break;
                }
            }

            // Shift up bitmasks by one step
            foreach (var mask in entityListenerMasks.Values)
            {
                //var mask = entry.value;
                for (int k = mask.length(); k > insertionIndex; k--)
                {
                    if (mask.get(k - 1))
                    {
                        mask.set(k);
                    }
                    else
                    {
                        mask.clear(k);
                    }
                }
                mask.clear(insertionIndex);
            }

            entityListenerMasks[family].set(insertionIndex);

            EntityListenerData entityListenerData = new EntityListenerData();

            entityListenerData.listener = listener;
            entityListenerData.priority = priority;
            entityListeners.insert(insertionIndex, entityListenerData);
        }