private void Rebuild() { if (!_overrideSystemViewport) { _viewport = _graphicsDevice.Viewport; } Vector2 value = new Vector2(_viewport.Width, _viewport.Height); Matrix identity = Matrix.Identity; if (_effects.HasFlag(SpriteEffects.FlipHorizontally)) { identity *= Matrix.CreateScale(-1f, 1f, 1f) * Matrix.CreateTranslation(value.X, 0f, 0f); } if (_effects.HasFlag(SpriteEffects.FlipVertically)) { identity *= Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, value.Y, 0f); } Vector2 value2 = value * 0.5f; Vector2 translation = value2 - value2 / _zoom; Matrix matrix = Matrix.CreateOrthographicOffCenter(0f, value.X, value.Y, 0f, 0f, 1f); _translation = translation; _zoomMatrix = Matrix.CreateTranslation(0f - translation.X, 0f - translation.Y, 0f) * Matrix.CreateScale(_zoom.X, _zoom.Y, 1f); _effectMatrix = identity; _transformationMatrix = identity * _zoomMatrix; _normalizedTransformationMatrix = Matrix.Invert(identity) * _zoomMatrix * matrix; _needsRebuild = false; }
public static Vector2 OriginFlip(this Rectangle rect, Vector2 origin, SpriteEffects effects) { if (effects.HasFlag(SpriteEffects.FlipHorizontally)) { origin.X = (float)rect.Width - origin.X; } if (effects.HasFlag(SpriteEffects.FlipVertically)) { origin.Y = (float)rect.Height - origin.Y; } return(origin); }
public static Vector2 Mirror(this Vector2 vector, SpriteEffects mirror) { if (mirror.HasFlag(SpriteEffects.FlipHorizontally)) { vector.X *= -1; } if (mirror.HasFlag(SpriteEffects.FlipVertically)) { vector.Y *= -1; } return(vector); }
private void Draw(SpriteBatch sb) { Texture2D texture2D = TextureAssets.Extra[48].get_Value(); SpriteEffects effect = SpriteEffects.None; Vector2 vector2 = this.GetPosition(out effect).Floor(); bool flag = this.lifeTime < 6 || this.lifeTimeStart - this.lifeTime < 6; Rectangle rectangle = texture2D.Frame(8, 38, flag ? 0 : 1, 0, 0, 0); Vector2 origin = new Vector2((float)(rectangle.Width / 2), (float)rectangle.Height); if ((double)Main.player[Main.myPlayer].gravDir == -1.0) { origin.Y = 0.0f; effect |= SpriteEffects.FlipVertically; vector2 = Main.ReverseGravitySupport(vector2, 0.0f); } sb.Draw(texture2D, vector2, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f); if (flag) { return; } if (this.emote >= 0) { if ((this.emote == 87 || this.emote == 89) && effect.HasFlag((Enum)SpriteEffects.FlipHorizontally)) { effect &= ~SpriteEffects.FlipHorizontally; vector2.X += 4f; } sb.Draw(texture2D, vector2, new Rectangle?(texture2D.Frame(8, 38, this.emote * 2 % 8 + this.frame, 1 + this.emote / 4, 0, 0)), Color.White, 0.0f, origin, 1f, effect, 0.0f); } else { if (this.emote != -1) { return; } Texture2D texture = TextureAssets.NpcHead[this.metadata].get_Value(); float scale = 1f; if ((double)texture.Width / 22.0 > 1.0) { scale = 22f / (float)texture.Width; } if ((double)texture.Height / 16.0 > 1.0 / (double)scale) { scale = 16f / (float)texture.Height; } sb.Draw(texture, vector2 + new Vector2(effect.HasFlag((Enum)SpriteEffects.FlipHorizontally) ? 1f : -1f, (float)(-rectangle.Height + 3)), new Rectangle?(), Color.White, 0.0f, new Vector2((float)(texture.Width / 2), 0.0f), scale, effect, 0.0f); } }
public void Draw(ref CreditsRollInfo info) { int num = info.TimeInAnimation - this._targetTime; if (num < 0 || (double)num >= (double)this.DedicatedTimeNeeded) { return; } Vector2 position = (info.AnchorPositionOnScreen + this._offset).Floor(); bool flag = num < 6 || (double)num >= (double)this.DedicatedTimeNeeded - 6.0; Texture2D texture2D = TextureAssets.Extra[48].Value; Rectangle rectangle = texture2D.Frame(8, 38, flag ? 0 : 1, 0, 0, 0); Vector2 origin = new Vector2((float)(rectangle.Width / 2), (float)rectangle.Height); SpriteEffects effect = this._effect; info.SpriteBatch.Draw(texture2D, position, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f); if (flag) { return; } switch (this._emoteId) { case 87: case 89: if (effect.HasFlag((Enum)SpriteEffects.FlipHorizontally)) { effect &= ~SpriteEffects.FlipHorizontally; position.X += 4f; break; } break; } info.SpriteBatch.Draw(texture2D, position, new Rectangle?(this.GetFrame(num % 20)), Color.White, 0.0f, origin, 1f, effect, 0.0f); }
public void Draw(CreditsRollInfo info) { int num = info.TimeInAnimation - _targetTime; if (num < 0 || (float)num >= DedicatedTimeNeeded) { return; } Vector2 vector = info.AnchorPositionOnScreen + _offset; vector = vector; bool flag = num < 6 || (float)num >= DedicatedTimeNeeded - 6f; Texture2D value = TextureAssets.Extra[48].Value; Rectangle value2 = value.Frame(8, 38, (!flag) ? 1 : 0); Vector2 origin = new Vector2(value2.Width / 2, value2.Height); SpriteEffects spriteEffects = _effect; info.SpriteBatch.Draw(value, vector, value2, Color.White, 0f, origin, 1f, spriteEffects, 0f); if (!flag) { int emoteId = _emoteId; if ((emoteId == 87 || emoteId == 89) && spriteEffects.HasFlag(SpriteEffects.FlipHorizontally)) { spriteEffects &= ~SpriteEffects.FlipHorizontally; vector.X += 4f; } info.SpriteBatch.Draw(value, vector, GetFrame(num % 20), Color.White, 0f, origin, 1f, spriteEffects, 0f); } }
private void Draw(SpriteBatch sb) { Texture2D value = TextureAssets.Extra[48].get_Value(); SpriteEffects effect = SpriteEffects.None; Vector2 vector = GetPosition(out effect); vector = vector.Floor(); bool flag = lifeTime < 6 || lifeTimeStart - lifeTime < 6; Rectangle value2 = value.Frame(8, 38, (!flag) ? 1 : 0); Vector2 origin = new Vector2(value2.Width / 2, value2.Height); if (Main.player[Main.myPlayer].gravDir == -1f) { origin.Y = 0f; effect |= SpriteEffects.FlipVertically; vector = Main.ReverseGravitySupport(vector); } sb.Draw(value, vector, value2, Color.White, 0f, origin, 1f, effect, 0f); if (flag) { return; } if (emote >= 0) { if ((emote == 87 || emote == 89) && effect.HasFlag(SpriteEffects.FlipHorizontally)) { effect &= ~SpriteEffects.FlipHorizontally; vector.X += 4f; } sb.Draw(value, vector, value.Frame(8, 38, emote * 2 % 8 + frame, 1 + emote / 4), Color.White, 0f, origin, 1f, effect, 0f); } else if (emote == -1) { value = TextureAssets.NpcHead[metadata].get_Value(); float num = 1f; if ((float)value.Width / 22f > 1f) { num = 22f / (float)value.Width; } if ((float)value.Height / 16f > 1f / num) { num = 16f / (float)value.Height; } sb.Draw(value, vector + new Vector2(effect.HasFlag(SpriteEffects.FlipHorizontally) ? 1 : (-1), -value2.Height + 3), null, Color.White, 0f, new Vector2(value.Width / 2, 0f), num, effect, 0f); } }
private void Draw(SpriteBatch sb) { Texture2D texture2D = Main.extraTexture[48]; SpriteEffects effect = SpriteEffects.None; Vector2 vector2 = GetPosition(out effect); bool flag = lifeTime < 6 || lifeTimeStart - lifeTime < 6; Rectangle rectangle = Utils.Frame(texture2D, 8, 33, flag ? 0 : 1, 0); Vector2 origin = new Vector2((float)(rectangle.Width / 2), (float)rectangle.Height); if (Main.player[Main.myPlayer].gravDir == -1.0) { origin.Y = 0.0f; effect |= SpriteEffects.FlipVertically; vector2 = Main.ReverseGravitySupport(vector2, 0.0f); } sb.Draw(texture2D, vector2, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f); if (flag) { return; } if (emote >= 0) { if (emote == 87) { effect = SpriteEffects.None; } sb.Draw(texture2D, vector2, new Rectangle?(Utils.Frame(texture2D, 8, 33, emote * 2 % 8 + frame, 1 + emote / 4)), Color.White, 0.0f, origin, 1f, effect, 0.0f); } else { if (this.emote != -1) { return; } Texture2D texture = Main.npcHeadTexture[metadata]; float scale = 1f; if (texture.Width / 22.0 > 1.0) { scale = 22f / (float)texture.Width; } if (texture.Height / 16.0 > 1.0 / scale) { scale = 16f / (float)texture.Height; } sb.Draw(texture, vector2 + new Vector2(effect.HasFlag(SpriteEffects.FlipHorizontally) ? 1f : -1f, (float)(-rectangle.Height + 3)), new Rectangle?(), Color.White, 0.0f, new Vector2((float)(texture.Width / 2), 0.0f), scale, effect, 0.0f); } }
/// <summary>Get the pixel coordinates within a sprite sheet corresponding to a sprite displayed in the world.</summary> /// <param name="worldPosition">The pixel position in the world.</param> /// <param name="worldRectangle">The sprite rectangle in the world.</param> /// <param name="spriteRectangle">The sprite rectangle in the sprite sheet.</param> /// <param name="spriteEffects">The transformation to apply on the sprite.</param> public Vector2 GetSpriteSheetCoordinates(Vector2 worldPosition, Rectangle worldRectangle, Rectangle spriteRectangle, SpriteEffects spriteEffects = SpriteEffects.None) { // get position within sprite rectangle float x = (worldPosition.X - worldRectangle.X) / Game1.pixelZoom; float y = (worldPosition.Y - worldRectangle.Y) / Game1.pixelZoom; // flip values if (spriteEffects.HasFlag(SpriteEffects.FlipHorizontally)) { x = spriteRectangle.Width - x; } if (spriteEffects.HasFlag(SpriteEffects.FlipVertically)) { y = spriteRectangle.Height - y; } // get position within sprite sheet x += spriteRectangle.X; y += spriteRectangle.Y; // return coordinates return(new Vector2(x, y)); }
public override void Draw(SceneGame scene, DrawPass pass) { var slash = SpriteLoader.Instance.AddSprite("content/slash_round"); var slashAngle = Angle; if (Mirror.HasFlag(SpriteEffects.FlipHorizontally)) { slashAngle = -slashAngle; } if (Size > 0.2) { scene.SpriteBatch.Draw(slash.Texture, Position + new Vector2(8, 8) - new Vector2(8, 8), slash.GetFrameRect(Math.Min(slash.SubImageCount - 1, (int)(slash.SubImageCount * Frame / FrameEnd) - 1)), Color.LightGray, slashAngle, slash.Middle, Size - 0.2f, Mirror, 0); } scene.SpriteBatch.Draw(slash.Texture, Position + new Vector2(8, 8) - new Vector2(8, 8), slash.GetFrameRect(Math.Min(slash.SubImageCount - 1, (int)(slash.SubImageCount * Frame / FrameEnd))), Color.White, slashAngle, slash.Middle, Size, Mirror, 0); }
private void Draw(SpriteBatch sb) { Texture2D texture2D = Main.extraTexture[48]; SpriteEffects effect = SpriteEffects.None; Vector2 vector = GetPosition(out effect); bool flag = lifeTime < 6 || lifeTimeStart - lifeTime < 6; Rectangle value = texture2D.Frame(8, 33, (!flag) ? 1 : 0); Vector2 origin = new Vector2(value.Width / 2, value.Height); if (Main.player[Main.myPlayer].gravDir == -1f) { origin.Y = 0f; effect |= SpriteEffects.FlipVertically; vector = Main.ReverseGravitySupport(vector); } sb.Draw(texture2D, vector, value, Color.White, 0f, origin, 1f, effect, 0f); if (flag) { return; } if (emote >= 0) { if (emote == 87) { effect = SpriteEffects.None; } sb.Draw(texture2D, vector, texture2D.Frame(8, 33, emote * 2 % 8 + frame, 1 + emote / 4), Color.White, 0f, origin, 1f, effect, 0f); } else if (emote == -1) { texture2D = Main.npcHeadTexture[metadata]; float num = 1f; if ((float)texture2D.Width / 22f > 1f) { num = 22f / (float)texture2D.Width; } if ((float)texture2D.Height / 16f > 1f / num) { num = 16f / (float)texture2D.Height; } sb.Draw(texture2D, vector + new Vector2(effect.HasFlag(SpriteEffects.FlipHorizontally) ? 1 : (-1), -value.Height + 3), null, Color.White, 0f, new Vector2(texture2D.Width / 2, 0f), num, effect, 0f); } }
// Token: 0x06001052 RID: 4178 RVA: 0x003FE558 File Offset: 0x003FC758 private void Draw(SpriteBatch sb) { Texture2D texture2D = Main.extraTexture[48]; SpriteEffects spriteEffects = SpriteEffects.None; Vector2 vector = this.GetPosition(out spriteEffects); bool flag = this.lifeTime < 6 || this.lifeTimeStart - this.lifeTime < 6; Rectangle rectangle = texture2D.Frame(8, 33, flag ? 0 : 1, 0); Vector2 origin = new Vector2((float)(rectangle.Width / 2), (float)rectangle.Height); if (Main.player[Main.myPlayer].gravDir == -1f) { origin.Y = 0f; spriteEffects |= SpriteEffects.FlipVertically; vector = Main.ReverseGravitySupport(vector, 0f); } sb.Draw(texture2D, vector, new Rectangle?(rectangle), Color.White, 0f, origin, 1f, spriteEffects, 0f); if (!flag) { if (this.emote >= 0) { if (this.emote == 87) { spriteEffects = SpriteEffects.None; } sb.Draw(texture2D, vector, new Rectangle?(texture2D.Frame(8, 35, this.emote * 2 % 8 + this.frame, 1 + this.emote / 4)), Color.White, 0f, origin, 1f, spriteEffects, 0f); return; } if (this.emote == -1) { texture2D = Main.npcHeadTexture[this.metadata]; float num = 1f; if ((float)texture2D.Width / 22f > 1f) { num = 22f / (float)texture2D.Width; } if ((float)texture2D.Height / 16f > 1f / num) { num = 16f / (float)texture2D.Height; } sb.Draw(texture2D, vector + new Vector2((float)(spriteEffects.HasFlag(SpriteEffects.FlipHorizontally) ? 1 : -1), (float)(-(float)rectangle.Height + 3)), null, Color.White, 0f, new Vector2((float)(texture2D.Width / 2), 0f), num, spriteEffects, 0f); } } }
public override bool PreDraw(SpriteBatch spriteBatch, Color drawColor) { SpriteEffects spriteEffects = 0; Color alpha = npc.GetAlpha(drawColor); Color color = Lighting.GetColor((int)(npc.position.X + npc.width * 0.5) / 16, (int)((npc.position.Y + npc.height * 0.5) / 16.0)); Texture2D texture2D = Main.npcTexture[npc.type]; int num = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; int num2 = num * (int)npc.frameCounter; Rectangle rectangle = new Rectangle(0, num2, texture2D.Width, num); Vector2 vector = rectangle.Size() / 2f; int num3 = 8; int num4 = 1; int num5 = 1; float num6 = 0f; int num7 = num5; while (((num4 > 0 && num7 < num3) || (num4 < 0 && num7 > num3)) && Lighting.NotRetro) { Color color2 = npc.GetAlpha(color); float num8 = (num3 - num7); if (num4 < 0) { num8 = (num5 - num7); } color2 *= num8 / (NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); Vector2 vector2 = npc.oldPos[num7]; float rotation = npc.rotation; Main.spriteBatch.Draw(texture2D, vector2 + npc.Size / 2f - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Rectangle?(rectangle), color2, rotation + npc.rotation * num6 * (num7 - 1) * -spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), vector, npc.scale, spriteEffects, 0f); num7 += num4; } SpriteEffects spriteEffects2 = (npc.direction == -1) ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(texture2D, npc.Center - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Rectangle?(npc.frame), alpha, npc.rotation, npc.frame.Size() / 2f, npc.scale, spriteEffects2, 0f); return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = Main.projectileTexture[projectile.type]; int num156 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y3 = num156 * projectile.frame; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 4f; int arg_5ADA_0 = projectile.type; int arg_5AE7_0 = projectile.type; int arg_5AF4_0 = projectile.type; int num157 = 10; int num158 = 1; int num159 = 1; float value3 = 1f; float num160 = 0f; float num153 = 1f / (float)projectile.oldPos.Length * 0.7f; int num161 = num159; while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) { float num155 = (float)(projectile.oldPos.Length - num161) / (float)projectile.oldPos.Length; Microsoft.Xna.Framework.Color color29 = projectile.GetAlpha(color25); { goto IL_6899; } IL_6881: num161 += num158; continue; IL_6899: float num164 = (float)(num157 - num161); if (num158 < 0) { num164 = (float)(num159 - num161); } //color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); Vector2 value4 = (projectile.oldPos[num161] + projectile.position * 2) / 3; float num165 = projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[projectile.type] == 2) { num165 = projectile.oldRot[num161]; effects = ((projectile.oldSpriteDirection[num161] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None); } Main.spriteBatch.Draw(texture2D3, value4 + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color29, num165 + projectile.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, projectile.scale * MathHelper.Lerp(0.3f, 1.1f, num155), effects, 0f); goto IL_6881; } Microsoft.Xna.Framework.Color color291 = projectile.GetAlpha(color25); Main.spriteBatch.Draw(texture2D3, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color291, projectile.rotation, origin2, projectile.scale, spriteEffects, 0f); return(false); }
public void Draw(Texture2D texture, Rectangle? sourceRect, Rectangle destRect, Color4 color, Vector2 scale, float depth = 0, SpriteEffects effects = SpriteEffects.None) { // Flush if the current texture is valid // and the new texture differs from the current texture if (CurrentTexture.TextureId != -1 && texture.TextureId != CurrentTexture.TextureId) Flush (); // Set the current texture to the new texture CurrentTexture = texture; // Flush if the vertex or index counts exceeds the maximum if (indexCount + 6 >= MAX_INDICES || vertexCount + 4 >= MAX_VERTICES) Flush (); // Construct source rectangle Rectangle source = sourceRect ?? new Rectangle (0, 0, texture.Width, texture.Height); // Decompose destination rectangle float x = destRect.X; float y = destRect.Y; float w = destRect.Width * scale.X; float h = destRect.Height * scale.Y; // Decompose source rectangle float srcX = source.X; float srcY = source.Y; float srcW = source.Width; float srcH = source.Height; var topLeftCoord = new Vector2 ( x: srcX / (float) texture.Width, y: srcY / (float) texture.Height); var topRightCoord = new Vector2 ( x: (srcX + srcW) / (float) texture.Width, y: srcY / (float) texture.Height); var bottomLeftCoord = new Vector2 ( x: srcX / (float) texture.Width, y: (srcY + srcH) / (float) texture.Height); var bottomRightCoord = new Vector2 ( x: (srcX + srcW) / (float) texture.Width, y: (srcY + srcH) / (float) texture.Height); // Flip the texture horizontally if requested if (effects.HasFlag (SpriteEffects.FlipHorizontal)) { SwapVec (ref topLeftCoord, ref topRightCoord); SwapVec (ref bottomLeftCoord, ref bottomRightCoord); } // Flip the texture horizontally if requested if (effects.HasFlag (SpriteEffects.FlipVertical)) { SwapVec (ref topLeftCoord, ref bottomLeftCoord); SwapVec (ref topRightCoord, ref bottomRightCoord); } // Top left Vertices[vertexCount++] = new Vertex2D ( new Vector3 (x, y, depth), topLeftCoord, color ); // Top right Vertices[vertexCount++] = new Vertex2D ( new Vector3 (x + w, y, depth), topRightCoord, color ); // Bottom left Vertices[vertexCount++] = new Vertex2D ( new Vector3 (x, y + h, depth), bottomLeftCoord, color ); // Bottom right Vertices[vertexCount++] = new Vertex2D ( new Vector3 (x + w, y + h, depth), bottomRightCoord, color ); // Increment the index count indexCount += 6; }
public void GUIDrawSprite(Texture2D texture, Rectangle destinationRectangle, Rectangle?sourceRectangle = null, Color?color = null, SpriteEffects effects = SpriteEffects.None, bool Palettized = false, int Palette = 0) { if (texture == null) { return; } Vector4 dest = new Vector4(destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Right, destinationRectangle.Bottom); Vector4 srcDelta = new Vector4(); if (sourceRectangle == null) { sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); } // clipping if (dest.X < m_GUIClipRect.X) { if (dest.Z < m_GUIClipRect.X) { return; } float delta = m_GUIClipRect.X - dest.X; dest.X += delta; srcDelta.X = delta / destinationRectangle.Width; } if (dest.Z > m_GUIClipRect.Z) { if (dest.X > m_GUIClipRect.Z) { return; } float delta = m_GUIClipRect.Z - dest.Z; dest.Z += delta; srcDelta.Z = delta / destinationRectangle.Width; } if (dest.Y < m_GUIClipRect.Y) { if (dest.W < m_GUIClipRect.Y) { return; } float delta = m_GUIClipRect.Y - dest.Y; dest.Y += delta; srcDelta.Y = delta / destinationRectangle.Width; } if (dest.W > m_GUIClipRect.W) { if (dest.Y > m_GUIClipRect.W) { return; } float delta = m_GUIClipRect.W - dest.W; dest.W += delta; srcDelta.W = delta / destinationRectangle.Width; } Vector4 source = new Vector4( (float)sourceRectangle.Value.X / texture.Width, (float)sourceRectangle.Value.Y / texture.Height, (float)sourceRectangle.Value.Right / texture.Width, (float)sourceRectangle.Value.Bottom / texture.Height); source.X += srcDelta.X * ((float)sourceRectangle.Value.Width / texture.Width); source.Y += srcDelta.Y * ((float)sourceRectangle.Value.Width / texture.Height); source.Z += srcDelta.Z * ((float)sourceRectangle.Value.Width / texture.Width); source.W += srcDelta.W * ((float)sourceRectangle.Value.Width / texture.Height); if (effects.HasFlag(SpriteEffects.FlipHorizontally)) { float x = source.X; source.X = source.Z; source.Z = x; } if (effects.HasFlag(SpriteEffects.FlipVertically)) { float y = source.Y; source.Y = source.W; source.W = y; } PreTransformedQuad q = new PreTransformedQuad(texture, dest, source, _zOffset.Z++, color == null ? Color.White : color.Value, new Vector2(Palette, Palettized ? 0 : 1)); List <VertexPositionTextureHueExtra> vertexList; if (_drawQueue.ContainsKey(texture)) { vertexList = _drawQueue[texture]; } else { if (_vertexListQueue.Count > 0) { vertexList = _vertexListQueue.Dequeue(); vertexList.Clear(); } else { vertexList = new List <VertexPositionTextureHueExtra>(1024); } _drawQueue.Add(texture, vertexList); } for (int i = 0; i < q.Vertices.Length; i++) { vertexList.Add(q.Vertices[i]); } }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects effects1 = SpriteEffects.None; if (projectile.direction == 1) { effects1 = SpriteEffects.FlipHorizontally; } Microsoft.Xna.Framework.Color color3 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); { Texture2D texture = Main.projectileTexture[projectile.type]; Texture2D glow = Main.projectileTexture[projectile.type]; int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; Microsoft.Xna.Framework.Rectangle r = new Microsoft.Xna.Framework.Rectangle(0, height * projectile.frame, texture.Width, height); Vector2 origin = r.Size() / 2f; int num2 = 5; int num3 = 1; int num4 = 1; float num5 = 1f; float num6 = 0.0f; num3 = 1; num5 = 3f; int index1 = num4; while (num3 > 0 && index1 < num2 || num3 < 0 && index1 > num2) { Microsoft.Xna.Framework.Color newColor = color3; newColor = Microsoft.Xna.Framework.Color.Lerp(newColor, Microsoft.Xna.Framework.Color.White, 2.5f); Microsoft.Xna.Framework.Color color1 = projectile.GetAlpha(newColor); float num7 = (float)(num2 - index1); if (num3 < 0) { num7 = (float)(num4 - index1); } Microsoft.Xna.Framework.Color color2 = color1 * (num7 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f)); Vector2 oldPo = projectile.oldPos[index1]; float rotation = projectile.rotation; SpriteEffects effects2 = effects1; if (ProjectileID.Sets.TrailingMode[projectile.type] == 2) { rotation = projectile.oldRot[index1]; effects2 = projectile.oldSpriteDirection[index1] == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } Main.spriteBatch.Draw(glow, oldPo + projectile.Size / 2f - Main.screenPosition + new Vector2(0.0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(r), color2, rotation + projectile.rotation * num6 * (float)(index1 - 1) * (float)-effects1.HasFlag((Enum)SpriteEffects.FlipHorizontally).ToDirectionInt(), origin, MathHelper.Lerp(projectile.scale, num5, (float)index1 / 15f), effects2, 0.0f); label_709: index1 += num3; } Microsoft.Xna.Framework.Color color4 = projectile.GetAlpha(color3); Main.spriteBatch.Draw(texture, projectile.Center - Main.screenPosition + new Vector2(0.0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(r), new Color(255 - projectile.alpha, 255 - projectile.alpha, 255 - projectile.alpha, 175), projectile.rotation, origin, projectile.scale, effects1, 0.0f); } for (int a = 0; a < 1; a++) { SpriteEffects spriteEffects = SpriteEffects.None; if (projectile.spriteDirection == 1) { spriteEffects = SpriteEffects.FlipHorizontally; } Texture2D texture = Main.projectileTexture[projectile.type]; Vector2 vector2_3 = new Vector2((float)(Main.projectileTexture[projectile.type].Width / 2), (float)(Main.projectileTexture[projectile.type].Height / 1 / 2)); int height = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; Microsoft.Xna.Framework.Rectangle r = new Microsoft.Xna.Framework.Rectangle(0, height * projectile.frame, texture.Width, height); float addY = 0f; float addHeight = 0f; int num7 = 5; float num9 = (float)(Math.Cos((double)Main.GlobalTime % 2.40000009536743 / 2.40000009536743 * 6.28318548202515) / 2.0 + 0.5); float num99 = (float)(Math.Cos((double)Main.GlobalTime % 2.40000009536743 / 2.40000009536743 * 6.28318548202515) / 4.0 + 0.5); float num8 = 0f; Microsoft.Xna.Framework.Color secondColor = Microsoft.Xna.Framework.Color.White; float num10 = 0.0f; Vector2 bb = projectile.Center - Main.screenPosition - new Vector2((float)texture.Width, (float)(texture.Height / 1)) * projectile.scale / 2f + vector2_3 * projectile.scale + new Vector2(0.0f, addY + addHeight + projectile.gfxOffY); Microsoft.Xna.Framework.Color color2 = new Microsoft.Xna.Framework.Color((int)sbyte.MaxValue - projectile.alpha, (int)sbyte.MaxValue - projectile.alpha, (int)sbyte.MaxValue - projectile.alpha, 0).MultiplyRGBA(Microsoft.Xna.Framework.Color.White); for (int index2 = 0; index2 < 4; ++index2) { Microsoft.Xna.Framework.Color newColor2 = color2; Microsoft.Xna.Framework.Color faa = projectile.GetAlpha(newColor2) * (1f - num99); Vector2 position2 = projectile.Center + ((float)((double)index2 / (double)4 * 6.28318548202515) + projectile.rotation + num10).ToRotationVector2() * (float)(8.0 * (double)num99 + 2.0) - Main.screenPosition - new Vector2((float)texture.Width, (float)(texture.Height / 1)) * projectile.scale / 2f + vector2_3 * projectile.scale + new Vector2(0.0f, addY + addHeight + projectile.gfxOffY); Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], position2, new Microsoft.Xna.Framework.Rectangle?(r), faa, projectile.rotation, vector2_3, projectile.scale, spriteEffects, 0.0f); } } Lighting.AddLight(projectile.Center, Color.White.ToVector3() / 2f); return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Player player = Main.player[projectile.owner]; SpriteEffects spriteEffects = SpriteEffects.None; if (player.direction == -1) { spriteEffects = SpriteEffects.FlipHorizontally; } Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = Main.projectileTexture[projectile.type]; int num156 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y3 = num156 * projectile.frame; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int arg_5ADA_0 = projectile.type; int arg_5AE7_0 = projectile.type; int arg_5AF4_0 = projectile.type; int num157 = 10; int num158 = 2; int num159 = 1; float value3 = 1f; float num160 = 0f; int num161 = num159; while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) { Microsoft.Xna.Framework.Color color26 = color25; color26 = projectile.GetAlpha(color26); { goto IL_6899; } color26 = Microsoft.Xna.Framework.Color.Lerp(color26, Microsoft.Xna.Framework.Color.Blue, 0.5f); IL_6881: num161 += num158; continue; IL_6899: float num164 = (float)(num157 - num161); if (num158 < 0) { num164 = (float)(num159 - num161); } color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); Vector2 value4 = projectile.oldPos[num161]; float num165 = projectile.rotation; SpriteEffects effects = spriteEffects; Main.spriteBatch.Draw(texture2D3, value4 + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + projectile.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, projectile.scale, effects, 0f); goto IL_6881; } Microsoft.Xna.Framework.Color color29 = projectile.GetAlpha(color25); Main.spriteBatch.Draw(texture2D3, projectile.Center - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color29, projectile.rotation, origin2, projectile.scale, spriteEffects, 0f); return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { if (phase >= 1) { //tf does this supposed to mean int num159 = 1; float num160 = 0f; int num161 = num159; SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); Texture2D texture2D4 = mod.GetTexture("NPCs/Boss/CosmicApparition/CosmicApparition2"); int num1561 = texture2D4.Height / Main.npcFrameCount[npc.type]; int y31 = num1561 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, y31, texture2D4.Width, num1561); Vector2 origin3 = rectangle2.Size() / 2f; SpriteEffects effects = spriteEffects; if (npc.spriteDirection > 0) { effects = SpriteEffects.FlipHorizontally; } float num165 = npc.rotation; Microsoft.Xna.Framework.Color color29 = npc.GetAlpha(color25); Main.spriteBatch.Draw(texture2D4, npc.position + npc.Size / 2f - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle2), color29, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin3, npc.scale, effects, 0f); return(false); } Vector2 drawOrigin = new Vector2(Main.npcTexture[npc.type].Width * 0.5f, npc.height * 0.5f); for (int k = 0; k < npc.oldPos.Length; k++) { Vector2 drawPos = npc.oldPos[k] - Main.screenPosition + drawOrigin + new Vector2(0f, npc.gfxOffY); Color color = npc.GetAlpha(lightColor) * ((float)(npc.oldPos.Length - k) / (float)npc.oldPos.Length); Texture2D shadowTexture = mod.GetTexture("NPCs/Boss/CosmicApparition/CosmicApparition_Shadow"); spriteBatch.Draw(shadowTexture, drawPos, null, color, npc.rotation, drawOrigin, npc.scale, SpriteEffects.None, 0f); } return(true); }
public void FlipGroup(SpriteEffects flip) { if (flip == SpriteEffects.None) return; if (SelectedPartEntities.Count <= 0) return; var centroid = SelectedPartEntities.Aggregate(Vector2.Zero, (ta, e) => ta += e.GetComponent<Transform>().Position) / SelectedPartEntities.Count; foreach (var item in SelectedPartEntities.Select(e => e.GetComponent<IShipPartComponent>().Part)) { //if (item is Hull) //{ // var hull = (Hull)item; // hull.SpriteEffect ^= flip; //} if (flip.HasFlag(SpriteEffects.FlipHorizontally)) item.Transform.Scale *= new Vector2(-1, 1); if (flip.HasFlag(SpriteEffects.FlipVertically)) item.Transform.Scale *= new Vector2(1, -1); if (flip == SpriteEffects.FlipVertically) { item.Transform.Position = new Vector2( item.Transform.Position.X, item.Transform.Position.Y - (item.Transform.Position.Y - centroid.Y)*2 ); } else if(flip == SpriteEffects.FlipHorizontally) { item.Transform.Position = new Vector2( item.Transform.Position.X - (item.Transform.Position.X - centroid.X) * 2, item.Transform.Position.Y ); } } }
public void FlipLocal(SpriteEffects flip) { if (SelectedPartEntities.Count <= 0) return; foreach(var item in SelectedPartEntities.Select(e => e.GetComponent<IShipPartComponent>().Part)) { //if(item is Hull) //{ // var hull = (Hull)item; // hull.SpriteEffect ^= fx; //} if (flip.HasFlag(SpriteEffects.FlipHorizontally)) item.Transform.Position *= new Vector2(-1, 1); if (flip.HasFlag(SpriteEffects.FlipVertically)) item.Transform.Position *= new Vector2(1, -1); } }
/*public override void SendExtraAI(BinaryWriter writer) * { * writer.Write(phase2); * } * * public override void ReceiveExtraAI(BinaryReader reader) * { * phase2 = reader.ReadBoolean(); * }*/ public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); Texture2D texture2D3 = mod.GetTexture("NPCs/Acheron/AcheronGhost"); int num156 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; int y3 = num156 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int arg_5ADA_0 = npc.type; int arg_5AE7_0 = npc.type; int arg_5AF4_0 = npc.type; int num157 = 10; int num158 = 2; int num159 = 1; float value3 = 1f; float num160 = 0f; int num161 = num159; if (phase2) { Texture2D texture2D4 = mod.GetTexture("NPCs/FaceOfInsanity/ArteriusP2"); int num1561 = texture2D4.Height / Main.npcFrameCount[npc.type]; int y31 = num1561 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, y31, texture2D4.Width, num1561); Vector2 origin3 = rectangle2.Size() / 2f; SpriteEffects effects = spriteEffects; if (npc.spriteDirection > 0) { effects = SpriteEffects.FlipHorizontally; } float num165 = npc.rotation; Microsoft.Xna.Framework.Color color29 = npc.GetAlpha(color25); Main.spriteBatch.Draw(texture2D4, npc.position + npc.Size / 2f - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle2), color29, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin3, npc.scale, effects, 0f); return(false); } else { var allahuakbar = npc.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(Main.npcTexture[npc.type], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, lightColor, npc.rotation, npc.frame.Size() / 2, npc.scale, allahuakbar, 0); } return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); Texture2D texture2D3 = Main.npcTexture[npc.type]; int num156 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; int y3 = num156 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int arg_5ADA_0 = npc.type; int arg_5AE7_0 = npc.type; int arg_5AF4_0 = npc.type; int num157 = 10; int num158 = 2; int num159 = 1; float value3 = 1f; float num160 = 0f; int num161 = num159; while (npc.velocity != Vector2.Zero && ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) { Microsoft.Xna.Framework.Color color26 = color25; color26 = npc.GetAlpha(color26); { goto IL_6899; } color26 = Microsoft.Xna.Framework.Color.Lerp(color26, Microsoft.Xna.Framework.Color.Orange, 0.5f); IL_6881: num161 += num158; continue; IL_6899: float num164 = (float)(num157 - num161); if (num158 < 0) { num164 = (float)(num159 - num161); } color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); Vector2 value4 = (npc.oldPos[num161]); float num165 = npc.rotation; SpriteEffects effects = spriteEffects; Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, effects, 0f); goto IL_6881; } Microsoft.Xna.Framework.Color color29 = npc.GetAlpha(color25); return(true); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { { SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)projectile.position.X + (double)projectile.width * 0.5) / 16, (int)(((double)projectile.position.Y + (double)projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = Main.projectileTexture[projectile.type]; int num156 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y3 = num156 * projectile.frame; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int arg_5ADA_0 = projectile.type; int arg_5AE7_0 = projectile.type; int arg_5AF4_0 = projectile.type; int num157 = 8; int num158 = 2; int num159 = 1; float value3 = 1f; float num160 = 0f; { //num157 = 3; num158 = 1; value3 = 8f; //rectangle = new Microsoft.Xna.Framework.Rectangle(25 * projectile.frame, 0, 36, 14); origin2 = rectangle.Size() / 2f; } int num161 = num159; while ((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157)) { Microsoft.Xna.Framework.Color color26 = color25; color26 = projectile.GetAlpha(color26); { goto IL_6899; } IL_6881: num161 += num158; continue; IL_6899: float num164 = (float)(num157 - num161); if (num158 < 0) { num164 = (float)(num159 - num161); } color26 *= num164 / ((float)ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f); Vector2 value4 = projectile.oldPos[num161]; float num165 = projectile.rotation; SpriteEffects effects = spriteEffects; if (ProjectileID.Sets.TrailingMode[projectile.type] == 2) { num165 = projectile.oldRot[num161]; effects = ((projectile.oldSpriteDirection[num161] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None); } color26.A /= (byte)2; Main.spriteBatch.Draw(texture2D3, value4 + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + projectile.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, projectile.scale, effects, 0f); goto IL_6881; } } { Texture2D texture2D3 = Main.projectileTexture[projectile.type]; int num156 = Main.projectileTexture[projectile.type].Height / Main.projFrames[projectile.type]; int y3 = num156 * projectile.frame; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; Main.spriteBatch.Draw(Main.projectileTexture[projectile.type], projectile.position + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), Color.White, projectile.rotation, origin2, projectile.scale, SpriteEffects.None, 0f); } return(false); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { Texture2D texture = Main.projectileTexture[projectile.type]; Rectangle rectangle = texture.Frame(14, 1, projectile.frame, 0); Vector2 drawPosition = projectile.Center - Main.screenPosition; float hitboxOffsetFloat = ((((rectangle.Width + rectangle.Height) * 0.5f) - ((projectile.width + projectile.height) * 0.5f)) * 0.5f); Vector2 hitboxOffset = new Vector2(-hitboxOffsetFloat, hitboxOffsetFloat).RotatedBy(projectile.rotation); Vector2 origin = rectangle.Size() * 0.5f; float sineScale = (float)Math.Sin(projectile.timeLeft * 0.4f) * 0.5f + 1f; Color phaseColor = new Color(rainbowColor.R, rainbowColor.G, rainbowColor.B, 0); Color color; SpriteEffects spriteEffects = projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; for (int i = 0; i < projectile.oldPos.Length; i++) { spriteEffects = projectile.oldSpriteDirection[i] == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Vector2 trailPosition = projectile.oldPos[i] - Main.screenPosition + projectile.Size * 0.5f; color = phaseColor * ((float)(projectile.oldPos.Length - i) / (float)projectile.oldPos.Length); spriteBatch.Draw(texture, trailPosition + hitboxOffset, rectangle, color, projectile.oldRot[i] + projectile.rotation * 0f * (float)(i - 1) * (float)(-spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt()), origin, projectile.scale * (projectile.scale * (i * 0.25f)), spriteEffects, 0f); } spriteBatch.Draw(texture, drawPosition + hitboxOffset, rectangle, phaseColor, projectile.rotation, origin, projectile.scale * sineScale, spriteEffects, 0f); color = new Color(255, 255, 255, phaseColor.A) * (1f - projectile.alpha / 255f); spriteBatch.Draw(texture, drawPosition + hitboxOffset, rectangle, color, projectile.rotation, origin, projectile.scale, spriteEffects, 0f); return(false); }
public void GUIDrawSprite(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle = null, Color? color = null, SpriteEffects effects = SpriteEffects.None) { if (texture == null) return; Vector4 dest = new Vector4(destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Right, destinationRectangle.Bottom); Vector4 srcDelta = new Vector4(); if (sourceRectangle == null) sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height); // clipping if (dest.X < m_GUIClipRect.X) { if (dest.Z < m_GUIClipRect.X) return; float delta = m_GUIClipRect.X - dest.X; dest.X += delta; srcDelta.X = delta / destinationRectangle.Width; } if (dest.Z > m_GUIClipRect.Z) { if (dest.X > m_GUIClipRect.Z) return; float delta = m_GUIClipRect.Z - dest.Z; dest.Z += delta; srcDelta.Z = delta / destinationRectangle.Width; } if (dest.Y < m_GUIClipRect.Y) { if (dest.W < m_GUIClipRect.Y) return; float delta = m_GUIClipRect.Y - dest.Y; dest.Y += delta; srcDelta.Y = delta / destinationRectangle.Width; } if (dest.W > m_GUIClipRect.W) { if (dest.Y > m_GUIClipRect.W) return; float delta = m_GUIClipRect.W - dest.W; dest.W += delta; srcDelta.W = delta / destinationRectangle.Width; } Vector4 source = new Vector4( sourceRectangle.Value.X, sourceRectangle.Value.Y, sourceRectangle.Value.Right, sourceRectangle.Value.Bottom); if (effects.HasFlag(SpriteEffects.FlipHorizontally)) { float x = source.X; source.X = source.Z; source.Z = x; } if (effects.HasFlag(SpriteEffects.FlipVertically)) { float y = source.Y; source.Y = source.W; source.W = y; } float width = texture.Width; float height = texture.Height; source.X /= width; source.Y /= height; source.Z /= width; source.W /= height; source.X += srcDelta.X * ((float)sourceRectangle.Value.Width / width); source.Y += srcDelta.Y * ((float)sourceRectangle.Value.Height / height); source.Z += srcDelta.Z * ((float)sourceRectangle.Value.Width / width); source.W += srcDelta.W * ((float)sourceRectangle.Value.Height / height); source.Y -= (0.5f / height); source.W -= (0.5f / height); Shape quad = Shape.CreateQuad( new Vector3(destinationRectangle.X, destinationRectangle.Y, 0), new Vector2(destinationRectangle.Width, destinationRectangle.Height), source, color); List<VertexPositionTextureHueExtra> vertexList = InternalGetVertexList(); for (int i = 0; i < quad.Vertices.Length; i++) { quad.Vertices[i].Position.Z = m_zOffset; vertexList.Add(quad.Vertices[i]); } // increment z offset for the spritebatch. m_zOffset++; m_DrawCommands.Add(new TextureAndVertexList(texture, vertexList)); }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects effect = projectile.direction == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Color col = Lighting.GetColor((int)(projectile.Center.Y) / 16, (int)(projectile.Center.Y) / 16); var basePos = projectile.Center - Main.screenPosition + new Vector2(0.0f, projectile.gfxOffY); Texture2D texture = Main.projectileTexture[projectile.type]; int height = texture.Height / Main.projFrames[projectile.type]; var frame = new Rectangle(0, height * projectile.frame, texture.Width, height); Vector2 origin = frame.Size() / 2f; int reps = 1; while (reps < 5) { col = projectile.GetAlpha(Color.Lerp(col, Color.White, 2.5f)); float num7 = 5 - reps; Color drawCol = col * (num7 / (ProjectileID.Sets.TrailCacheLength[projectile.type] * 1.5f)); Vector2 oldPo = projectile.oldPos[reps]; float rotation = projectile.rotation; SpriteEffects effects2 = effect; if (ProjectileID.Sets.TrailingMode[projectile.type] == 2) { rotation = projectile.oldRot[reps]; effects2 = projectile.oldSpriteDirection[reps] == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } Vector2 drawPos = oldPo + projectile.Size / 2f - Main.screenPosition + new Vector2(0f, projectile.gfxOffY); Main.spriteBatch.Draw(texture, drawPos, frame, drawCol, rotation + projectile.rotation * (reps - 1) * -effect.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin, MathHelper.Lerp(projectile.scale, 3f, reps / 15f), effects2, 0.0f); reps++; } Main.spriteBatch.Draw(texture, basePos, frame, new Color(255 - projectile.alpha, 255 - projectile.alpha, 255 - projectile.alpha, 175), projectile.rotation, origin, projectile.scale, effect, 0.0f); height = texture.Height / Main.projFrames[projectile.type]; frame = new Rectangle(0, height * projectile.frame, texture.Width, height); origin = new Vector2(texture.Width / 2, texture.Height / 2); float num99 = (float)(Math.Cos(Main.GlobalTime % 2.40000009536743 / 2.40000009536743 * MathHelper.TwoPi) / 4.0f + 0.5f); Color color2 = new Color(sbyte.MaxValue - projectile.alpha, sbyte.MaxValue - projectile.alpha, sbyte.MaxValue - projectile.alpha, 0).MultiplyRGBA(Color.White); for (int i = 0; i < 4; ++i) { Color drawCol = projectile.GetAlpha(color2) * (1f - num99); Vector2 offset = ((i / 4 * MathHelper.TwoPi) + projectile.rotation).ToRotationVector2(); Vector2 position2 = projectile.Center + offset * (8.0f * num99 + 2.0f) - Main.screenPosition - texture.Size() * projectile.scale / 2f + origin * projectile.scale + new Vector2(0.0f, projectile.gfxOffY); Main.spriteBatch.Draw(texture, position2, frame, drawCol, projectile.rotation, origin, projectile.scale, effect, 0.0f); } Lighting.AddLight(projectile.Center, Color.Purple.ToVector3() / 2f); return(false); }
public override bool PreDraw(ref Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; Color color25 = Lighting.GetColor((int)(Projectile.position.X + Projectile.width * 0.5) / 16, (int)((Projectile.position.Y + Projectile.height * 0.5) / 16.0)); Texture2D texture2D3 = TextureAssets.Projectile[Projectile.type].Value; int num156 = TextureAssets.Projectile[Projectile.type].Value.Height / Main.projFrames[Projectile.type]; int y3 = num156 * Projectile.frame; Rectangle rectangle = new Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int num157 = 7; int num159 = 0; float num160 = 0f; int num161 = num159; while (Projectile.ai[0] != 1 && num161 < num157) //doesnt draw trail while stuck in enemy { Color color26 = color25; color26 = Projectile.GetAlpha(color26); float num164 = (num157 - num161); color26 *= num164 / (ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); color26 *= 0.75f; Vector2 value4 = Projectile.oldPos[num161]; float num165 = Projectile.rotation; SpriteEffects effects = spriteEffects; Main.EntitySpriteDraw(texture2D3, value4 + Projectile.Size / 2f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + Projectile.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, Projectile.scale * 0.8f, effects, 0); num161++; } Color color29 = Projectile.GetAlpha(color25); Main.EntitySpriteDraw(texture2D3, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle), color29, Projectile.rotation, origin2, Projectile.scale, spriteEffects, 0); return(false); }
public Command( Texture2D texture, Vector2 pos, Rectangle srcRect, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float depth, int index) { int srcRectLeft = srcRect.Left; int srcRectRight = srcRect.Right; int srcRectTop = srcRect.Top; int srcRectBottom = srcRect.Bottom; if (effects.HasFlag(SpriteEffects.FlipHorizontally)) { var temp = srcRectRight; srcRectRight = srcRectLeft; srcRectLeft = temp; } if (effects.HasFlag(SpriteEffects.FlipVertically)) { var temp = srcRectBottom; srcRectBottom = srcRectTop; srcRectTop = temp; } rotation = MathHelper.ToRadians(rotation); float sin = (float)Math.Sin(rotation); float cos = (float)Math.Cos(rotation); var size = srcRect.Size.ToVector2() * scale; Vector2 wAdd = new Vector2(size.X * cos, size.X * sin); Vector2 hAdd = new Vector2(-size.Y * sin, size.Y * cos); pos.X -= origin.X * scale.X * cos - origin.Y * scale.Y * sin; pos.Y -= origin.Y * scale.Y * cos + origin.X * scale.X * sin; Texture = texture; Depth = depth; VertexTL.Color = color; VertexTR.Color = color; VertexBL.Color = color; VertexBR.Color = color; VertexTL.Position = new Vector3(pos.X, pos.Y, 0f); VertexTR.Position = new Vector3(pos.X + wAdd.X, pos.Y + wAdd.Y, 0f); VertexBL.Position = new Vector3(pos.X + hAdd.X, pos.Y + hAdd.Y, 0f); VertexBR.Position = new Vector3(pos.X + wAdd.X + hAdd.X, pos.Y + wAdd.Y + hAdd.Y, 0f); Min = new Vector2( MathUtils.Min ( VertexTL.Position.X, VertexTR.Position.X, VertexBL.Position.X, VertexBR.Position.X ), MathUtils.Min ( VertexTL.Position.Y, VertexTR.Position.Y, VertexBL.Position.Y, VertexBR.Position.Y )); Max = new Vector2( MathUtils.Max ( VertexTL.Position.X, VertexTR.Position.X, VertexBL.Position.X, VertexBR.Position.X ), MathUtils.Max ( VertexTL.Position.Y, VertexTR.Position.Y, VertexBL.Position.Y, VertexBR.Position.Y )); VertexTL.TextureCoordinate = new Vector2((float)srcRectLeft / (float)texture.Width, (float)srcRectTop / (float)texture.Height); VertexTR.TextureCoordinate = new Vector2((float)srcRectRight / (float)texture.Width, (float)srcRectTop / (float)texture.Height); VertexBL.TextureCoordinate = new Vector2((float)srcRectLeft / (float)texture.Width, (float)srcRectBottom / (float)texture.Height); VertexBR.TextureCoordinate = new Vector2((float)srcRectRight / (float)texture.Width, (float)srcRectBottom / (float)texture.Height); Index = index; }
public override bool PreDraw(ref Color lightColor) { SpriteEffects spriteEffects = Projectile.spriteDirection > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; Rectangle origSourceRect = texture.Frame(1, Main.projFrames[Projectile.type], frameY: Projectile.frame); Vector2 origin = origSourceRect.Size() / 2f; //Extra offset origin.X = (Projectile.spriteDirection == 1) ? (origSourceRect.Width - 20) : 20; //TODO Generic projectile trail code, maybe make a method? int trailMax = 5; int trailStep = 1; int trailStart = 1; float trailMaxScale = 2.6f; float trailScaleDenominator = 15f; float trailRotAffection = 0f; Rectangle sourceRect = origSourceRect; Vector2 gfxOffY = new Vector2(0f, Projectile.gfxOffY); //Draw trail for (int i = trailStart; (trailStep > 0 && i < trailMax) || (trailStep < 0 && i > trailMax); i += trailStep) { if (i >= Projectile.oldPos.Length) { continue; } float lastTrailIndex = trailMax - i; if (trailStep < 0) { lastTrailIndex = trailStart - i; } Color trailColor = Color.Black * Projectile.Opacity; trailColor *= lastTrailIndex / (ProjectileID.Sets.TrailCacheLength[Projectile.type] * 1.5f); Vector2 oldPos = Projectile.oldPos[i]; float trailRot = Projectile.rotation; SpriteEffects trailEffects = spriteEffects; int mode = ProjectileID.Sets.TrailingMode[Projectile.type]; if (mode == 2 || mode == 3 || mode == 4) { trailRot = Projectile.oldRot[i]; trailEffects = (Projectile.oldSpriteDirection[i] == -1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None; } if (oldPos == Vector2.Zero) { continue; } Vector2 trailPos = oldPos + Projectile.Size / 2f - Main.screenPosition + gfxOffY; Main.EntitySpriteDraw(texture, trailPos, sourceRect, trailColor, trailRot + Projectile.rotation * trailRotAffection * (i - 1f) * -spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin, MathHelper.Lerp(Projectile.scale, trailMaxScale, i / trailScaleDenominator), trailEffects, 0); } Color outlineColor = Color.Lerp(Color.Red, Color.White, 0.5f); //Draw "spooky" outline outlineColor = outlineColor * 0.5f * Projectile.Opacity; float outlineRotationDenominator = 60; for (int i = 0; i < 4; i++) { Vector2 outlinePos = Projectile.Center - Main.screenPosition + gfxOffY + Projectile.rotation.ToRotationVector2().RotatedBy((180 + Counter) / outlineRotationDenominator * MathHelper.TwoPi + MathHelper.PiOver2 * i) * 6f; Main.EntitySpriteDraw(texture, outlinePos, origSourceRect, outlineColor, Projectile.rotation, origin, Projectile.scale, spriteEffects, 0); } //Draw actual projectile Color drawColor = Color.Black * Projectile.Opacity; float drawScale = Projectile.scale; float drawRotation = Projectile.rotation; Vector2 drawPos = Projectile.Center - Main.screenPosition + gfxOffY; Main.EntitySpriteDraw(texture, drawPos, origSourceRect, drawColor, drawRotation, origin, drawScale, spriteEffects, 0); return(false); }
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { if (!Visible) { return; } Color color = (IsSelected && editing) ? color = Color.Red : spriteColor; if (isHighlighted) { color = Color.Orange; } SpriteEffects oldEffects = prefab.sprite.effects; prefab.sprite.effects ^= SpriteEffects; if (prefab.sprite != null) { float depth = GetDrawDepth(); if (body == null) { if (prefab.ResizeHorizontal || prefab.ResizeVertical || SpriteEffects.HasFlag(SpriteEffects.FlipHorizontally) || SpriteEffects.HasFlag(SpriteEffects.FlipVertically)) { prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), color); } else { prefab.sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, 0.0f, 1.0f, SpriteEffects.None, depth); } } else if (body.Enabled) { var holdable = GetComponent <Holdable>(); if (holdable != null && holdable.Picker?.AnimController != null) { if (holdable.Picker.SelectedItems[0] == this) { depth = holdable.Picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.000001f; } else if (holdable.Picker.SelectedItems[1] == this) { depth = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm).sprite.Depth - 0.000001f; } body.Draw(spriteBatch, prefab.sprite, color, depth); } else { body.Draw(spriteBatch, prefab.sprite, color, depth); } } } prefab.sprite.effects = oldEffects; List <IDrawableComponent> staticDrawableComponents = new List <IDrawableComponent>(drawableComponents); //static list to compensate for drawable toggling for (int i = 0; i < staticDrawableComponents.Count; i++) { staticDrawableComponents[i].Draw(spriteBatch, editing); } if (GameMain.DebugDraw && aiTarget != null) { aiTarget.Draw(spriteBatch); } if (!editing || (body != null && !body.Enabled)) { return; } if (IsSelected || isHighlighted) { GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), Color.Green, false, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f)); foreach (Rectangle t in prefab.Triggers) { Rectangle transformedTrigger = TransformTrigger(t); Vector2 rectWorldPos = new Vector2(transformedTrigger.X, transformedTrigger.Y); if (Submarine != null) { rectWorldPos += Submarine.Position; } rectWorldPos.Y = -rectWorldPos.Y; GUI.DrawRectangle(spriteBatch, rectWorldPos, new Vector2(transformedTrigger.Width, transformedTrigger.Height), Color.Green, false, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f)); } } if (!ShowLinks) { return; } foreach (MapEntity e in linkedTo) { GUI.DrawLine(spriteBatch, new Vector2(WorldPosition.X, -WorldPosition.Y), new Vector2(e.WorldPosition.X, -e.WorldPosition.Y), Color.Red * 0.3f); } }
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { if (!Visible) { return; } Color color = (IsSelected && editing) ? Color.Red : GetSpriteColor(); if (isHighlighted) { color = Color.Orange; } Sprite activeSprite = prefab.sprite; BrokenItemSprite fadeInBrokenSprite = null; float fadeInBrokenSpriteAlpha = 0.0f; if (condition < 100.0f) { for (int i = 0; i < prefab.BrokenSprites.Count; i++) { if (condition <= prefab.BrokenSprites[i].MaxCondition) { activeSprite = prefab.BrokenSprites[i].Sprite; break; } if (prefab.BrokenSprites[i].FadeIn) { float min = i > 0 ? prefab.BrokenSprites[i].MaxCondition : 0.0f; float max = i < prefab.BrokenSprites.Count - 1 ? prefab.BrokenSprites[i + 1].MaxCondition : 100.0f; fadeInBrokenSpriteAlpha = 1.0f - ((condition - min) / (max - min)); if (fadeInBrokenSpriteAlpha > 0.0f && fadeInBrokenSpriteAlpha < 1.0f) { fadeInBrokenSprite = prefab.BrokenSprites[i]; } } } } Sprite selectedSprite = prefab.GetActiveSprite(condition); if (selectedSprite != null) { SpriteEffects oldEffects = selectedSprite.effects; selectedSprite.effects ^= SpriteEffects; float depth = GetDrawDepth(); if (body == null) { if (prefab.ResizeHorizontal || prefab.ResizeVertical || SpriteEffects.HasFlag(SpriteEffects.FlipHorizontally) || SpriteEffects.HasFlag(SpriteEffects.FlipVertically)) { selectedSprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), color); fadeInBrokenSprite?.Sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), color * fadeInBrokenSpriteAlpha, Point.Zero, selectedSprite.Depth - 0.000001f); } else { selectedSprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, 0.0f, 1.0f, SpriteEffects.None, depth); fadeInBrokenSprite?.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color * fadeInBrokenSpriteAlpha, 0.0f, 1.0f, SpriteEffects.None, depth - 0.000001f); } } else if (body.Enabled) { var holdable = GetComponent <Holdable>(); if (holdable != null && holdable.Picker?.AnimController != null) { if (holdable.Picker.SelectedItems[0] == this) { Limb holdLimb = holdable.Picker.AnimController.GetLimb(LimbType.RightHand); depth = holdLimb.sprite.Depth + 0.000001f; foreach (WearableSprite wearableSprite in holdLimb.WearingItems) { if (!wearableSprite.InheritLimbDepth && wearableSprite.Sprite != null) { depth = Math.Min(wearableSprite.Sprite.Depth, depth); } } } else if (holdable.Picker.SelectedItems[1] == this) { Limb holdLimb = holdable.Picker.AnimController.GetLimb(LimbType.LeftHand); depth = holdLimb.sprite.Depth - 0.000001f; foreach (WearableSprite wearableSprite in holdLimb.WearingItems) { if (!wearableSprite.InheritLimbDepth && wearableSprite.Sprite != null) { depth = Math.Max(wearableSprite.Sprite.Depth, depth); } } } } body.Draw(spriteBatch, selectedSprite, color, depth); if (fadeInBrokenSprite != null) { body.Draw(spriteBatch, fadeInBrokenSprite.Sprite, color * fadeInBrokenSpriteAlpha, depth - 0.000001f); } } selectedSprite.effects = oldEffects; } List <IDrawableComponent> staticDrawableComponents = new List <IDrawableComponent>(drawableComponents); //static list to compensate for drawable toggling for (int i = 0; i < staticDrawableComponents.Count; i++) { staticDrawableComponents[i].Draw(spriteBatch, editing); } if (GameMain.DebugDraw && aiTarget != null) { aiTarget.Draw(spriteBatch); } if (!editing || (body != null && !body.Enabled)) { return; } if (IsSelected || isHighlighted) { GUI.DrawRectangle(spriteBatch, new Vector2(DrawPosition.X - rect.Width / 2, -(DrawPosition.Y + rect.Height / 2)), new Vector2(rect.Width, rect.Height), Color.Green, false, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f)); foreach (Rectangle t in prefab.Triggers) { Rectangle transformedTrigger = TransformTrigger(t); Vector2 rectWorldPos = new Vector2(transformedTrigger.X, transformedTrigger.Y); if (Submarine != null) { rectWorldPos += Submarine.Position; } rectWorldPos.Y = -rectWorldPos.Y; GUI.DrawRectangle(spriteBatch, rectWorldPos, new Vector2(transformedTrigger.Width, transformedTrigger.Height), Color.Green, false, 0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f)); } } if (!ShowLinks) { return; } foreach (MapEntity e in linkedTo) { GUI.DrawLine(spriteBatch, new Vector2(WorldPosition.X, -WorldPosition.Y), new Vector2(e.WorldPosition.X, -e.WorldPosition.Y), Color.Red * 0.3f); } }
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor) { SpriteEffects spriteEffects = SpriteEffects.None; Microsoft.Xna.Framework.Color color25 = Lighting.GetColor((int)((double)npc.position.X + (double)npc.width * 0.5) / 16, (int)(((double)npc.position.Y + (double)npc.height * 0.5) / 16.0)); Texture2D texture2D3 = mod.GetTexture("NPCs/Acheron/AcheronGhost"); int num156 = Main.npcTexture[npc.type].Height / Main.npcFrameCount[npc.type]; int y3 = num156 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(0, y3, texture2D3.Width, num156); Vector2 origin2 = rectangle.Size() / 2f; int arg_5ADA_0 = npc.type; int arg_5AE7_0 = npc.type; int arg_5AF4_0 = npc.type; int num157 = 10; int num158 = 2; int num159 = 1; float value3 = 1f; float num160 = 0f; int num161 = num159; while (((num158 > 0 && num161 < num157) || (num158 < 0 && num161 > num157))) { Microsoft.Xna.Framework.Color color26 = color25; color26 = npc.GetAlpha(color26); { goto IL_6899; } color26 = Microsoft.Xna.Framework.Color.Lerp(color26, Microsoft.Xna.Framework.Color.Blue, 0.5f); color26.A += (byte)(150); IL_6881: num161 += num158; continue; IL_6899: float num164 = (float)(num157 - num161); if (num158 < 0) { num164 = (float)(num159 - num161); } color26 *= num164 / ((float)NPCID.Sets.TrailCacheLength[npc.type] * 1.5f); Vector2 value4 = (npc.oldPos[num161]); float num165 = npc.rotation; SpriteEffects effects = spriteEffects; Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(15f, npc.gfxOffY).RotatedBy(npc.rotation), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, effects, 0f); Main.spriteBatch.Draw(texture2D3, value4 + npc.Size / 2f - Main.screenPosition + new Vector2(-15f, npc.gfxOffY).RotatedBy(npc.rotation), new Microsoft.Xna.Framework.Rectangle?(rectangle), color26, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin2, npc.scale, effects, 0f); goto IL_6881; } if (phase2) { Texture2D texture2D4 = mod.GetTexture("NPCs/Acheron/AcheronP2"); int num1561 = texture2D4.Height / Main.npcFrameCount[npc.type]; int y31 = num1561 * (int)npc.frameCounter; Microsoft.Xna.Framework.Rectangle rectangle2 = new Microsoft.Xna.Framework.Rectangle(0, y31, texture2D4.Width, num1561); Vector2 origin3 = rectangle2.Size() / 2f; SpriteEffects effects = spriteEffects; if (npc.spriteDirection > 0) { effects = SpriteEffects.FlipHorizontally; } float num165 = npc.rotation; Microsoft.Xna.Framework.Color color29 = npc.GetAlpha(color25); Main.spriteBatch.Draw(texture2D4, npc.position + npc.Size / 2f - Main.screenPosition + new Vector2(0f, npc.gfxOffY), new Microsoft.Xna.Framework.Rectangle?(rectangle2), color29, num165 + npc.rotation * num160 * (float)(num161 - 1) * -(float)spriteEffects.HasFlag(SpriteEffects.FlipHorizontally).ToDirectionInt(), origin3, npc.scale, effects, 0f); return(false); } var allahuakbar = npc.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; spriteBatch.Draw(Main.npcTexture[npc.type], npc.Center - Main.screenPosition + new Vector2(0, npc.gfxOffY), npc.frame, lightColor, npc.rotation, npc.frame.Size() / 2, npc.scale, allahuakbar, 0); return(false); }
internal static bool OnDraw( this XSpriteBatch @this, ref XTexture2D?texture, ref XVector2 position, ref XRectangle?source, ref XColor color, float rotation, ref XVector2 origin, ref XVector2 scale, SpriteEffects effects, ref float layerDepth ) { if (texture is null) { return(false); } GetDrawParameters( texture: texture, source: source, bounds: out var sourceRectangle, scaleFactor: out var scaleFactor ); var originalSourceRect = sourceRectangle; ManagedSpriteInstance?spriteInstance; ManagedTexture2D? resampledTexture; if (texture is ManagedTexture2D texture2D) { resampledTexture = texture2D; spriteInstance = resampledTexture.SpriteInstance; sourceRectangle = resampledTexture.Dimensions; } else if (texture.FetchScaledTexture( expectedScale: EstimateScale(scale, scaleFactor), source: ref sourceRectangle, spriteInstance: out spriteInstance, create: true )) { spriteInstance.UpdateReferenceFrame(); resampledTexture = spriteInstance.Texture !; } else { resampledTexture = null; } if (spriteInstance is null || resampledTexture is null) { return(Continue); } if (originalSourceRect.X < 0) { position.X -= originalSourceRect.X * scale.X; } if (originalSourceRect.Y < 0) { position.Y -= originalSourceRect.Y * scale.Y; } var adjustedScale = (Vector2F)scale / spriteInstance.Scale; var adjustedPosition = position; var adjustedOrigin = (Vector2F)origin; if (spriteInstance.TexType == TextureType.SlicedImage) { sourceRectangle = source ?? resampledTexture.Bounds; if (source is not null) { sourceRectangle = new Bounds( (Vector2I)source.Value.Location - spriteInstance.OriginalSourceRectangle.Offset, source.Value.Size ); sourceRectangle.Offset = (sourceRectangle.OffsetF * spriteInstance.Scale).NearestInt(); sourceRectangle.Extent = (sourceRectangle.ExtentF * spriteInstance.Scale).NearestInt(); } } if (!spriteInstance.Padding.IsZero) { var paddingX = spriteInstance.Padding.X; var paddingY = spriteInstance.Padding.Y; if (effects.HasFlag(SpriteEffects.FlipHorizontally)) { paddingX = (paddingX.Y, paddingX.X); } if (effects.HasFlag(SpriteEffects.FlipVertically)) { paddingY = (paddingY.Y, paddingY.X); } var padding = new PaddingQuad(paddingX, paddingY); var textureSize = new Vector2F(sourceRectangle.Extent); var innerSize = (Vector2F)spriteInstance.UnpaddedSize; // This is the scale factor to bring the inner size to the draw size. var innerRatio = textureSize / innerSize; // spriteInstance.InnerRatio; // Scale the... scale by the scale factor. adjustedScale *= innerRatio; adjustedOrigin *= spriteInstance.Scale; adjustedOrigin /= innerRatio; adjustedOrigin += (Vector2F)padding.Offset; } else { adjustedOrigin *= spriteInstance.Scale; } if (source.HasValue) { sourceRectangle.Invert.X = source.Value.Width < 0; sourceRectangle.Invert.Y = source.Value.Height < 0; } if (Debug.Mode.RegisterDrawForSelect( instance: spriteInstance, texture: texture, originalPosition: position, originalSource: source, position: adjustedPosition, source: sourceRectangle, color: color, rotation: rotation, originalOrigin: origin, origin: adjustedOrigin, scale: adjustedScale, effects: effects, layerDepth: layerDepth )) { color = XColor.Red; } texture = resampledTexture; source = sourceRectangle; origin = adjustedOrigin; scale = adjustedScale; position = adjustedPosition; return(Continue); }