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> /// Determines if each Entity has left the bounds of the screen. If it has, /// then it is removed from the World. /// </summary> public override void Process() { CPosition pos; /// <summary> /// Backwards loop to allow Entities to be removed from the World while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { pos = World.GetComponent <CPosition>(Entities[i]); if (!ProjectileOnScreen(pos)) { World.RemoveEntity(Entities[i]); } } }
/// <summary> /// Checks the Lifetime of each Entity. If their Lifetime has passed, /// the Entity is removed from the World. /// </summary> public override void Process() { CLifetime lifetime; /// <summary> /// This loop represents each Entity with a Lifetime. /// Backwards loop to allow Entities to be removed from the World while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { lifetime = World.GetComponent <CLifetime>(Entities[i]); if (TimeLimitReached(lifetime.CreatedAt, lifetime.Lifetime)) { World.RemoveEntity(Entities[i]); } } }
/// <summary> /// Checks the collisions of each Entity which deals damage on impact. If it has collided with something containing a Health Component, /// an Attack is registered with the Damage System. /// </summary> public override void Process() { /// <summary> /// The System where Attacks are registered. /// </summary> DamageSystem damageSystem = World.GetSystem <DamageSystem>(); for (int i = Entities.Count - 1; i >= 0; i--) { CDamage damage; CCollision collision; CDamagesOnImpact dmgOnImp; collision = World.GetComponent <CCollision>(Entities[i]); /// <summary> /// Apply damage to the first Entity the Entity has collided with that still exists in /// the World and also has a Health Component. If none are found, the Arrow remains live. /// </summary> for (int j = 0; j < collision.Count; j++) { if (World.HasEntity(collision[j])) { if (World.EntityHasComponent(collision[j], typeof(CHealth))) { damage = World.GetComponent <CDamage>(Entities[i]); damageSystem.RegisterAttack(collision[j], damage.Damage); } } } /// <summary> /// If the Entity is set to die after impact, remove it from the World. /// </summary> dmgOnImp = World.GetComponent <CDamagesOnImpact>(Entities[i]); if (dmgOnImp.DiesAfterImpact) { World.RemoveEntity(Entities[i]); } } }
/// <summary> /// Loops through all Freezing Bullet entities and checks if they've reached their destination. /// If they have, the Bullet is removed and a Freeze Zone is created at the bullet's location. /// </summary> public override void Process() { CFreezingBullet freezingBullet; CPosition pos; /// <summary> /// This loop represents each Freezing Bullet. /// Backwards loop to allow Enities to be removed from the World while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { freezingBullet = World.GetComponent <CFreezingBullet>(Entities[i]); pos = World.GetComponent <CPosition>(Entities[i]); if (ReachedTarget(pos, freezingBullet)) { EntityFactory.CreateFreezeZone(pos); World.RemoveEntity(Entities[i]); } } }