Remove() public method

public Remove ( item ) : bool
return bool
示例#1
0
        void ReplacePathManager()
        {
            if (Singleton <PathManager> .instance as CustomPathManager != null)
            {
                return;
            }

            // Change PathManager to CustomPathManager
            FieldInfo         sInstance           = typeof(ColossalFramework.Singleton <PathManager>).GetFieldByName("sInstance");
            PathManager       originalPathManager = ColossalFramework.Singleton <PathManager> .instance;
            CustomPathManager customPathManager   = originalPathManager.gameObject.AddComponent <CustomPathManager>();

            customPathManager.SetOriginalValues(originalPathManager);

            // change the new instance in the singleton
            sInstance.SetValue(null, customPathManager);

            // change the manager in the SimulationManager
            FastList <ISimulationManager> managers = (FastList <ISimulationManager>) typeof(SimulationManager).GetFieldByName("m_managers").GetValue(null);

            managers.Remove(originalPathManager);
            managers.Add(customPathManager);

            // Destroy in 10 seconds to give time to all references to update to the new manager without crashing
            GameObject.Destroy(originalPathManager, 10f);
        }
示例#2
0
        public override void Update()
        {
            _isUpdating = true;

            // loop backwards so we can remove completed tweens
            for (var i = _activeTweens.Length - 1; i >= 0; --i)
            {
                var tween = _activeTweens.Buffer[i];
                if (tween.Tick())
                {
                    _tempTweens.Add(tween);
                }
            }

            _isUpdating = false;

            // kill the dead Tweens
            for (var i = 0; i < _tempTweens.Length; i++)
            {
                _tempTweens.Buffer[i].RecycleSelf();
                _activeTweens.Remove(_tempTweens[i]);
            }

            _tempTweens.Clear();
        }
示例#3
0
        /// <summary>
        /// Removes a child shape.
        /// </summary>
        /// <param name="shape">The shape.</param>
        public void RemoveChildShape(ColliderShape shape)
        {
            colliderShapes.Remove(shape);

            InternalCompoundShape.RemoveChildShape(shape.InternalShape);

            shape.Parent = null;
        }
        private void RemoveFromRenderables()
        {
            RenderManager.GetManagers(out IRenderableManager[] _, out int count);
            FieldInfo fieldInfo = typeof(RenderManager).GetField("m_renderables", BindingFlags.Static | BindingFlags.NonPublic);
            FastList <IRenderableManager> value = (FastList <IRenderableManager>)fieldInfo.GetValue(null);

            value.Remove(_highlightManager);
            RenderManager.GetManagers(out IRenderableManager[] _, out int count2);
        }
        /// <summary>
        /// Publish event.
        /// </summary>
        /// <param name="eventMessage">Event message.</param>
        public void Publish <T> (T eventMessage)
        {
            var eventType = typeof(T);
            FastList <Func <T, bool> > list = null;

            lock (_syncObj) {
                if (_eventsInCall.Contains(eventType))
                {
                    Debug.LogError("Already in calling of " + eventType.Name);
                    return;
                }
                object objList;
                if (_events.TryGetValue(eventType, out objList))
                {
                    list = (FastList <Func <T, bool> >)objList;

                    // kept for no new GC alloc, but empty.
                    if (list.Count == 0)
                    {
                        list = null;
                    }
                }
                if (list != null)
                {
                    _eventsInCall.Add(eventType);
                }
            }
            if (list != null)
            {
                var cacheList = _eventSpecificListCaches[eventType];
                int i;
                int iMax;
                var listData = list.GetData(out iMax);
                cacheList.Reserve(iMax, true, false);
                var cacheListData = cacheList.GetData();
                // we cant use direct copy because cached list dont know T-generic type of event.
                for (i = 0; i < iMax; i++)
                {
                    cacheListData[i] = listData[i];
                }
                try {
                    for (i = 0; i < iMax; i++)
                    {
                        if (((Func <T, bool>)cacheListData[i])(eventMessage))
                        {
                            // Event was interrupted / processed, we can exit.
                            return;
                        }
                    }
                } finally {
                    cacheList.Clear();
                    lock (_syncObj) {
                        _eventsInCall.Remove(eventType);
                    }
                }
            }
        }
示例#6
0
        public void Unsubscribe(Entity entity)
        {
            if (!Enable)
            {
                return;
            }

            if (subscribers.Contains(entity))
            {
                subscribers.Remove(entity);
            }
        }
