public override void Draw(SpriteBatch sb) { base.Draw(sb); HologramDefinition def = this.CreateHologramDefinition(); def.CurrentFrame = this.CachedHologramDef?.CurrentFrame ?? 0; def.CurrentFrameElapsedTicks = this.CachedHologramDef?.CurrentFrameElapsedTicks ?? 0; this.CachedHologramDef = def; var mouseScr = new Vector2(Main.mouseX + 12, Main.mouseY); mouseScr = UIZoomHelpers.ApplyZoomFromScreenCenter(mouseScr, false, true, null, null); var mouseWld = mouseScr + Main.screenPosition; if (def.AnimateHologram(mouseWld, true)) { try { def.DrawHologram(sb, mouseWld, true); } catch (Exception e) { LogHelpers.AlertOnce(e.ToString()); } } }
public void DrawHologramRaw(SpriteBatch sb, Vector2 worldPos, bool isUI, Texture2D tex, int frameHeight) { Color color = this.Color; SpriteEffects effects = SpriteEffects.None; Vector2 origin = new Vector2(tex.Width, frameHeight) * 0.5f; Vector2 scrPos; Rectangle frame = new Rectangle( x: 0, y: frameHeight * this.CurrentFrame, width: tex.Width, height: frameHeight ); if (this.WorldLighting) { color = Lighting.GetColor((int)(worldPos.X / 16f), (int)(worldPos.Y / 16f)); color = XNAColorHelpers.Mul(color, this.Color); } color *= (float)this.Alpha / 255f; scrPos = worldPos - Main.screenPosition; scrPos.X += this.OffsetX; scrPos.Y += this.OffsetY; scrPos = UIZoomHelpers.ApplyZoomFromScreenCenter( value: scrPos, uiZoomState: isUI ? (bool?)true : null, gameZoomState: null, uiZoomStateForCenterOffset: null, gameZoomStateForCenterOffset: null ); if (this.Direction == -1) { effects = SpriteEffects.FlipHorizontally; } try { sb.Draw( texture: tex, position: scrPos, sourceRectangle: frame, color: color, rotation: MathHelper.ToRadians(this.Rotation), origin: isUI ? default(Vector2) : origin, scale: this.Scale, // * Main.GameZoomTarget, effects: effects, layerDepth: 1f ); } catch (Exception e) { LogHelpers.Warn(e.ToString()); throw; } }
//////////////// public void DrawEmitterTile(SpriteBatch sb, int tileX, int tileY) { Vector2 wldPos = new Vector2(tileX << 4, tileY << 4); //Vector2 scr = UIHelpers.ConvertToScreenPosition( wldPos ); Vector2 scr = UIZoomHelpers.ApplyZoomFromScreenCenter(wldPos - Main.screenPosition, null, false, null, null); sb.Draw( texture: EmittersMod.Instance.EmitterTex, position: scr, sourceRectangle: null, color: Color.White, rotation: 0f, origin: default(Vector2), scale: Main.GameZoomTarget, effects: SpriteEffects.None, layerDepth: 1f ); this.DrawEmitterInfo(sb, tileX, tileY); }