private void RunUpdateBehaviorIfNotPaused(UpdateBehavior updateBehavior,
                                                  ICollection <Entity> entities)
        {
            if (isPaused && updateBehavior.isPauseable)
            {
                return;
            }
            var filtered = updateBehavior as Filtered;

            updateBehavior.Update(filtered != null ? entities.Where(filtered.Filter).ToList() : entities);
        }
		public bool RemoveEntityFromBehaviors(Entity entity, UpdateBehavior updateBehavior)
		{
			if (behaviorsEnumerationDepth > 0)
			{
				if (behaviorsToBeAdded.ContainsKey(updateBehavior))
					behaviorsToBeAdded[updateBehavior].Remove(entity);
				AddToBehaviors(behaviorsToBeRemoved, updateBehavior, entity);
				return true;
			}
			return behaviors.ContainsKey(updateBehavior) && behaviors[updateBehavior].Remove(entity);
		}
Example #3
0
 public bool RemoveEntityFromBehaviors(Entity entity, UpdateBehavior updateBehavior)
 {
     if (behaviorsEnumerationDepth > 0)
     {
         if (behaviorsToBeAdded.ContainsKey(updateBehavior))
         {
             behaviorsToBeAdded[updateBehavior].Remove(entity);
         }
         AddToBehaviors(behaviorsToBeRemoved, updateBehavior, entity);
         return(true);
     }
     return(behaviors.ContainsKey(updateBehavior) && behaviors[updateBehavior].Remove(entity));
 }
		private static void AddToBehaviors(
			Dictionary<UpdateBehavior, List<Entity>> dictionary, UpdateBehavior behavior,
			Entity entity)
		{
			if (dictionary.ContainsKey(behavior))
			{
				if (entity != null && !dictionary[behavior].Contains(entity))
					dictionary[behavior].Add(entity);
			}
			else
			{
				var list = new List<Entity>();
				if (entity != null)
					list.Add(entity);
				dictionary.Add(behavior, list);
			}
		}
Example #5
0
 private static void AddToBehaviors(
     Dictionary <UpdateBehavior, List <Entity> > dictionary, UpdateBehavior behavior,
     Entity entity)
 {
     if (dictionary.ContainsKey(behavior))
     {
         if (entity != null && !dictionary[behavior].Contains(entity))
         {
             dictionary[behavior].Add(entity);
         }
     }
     else
     {
         var list = new List <Entity>();
         if (entity != null)
         {
             list.Add(entity);
         }
         dictionary.Add(behavior, list);
     }
 }
Example #6
0
 internal bool ContainsActiveBehavior(UpdateBehavior updateBehavior)
 {
     return(activeBehaviors.Contains(updateBehavior));
 }
		public void AddEntityToBehavior(UpdateBehavior behavior, Entity entity)
		{
			AddToBehaviors(behaviorsEnumerationDepth > 0 ? behaviorsToBeAdded : behaviors, behavior,
				entity);
		}
Example #8
0
 public void AddEntityToBehavior(UpdateBehavior behavior, Entity entity)
 {
     AddToBehaviors(behaviorsEnumerationDepth > 0 ? behaviorsToBeAdded : behaviors, behavior,
                    entity);
 }
 internal void RemoveFromBehaviorList(UpdateBehavior behavior, Entity entity)
 {
     prioritizedEntities[(int)behavior.priority].RemoveEntityFromBehaviors(entity, behavior);
 }
 internal void AddToUpdateBehavior(UpdateBehavior behavior, Entity entity)
 {
     prioritizedEntities[(int)behavior.priority].AddEntityToBehavior(behavior, entity);
 }