Terraria 1.3.5.3 Source Code

This commit is contained in:
MikeyIsBaeYT 2021-10-27 18:03:19 -04:00
commit 4b21dac4b6
503 changed files with 409032 additions and 0 deletions

View file

@ -0,0 +1,72 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.BlizzardSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class BlizzardSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private bool _isActive;
private bool _isLeaving;
private float _opacity;
public override void OnLoad()
{
}
public override void Update(GameTime gameTime)
{
if (Main.gamePaused || !Main.hasFocus)
return;
if (this._isLeaving)
{
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
if ((double) this._opacity >= 0.0)
return;
this._isActive = false;
this._opacity = 0.0f;
}
else
{
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
if ((double) this._opacity <= 1.0)
return;
this._opacity = 1f;
}
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
return;
float num = Math.Min(1f, Main.cloudAlpha * 2f);
Color color = new Color(new Vector4(1f) * Main.bgColor.ToVector4()) * this._opacity * 0.7f * num;
spriteBatch.Draw(Main.magicPixel, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
}
internal override void Activate(Vector2 position, params object[] args)
{
this._isActive = true;
this._isLeaving = false;
}
internal override void Deactivate(params object[] args) => this._isLeaving = true;
public override void Reset()
{
this._opacity = 0.0f;
this._isActive = false;
}
public override bool IsActive() => this._isActive;
}
}

View file