示例#7
0
        void ReplaceTransportManager()
        {
            if (Singleton <TransportManager> .instance as CustomTransportManager != null)
            {
                return;
            }

            Debug.Log("Traffic++: Replacing Transport Manager");

            // Change TransportManager to CustomTransportManager
            FieldInfo              sInstance = typeof(ColossalFramework.Singleton <TransportManager>).GetFieldByName("sInstance");
            TransportManager       originalTransportManager = ColossalFramework.Singleton <TransportManager> .instance;
            CustomTransportManager customTransportManager   = originalTransportManager.gameObject.AddComponent <CustomTransportManager>();

            customTransportManager.SetOriginalValues(originalTransportManager);

            // change the new instance in the singleton
            sInstance.SetValue(null, customTransportManager);

            // change the manager in the SimulationManager
            FastList <ISimulationManager> managers = (FastList <ISimulationManager>) typeof(SimulationManager).GetFieldByName("m_managers").GetValue(null);

            managers.Remove(originalTransportManager);
            managers.Add(customTransportManager);

            // add to renderable managers
            IRenderableManager[] renderables;
            int count;

            RenderManager.GetManagers(out renderables, out count);
            if (renderables != null && count != 0)
            {
                for (int i = 0; i < count; i++)
                {
                    TransportManager temp = renderables[i] as TransportManager;
                    if (temp != null && temp == originalTransportManager)
                    {
                        renderables[i] = customTransportManager;
                        break;
                    }
                }
            }
            else
            {
                RenderManager.RegisterRenderableManager(customTransportManager);
            }

            // Destroy in 10 seconds to give time to all references to update to the new manager without crashing
            GameObject.Destroy(originalTransportManager, 10f);

            Debug.Log("Traffic++: Transport Manager successfully replaced.");
        }
示例#8
0
        public void NotifyLostCity(City city)
        {
            if (object.ReferenceEquals(rootCity, city))
            {
                rootCity = null;
            }

            cities.Remove(city);
            if (LostCity != null)
            {
                LostCity(city);
            }
        }
        public override void OnCreated(ILoading loading)
        {
            FieldInfo              pathManagerInstance = typeof(ColossalFramework.Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic);
            PathManager            stockPathManager    = PathManager.instance;
            LaneChangerPathManager lcPathManager       = stockPathManager.gameObject.AddComponent <LaneChangerPathManager>();

            lcPathManager.UpdateWithPathManagerValues(stockPathManager);
            pathManagerInstance.SetValue(null, lcPathManager);
            FastList <ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList <ISimulationManager>;

            managers.Remove(stockPathManager);
            managers.Add(lcPathManager);
            GameObject.Destroy(stockPathManager, 10f);
        }
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);

            switch (mode)
            {
            case LoadMode.NewGame:
                OnNewGame();
                break;

            case LoadMode.LoadGame:
                OnLoaded();
                break;

            default:

                break;
            }

            if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame)
            {
                if (Instance == null)
                {
                    if (Singleton <PathManager> .instance.GetType() != typeof(PathManager))
                    {
                        LoadingExtension.PathfinderIncompatibility = true;
                    }


                    Instance = this;
                }

                if (!LoadingExtension.PathfinderIncompatibility)
                {
                    FieldInfo   pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic);
                    PathManager stockPathManager    = PathManager.instance;
                    customPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>();
                    customPathManager.UpdateWithPathManagerValues(stockPathManager);
                    pathManagerInstance.SetValue(null, customPathManager);
                    FastList <ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList <ISimulationManager>;
                    managers.Remove(stockPathManager);
                    managers.Add(customPathManager);
                    GameObject.Destroy(stockPathManager, 10f);
                }

                UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>();
                TrafficPriority.leftHandDrive = Singleton <SimulationManager> .instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;
            }
        }
示例#11
0
 //从四叉树中移除一个对象
 public void Remove(CollisionComponent coll)
 {
     if (m_objectList.Contains(coll))
     {
         m_objectList.Remove(coll);
         m_objectListCount--;
     }
     else
     {
         for (int i = 0; i < m_childListCount; i++)
         {
             m_childList[i].Remove(coll);
         }
     }
 }
