Esempio n. 1
0
        public virtual void RegisterMob(Mob mob)
        {
            if (mob != null && !Mobs.Contains(mob))
            {
                _mobs.Add(mob);

                if (!(mob is DrawOnlyMob))
                {
                    if (mob.PhysicalBody is FarseerPhysicalBody)
                    {
                        FarseerPhysicalBody physicalBody = (FarseerPhysicalBody)mob.PhysicalBody;

                        foreach (Fixture fixture in physicalBody.Body.FixtureList)
                        {
                            MobFixtures[fixture] = mob;
                            fixture.OnCollision -= OnMobCollision; //Unregister in case event is already hooked (no exception is thrown if absent)
                            fixture.OnCollision += OnMobCollision;
                        }
                    }
                    else
                    {
                        MobBodies[mob.PhysicalBody] = mob;
                    }
                }
            }
        }
        public T AddComponent <T>(T component)
            where T : TdglComponent
        {
            if (component != null && !_components.Contains(component))
            {
                if (!component.IsLoaded)
                {
                    ComponentsStillLoading = true;
                }
                _components.Add(component);
            }

            return(component);
        }