@ -0,0 +1,277 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.MartianSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class MartianSky : CustomSky
{
private MartianSky.Ufo[] _ufos;
private UnifiedRandom _random = new UnifiedRandom();
private int _maxUfos;
private bool _active;
private bool _leaving;
private int _activeUfos;
public override void Update(GameTime gameTime)
{
if (Main.gamePaused || !Main.hasFocus)
return;
int activeUfos = this._activeUfos;
for (int index = 0; index < this._ufos.Length; ++index)
{
MartianSky.Ufo ufo = this._ufos[index];
if (ufo.IsActive)
{
++ufo.Frame;
if (!ufo.Update())
{
if (!this._leaving)
{
ufo.AssignNewBehavior();
}
else
{
ufo.IsActive = false;
--activeUfos;
}
}
}
this._ufos[index] = ufo;
}
if (!this._leaving && activeUfos != this._maxUfos)
{
this._ufos[activeUfos].IsActive = true;
this._ufos[activeUfos++].AssignNewBehavior();
}
this._active = !this._leaving || (uint) activeUfos > 0U;
this._activeUfos = activeUfos;
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) Main.screenPosition.Y > 10000.0)
return;
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._ufos.Length; ++index)
{
float depth = this._ufos[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f));
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = num1; index < num2; ++index)
{
Vector2 vector2_2 = new Vector2(1f / this._ufos[index].Depth, 0.9f / this._ufos[index].Depth);
Vector2 position = (this._ufos[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
if (this._ufos[index].IsActive && rectangle.Contains((int) position.X, (int) position.Y))
{
spriteBatch.Draw(this._ufos[index].Texture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), color * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
if (this._ufos[index].GlowTexture != null)
spriteBatch.Draw(this._ufos[index].GlowTexture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), Color.White * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
}
}
}
private void GenerateUfos()
{
this._maxUfos = (int) (256.0 * (double) ((float) Main.maxTilesX / 4200f));
this._ufos = new MartianSky.Ufo[this._maxUfos];
int num1 = this._maxUfos >> 4;
for (int index = 0; index < num1; ++index)
{
double num2 = (double) index / (double) num1;
this._ufos[index] = new MartianSky.Ufo(Main.extraTexture[5], (float) (Main.rand.NextDouble() * 4.0 + 6.59999990463257));
this._ufos[index].GlowTexture = Main.glowMaskTexture[90];
}
for (int index = num1; index < this._ufos.Length; ++index)
{
double num3 = (double) (index - num1) / (double) (this._ufos.Length - num1);
this._ufos[index] = new MartianSky.Ufo(Main.extraTexture[6], (float) (Main.rand.NextDouble() * 5.0 + 1.60000002384186));
this._ufos[index].Scale = 0.5f;
this._ufos[index].GlowTexture = Main.glowMaskTexture[91];
}
}
internal override void Activate(Vector2 position, params object[] args)
{
this._activeUfos = 0;
this.GenerateUfos();
Array.Sort<MartianSky.Ufo>(this._ufos, (Comparison<MartianSky.Ufo>) ((ufo1, ufo2) => ufo2.Depth.CompareTo(ufo1.Depth)));
this._active = true;
this._leaving = false;
}
internal override void Deactivate(params object[] args) => this._leaving = true;
public override bool IsActive() => this._active;
public override void Reset() => this._active = false;
private abstract class IUfoController
{
public abstract void InitializeUfo(ref MartianSky.Ufo ufo);
public abstract bool Update(ref MartianSky.Ufo ufo);
}
private class ZipBehavior : MartianSky.IUfoController
{
private Vector2 _speed;
private int _ticks;
private int _maxTicks;
public override void InitializeUfo(ref MartianSky.Ufo ufo)
{
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
ufo.Opacity = 0.0f;
float num1 = (float) (MartianSky.Ufo.Random.NextDouble() * 5.0 + 10.0);
double num2 = MartianSky.Ufo.Random.NextDouble() * 0.600000023841858 - 0.300000011920929;
ufo.Rotation = (float) num2;
if (MartianSky.Ufo.Random.Next(2) == 0)
num2 += 3.14159274101257;
this._speed = new Vector2((float) Math.Cos(num2) * num1, (float) Math.Sin(num2) * num1);
this._ticks = 0;
this._maxTicks = MartianSky.Ufo.Random.Next(400, 500);
}
public override bool Update(ref MartianSky.Ufo ufo)
{
if (this._ticks < 10)
ufo.Opacity += 0.1f;
else if (this._ticks > this._maxTicks - 10)
ufo.Opacity -= 0.1f;
ufo.Position += this._speed;
if (this._ticks == this._maxTicks)
return false;
++this._ticks;
return true;
}
}
private class HoverBehavior : MartianSky.IUfoController
{
private int _ticks;
private int _maxTicks;
public override void InitializeUfo(ref MartianSky.Ufo ufo)
{
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
ufo.Opacity = 0.0f;
ufo.Rotation = 0.0f;
this._ticks = 0;
this._maxTicks = MartianSky.Ufo.Random.Next(120, 240);
}
public override bool Update(ref MartianSky.Ufo ufo)
{
if (this._ticks < 10)
ufo.Opacity += 0.1f;
else if (this._ticks > this._maxTicks - 10)
ufo.Opacity -= 0.1f;
if (this._ticks == this._maxTicks)
return false;
++this._ticks;
return true;
}
}
private struct Ufo
{
private const int MAX_FRAMES = 3;
private const int FRAME_RATE = 4;
public static UnifiedRandom Random = new UnifiedRandom();
private int _frame;
private Texture2D _texture;
private MartianSky.IUfoController _controller;
public Texture2D GlowTexture;
public Vector2 Position;
public int FrameHeight;
public int FrameWidth;
public float Depth;
public float Scale;
public float Opacity;
public bool IsActive;
public float Rotation;
public int Frame
{
get => this._frame;
set => this._frame = value % 12;
}
public Texture2D Texture
{
get => this._texture;
set
{
this._texture = value;
this.FrameWidth = value.Width;
this.FrameHeight = value.Height / 3;
}
}
public MartianSky.IUfoController Controller
{
get => this._controller;
set
{
this._controller = value;
value.InitializeUfo(ref this);
}
}
public Ufo(Texture2D texture, float depth = 1f)
{
this._frame = 0;
this.Position = Vector2.Zero;
this._texture = texture;
this.Depth = depth;
this.Scale = 1f;
this.FrameWidth = texture.Width;
this.FrameHeight = texture.Height / 3;
this.GlowTexture = (Texture2D) null;
this.Opacity = 0.0f;
this.Rotation = 0.0f;
this.IsActive = false;
this._controller = (MartianSky.IUfoController) null;
}
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 4 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
public bool Update() => this.Controller.Update(ref this);
public void AssignNewBehavior()
{
switch (MartianSky.Ufo.Random.Next(2))
{
case 0:
this.Controller = (MartianSky.IUfoController) new MartianSky.ZipBehavior();
break;
case 1:
this.Controller = (MartianSky.IUfoController) new MartianSky.HoverBehavior();
break;
}
}
}
}
}

View file

