public override void Process() { CCollision collision; CFrozen freezeZoneFrozen; CFrozen collidedFrozen; List <int> deadFreezeEffects = new List <int>(); /// <summary> /// This loop represents each Freeze Zone. /// Backwards loop to allow Entities to be removed while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { freezeZoneFrozen = World.GetComponent <CFrozen>(Entities[i]); collision = World.GetComponent <CCollision>(Entities[i]); /// <summary> /// This loop represents each Entity colliding with the Freeze Zone. /// </summary> for (int j = 0; j < collision.Count; j++) { //If not already Frozen, add a Frozen Component. if (!World.EntityHasComponent(collision[j], typeof(CFrozen))) { //Don't freeze projectiles if (!World.EntityHasComponent(collision[j], typeof(CProjectile))) { World.AddComponent(collision[j], new CFrozen(freezeZoneFrozen.Duration, World.GameTime)); } if (!World.EntityHasComponent(collision[j], typeof(CGotStatusEffect))) { World.AddComponent(collision[j], new CGotStatusEffect(typeof(CFrozen))); } else { CGotStatusEffect statusEffects = World.GetComponent <CGotStatusEffect>(collision[j]); statusEffects.AddEffect(typeof(CFrozen)); } } else //If already Frozen, refresh the duration. { collidedFrozen = World.GetComponent <CFrozen>(collision[i]); collidedFrozen.TimeApplied = World.GameTime; } } /// <summary> /// Freeze Zone only lasts for one frame to apply Frozen Components. /// Each Freeze Zone is removed from the World once its collisions are processed. /// </summary> World.RemoveEntity(Entities[i]); } }
/// <summary> /// Checks each Entity colliding with each Poison Zone. If the Entity does not have /// a Poison Component, then a Poison Component and a GotStatusEffect Component are added. /// Otherwise, the Entity's Poison Component duration is refreshed. /// </summary> public override void Process() { CPoison poisonEffect; CPoison targetPoisonEffect; CCollision collision; /// <summary> /// This loop represents each Poison Zone. /// </summary> for (int i = 0; i < Entities.Count; i++) { poisonEffect = World.GetComponent <CPoison>(Entities[i]); collision = World.GetComponent <CCollision>(Entities[i]); /// <summary> /// This loop represents each Entity colliding with the Poison Zone. /// </summary> for (int j = 0; j < collision.Count; j++) { if (!World.EntityHasComponent(collision[j], typeof(CPoison))) { World.AddComponent(collision[j], new CPoison(poisonEffect.Strength, poisonEffect.Duration, World.GameTime)); if (!World.EntityHasComponent(collision[j], typeof(CGotStatusEffect))) { World.AddComponent(collision[j], new CGotStatusEffect(typeof(CPoison))); } else { CGotStatusEffect statusEffects = World.GetComponent <CGotStatusEffect>(collision[j]); statusEffects.AddEffect(typeof(CPoison)); } } else //If entity already has a Poison Component, refresh its duration. { targetPoisonEffect = World.GetComponent <CPoison>(collision[j]); targetPoisonEffect.TimeApplied = World.GameTime; } } } }