public override void Process(EntityManagerManager toProcess, GameTime gameTime)
 {
     foreach (Entity ent in clamped.entities)
     {
         Process(ent, gameTime);
     }
 }
 public override void Process(EntityManagerManager toProcess, GameTime gameTime)
 {
     foreach (Entity ent in entities.entities)
     {
         if (IsApplicableTo(ent))
         {
             process(ent);
         }
     }
 }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            foreach (Entity ent in entities.entities)
            {
                if (IsApplicableTo(ent))
                {
                    SoundEffectComponent comp = (SoundEffectComponent)ent.components[typeof(SoundEffectComponent)];
                    comp.effect.Play();

                    ent.RemoveComponent(comp);
                }
            }
        }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            foreach (Entity ent in entities.entities)
            {
                if (IsApplicableTo(ent))
                {
                    AddComponentOnDestructionComponent wrapper = (AddComponentOnDestructionComponent)ent.components[typeof(AddComponentOnDestructionComponent)];
                    IComponent compTemplate = wrapper.ToAdd;

                    IComponent comp = compTemplate.Clone();

                    ent.AddComponent(comp);
                }
            }
        }
 public override void Process(EntityManagerManager toProcess, GameTime gameTime)
 {
     //find the dead entities and mark them for removal
     foreach (Entity ent in entities.entities)
     {
         if (IsApplicableTo(ent))
         {
             HealthComponent hp = (HealthComponent)ent.components[typeof(HealthComponent)];
             if (hp.Health <= 0 && !ent.components.ContainsKey(typeof(MarkedForDeathComponent)))
             {
                 ent.AddComponent(new MarkedForDeathComponent());
             }
         }
     }
 }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            foreach (Entity ent in entities.entities)
            {
                if (IsApplicableTo(ent))
                {
                    AnimationComponent anim = (AnimationComponent)ent.components[typeof(AnimationComponent)];

                    //If the animation is complete
                    if (anim.CurrentFrameIndex == -1 && !ent.components.ContainsKey(typeof(MarkedForDeathComponent)))
                    {
                        ent.AddComponent(new MarkedForDeathComponent());
                    }
                }
            }
        }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            List<Entity> toRemove = new List<Entity>();
            foreach (Entity ent in entities.entities)
            {
                if (IsApplicableTo(ent))
                {
                    toRemove.Add(ent);
                }
            }

            foreach (Entity ent in toRemove)
            {
                toProcess.Remove(ent);
            }
        }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            List<Entity> marked = new List<Entity>();
            foreach (Entity toDiscard in collisions.entities)
            {
                if (IsApplicableTo(toDiscard))
                {
                    marked.Add(toDiscard);
                }
            }

            foreach (Entity toRemove in marked)
            {
                toProcess.Remove(toRemove);
            }
        }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            //Get the list of entities that need to be spawned this tick
            IList<Entity> toSpawn = new List<Entity>();
            foreach (Entity ent in entities.entities)
            {
                Entity tentative = Process(toProcess, ent, gameTime);
                if (tentative != null)
                {
                    toSpawn.Add(tentative);
                }
            }

            // Spawn them all by adding them to the EntityManagers
            foreach (Entity toBeManaged in toSpawn)
            {
                toProcess.Add(toBeManaged);
            }
        }
        public Entity Process(EntityManagerManager manager, Entity toProcess, GameTime gameTime)
        {
            if (!IsApplicableTo(toProcess))
            {
                return null;
            }

            //Get the component
            SpawnEntityComponent spawner = (SpawnEntityComponent)toProcess.components[typeof(SpawnEntityComponent)];

            //Construct a copy of the entity to be spawned
            Entity toSpawn = spawner.Factory.CreateEntity(toProcess, new Entity());

            //Remove the offending component so we don't get more spawns
            toProcess.RemoveComponent(spawner);

            //Spawn that entity by adding it to the list of entities to be updated by systems
            return toSpawn;
        }
        public override void Process(EntityManagerManager toProcess, GameTime gameTime)
        {
            foreach (Entity ent in entities.entities)
            {
                if (IsApplicableTo(ent))
                {
                    MusicComponent comp = (MusicComponent)ent.components[typeof(MusicComponent)];

                    try
                    {
                        MediaPlayer.Play(comp.music);

                        MediaPlayer.IsRepeating = comp.repeat;
                    }
                    catch { } //catch all the things!

                    //Only play the music once!
                    ent.RemoveComponent(comp);
                }
            }
        }
 public override void Initialize(EntityManagerManager entityStorage)
 {
     entities = entityStorage.DefaultManager;
 }
Example #13
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //Initialize the entity list
            entityStorage = new EntityManagerManager();

            //Initialize the systems lists
            updateTimeSystems = new List<ASystem>();
            renderTimeSystems = new List<ASystem>();

            //Enable the FreeDrag gesture.
            TouchPanel.EnabledGestures = GestureType.FreeDrag;

            base.Initialize();
        }