public void RemoveComponent(TdglComponent component)
 {
     if (component != null)
     {
         _components.Remove(component);
         _componentsSortedByDrawOrder.Remove(component);
         component.Destruct();
     }
 }
Пример #2
0
        public virtual void UnregisterMob(Mob mob)
        {
            if (mob != null && Mobs.Contains(mob))
            {
                _mobs.Remove(mob);

                if (!(mob is DrawOnlyMob))
                {
                    // fixtures
                    List <Fixture> fixturesToUnregister = new List <Fixture>();
                    foreach (Fixture key in MobFixtures.Keys)
                    {
                        if (MobFixtures[key] == mob)
                        {
                            fixturesToUnregister.Add(key);
                        }
                    }
                    foreach (Fixture fixture in fixturesToUnregister)
                    {
                        fixture.OnCollision -= OnMobCollision;
                        MobFixtures.Remove(fixture);
                    }

                    // physical bodies
                    List <PhysicalBody> bodiesToUnregister = new List <PhysicalBody>();
                    foreach (PhysicalBody key in MobBodies.Keys)
                    {
                        if (MobBodies[key] == mob)
                        {
                            bodiesToUnregister.Add(key);
                        }
                    }
                    foreach (PhysicalBody p in bodiesToUnregister)
                    {
                        MobBodies.Remove(p);
                    }

                    MobBucketManager.UpdateMobBucket(mob);
                }
            }
        }