示例#12
0
 public void Remove(int item)
 {
     //todo get rid of this linear search
     if (ContainedDynamicObjects.Remove(item))
     {
         if (DynamicCount == 0)
         {
             Partition.RemoveNode(activationID);
             activationID = -1;
         }
     }
     else
     {
         Debug.LogError("Item not removed");
     }
 }
        /// <summary>
        /// Unsubscribe from a message distribution identified by messageName.
        /// </summary>
        /// <param name="messageName">Message name.</param>
        /// <param name="handler">Handler.</param>
        /// <typeparam name="T">The return type of the message distribution.</typeparam>
        public static bool Unsubscribe <T> (string messageName, Del <T> handler) where T : LSMessage
        {
            object o;

            if (events.TryGetValue(messageName, out o) == false)
            {
                return(false);
            }
            FastList <Del <T> > dels = o as FastList <Del <T> >;

            if (dels == null)
            {
                return(false);
            }
            dels.Remove(handler);
            return(true);
        }
示例#14
0
        public override void OnCreated(ILoading loading)
        {
            base.OnCreated(loading);

            if (Instance == null)
            {
                Instance = this;
            }

            FieldInfo   pathManagerInstance = typeof(Singleton <PathManager>).GetField("sInstance", BindingFlags.Static | BindingFlags.NonPublic);
            PathManager stockPathManager    = PathManager.instance;

            customPathManager = stockPathManager.gameObject.AddComponent <CustomPathManager>();
            customPathManager.UpdateWithPathManagerValues(stockPathManager);
            pathManagerInstance.SetValue(null, customPathManager);
            FastList <ISimulationManager> managers = typeof(SimulationManager).GetField("m_managers", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as FastList <ISimulationManager>;

            managers.Remove(stockPathManager);
            managers.Add(customPathManager);
            GameObject.Destroy(stockPathManager, 10f);
        }
示例#15
0
    //从四叉树中移除一个对象
    public bool Remove(CollisionComponent coll)
    {
        if (m_objectList.Contains(coll))
        {
            m_objectList.Remove(coll);
            m_objectListCount--;
            return(true);
        }
        else
        {
            for (int i = 0; i < m_childListCount; i++)
            {
                bool isRemove = m_childList[i].Remove(coll);
                if (isRemove)
                {
                    return(true);
                }
            }

            return(false);
        }
    }
示例#16
0
        void DeleteElement(PhysicsElement element, bool now = false)
        {
            //might be possible that this element was not valid during creation so it would be already null
            if (element.Collider == null)
            {
                return;
            }

            var toDispose = new List <IDisposable>();

            elements.Remove(element);

            switch (element.Type)
            {
            case PhysicsElement.Types.PhantomCollider:
            case PhysicsElement.Types.StaticCollider:
            {
                physicsSystem.PhysicsEngine.RemoveCollider(element.Collider);
            }
            break;

            case PhysicsElement.Types.StaticRigidBody:
            case PhysicsElement.Types.DynamicRigidBody:
            case PhysicsElement.Types.KinematicRigidBody:
            {
                var rb          = (RigidBody)element.Collider;
                var constraints = rb.LinkedConstraints.ToArray();
                foreach (var c in constraints)
                {
                    physicsSystem.PhysicsEngine.RemoveConstraint(c);
                    toDispose.Add(c);
                }

                physicsSystem.PhysicsEngine.RemoveRigidBody(rb);
            }
            break;

            case PhysicsElement.Types.CharacterController:
            {
                characters.Remove(element);
                physicsSystem.PhysicsEngine.RemoveCharacter((Character)element.Collider);
            }
            break;
            }

            toDispose.Add(element.Collider);
            element.Collider = null;

            //dispose in another thread for better performance
            if (!now)
            {
                TaskList.Dispatch(toDispose, 4, 128, (i, disposable) => disposable.Dispose());
            }
            else
            {
                foreach (var d in toDispose)
                {
                    d.Dispose();
                }
            }
        }
示例#17
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.size > 0)
        {
            lock (mAdded)
            {
                while (mAdded.size > 0)
                {
                    int index = mAdded.size - 1;
                    mRevealers.Add(mAdded.buffer[index]);
                    mAdded.RemoveAt(index);
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.size > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.size > 0)
                {
                    int index = mRemoved.size - 1;
                    mRevealers.Remove(mRemoved.buffer[index]);
                    mRemoved.RemoveAt(index);
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        float factor = (map.fow.textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + map.elapsed / map.fow.textureBlendTime) : 1f;

        // Clear the buffer's red channel (channel used for current visibility -- it's updated right after)
        if (mBuffer0 != null)
        {
            for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
            {
                mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
                mBuffer0[i].r = 0;
            }
        }

        // For conversion from world coordinates to texture coordinates
        float worldToTex = (float)(map.fow.textureSize / map.fow.textureSize);

        // Update the visibility buffer, one revealer at a time
        for (int i = 0; i != mRevealers.size; ++i)
        {
            Revealer rev = mRevealers[i];

            if (!rev.isActive)
            {
                continue;
            }

            RevealAtPosition(rev, worldToTex);
        }

        // Blur the final visibility data
        for (int i = 0; i != map.fow.blurIterations; ++i)
        {
            BlurVisibility();
        }

        // Reveal the map based on what's currently visible
        RevealMap();
    }
示例#18
0
 /// <summary>
 /// removes a Constraint from the Composite
 /// </summary>
 /// <param name="constraint">Constraint.</param>
 public void RemoveConstraint(Constraint constraint)
 {
     _constraints.Remove(constraint);
 }
示例#19
0
 /// <summary>
 /// removes the Particle from the Composite
 /// </summary>
 /// <param name="particle">Particle.</param>
 public void RemoveParticle(Particle particle)
 {
     Particles.Remove(particle);
 }
示例#20
0
 /// <summary>
 /// removes a Composite from the simulation
 /// </summary>
 /// <param name="composite">Composite.</param>
 public void RemoveComposite(Composite composite)
 {
     _composites.Remove(composite);
 }
示例#21
0
        private void Add(Scene scene)
        {
            if (scene.Entities.Count > 0)
            {
                var entitiesToAdd = new FastList <Entity>();
                // Reverse order, we're adding and removing from the tail to
                // avoid forcing the list to move all items when removing at [0]
                for (int i = scene.Entities.Count - 1; i >= 0; i--)
                {
                    entitiesToAdd.Add(scene.Entities[i]);
                }

                scene.Entities.CollectionChanged += DealWithTempChanges;
                while (entitiesToAdd.Count > 0)
                {
                    int i      = entitiesToAdd.Count - 1;
                    var entity = entitiesToAdd[i];
                    entitiesToAdd.RemoveAt(i);
                    Add(entity);
                }
                scene.Entities.CollectionChanged -= DealWithTempChanges;

                void DealWithTempChanges(object sender, TrackingCollectionChangedEventArgs e)
                {
                    Entity entity = (Entity)e.Item;

                    if (e.Action == NotifyCollectionChangedAction.Remove)
                    {
                        if (entitiesToAdd.Remove(entity) == false)
                        {
                            Remove(entity);
                        }
                    }
                    else if (e.Action == NotifyCollectionChangedAction.Add)
                    {
                        entitiesToAdd.Add(entity);
                    }
                }
            }

            if (scene.Children.Count > 0)
            {
                var scenesToAdd = new FastList <Scene>();
                // Reverse order, we're adding and removing from the tail to
                // avoid forcing the list to move all items when removing at [0]
                for (int i = scene.Children.Count - 1; i >= 0; i--)
                {
                    scenesToAdd.Add(scene.Children[i]);
                }

                scene.Children.CollectionChanged += DealWithTempChanges;
                while (scenesToAdd.Count > 0)
                {
                    int i      = scenesToAdd.Count - 1;
                    var entity = scenesToAdd[i];
                    scenesToAdd.RemoveAt(i);
                    Add(entity);
                }
                scene.Children.CollectionChanged -= DealWithTempChanges;

                void DealWithTempChanges(object sender, TrackingCollectionChangedEventArgs e)
                {
                    Scene subScene = (Scene)e.Item;

                    if (e.Action == NotifyCollectionChangedAction.Remove)
                    {
                        if (scenesToAdd.Remove(subScene) == false)
                        {
                            Remove(subScene);
                        }
                    }
                    else if (e.Action == NotifyCollectionChangedAction.Add)
                    {
                        scenesToAdd.Add(subScene);
                    }
                }
            }

            // Listen to future changes in entities and child scenes
            scene.Children.CollectionChanged += Children_CollectionChanged;
            scene.Entities.CollectionChanged += Entities_CollectionChanged;
        }
示例#22
0
 public void RemoveImmovable(int item)
 {
     if (ContainedImmovableObjects.Remove(item))
     {
     }
 }
示例#23
0
 public void RemoveObject(Data obj)
 {
     objects.Remove(obj.index);
     objects[obj.index].index = obj.index;
 }