/// <summary> /// Loops through each animation, updating and drawing them. /// If an animation has ended, the Animation Component is removed from the Entity. /// If the Entity has no other Components, it is removed from the World. /// </summary> public override void Process() { CAnimation anim; CPosition pos; /// <summary> /// This loop represents each Entity with an Animation Component. /// Backwards loop to allow Entities to be removed from the World while looping. /// </summary> for (int i = Entities.Count - 1; i >= 0; i--) { anim = World.GetComponent <CAnimation>(Entities[i]); pos = World.GetComponent <CPosition>(Entities[i]); if (SwinGame.AnimationEnded(anim.Anim)) { if (World.GetAllComponentsOfEntity(Entities[i]).Count == 1) { World.RemoveEntity(Entities[i]); } } else { SwinGame.DrawAnimation(anim.Anim, anim.Img, pos.X, pos.Y); SwinGame.UpdateAnimation(anim.Anim); } } }
/// <summary> /// Updates and Draws each Animation in each Entity's StatusAnimation Component. /// If an Entity no longer has the required Component for the StatusAnimation, it /// is removed from the StatusAnimations Component. /// </summary> public override void Process() { CStatusAnimations statusAnims; CStatusAnimation anim; CPosition pos; /// <summary> /// This loop represents each Entity with a Status Animations Component. /// </summary> for (int i = 0; i < Entities.Count; i++) { statusAnims = World.GetComponent <CStatusAnimations>(Entities[i]); pos = World.GetComponent <CPosition>(Entities[i]); /// <summary> /// This loop represents each Status Animation inside the Status Animations Component. /// Backwards loop to allow Status Animations to be removed while looping. /// </summary> for (int j = statusAnims.Anims.Count - 1; j >= 0; j--) { anim = statusAnims[j]; if (World.EntityHasComponent(Entities[i], anim.LinkedComponent)) { float x = pos.X + anim.XOffset; float y = pos.Y + anim.YOffset; SwinGame.DrawAnimation(anim.Anim, anim.Img, x, y); SwinGame.UpdateAnimation(anim.Anim); } else { statusAnims.Anims.RemoveAt(j); } } } }