@ -0,0 +1,79 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.MoonLordSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class MoonLordSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private bool _isActive;
private int _moonLordIndex = -1;
public override void OnLoad()
{
}
public override void Update(GameTime gameTime)
{
}
private float GetIntensity()
{
if (!this.UpdateMoonLordIndex())
return 0.0f;
float x = 0.0f;
if (this._moonLordIndex != -1)
x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this._moonLordIndex].Center);
return 1f - Utils.SmoothStep(3000f, 6000f, x);
}
public override Color OnTileColor(Color inColor)
{
float intensity = this.GetIntensity();
return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity));
}
private bool UpdateMoonLordIndex()
{
if (this._moonLordIndex >= 0 && Main.npc[this._moonLordIndex].active && Main.npc[this._moonLordIndex].type == 398)
return true;
int num = -1;
for (int index = 0; index < Main.npc.Length; ++index)
{
if (Main.npc[index].active && Main.npc[index].type == 398)
{
num = index;
break;
}
}
this._moonLordIndex = num;
return num != -1;
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) maxDepth < 0.0 || (double) minDepth >= 0.0)
return;
float intensity = this.GetIntensity();
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity);
}
public override float GetCloudAlpha() => 0.0f;
internal override void Activate(Vector2 position, params object[] args) => this._isActive = true;
internal override void Deactivate(params object[] args) => this._isActive = false;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive;
}
}

View file

@ -0,0 +1,123 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.NebulaSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class NebulaSky : CustomSky
{
private NebulaSky.LightPillar[] _pillars;
private UnifiedRandom _random = new UnifiedRandom();
private Texture2D _planetTexture;
private Texture2D _bgTexture;
private Texture2D _beamTexture;
private Texture2D[] _rockTextures;
private bool _isActive;
private float _fadeOpacity;
public override void OnLoad()
{
this._planetTexture = TextureManager.Load("Images/Misc/NebulaSky/Planet");
this._bgTexture = TextureManager.Load("Images/Misc/NebulaSky/Background");
this._beamTexture = TextureManager.Load("Images/Misc/NebulaSky/Beam");
this._rockTextures = new Texture2D[3];
for (int index = 0; index < this._rockTextures.Length; ++index)
this._rockTextures[index] = TextureManager.Load("Images/Misc/NebulaSky/Rock_" + (object) index);
}
public override void Update(GameTime gameTime)
{
if (this._isActive)
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
else
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
}
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
{
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
}
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._pillars.Length; ++index)
{
float depth = this._pillars[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
for (int index1 = num1; index1 < num2; ++index1)
{
Vector2 vector2_4 = new Vector2(1f / this._pillars[index1].Depth, 0.9f / this._pillars[index1].Depth);
Vector2 position = (this._pillars[index1].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
if (rectangle.Contains((int) position.X, (int) position.Y))
{
float num4 = vector2_4.X * 450f;
spriteBatch.Draw(this._beamTexture, position, new Rectangle?(), Color.White * 0.2f * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, new Vector2(num4 / 70f, num4 / 45f), SpriteEffects.None, 0.0f);
int index2 = 0;
for (float num5 = 0.0f; (double) num5 <= 1.0; num5 += 0.03f)
{
float num6 = (float) (1.0 - ((double) num5 + (double) Main.GlobalTime * 0.0199999995529652 + Math.Sin((double) index1)) % 1.0);
spriteBatch.Draw(this._rockTextures[index2], position + new Vector2((float) (Math.Sin((double) num5 * 1582.0) * ((double) num4 * 0.5) + (double) num4 * 0.5), num6 * 2000f), new Rectangle?(), Color.White * num6 * num3 * this._fadeOpacity, num6 * 20f, new Vector2((float) (this._rockTextures[index2].Width >> 1), (float) (this._rockTextures[index2].Height >> 1)), 0.9f, SpriteEffects.None, 0.0f);
index2 = (index2 + 1) % this._rockTextures.Length;
}
}
}
}
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
internal override void Activate(Vector2 position, params object[] args)
{
this._fadeOpacity = 1f / 500f;
this._isActive = true;
this._pillars = new NebulaSky.LightPillar[40];
for (int index = 0; index < this._pillars.Length; ++index)
{
this._pillars[index].Position.X = (float) ((double) index / (double) this._pillars.Length * ((double) Main.maxTilesX * 16.0 + 20000.0) + (double) this._random.NextFloat() * 40.0 - 20.0 - 20000.0);
this._pillars[index].Position.Y = (float) ((double) this._random.NextFloat() * 200.0 - 2000.0);
this._pillars[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 7.0);
}
Array.Sort<NebulaSky.LightPillar>(this._pillars, new Comparison<NebulaSky.LightPillar>(this.SortMethod));
}
private int SortMethod(NebulaSky.LightPillar pillar1, NebulaSky.LightPillar pillar2) => pillar2.Depth.CompareTo(pillar1.Depth);
internal override void Deactivate(params object[] args) => this._isActive = false;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
private struct LightPillar
{
public Vector2 Position;
public float Depth;
}
}
}

