public override void Render(bool shadow) { if (!shadow) { var m = (Mob)Entity; if (m.HasPrefix) { var p = m.Prefix; var pos = Entity.Position + Offset; var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(p.GetColor()); foreach (var d in MathUtils.Directions) { CallRender(pos + d, false); } Shaders.End(); } } base.Render(shadow); }
public override void Render(bool shadow) { var timer = Entity.GetComponent <ExplodeComponent>(); var origin = new Vector2(Sprite.Center.X, shadow ? 0 : Sprite.Source.Height); var stopShader = false; var bomb = (Bomb)Entity; if (!shadow && (timer.Timer <1f ? timer.Timer % 0.3f> 0.1f : timer.Timer % 0.5f > 0.4f)) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); stopShader = true; } Graphics.Render(Sprite, Entity.Position + new Vector2(origin.X, origin.Y + (shadow ? Sprite.Height : 0)), 0, origin, new Vector2( (float)((Math.Cos(timer.Timer * 16) / 2f) + 1) * bomb.Scale * Math.Min(bomb.T * 4f, 1), (float)((Math.Cos(timer.Timer * 16 + Math.PI) / 3f) + 1) * bomb.Scale ), Graphics.ParseEffect(false, shadow)); if (stopShader) { Shaders.End(); } }
public override void Render(bool shadow) { var p = (Projectile)Entity; var scale = new Vector2(p.Scale); var a = Rotation; var b = p.FlashTimer > 0; var spr = b ? Flash : Sprite; var or = spr.Center; if (shadow) { Graphics.Render(spr, Entity.Center + new Vector2(0, 6), a, or, scale); return; } var d = p.Dying || (p.IndicateDeath && p.NearingDeath); var started = false; if (!d) { // fixme: p.Effect.GetColor() Graphics.Color = p.Color; } else if (Light == null) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); started = true; } Graphics.Render(spr, Entity.Center, a, or, scale); Graphics.Color = ColorUtils.WhiteColor; if (started) { Shaders.End(); } if (!b && Light != null) { if (p.Scourged) { Graphics.Color = ProjectileColor.Red; } Graphics.Render(Light, Entity.Center, a, or, scale); if (p.Scourged) { Graphics.Color = ColorUtils.WhiteColor; } } }
public override void Render(bool shadow) { if (shadow) { Graphics.Render(Sprite, Entity.Position + Origin + new Vector2(0, ShadowZ + Sprite.Height), Angle, Origin, Scale, Graphics.ParseEffect(Flipped, ShadowZ > 0 ? FlippedVerticaly : !FlippedVerticaly)); return; } var stopShader = false; if (Entity.TryGetComponent <HealthComponent>(out var health) && health.RenderInvt) { var i = health.InvincibilityTimer; if (i > health.InvincibilityTimerMax / 2f || i % 0.1f > 0.05f) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); stopShader = true; } } Graphics.Render(Sprite, Entity.Position + Origin, Angle, Origin, Scale); if (stopShader) { Shaders.End(); } }
public override void Render(bool shadow) { var origin = new Vector2(Sprite.Width / 2, Sprite.Height); var pos = Entity.Position + origin + Offset; if (shadow) { Graphics.Render(Sprite, pos, 0, new Vector2(origin.X, 0), Scale, Graphics.ParseEffect(Flipped, !FlippedVerticaly)); return; } if (Entity.TryGetComponent <ZComponent>(out var z)) { pos -= new Vector2(0, z.Z); } if (Entity.TryGetComponent <InteractableComponent>(out var component) && component.OutlineAlpha > 0.05f) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(component.OutlineAlpha); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); foreach (var d in MathUtils.Directions) { Graphics.Render(Sprite, pos + d, 0, origin, Scale); } Shaders.End(); } var stopShader = false; if (Entity.TryGetComponent <HealthComponent>(out var health) && health.RenderInvt) { var i = health.InvincibilityTimer; if (i > health.InvincibilityTimerMax / 2f || i % 0.1f > 0.05f) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); stopShader = true; } } Graphics.Render(Sprite, pos, 0, origin, Scale); if (stopShader) { Shaders.End(); } }
public override void Render() { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(color); Graphics.Render(region, Center, 0, region.Center, scale); Shaders.End(); }
public override void Render(bool shadow) { var pos = (Centered ? Entity.Center : Entity.Position) + Offset; if (shadow) { FlippedVerticaly = !FlippedVerticaly; pos.Y += Animation.GetCurrentTexture().Height - ShadowOffset * 2; } if (Entity.TryGetComponent <InteractableComponent>(out var component) && component.OutlineAlpha > 0.05f) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(component.OutlineAlpha); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); foreach (var d in MathUtils.Directions) { CallRender(pos + d, shadow); } Shaders.End(); } var stopShader = !shadow && StartShaders(); Graphics.Color = Tint; CallRender(pos, shadow); Graphics.Color = ColorUtils.WhiteColor; if (stopShader) { Shaders.End(); } if (shadow) { FlippedVerticaly = !FlippedVerticaly; } }
public void Render(bool shadow, int offset) { if (!Disabled && Item != null && Item.Renderer != null) { if (!shadow) { var sh = Shaders.Item; Shaders.Begin(sh); sh.Parameters["time"].SetValue(Engine.Time * 0.1f); sh.Parameters["size"].SetValue(ItemGraphicsComponent.FlashSize); } Item.Renderer.Render(AtBack, Engine.Instance.State.Paused, Engine.Delta, shadow, offset); if (!shadow) { Shaders.End(); } } }
public override void Render(bool shadow) { var pos = Entity.Position + Offset; if (shadow) { FlippedVerticaly = !FlippedVerticaly; pos.Y += Animation.GetCurrentTexture().Height - ShadowOffset * 2 + 4; Graphics.Color.A = (byte)(Alpha * 255); } else { var shader = Shaders.Bk; var region = Animation.GetCurrentTexture(); shader.Parameters["pos"].SetValue(new Vector2(region.Source.X / (float)region.Texture.Width, region.Source.Y / (float)region.Texture.Height)); shader.Parameters["size"].SetValue(new Vector2(region.Width / (float)region.Texture.Width, region.Height / (float)region.Texture.Height)); shader.Parameters["time"].SetValue(t); shader.Parameters["a"].SetValue(Alpha); Shaders.Begin(shader); } CallRender(pos, shadow); if (shadow) { Graphics.Color.A = 255; FlippedVerticaly = !FlippedVerticaly; } else { Shaders.End(); } }
public override void Render() { if (Hidden || !TryGetComponent <InteractableComponent>(out var component)) { return; } var cursed = item != null && item.Scourged; var interact = component.OutlineAlpha > 0.05f; var renderOutline = interact || cursed; if (item == null && renderOutline) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(component.OutlineAlpha); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); foreach (var d in MathUtils.Directions) { Graphics.Render(((SliceComponent)GraphicsComponent).Sprite, Position + d); } Shaders.End(); } GraphicsComponent.Render(false); if (item == null) { return; } Graphics.Color = Level.ShadowColor; Graphics.Render(itemShadow, Position + shadowOffset); Graphics.Color = ColorUtils.WhiteColor; var t = item.Animation == null?item.GetComponent <ItemGraphicsComponent>().T : 0; var angle = (float)Math.Cos(t * 3f) * 0.4f; var region = item.Region; var animated = item.Animation != null; var pos = item.Center + new Vector2(0, (animated ? 0 : (float)(Math.Sin(t * 3f) * 0.5f + 0.5f) * -5.5f - 3) - 5.5f); if (renderOutline) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(cursed ? 1f : component.OutlineAlpha); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(!cursed ? ColorUtils.White : ColorUtils.Mix(ItemGraphicsComponent.ScourgedColor, ColorUtils.White, component.OutlineAlpha)); foreach (var d in MathUtils.Directions) { Graphics.Render(region, pos + d, animated ? 0 : angle, region.Center); } Shaders.End(); } if (animated) { Graphics.Render(region, pos, 0, region.Center); } else { if (item.Masked) { Graphics.Color = ItemGraphicsComponent.MaskedColor; Graphics.Render(region, pos, angle, region.Center); Graphics.Color = ColorUtils.WhiteColor; } else { var shader = Shaders.Item; Shaders.Begin(shader); shader.Parameters["time"].SetValue(t * 0.1f); shader.Parameters["size"].SetValue(ItemGraphicsComponent.FlashSize); Graphics.Render(region, pos, angle, region.Center); Shaders.End(); } } }
public override void Render(bool shadow) { if (Entity.HasComponent <OwnerComponent>()) { return; } var item = (Item)Entity; var s = item.Hidden ? Item.UnknownRegion : Sprite; var origin = s.Center; var position = CalculatePosition(shadow); var angle = (float)Math.Cos(T * 1.8f) * 0.4f; var cursed = item.Scourged; if (!shadow) { var interact = Entity.TryGetComponent <InteractableComponent>(out var component) && component.OutlineAlpha > 0.05f; if (cursed || interact) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(cursed ? 1f : component.OutlineAlpha); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(!cursed ? ColorUtils.White : ColorUtils.Mix(ScourgedColor, ColorUtils.White, component.OutlineAlpha)); foreach (var d in MathUtils.Directions) { Graphics.Render(s, position + d, angle, origin); } Shaders.End(); } } if (item.Masked) { Graphics.Color = MaskedColor; Graphics.Render(s, position, angle, origin); Graphics.Color = ColorUtils.WhiteColor; } else { if (!shadow && DebugWindow.ItemShader && !Settings.LowQuality) { var shader = Shaders.Item; Shaders.Begin(shader); shader.Parameters["time"].SetValue(T * 0.1f); shader.Parameters["size"].SetValue(FlashSize); } Graphics.Render(s, position, angle, origin); if (!shadow && DebugWindow.ItemShader && !Settings.LowQuality) { Shaders.End(); } } }
private void RealRender(bool shadow = false) { if (shadow) { Graphics.Render(bottom, Position + new Vector2(0, 34), 0, Vector2.Zero, MathUtils.InvertY); if (broken) { return; } Graphics.Render(top, Position + new Vector2(9, 28), (float)Math.Cos(t) * -0.1f, new Vector2(9, 14), new Vector2((float)Math.Cos(t * 2f) * 0.05f + 1f, (float)Math.Sin(t * 2f) * -0.05f - 1f)); return; } /*var c = GetComponent<InteractableComponent>(); * * if (c.OutlineAlpha > 0.05f) { * var shader = Shaders.Entity; * Shaders.Begin(shader); * * shader.Parameters["flash"].SetValue(c.OutlineAlpha); * shader.Parameters["flashReplace"].SetValue(1f); * shader.Parameters["flashColor"].SetValue(ColorUtils.White); * * foreach (var d in MathUtils.Directions) { * Graphics.Render(bottom, Position + new Vector2(0, 12) + d); * * if (!broken) { * Graphics.Render(top, Position + new Vector2(9, 14) + d, (float) Math.Cos(t) * 0.1f, new Vector2(9, 14), * new Vector2((float) Math.Cos(t * 2f) * 0.05f + 1f, (float) Math.Sin(t * 2f) * 0.05f + 1f)); * } * } * * Shaders.End(); * }*/ var stopShader = false; var h = GetComponent <HealthComponent>(); if (h.RenderInvt) { var i = h.InvincibilityTimer; if (i > h.InvincibilityTimerMax / 2f || i % 0.1f > 0.05f) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ColorUtils.White); stopShader = true; } } Graphics.Render(bottom, Position + new Vector2(0, 12)); if (disk > 0) { Graphics.Render(tdisk, Position + new Vector2(2, 13)); } if (!broken) { Graphics.Render(top, Position + new Vector2(9, 14), (float)Math.Cos(t) * 0.1f, new Vector2(9, 14), new Vector2((float)Math.Cos(t * 2f) * 0.05f + 1f, (float)Math.Sin(t * 2f) * 0.05f + 1f)); } if (stopShader) { Shaders.End(); } }
public override void Render(bool atBack, bool paused, float dt, bool shadow, int offset) { if (Hidden) { return; } var region = Item.Region; var owner = Item.Owner; if (!atBack && !paused && !shadow) { var to = owner.GetComponent <AimComponent>().Aim; /*var dx = Nozzle.X - Origin.X; * var dy = Nozzle.Y - Origin.Y; * * var a = MathUtils.Angle(dx, dy) + lastAngle; * var d = MathUtils.Distance(dx, dy); * * to -= MathUtils.CreateVector(a, d);*/ lastAngle = MathUtils.LerpAngle(lastAngle, owner.AngleTo(to) + Math.PI * 0.5f, dt * 24f); } var angle = atBack ? (float)Math.PI * (owner.GraphicsComponent.Flipped ? 0.25f : -0.25f) : (float)lastAngle; if (horizontal) { angle -= (float)Math.PI * 0.5f; } var pos = new Vector2( owner.CenterX + (owner.GraphicsComponent.Flipped ? -5 : 5) + (horizontal ? 0 : (region.Width / 2f) * (owner.GraphicsComponent.Flipped ? -1 : 1)), owner.CenterY + offset + (shadow ? owner.Height : 0) ); var or = Origin + new Vector2(0, currentMove); var fangle = shadow ? -angle : angle; var sc = new Vector2(scale.X, shadow ? -scale.Y : scale.Y); if (!shadow && !atBack) { var dx = Nozzle.X - or.X; var dy = Nozzle.Y - or.Y; var a = MathUtils.Angle(dx, dy) + angle; var d = MathUtils.Distance(dx, dy); var aim = owner.GetComponent <AimComponent>(); aim.Center = pos + MathUtils.CreateVector(a, d); d = (aim.Aim - pos).Length(); aim.RealAim = aim.Center + MathUtils.CreateVector(angle - (horizontal ? 0 : Math.PI / 2), d); } if (Item.Scourged) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ItemGraphicsComponent.ScourgedColor); foreach (var d in MathUtils.Directions) { Graphics.Render(region, pos + d, fangle, or, sc); } Shaders.End(); } Graphics.Render(region, pos, fangle, or, sc); }
public override void Render(bool shadow) { if (Hidden) { return; } var o = (shadow ? -1 : 1) * (offsets[Math.Min(offsets.Length - 1, Animation.Frame + Animation.StartFrame)] - 11); var s = GetComponent <StateComponent>().StateInstance; var w = !(s is Player.RollState || s is Player.SleepingState); var z = GetComponent <ZComponent>(); // Render wings if (((Player)Entity).HasFlight) { var a = (float)(Math.Sin(Engine.Time * 5f) * 0.5f) * (shadow ? -1 : 1); if (!shadow) { z.Z = -a * 3 + 4; } a -= (float)Math.PI / 4 * (shadow ? -1 : 1); var wy = shadow ? Entity.Height : 0; wy += GetComponent <ZComponent>().Z *(shadow ? 1 : -1); Graphics.Render(wing, Entity.Center + new Vector2(-1, wy), a, new Vector2(8), shadow ? MathUtils.InvertY : Vector2.One); Graphics.Render(wing, Entity.Center + new Vector2(1, wy), -a, new Vector2(8), shadow ? MathUtils.InvertXY : MathUtils.InvertX); } var g = shadow ? 0 : (int)z.Z; if (w) { GetComponent <WeaponComponent>().Render(shadow, o - g); } if (!shadow && InGameState.Multiplayer) { var pos = Entity.Position + Offset; var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(Player.VectorTints[Entity.GetComponent <InputComponent>().Index]); foreach (var d in MathUtils.Directions) { CallRender(pos + d, false); } Shaders.End(); } var stopShader = StartShaders(); SimpleRender(shadow); if (stopShader) { Shaders.End(); } if (!shadow) { var aim = GetComponent <AimComponent>(); if (aim.ShowLaserLine) { var from = aim.Center; var to = aim.RealAim; var min = 1f; var closest = MathUtils.CreateVector(MathUtils.Angle(to.X - from.X, to.Y - from.Y), Display.UiWidth) + from; Physics.World.RayCast((fixture, point, normal, fraction) => { if (min > fraction && fixture.Body.UserData is BodyComponent b && RayShouldCollide(b.Entity)) { min = fraction; closest = point; } return(min); }, from, to); Graphics.Batch.FillRectangle((int)closest.X - 1, (int)closest.Y - 1, 3, 3, AimLineColor); Graphics.Batch.DrawLine(from, new Vector2((int)closest.X, (int)closest.Y), AimLineColor, 1); } } if (w) { GetComponent <ActiveWeaponComponent>().Render(shadow, o - g); } }
public override void Render(bool atBack, bool paused, float dt, bool shadow, int offset) { if (Hidden) { return; } var s = dt * 10f; sx += (1 - sx) * s; sy += (1 - sy) * s; ox += (-ox) * s; oy += (-oy) * s; var region = Item.Region; var owner = Item.Owner; var of = owner.GraphicsComponent.Flipped; var flipped = false; var angle = MathUtils.Mod((of ? -Angle : Angle) + (atBack ? ((InvertBack ? -1 : 1) * (of ? -Math.PI / 4 : Math.PI / 4)) : lastAngle), Math.PI * 2); var vf = angle > Math.PI * 0.5f && angle < Math.PI * 1.5f; if (!atBack && !paused && !shadow) { var to = owner.GetComponent <AimComponent>().Aim; /*var dx = Nozzle.X - Origin.X; * var dy = Nozzle.Y - Origin.Y; * * if (vf) { * dy *= -1; * } * * var a = MathUtils.Angle(dx, dy) + lastAngle - AddedAngle - SwingAngle; * var d = MathUtils.Distance(dx, dy); * to -= MathUtils.CreateVector(a, d); * * owner.GetComponent<AimComponent>().Aim = to;*/ lastAngle = MathUtils.LerpAngle(lastAngle, owner.AngleTo(to), dt * 24f); } if (atBack) { flipped = !flipped; } else { angle += (SwingAngle + AddedAngle) * (of ? -1 : 1); } var pos = new Vector2(owner.CenterX + (of ? -5 : 5), owner.CenterY + offset + (shadow ? owner.Height : 0)); var or = Origin + new Vector2(ox, oy); var sc = new Vector2(flipped ? -sx : sx, (shadow ^ vf) ? -sy : sy); var fangle = (float)angle * (shadow ? -1 : 1); if (!shadow && !atBack) { var dx = Nozzle.X - or.X; var dy = Nozzle.Y - or.Y; if (vf) { dy *= -1; } var a = MathUtils.Angle(dx, dy) + angle; var d = MathUtils.Distance(dx, dy); var aim = owner.GetComponent <AimComponent>(); aim.Center = pos + MathUtils.CreateVector(a, d); d = (aim.Aim - pos).Length(); aim.RealAim = aim.Center + MathUtils.CreateVector(angle - AddedAngle - SwingAngle, d); } if (Item.Scourged) { var shader = Shaders.Entity; Shaders.Begin(shader); shader.Parameters["flash"].SetValue(1f); shader.Parameters["flashReplace"].SetValue(1f); shader.Parameters["flashColor"].SetValue(ItemGraphicsComponent.ScourgedColor); foreach (var d in MathUtils.Directions) { Graphics.Render(region, pos + d, fangle, or, sc); } Shaders.End(); } Graphics.Render(region, pos, fangle, or, sc); }