public virtual void Render(Vector2D topLeft, Vector2D bottomRight) { var blend = Gorgon.CurrentRenderTarget.BlendingMode; Gorgon.CurrentRenderTarget.BlendingMode = BlendingModes.Additive; Vector2D renderPos = ClientWindowData.WorldToScreen( Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position); foreach (KeyValuePair <string, ParticleSystem> particleSystem in _emitters.OrderBy(x => x.Value.ParticleSprite.Image.Name)) //Render sorted by atlas. Tiny performance improvement for entities with a bunch of particlesystems. { particleSystem.Value.Move(renderPos); particleSystem.Value.Render(); } //_emitter.Move(renderPos); //_emitter.Render(); Gorgon.CurrentRenderTarget.BlendingMode = blend; }
public override void Render(Vector2D topLeft, Vector2D bottomRight) { if (IsCurrentlyWorn && currentSprite == baseSprite) { base.Render(topLeft, bottomRight); return; } else if (IsCurrentlyCarried && currentSprite != CarriedSprite) { SetSprite(CarriedSprite); base.Render(topLeft, bottomRight); return; } //Render slaves beneath IEnumerable <SpriteComponent> renderablesBeneath = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth < DrawDepth select c; foreach (SpriteComponent component in renderablesBeneath.ToList()) { component.Render(topLeft, bottomRight); } //Render this sprite if (!visible) { return; } if (NotWornSprite == null) { return; } Sprite spriteToRender = NotWornSprite; Vector2D renderPos = ClientWindowData.WorldToScreen( Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position); spriteToRender.SetPosition(renderPos.X - (spriteToRender.AABB.Width / 2), renderPos.Y - (spriteToRender.AABB.Height / 2)); if (Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X + spriteToRender.AABB.Right < topLeft.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X > bottomRight.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y + spriteToRender.AABB.Bottom < topLeft.Y || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y > bottomRight.Y) { return; } spriteToRender.HorizontalFlip = flip; spriteToRender.Draw(); spriteToRender.HorizontalFlip = false; //Render slaves above IEnumerable <SpriteComponent> renderablesAbove = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth >= DrawDepth select c; foreach (SpriteComponent component in renderablesAbove.ToList()) { component.Render(topLeft, bottomRight); } //Draw AABB var aabb = AABB; //Gorgon.CurrentRenderTarget.Rectangle(renderPos.X - aabb.Width / 2, renderPos.Y - aabb.Height / 2, aabb.Width, aabb.Height, Color.Lime); }
public virtual void Render(Vector2D topLeft, Vector2D bottomRight) { //Render slaves beneath IEnumerable <SpriteComponent> renderablesBeneath = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth < DrawDepth select c; foreach (SpriteComponent component in renderablesBeneath.ToList()) { component.Render(topLeft, bottomRight); } //Render this sprite if (!visible) { return; } if (currentBaseSprite == null) { return; } Sprite spriteToRender = GetActiveDirectionalSprite(); Vector2D renderPos = ClientWindowData.WorldToScreen( Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position); SetSpriteCenter(spriteToRender, renderPos); if (Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X + spriteToRender.AABB.Right < topLeft.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.X > bottomRight.X || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y + spriteToRender.AABB.Bottom < topLeft.Y || Owner.GetComponent <TransformComponent>(ComponentFamily.Transform).Position.Y > bottomRight.Y) { return; } spriteToRender.HorizontalFlip = flip; spriteToRender.Draw(); spriteToRender.HorizontalFlip = false; //Render slaves above IEnumerable <SpriteComponent> renderablesAbove = from SpriteComponent c in slaves //FIXTHIS orderby c.DrawDepth ascending where c.DrawDepth >= DrawDepth select c; foreach (SpriteComponent component in renderablesAbove.ToList()) { component.Render(topLeft, bottomRight); } //Draw AABB var aabb = AABB; //Gorgon.CurrentRenderTarget.Rectangle(renderPos.X - aabb.Width / 2, renderPos.Y - aabb.Height / 2, aabb.Width, aabb.Height, Color.Lime); }