View file

@ -0,0 +1,212 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.PartySky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class PartySky : CustomSky
{
public static bool MultipleSkyWorkaroundFix;
private bool _active;
private bool _leaving;
private float _opacity;
private Texture2D[] _textures;
private PartySky.Balloon[] _balloons;
private UnifiedRandom _random = new UnifiedRandom();
private int _balloonsDrawing;
public override void OnLoad()
{
this._textures = new Texture2D[3];
for (int index = 0; index < this._textures.Length; ++index)
this._textures[index] = Main.extraTexture[69 + index];
this.GenerateBalloons(false);
}
private void GenerateBalloons(bool onlyMissing)
{
if (!onlyMissing)
this._balloons = new PartySky.Balloon[Main.maxTilesY / 4];
for (int i = 0; i < this._balloons.Length; ++i)
{
if (!onlyMissing || !this._balloons[i].Active)
{
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
this.ResetBalloon(i);
this._balloons[i].Active = true;
}
}
this._balloonsDrawing = this._balloons.Length;
}
public void ResetBalloon(int i)
{
this._balloons[i].Depth = (float) ((double) i / (double) this._balloons.Length * 1.75 + 1.60000002384186);
this._balloons[i].Speed = (float) (-1.5 - 2.5 * this._random.NextDouble());
this._balloons[i].Texture = this._textures[this._random.Next(2)];
this._balloons[i].Variant = this._random.Next(3);
if (this._random.Next(30) != 0)
return;
this._balloons[i].Texture = this._textures[2];
}
private bool IsNearParty() => (double) Main.player[Main.myPlayer].townNPCs > 0.0 || Main.partyMonoliths > 0;
public override void Update(GameTime gameTime)
{
if (!PartySky.MultipleSkyWorkaroundFix)
return;
PartySky.MultipleSkyWorkaroundFix = false;
if (Main.gamePaused || !Main.hasFocus)
return;
this._opacity = Utils.Clamp<float>(this._opacity + (float) this.IsNearParty().ToDirectionInt() * 0.01f, 0.0f, 1f);
for (int i = 0; i < this._balloons.Length; ++i)
{
if (this._balloons[i].Active)
{
++this._balloons[i].Frame;
this._balloons[i].Position.Y += this._balloons[i].Speed;
this._balloons[i].Position.X += Main.windSpeed * (3f - this._balloons[i].Speed);
if ((double) this._balloons[i].Position.Y < 300.0)
{
if (!this._leaving)
{
this.ResetBalloon(i);
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) (Main.worldSurface * 16.0 + 1600.0));
if (this._random.Next(30) == 0)
this._balloons[i].Texture = this._textures[2];
}
else
{
this._balloons[i].Active = false;
--this._balloonsDrawing;
}
}
}
}
if (this._balloonsDrawing == 0)
this._active = false;
this._active = true;
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if (Main.gameMenu && this._active)
{
this._active = false;
this._leaving = false;
for (int index = 0; index < this._balloons.Length; ++index)
this._balloons[index].Active = false;
}
if ((double) Main.screenPosition.Y > Main.worldSurface * 16.0 || Main.gameMenu || (double) this._opacity <= 0.0)
return;
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._balloons.Length; ++index)
{
float depth = this._balloons[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = num1; index < num2; ++index)
{
if (this._balloons[index].Active)
{
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
float num3 = 1f;
if ((double) this._balloons[index].Depth > 3.0)
num3 = 0.6f;
else if ((double) this._balloons[index].Depth > 2.5)
num3 = 0.7f;
else if ((double) this._balloons[index].Depth > 2.0)
num3 = 0.8f;
else if ((double) this._balloons[index].Depth > 1.5)
num3 = 0.9f;
float num4 = num3 * 0.9f;
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
Vector2 vector2_2 = new Vector2(1f / this._balloons[index].Depth, 0.9f / this._balloons[index].Depth);
Vector2 position = (this._balloons[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
position.X = (float) (((double) position.X + 500.0) % 4000.0);
if ((double) position.X < 0.0)
position.X += 4000f;
position.X -= 500f;
if (rectangle.Contains((int) position.X, (int) position.Y))
spriteBatch.Draw(this._balloons[index].Texture, position, new Rectangle?(this._balloons[index].GetSourceRectangle()), color * this._opacity, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
}
}
}
internal override void Activate(Vector2 position, params object[] args)
{
if (this._active)
{
this._leaving = false;
this.GenerateBalloons(true);
}
else
{
this.GenerateBalloons(false);
this._active = true;
this._leaving = false;
}
}
internal override void Deactivate(params object[] args) => this._leaving = true;
public override bool IsActive() => this._active;
public override void Reset() => this._active = false;
private struct Balloon
{
private const int MAX_FRAMES_X = 3;
private const int MAX_FRAMES_Y = 3;
private const int FRAME_RATE = 14;
public int Variant;
private Texture2D _texture;
public Vector2 Position;
public float Depth;
public int FrameHeight;
public int FrameWidth;
public float Speed;
public bool Active;
private int _frameCounter;
public Texture2D Texture
{
get => this._texture;
set
{
this._texture = value;
this.FrameWidth = value.Width / 3;
this.FrameHeight = value.Height / 3;
}
}
public int Frame
{
get => this._frameCounter;
set => this._frameCounter = value % 42;
}
public Rectangle GetSourceRectangle() => new Rectangle(this.FrameWidth * this.Variant, this._frameCounter / 14 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
}
}
}

View file

@ -0,0 +1,73 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.SandstormSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.GameContent.Events;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class SandstormSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private bool _isActive;
private bool _isLeaving;
private float _opacity;
public override void OnLoad()
{
}
public override void Update(GameTime gameTime)
{
if (Main.gamePaused || !Main.hasFocus)
return;
if (this._isLeaving)
{
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
if ((double) this._opacity >= 0.0)
return;
this._isActive = false;
this._opacity = 0.0f;
}
else
{
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
if ((double) this._opacity <= 1.0)
return;
this._opacity = 1f;
}
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
return;
float num = Math.Min(1f, Sandstorm.Severity * 1.5f);
Color color = new Color(new Vector4(0.85f, 0.66f, 0.33f, 1f) * 0.8f * Main.bgColor.ToVector4()) * this._opacity * num;
spriteBatch.Draw(Main.magicPixel, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
}
internal override void Activate(Vector2 position, params object[] args)
{
this._isActive = true;
this._isLeaving = false;
}
internal override void Deactivate(params object[] args) => this._isLeaving = true;
public override void Reset()
{
this._opacity = 0.0f;
this._isActive = false;
}
public override bool IsActive() => this._isActive;
}
}

View file

@ -0,0 +1,196 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.SlimeSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class SlimeSky : CustomSky
{
private Texture2D[] _textures;
private SlimeSky.Slime[] _slimes;
private UnifiedRandom _random = new UnifiedRandom();
private int _slimesRemaining;
private bool _isActive;
private bool _isLeaving;
public override void OnLoad()
{
this._textures = new Texture2D[4];
for (int index = 0; index < 4; ++index)
this._textures[index] = TextureManager.Load("Images/Misc/Sky_Slime_" + (object) (index + 1));
this.GenerateSlimes();
}
private void GenerateSlimes()
{
this._slimes = new SlimeSky.Slime[Main.maxTilesY / 6];
for (int index = 0; index < this._slimes.Length; ++index)
{
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
this._slimes[index].Texture = this._textures[this._random.Next(2)];
if (this._random.Next(60) == 0)
{
this._slimes[index].Texture = this._textures[3];
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
this._slimes[index].Depth += 0.5f;
}
else if (this._random.Next(30) == 0)
{
this._slimes[index].Texture = this._textures[2];
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
}
this._slimes[index].Active = true;
}
this._slimesRemaining = this._slimes.Length;
}
public override void Update(GameTime gameTime)
{
if (Main.gamePaused || !Main.hasFocus)
return;
for (int index = 0; index < this._slimes.Length; ++index)
{
if (this._slimes[index].Active)
{
++this._slimes[index].Frame;
this._slimes[index].Position.Y += this._slimes[index].Speed;
if ((double) this._slimes[index].Position.Y > Main.worldSurface * 16.0)
{
if (!this._isLeaving)
{
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), -100f);
this._slimes[index].Texture = this._textures[this._random.Next(2)];
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
if (this._random.Next(60) == 0)
{
this._slimes[index].Texture = this._textures[3];
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
this._slimes[index].Depth += 0.5f;
}
else if (this._random.Next(30) == 0)
{
this._slimes[index].Texture = this._textures[2];
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
}
}
else
{
this._slimes[index].Active = false;
--this._slimesRemaining;
}
}
}
}
if (this._slimesRemaining != 0)
return;
this._isActive = false;
}
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) Main.screenPosition.Y > 10000.0 || Main.gameMenu)
return;
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._slimes.Length; ++index)
{
float depth = this._slimes[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = num1; index < num2; ++index)
{
if (this._slimes[index].Active)
{
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
float num3 = 1f;
if ((double) this._slimes[index].Depth > 3.0)
num3 = 0.6f;
else if ((double) this._slimes[index].Depth > 2.5)
num3 = 0.7f;
else if ((double) this._slimes[index].Depth > 2.0)
num3 = 0.8f;
else if ((double) this._slimes[index].Depth > 1.5)
num3 = 0.9f;
float num4 = num3 * 0.8f;
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
Vector2 vector2_2 = new Vector2(1f / this._slimes[index].Depth, 0.9f / this._slimes[index].Depth);
Vector2 position = (this._slimes[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
position.X = (float) (((double) position.X + 500.0) % 4000.0);
if ((double) position.X < 0.0)
position.X += 4000f;
position.X -= 500f;
if (rectangle.Contains((int) position.X, (int) position.Y))
spriteBatch.Draw(this._slimes[index].Texture, position, new Rectangle?(this._slimes[index].GetSourceRectangle()), color, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
}
}
}
internal override void Activate(Vector2 position, params object[] args)
{
this.GenerateSlimes();
this._isActive = true;
this._isLeaving = false;
}
internal override void Deactivate(params object[] args) => this._isLeaving = true;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive;
private struct Slime
{
private const int MAX_FRAMES = 4;
private const int FRAME_RATE = 6;
private Texture2D _texture;
public Vector2 Position;
public float Depth;
public int FrameHeight;
public int FrameWidth;
public float Speed;
public bool Active;
private int _frame;
public Texture2D Texture
{
get => this._texture;
set
{
this._texture = value;
this.FrameWidth = value.Width;
this.FrameHeight = value.Height / 4;
}
}
public int Frame
{
get => this._frame;
set => this._frame = value % 24;
}
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 6 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
}
}
}

View file

@ -0,0 +1,126 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.SolarSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class SolarSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private Texture2D _planetTexture;
private Texture2D _bgTexture;
private Texture2D _meteorTexture;
private bool _isActive;
private SolarSky.Meteor[] _meteors;
private float _fadeOpacity;
public override void OnLoad()
{
this._planetTexture = TextureManager.Load("Images/Misc/SolarSky/Planet");
this._bgTexture = TextureManager.Load("Images/Misc/SolarSky/Background");
this._meteorTexture = TextureManager.Load("Images/Misc/SolarSky/Meteor");
}
public override void Update(GameTime gameTime)
{
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
float num = 1200f;
for (int index = 0; index < this._meteors.Length; ++index)
{
this._meteors[index].Position.X -= num * (float) gameTime.ElapsedGameTime.TotalSeconds;
this._meteors[index].Position.Y += num * (float) gameTime.ElapsedGameTime.TotalSeconds;
if ((double) this._meteors[index].Position.Y > Main.worldSurface * 16.0)
{
this._meteors[index].Position.X = this._meteors[index].StartX;
this._meteors[index].Position.Y = -10000f;
}
}
}
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
{
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
}
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._meteors.Length; ++index)
{
float depth = this._meteors[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = num1; index < num2; ++index)
{
Vector2 vector2_4 = new Vector2(1f / this._meteors[index].Depth, 0.9f / this._meteors[index].Depth);
Vector2 position = (this._meteors[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
int num4 = this._meteors[index].FrameCounter / 3;
this._meteors[index].FrameCounter = (this._meteors[index].FrameCounter + 1) % 12;
if (rectangle.Contains((int) position.X, (int) position.Y))
spriteBatch.Draw(this._meteorTexture, position, new Rectangle?(new Rectangle(0, num4 * (this._meteorTexture.Height / 4), this._meteorTexture.Width, this._meteorTexture.Height / 4)), Color.White * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f * this._meteors[index].Scale, SpriteEffects.None, 0.0f);
}
}
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
internal override void Activate(Vector2 position, params object[] args)
{
this._fadeOpacity = 1f / 500f;
this._isActive = true;
this._meteors = new SolarSky.Meteor[150];
for (int index = 0; index < this._meteors.Length; ++index)
{
float num = (float) index / (float) this._meteors.Length;
this._meteors[index].Position.X = (float) ((double) num * ((double) Main.maxTilesX * 16.0) + (double) this._random.NextFloat() * 40.0 - 20.0);
this._meteors[index].Position.Y = (float) ((double) this._random.NextFloat() * -(Main.worldSurface * 16.0 + 10000.0) - 10000.0);
this._meteors[index].Depth = this._random.Next(3) == 0 ? (float) ((double) this._random.NextFloat() * 5.0 + 4.80000019073486) : (float) ((double) this._random.NextFloat() * 3.0 + 1.79999995231628);
this._meteors[index].FrameCounter = this._random.Next(12);
this._meteors[index].Scale = (float) ((double) this._random.NextFloat() * 0.5 + 1.0);
this._meteors[index].StartX = this._meteors[index].Position.X;
}
Array.Sort<SolarSky.Meteor>(this._meteors, new Comparison<SolarSky.Meteor>(this.SortMethod));
}
private int SortMethod(SolarSky.Meteor meteor1, SolarSky.Meteor meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
internal override void Deactivate(params object[] args) => this._isActive = false;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
private struct Meteor
{
public Vector2 Position;
public float Depth;
public int FrameCounter;
public float Scale;
public float StartX;
}
}
}

View file

@ -0,0 +1,134 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.StardustSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class StardustSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private Texture2D _planetTexture;
private Texture2D _bgTexture;
private Texture2D[] _starTextures;
private bool _isActive;
private StardustSky.Star[] _stars;
private float _fadeOpacity;
public override void OnLoad()
{
this._planetTexture = TextureManager.Load("Images/Misc/StarDustSky/Planet");
this._bgTexture = TextureManager.Load("Images/Misc/StarDustSky/Background");
this._starTextures = new Texture2D[2];
for (int index = 0; index < this._starTextures.Length; ++index)
this._starTextures[index] = TextureManager.Load("Images/Misc/StarDustSky/Star " + (object) index);
}
public override void Update(GameTime gameTime)
{
if (this._isActive)
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
else
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
}
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
{
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
}
int num1 = -1;
int num2 = 0;
for (int index = 0; index < this._stars.Length; ++index)
{
float depth = this._stars[index].Depth;
if (num1 == -1 && (double) depth < (double) maxDepth)
num1 = index;
if ((double) depth > (double) minDepth)
num2 = index;
else
break;
}
if (num1 == -1)
return;
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = num1; index < num2; ++index)
{
Vector2 vector2_4 = new Vector2(1f / this._stars[index].Depth, 1.1f / this._stars[index].Depth);
Vector2 position = (this._stars[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
if (rectangle.Contains((int) position.X, (int) position.Y))
{
float num4 = (float) Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTime + (double) this._stars[index].SinOffset) * this._stars[index].AlphaAmplitude + this._stars[index].AlphaAmplitude;
float num5 = (float) (Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTime * 5.0 + (double) this._stars[index].SinOffset) * 0.100000001490116 - 0.100000001490116);
float num6 = MathHelper.Clamp(num4, 0.0f, 1f);
Texture2D starTexture = this._starTextures[this._stars[index].TextureIndex];
spriteBatch.Draw(starTexture, position, new Rectangle?(), Color.White * num3 * num6 * 0.8f * (1f - num5) * this._fadeOpacity, 0.0f, new Vector2((float) (starTexture.Width >> 1), (float) (starTexture.Height >> 1)), (float) (((double) vector2_4.X * 0.5 + 0.5) * ((double) num6 * 0.300000011920929 + 0.699999988079071)), SpriteEffects.None, 0.0f);
}
}
}
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
internal override void Activate(Vector2 position, params object[] args)
{
this._fadeOpacity = 1f / 500f;
this._isActive = true;
int num1 = 200;
int num2 = 10;
this._stars = new StardustSky.Star[num1 * num2];
int index1 = 0;
for (int index2 = 0; index2 < num1; ++index2)
{
float num3 = (float) index2 / (float) num1;
for (int index3 = 0; index3 < num2; ++index3)
{
float num4 = (float) index3 / (float) num2;
this._stars[index1].Position.X = (float) ((double) num3 * (double) Main.maxTilesX * 16.0);
this._stars[index1].Position.Y = (float) ((double) num4 * (Main.worldSurface * 16.0 + 2000.0) - 1000.0);
this._stars[index1].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 1.5);
this._stars[index1].TextureIndex = this._random.Next(this._starTextures.Length);
this._stars[index1].SinOffset = this._random.NextFloat() * 6.28f;
this._stars[index1].AlphaAmplitude = this._random.NextFloat() * 5f;
this._stars[index1].AlphaFrequency = this._random.NextFloat() + 1f;
++index1;
}
}
Array.Sort<StardustSky.Star>(this._stars, new Comparison<StardustSky.Star>(this.SortMethod));
}
private int SortMethod(StardustSky.Star meteor1, StardustSky.Star meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
internal override void Deactivate(params object[] args) => this._isActive = false;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
private struct Star
{
public Vector2 Position;
public float Depth;
public int TextureIndex;
public float SinOffset;
public float AlphaFrequency;
public float AlphaAmplitude;
}
}
}

