Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Draw()

override void Terraria.GameContent.Skies.SolarSky.Draw ( SpriteBatch spriteBatch,
float minDepth,
float maxDepth )
inline

Definition at line 74 of file SolarSky.cs.

75 {
76 if (maxDepth >= float.MaxValue && minDepth < float.MaxValue)
77 {
78 spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * _fadeOpacity);
79 spriteBatch.Draw(_bgTexture.Value, new Rectangle(0, Math.Max(0, (int)((Main.worldSurface * 16.0 - (double)Main.screenPosition.Y - 2400.0) * 0.10000000149011612)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (Main.screenPosition.Y - 800f) / 1000f * _fadeOpacity));
80 Vector2 vector = new Vector2(Main.screenWidth >> 1, Main.screenHeight >> 1);
81 Vector2 vector2 = 0.01f * (new Vector2((float)Main.maxTilesX * 8f, (float)Main.worldSurface / 2f) - Main.screenPosition);
82 spriteBatch.Draw(_planetTexture.Value, vector + new Vector2(-200f, -200f) + vector2, null, Color.White * 0.9f * _fadeOpacity, 0f, new Vector2(_planetTexture.Width() >> 1, _planetTexture.Height() >> 1), 1f, SpriteEffects.None, 1f);
83 }
84 int num = -1;
85 int num2 = 0;
86 for (int i = 0; i < _meteors.Length; i++)
87 {
88 float depth = _meteors[i].Depth;
89 if (num == -1 && depth < maxDepth)
90 {
91 num = i;
92 }
93 if (depth <= minDepth)
94 {
95 break;
96 }
97 num2 = i;
98 }
99 if (num == -1)
100 {
101 return;
102 }
103 float num3 = Math.Min(1f, (Main.screenPosition.Y - 1000f) / 1000f);
104 Vector2 vector3 = Main.screenPosition + new Vector2(Main.screenWidth >> 1, Main.screenHeight >> 1);
105 Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
106 for (int j = num; j < num2; j++)
107 {
108 Vector2 vector4 = new Vector2(1f / _meteors[j].Depth, 0.9f / _meteors[j].Depth);
109 Vector2 position = (_meteors[j].Position - vector3) * vector4 + vector3 - Main.screenPosition;
110 int num4 = _meteors[j].FrameCounter / 3;
111 _meteors[j].FrameCounter = (_meteors[j].FrameCounter + 1) % 12;
112 if (rectangle.Contains((int)position.X, (int)position.Y))
113 {
114 spriteBatch.Draw(_meteorTexture.Value, position, new Rectangle(0, num4 * (_meteorTexture.Height() / 4), _meteorTexture.Width(), _meteorTexture.Height() / 4), Color.White * num3 * _fadeOpacity, 0f, Vector2.Zero, vector4.X * 5f * _meteors[j].Scale, SpriteEffects.None, 0f);
115 }
116 }
117 }
void Draw(Texture2D texture, Vector2 position, Color color)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static byte Max(byte val1, byte val2)
Definition Math.cs:738
Asset< Texture2D > _meteorTexture
Definition SolarSky.cs:31
Asset< Texture2D > _bgTexture
Definition SolarSky.cs:29
Asset< Texture2D > _planetTexture
Definition SolarSky.cs:27
bool Contains(int x, int y)
Definition Rectangle.cs:92

References Terraria.GameContent.Skies.SolarSky._bgTexture, Terraria.GameContent.Skies.SolarSky._fadeOpacity, Terraria.GameContent.Skies.SolarSky._meteors, Terraria.GameContent.Skies.SolarSky._meteorTexture, Terraria.GameContent.Skies.SolarSky._planetTexture, Microsoft.Xna.Framework.Color.Black, Terraria.GameContent.TextureAssets.BlackTile, Microsoft.Xna.Framework.Rectangle.Contains(), Microsoft.Xna.Framework.Graphics.Depth, Terraria.GameContent.Skies.SolarSky.Meteor.Depth, Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(), Terraria.GameContent.Skies.SolarSky.Meteor.FrameCounter, System.Math.Max(), Terraria.Main.maxTilesX, System.Math.Min(), Terraria.GameContent.Skies.SolarSky.Meteor.Position, Terraria.GameContent.Skies.SolarSky.Meteor.Scale, Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, ReLogic.Content.Asset< T >.Value, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Color.White, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Microsoft.Xna.Framework.Vector2.Zero.