View file

@ -0,0 +1,122 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Skies.VortexSky
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria.Graphics;
using Terraria.Graphics.Effects;
using Terraria.Utilities;
namespace Terraria.GameContent.Skies
{
public class VortexSky : CustomSky
{
private UnifiedRandom _random = new UnifiedRandom();
private Texture2D _planetTexture;
private Texture2D _bgTexture;
private Texture2D _boltTexture;
private Texture2D _flashTexture;
private bool _isActive;
private int _ticksUntilNextBolt;
private float _fadeOpacity;
private VortexSky.Bolt[] _bolts;
public override void OnLoad()
{
this._planetTexture = TextureManager.Load("Images/Misc/VortexSky/Planet");
this._bgTexture = TextureManager.Load("Images/Misc/VortexSky/Background");
this._boltTexture = TextureManager.Load("Images/Misc/VortexSky/Bolt");
this._flashTexture = TextureManager.Load("Images/Misc/VortexSky/Flash");
}
public override void Update(GameTime gameTime)
{
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
if (this._ticksUntilNextBolt <= 0)
{
this._ticksUntilNextBolt = this._random.Next(1, 5);
int index = 0;
while (this._bolts[index].IsAlive && index != this._bolts.Length - 1)
++index;
this._bolts[index].IsAlive = true;
this._bolts[index].Position.X = (float) ((double) this._random.NextFloat() * ((double) Main.maxTilesX * 16.0 + 4000.0) - 2000.0);
this._bolts[index].Position.Y = this._random.NextFloat() * 500f;
this._bolts[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 2.0);
this._bolts[index].Life = 30;
}
--this._ticksUntilNextBolt;
for (int index = 0; index < this._bolts.Length; ++index)
{
if (this._bolts[index].IsAlive)
{
--this._bolts[index].Life;
if (this._bolts[index].Life <= 0)
this._bolts[index].IsAlive = false;
}
}
}
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
{
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
{
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0)) * this._fadeOpacity);
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
}
float num1 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
for (int index = 0; index < this._bolts.Length; ++index)
{
if (this._bolts[index].IsAlive && (double) this._bolts[index].Depth > (double) minDepth && (double) this._bolts[index].Depth < (double) maxDepth)
{
Vector2 vector2_4 = new Vector2(1f / this._bolts[index].Depth, 0.9f / this._bolts[index].Depth);
Vector2 position = (this._bolts[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
if (rectangle.Contains((int) position.X, (int) position.Y))
{
Texture2D texture = this._boltTexture;
int life = this._bolts[index].Life;
if (life > 26 && life % 2 == 0)
texture = this._flashTexture;
float num2 = (float) life / 30f;
spriteBatch.Draw(texture, position, new Rectangle?(), Color.White * num1 * num2 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f, SpriteEffects.None, 0.0f);
}
}
}
}
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
internal override void Activate(Vector2 position, params object[] args)
{
this._fadeOpacity = 1f / 500f;
this._isActive = true;
this._bolts = new VortexSky.Bolt[500];
for (int index = 0; index < this._bolts.Length; ++index)
this._bolts[index].IsAlive = false;
}
internal override void Deactivate(params object[] args) => this._isActive = false;
public override void Reset() => this._isActive = false;
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
private struct Bolt
{
public Vector2 Position;
public float Depth;
public int Life;
public bool IsAlive;
}
}
}