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,149 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.BirthdayParty
// 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 System;
using System.Collections.Generic;
using System.Linq;
using Terraria.Graphics.Effects;
using Terraria.Localization;
namespace Terraria.GameContent.Events
{
public class BirthdayParty
{
public static bool ManualParty = false;
public static bool GenuineParty = false;
public static int PartyDaysOnCooldown = 0;
public static List<int> CelebratingNPCs = new List<int>();
private static bool _wasCelebrating = false;
public static bool PartyIsUp => BirthdayParty.GenuineParty || BirthdayParty.ManualParty;
public static void CheckMorning() => BirthdayParty.NaturalAttempt();
public static void CheckNight()
{
bool flag = false;
if (BirthdayParty.GenuineParty)
{
flag = true;
BirthdayParty.GenuineParty = false;
BirthdayParty.CelebratingNPCs.Clear();
}
if (BirthdayParty.ManualParty)
{
flag = true;
BirthdayParty.ManualParty = false;
}
if (!flag)
return;
Color color = new Color((int) byte.MaxValue, 0, 160);
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color);
}
private static void NaturalAttempt()
{
if (Main.netMode == 1)
return;
if (BirthdayParty.PartyDaysOnCooldown > 0)
{
--BirthdayParty.PartyDaysOnCooldown;
}
else
{
if (Main.rand.Next(10) != 0)
return;
List<NPC> source = new List<NPC>();
for (int index = 0; index < 200; ++index)
{
NPC npc = Main.npc[index];
if (npc.active && npc.townNPC && npc.type != 37 && npc.type != 453 && npc.aiStyle != 0)
source.Add(npc);
}
if (source.Count < 5)
return;
BirthdayParty.GenuineParty = true;
BirthdayParty.PartyDaysOnCooldown = Main.rand.Next(5, 11);
BirthdayParty.CelebratingNPCs.Clear();
List<int> intList = new List<int>();
int num = 1;
if (Main.rand.Next(5) == 0 && source.Count > 12)
num = 3;
else if (Main.rand.Next(3) == 0)
num = 2;
List<NPC> list = source.OrderBy<NPC, int>((Func<NPC, int>) (i => Main.rand.Next())).ToList<NPC>();
for (int index = 0; index < num; ++index)
intList.Add(index);
for (int index = 0; index < intList.Count; ++index)
BirthdayParty.CelebratingNPCs.Add(list[intList[index]].whoAmI);
Color color = new Color((int) byte.MaxValue, 0, 160);
if (BirthdayParty.CelebratingNPCs.Count == 3)
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_3", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[1]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[2]].GetGivenOrTypeNetName()), color);
else if (BirthdayParty.CelebratingNPCs.Count == 2)
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_2", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[1]].GetGivenOrTypeNetName()), color);
else
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_1", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName()), color);
}
}
public static void ToggleManualParty()
{
int num1 = BirthdayParty.PartyIsUp ? 1 : 0;
if (Main.netMode != 1)
BirthdayParty.ManualParty = !BirthdayParty.ManualParty;
else
NetMessage.SendData(111);
int num2 = BirthdayParty.PartyIsUp ? 1 : 0;
if (num1 == num2 || Main.netMode != 2)
return;
NetMessage.SendData(7);
}
public static void WorldClear()
{
BirthdayParty.ManualParty = false;
BirthdayParty.GenuineParty = false;
BirthdayParty.PartyDaysOnCooldown = 0;
BirthdayParty.CelebratingNPCs.Clear();
BirthdayParty._wasCelebrating = false;
}
public static void UpdateTime()
{
if (BirthdayParty._wasCelebrating != BirthdayParty.PartyIsUp)
{
if (Main.netMode != 2)
{
if (BirthdayParty.PartyIsUp)
SkyManager.Instance.Activate("Party", new Vector2());
else
SkyManager.Instance.Deactivate("Party");
}
if (Main.netMode != 1 && BirthdayParty.CelebratingNPCs.Count > 0)
{
for (int index = 0; index < BirthdayParty.CelebratingNPCs.Count; ++index)
{
NPC npc = Main.npc[BirthdayParty.CelebratingNPCs[index]];
if (!npc.active || !npc.townNPC || npc.type == 37 || npc.type == 453 || npc.aiStyle == 0)
BirthdayParty.CelebratingNPCs.RemoveAt(index);
}
if (BirthdayParty.CelebratingNPCs.Count == 0)
{
BirthdayParty.GenuineParty = false;
if (!BirthdayParty.ManualParty)
{
Color color = new Color((int) byte.MaxValue, 0, 160);
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color);
NetMessage.SendData(7);
}
}
}
}
BirthdayParty._wasCelebrating = BirthdayParty.PartyIsUp;
}
}
}

View file

@ -0,0 +1,90 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.CultistRitual
// 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;
namespace Terraria.GameContent.Events
{
public class CultistRitual
{
public const int delayStart = 86400;
public const int respawnDelay = 43200;
private const int timePerCultist = 3600;
private const int recheckStart = 600;
public static int delay;
public static int recheck;
public static void UpdateTime()
{
if (Main.netMode == 1)
return;
CultistRitual.delay -= Main.dayRate;
if (CultistRitual.delay < 0)
CultistRitual.delay = 0;
CultistRitual.recheck -= Main.dayRate;
if (CultistRitual.recheck < 0)
CultistRitual.recheck = 0;
if (CultistRitual.delay != 0 || CultistRitual.recheck != 0)
return;
CultistRitual.recheck = 600;
if (NPC.AnyDanger())
CultistRitual.recheck *= 6;
else
CultistRitual.TrySpawning(Main.dungeonX, Main.dungeonY);
}
public static void CultistSlain() => CultistRitual.delay -= 3600;
public static void TabletDestroyed() => CultistRitual.delay = 43200;
public static void TrySpawning(int x, int y)
{
if (WorldGen.PlayerLOS(x - 6, y) || WorldGen.PlayerLOS(x + 6, y) || !CultistRitual.CheckRitual(x, y))
return;
NPC.NewNPC(x * 16 + 8, (y - 4) * 16 - 8, 437);
}
private static bool CheckRitual(int x, int y)
{
if (CultistRitual.delay != 0 || !Main.hardMode || !NPC.downedGolemBoss || !NPC.downedBoss3 || y < 7 || WorldGen.SolidTile(Main.tile[x, y - 7]) || NPC.AnyNPCs(437))
return false;
Vector2 Center = new Vector2((float) (x * 16 + 8), (float) (y * 16 - 64 - 8 - 27));
Point[] pointArray = (Point[]) null;
ref Point[] local = ref pointArray;
return CultistRitual.CheckFloor(Center, out local);
}
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints)
{
Point[] pointArray = new Point[4];
int num1 = 0;
Point tileCoordinates = Center.ToTileCoordinates();
for (int index1 = -5; index1 <= 5; index1 += 2)
{
if (index1 != -1 && index1 != 1)
{
for (int index2 = -5; index2 < 12; ++index2)
{
int num2 = tileCoordinates.X + index1 * 2;
int num3 = tileCoordinates.Y + index2;
if (WorldGen.SolidTile(num2, num3) && !Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1))
{
pointArray[num1++] = new Point(num2, num3);
break;
}
}
}
}
if (num1 != 4)
{
spawnPoints = (Point[]) null;
return false;
}
spawnPoints = pointArray;
return true;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,220 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.MoonlordDeathDrama
// 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 System.Collections.Generic;
using Terraria.Graphics;
using Terraria.Utilities;
namespace Terraria.GameContent.Events
{
public class MoonlordDeathDrama
{
private static List<MoonlordDeathDrama.MoonlordPiece> _pieces = new List<MoonlordDeathDrama.MoonlordPiece>();
private static List<MoonlordDeathDrama.MoonlordExplosion> _explosions = new List<MoonlordDeathDrama.MoonlordExplosion>();
private static List<Vector2> _lightSources = new List<Vector2>();
private static float whitening = 0.0f;
private static float requestedLight = 0.0f;
public static void Update()
{
for (int index = 0; index < MoonlordDeathDrama._pieces.Count; ++index)
{
MoonlordDeathDrama.MoonlordPiece piece = MoonlordDeathDrama._pieces[index];
piece.Update();
if (piece.Dead)
{
MoonlordDeathDrama._pieces.Remove(piece);
--index;
}
}
for (int index = 0; index < MoonlordDeathDrama._explosions.Count; ++index)
{
MoonlordDeathDrama.MoonlordExplosion explosion = MoonlordDeathDrama._explosions[index];
explosion.Update();
if (explosion.Dead)
{
MoonlordDeathDrama._explosions.Remove(explosion);
--index;
}
}
bool flag = false;
for (int index = 0; index < MoonlordDeathDrama._lightSources.Count; ++index)
{
if ((double) Main.player[Main.myPlayer].Distance(MoonlordDeathDrama._lightSources[index]) < 2000.0)
{
flag = true;
break;
}
}
MoonlordDeathDrama._lightSources.Clear();
if (!flag)
MoonlordDeathDrama.requestedLight = 0.0f;
if ((double) MoonlordDeathDrama.requestedLight != (double) MoonlordDeathDrama.whitening)
{
if ((double) Math.Abs(MoonlordDeathDrama.requestedLight - MoonlordDeathDrama.whitening) < 0.0199999995529652)
MoonlordDeathDrama.whitening = MoonlordDeathDrama.requestedLight;
else
MoonlordDeathDrama.whitening += (float) Math.Sign(MoonlordDeathDrama.requestedLight - MoonlordDeathDrama.whitening) * 0.02f;
}
MoonlordDeathDrama.requestedLight = 0.0f;
}
public static void DrawPieces(SpriteBatch spriteBatch)
{
Rectangle playerScreen = Utils.CenteredRectangle(Main.screenPosition + new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f, new Vector2((float) (Main.screenWidth + 1000), (float) (Main.screenHeight + 1000)));
for (int index = 0; index < MoonlordDeathDrama._pieces.Count; ++index)
{
if (MoonlordDeathDrama._pieces[index].InDrawRange(playerScreen))
MoonlordDeathDrama._pieces[index].Draw(spriteBatch);
}
}
public static void DrawExplosions(SpriteBatch spriteBatch)
{
Rectangle playerScreen = Utils.CenteredRectangle(Main.screenPosition + new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f, new Vector2((float) (Main.screenWidth + 1000), (float) (Main.screenHeight + 1000)));
for (int index = 0; index < MoonlordDeathDrama._explosions.Count; ++index)
{
if (MoonlordDeathDrama._explosions[index].InDrawRange(playerScreen))
MoonlordDeathDrama._explosions[index].Draw(spriteBatch);
}
}
public static void DrawWhite(SpriteBatch spriteBatch)
{
if ((double) MoonlordDeathDrama.whitening == 0.0)
return;
Color color = Color.White * MoonlordDeathDrama.whitening;
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
}
public static void ThrowPieces(Vector2 MoonlordCoreCenter, int DramaSeed)
{
UnifiedRandom r = new UnifiedRandom(DramaSeed);
Vector2 vector2_1 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Spine"), new Vector2(64f, 150f), MoonlordCoreCenter + new Vector2(0.0f, 50f), vector2_1 * 6f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
Vector2 vector2_2 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Shoulder"), new Vector2(40f, 120f), MoonlordCoreCenter + new Vector2(50f, -120f), vector2_2 * 10f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
Vector2 vector2_3 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Torso"), new Vector2(192f, 252f), MoonlordCoreCenter, vector2_3 * 8f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
Vector2 vector2_4 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Head"), new Vector2(138f, 185f), MoonlordCoreCenter - new Vector2(0.0f, 200f), vector2_4 * 12f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
}
public static void AddExplosion(Vector2 spot) => MoonlordDeathDrama._explosions.Add(new MoonlordDeathDrama.MoonlordExplosion(TextureManager.Load("Images/Misc/MoonExplosion/Explosion"), spot, Main.rand.Next(2, 4)));
public static void RequestLight(float light, Vector2 spot)
{
MoonlordDeathDrama._lightSources.Add(spot);
if ((double) light > 1.0)
light = 1f;
if ((double) MoonlordDeathDrama.requestedLight >= (double) light)
return;
MoonlordDeathDrama.requestedLight = light;
}
public class MoonlordPiece
{
private Texture2D _texture;
private Vector2 _position;
private Vector2 _velocity;
private Vector2 _origin;
private float _rotation;
private float _rotationVelocity;
public MoonlordPiece(
Texture2D pieceTexture,
Vector2 textureOrigin,
Vector2 centerPos,
Vector2 velocity,
float rot,
float angularVelocity)
{
this._texture = pieceTexture;
this._origin = textureOrigin;
this._position = centerPos;
this._velocity = velocity;
this._rotation = rot;
this._rotationVelocity = angularVelocity;
}
public void Update()
{
this._velocity.Y += 0.3f;
this._rotation += this._rotationVelocity;
this._rotationVelocity *= 0.99f;
this._position += this._velocity;
}
public void Draw(SpriteBatch sp)
{
Color light = this.GetLight();
sp.Draw(this._texture, this._position - Main.screenPosition, new Rectangle?(), light, this._rotation, this._origin, 1f, SpriteEffects.None, 0.0f);
}
public bool Dead => (double) this._position.Y > (double) (Main.maxTilesY * 16) - 480.0 || (double) this._position.X < 480.0 || (double) this._position.X >= (double) (Main.maxTilesX * 16) - 480.0;
public bool InDrawRange(Rectangle playerScreen) => playerScreen.Contains(this._position.ToPoint());
public Color GetLight()
{
Vector3 zero = Vector3.Zero;
float num1 = 0.0f;
int num2 = 5;
Point tileCoordinates = this._position.ToTileCoordinates();
for (int x = tileCoordinates.X - num2; x <= tileCoordinates.X + num2; ++x)
{
for (int y = tileCoordinates.Y - num2; y <= tileCoordinates.Y + num2; ++y)
{
zero += Lighting.GetColor(x, y).ToVector3();
++num1;
}
}
return (double) num1 == 0.0 ? Color.White : new Color(zero / num1);
}
}
public class MoonlordExplosion
{
private Texture2D _texture;
private Vector2 _position;
private Vector2 _origin;
private Rectangle _frame;
private int _frameCounter;
private int _frameSpeed;
public MoonlordExplosion(Texture2D pieceTexture, Vector2 centerPos, int frameSpeed)
{
this._texture = pieceTexture;
this._position = centerPos;
this._frameSpeed = frameSpeed;
this._frameCounter = 0;
this._frame = this._texture.Frame(verticalFrames: 7);
this._origin = this._frame.Size() / 2f;
}
public void Update()
{
++this._frameCounter;
this._frame = this._texture.Frame(verticalFrames: 7, frameY: (this._frameCounter / this._frameSpeed));
}
public void Draw(SpriteBatch sp)
{
Color light = this.GetLight();
sp.Draw(this._texture, this._position - Main.screenPosition, new Rectangle?(this._frame), light, 0.0f, this._origin, 1f, SpriteEffects.None, 0.0f);
}
public bool Dead => (double) this._position.Y > (double) (Main.maxTilesY * 16) - 480.0 || (double) this._position.X < 480.0 || (double) this._position.X >= (double) (Main.maxTilesX * 16) - 480.0 || this._frameCounter >= this._frameSpeed * 7;
public bool InDrawRange(Rectangle playerScreen) => playerScreen.Contains(this._position.ToPoint());
public Color GetLight() => new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, (int) sbyte.MaxValue);
}
}
}

View file

@ -0,0 +1,202 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.Sandstorm
// 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.Events
{
public class Sandstorm
{
public static bool Happening;
public static int TimeLeft;
public static float Severity;
public static float IntendedSeverity;
private static bool _effectsUp;
public static void WorldClear() => Sandstorm.Happening = false;
public static void UpdateTime()
{
if (Main.netMode != 1)
{
if (Sandstorm.Happening)
{
if (Sandstorm.TimeLeft > 86400)
Sandstorm.TimeLeft = 0;
Sandstorm.TimeLeft -= Main.dayRate;
if (Sandstorm.TimeLeft <= 0)
Sandstorm.StopSandstorm();
}
else
{
int num = (int) ((double) Main.windSpeed * 100.0);
for (int index = 0; index < Main.dayRate; ++index)
{
if (Main.rand.Next(777600) == 0)
Sandstorm.StartSandstorm();
else if ((Main.numClouds < 40 || Math.Abs(num) > 50) && Main.rand.Next(518400) == 0)
Sandstorm.StartSandstorm();
}
}
if (Main.rand.Next(18000) == 0)
Sandstorm.ChangeSeverityIntentions();
}
Sandstorm.UpdateSeverity();
}
private static void ChangeSeverityIntentions()
{
Sandstorm.IntendedSeverity = !Sandstorm.Happening ? (Main.rand.Next(3) != 0 ? Main.rand.NextFloat() * 0.3f : 0.0f) : 0.4f + Main.rand.NextFloat();
if (Main.netMode == 1)
return;
NetMessage.SendData(7);
}
private static void UpdateSeverity()
{
int num1 = Math.Sign(Sandstorm.IntendedSeverity - Sandstorm.Severity);
Sandstorm.Severity = MathHelper.Clamp(Sandstorm.Severity + 3f / 1000f * (float) num1, 0.0f, 1f);
int num2 = Math.Sign(Sandstorm.IntendedSeverity - Sandstorm.Severity);
if (num1 == num2)
return;
Sandstorm.Severity = Sandstorm.IntendedSeverity;
}
private static void StartSandstorm()
{
Sandstorm.Happening = true;
Sandstorm.TimeLeft = (int) (3600.0 * (8.0 + (double) Main.rand.NextFloat() * 16.0));
Sandstorm.ChangeSeverityIntentions();
}
private static void StopSandstorm()
{
Sandstorm.Happening = false;
Sandstorm.TimeLeft = 0;
Sandstorm.ChangeSeverityIntentions();
}
public static void HandleEffectAndSky(bool toState)
{
if (toState == Sandstorm._effectsUp)
return;
Sandstorm._effectsUp = toState;
Vector2 center = Main.player[Main.myPlayer].Center;
if (Sandstorm._effectsUp)
{
SkyManager.Instance.Activate(nameof (Sandstorm), center);
Filters.Scene.Activate(nameof (Sandstorm), center);
Overlays.Scene.Activate(nameof (Sandstorm), center);
}
else
{
SkyManager.Instance.Deactivate(nameof (Sandstorm));
Filters.Scene.Deactivate(nameof (Sandstorm));
Overlays.Scene.Deactivate(nameof (Sandstorm));
}
}
public static void EmitDust()
{
if (Main.gamePaused)
return;
int sandTiles = Main.sandTiles;
Player player = Main.player[Main.myPlayer];
bool flag = Sandstorm.Happening && player.ZoneSandstorm && (Main.bgStyle == 2 || Main.bgStyle == 5) && Main.bgDelay < 50;
Sandstorm.HandleEffectAndSky(flag && Main.UseStormEffects);
if (sandTiles < 100 || (double) player.position.Y > Main.worldSurface * 16.0 || player.ZoneBeach)
return;
int maxValue1 = 1;
if (!flag || Main.rand.Next(maxValue1) != 0)
return;
int num1 = Math.Sign(Main.windSpeed);
float amount = Math.Abs(Main.windSpeed);
if ((double) amount < 0.00999999977648258)
return;
float num2 = (float) num1 * MathHelper.Lerp(0.9f, 1f, amount);
float num3 = 2000f / (float) sandTiles;
float num4 = MathHelper.Clamp(3f / num3, 0.77f, 1f);
int num5 = (int) num3;
int num6 = (int) (1000.0 * (double) ((float) Main.screenWidth / (float) Main.maxScreenW));
float num7 = 20f * Sandstorm.Severity;
float num8 = (float) ((double) num6 * ((double) Main.gfxQuality * 0.5 + 0.5) + (double) num6 * 0.100000001490116) - (float) Dust.SandStormCount;
if ((double) num8 <= 0.0)
return;
float num9 = (float) Main.screenWidth + 1000f;
float screenHeight = (float) Main.screenHeight;
Vector2 vector2 = Main.screenPosition + player.velocity;
WeightedRandom<Color> weightedRandom = new WeightedRandom<Color>();
weightedRandom.Add(new Color(200, 160, 20, 180), (double) (Main.screenTileCounts[53] + Main.screenTileCounts[396] + Main.screenTileCounts[397]));
weightedRandom.Add(new Color(103, 98, 122, 180), (double) (Main.screenTileCounts[112] + Main.screenTileCounts[400] + Main.screenTileCounts[398]));
weightedRandom.Add(new Color(135, 43, 34, 180), (double) (Main.screenTileCounts[234] + Main.screenTileCounts[401] + Main.screenTileCounts[399]));
weightedRandom.Add(new Color(213, 196, 197, 180), (double) (Main.screenTileCounts[116] + Main.screenTileCounts[403] + Main.screenTileCounts[402]));
float num10 = MathHelper.Lerp(0.2f, 0.35f, Sandstorm.Severity);
float num11 = MathHelper.Lerp(0.5f, 0.7f, Sandstorm.Severity);
int maxValue2 = (int) MathHelper.Lerp(1f, 10f, (float) (((double) num4 - 0.769999980926514) / 0.230000019073486));
for (int index1 = 0; (double) index1 < (double) num7; ++index1)
{
if (Main.rand.Next(num5 / 4) == 0)
{
Vector2 Position = new Vector2((float) ((double) Main.rand.NextFloat() * (double) num9 - 500.0), Main.rand.NextFloat() * -50f);
if (Main.rand.Next(3) == 0 && num1 == 1)
Position.X = (float) (Main.rand.Next(500) - 500);
else if (Main.rand.Next(3) == 0 && num1 == -1)
Position.X = (float) (Main.rand.Next(500) + Main.screenWidth);
if ((double) Position.X < 0.0 || (double) Position.X > (double) Main.screenWidth)
Position.Y += (float) ((double) Main.rand.NextFloat() * (double) screenHeight * 0.899999976158142);
Position += vector2;
int index2 = (int) Position.X / 16;
int index3 = (int) Position.Y / 16;
if (Main.tile[index2, index3] != null && Main.tile[index2, index3].wall == (byte) 0)
{
for (int index4 = 0; index4 < 1; ++index4)
{
Dust dust = Main.dust[Dust.NewDust(Position, 10, 10, 268)];
dust.velocity.Y = (float) (2.0 + (double) Main.rand.NextFloat() * 0.200000002980232);
dust.velocity.Y *= dust.scale;
dust.velocity.Y *= 0.35f;
dust.velocity.X = (float) ((double) num2 * 5.0 + (double) Main.rand.NextFloat() * 1.0);
dust.velocity.X += (float) ((double) num2 * (double) num11 * 20.0);
dust.fadeIn += num11 * 0.2f;
dust.velocity *= (float) (1.0 + (double) num10 * 0.5);
dust.color = (Color) weightedRandom;
dust.velocity *= 1f + num10;
dust.velocity *= num4;
dust.scale = 0.9f;
--num8;
if ((double) num8 > 0.0)
{
if (Main.rand.Next(maxValue2) != 0)
{
--index4;
Position += Utils.RandomVector2(Main.rand, -10f, 10f) + dust.velocity * -1.1f;
int x = (int) Position.X / 16;
int y = (int) Position.Y / 16;
if (WorldGen.InWorld(x, y, 10) && Main.tile[x, y] != null)
{
int wall = (int) Main.tile[x, y].wall;
}
}
}
else
break;
}
if ((double) num8 <= 0.0)
break;
}
}
}
}
public static void DrawGrains(SpriteBatch spriteBatch)
{
}
}
}

View file

@ -0,0 +1,48 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.ScreenDarkness
// 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;
namespace Terraria.GameContent.Events
{
public class ScreenDarkness
{
public static float screenObstruction;
public static void Update()
{
float num = 0.0f;
float amount = 0.1f;
Vector2 mountedCenter = Main.player[Main.myPlayer].MountedCenter;
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && Main.npc[index].type == 370 && (double) Main.npc[index].Distance(mountedCenter) < 3000.0 && ((double) Main.npc[index].ai[0] >= 10.0 || (double) Main.npc[index].ai[0] == 9.0 && (double) Main.npc[index].ai[2] > 120.0))
{
num = 0.95f;
amount = 0.03f;
}
}
ScreenDarkness.screenObstruction = MathHelper.Lerp(ScreenDarkness.screenObstruction, num, amount);
}
public static void DrawBack(SpriteBatch spriteBatch)
{
if ((double) ScreenDarkness.screenObstruction == 0.0)
return;
Color color = Color.Black * ScreenDarkness.screenObstruction;
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
}
public static void DrawFront(SpriteBatch spriteBatch)
{
if ((double) ScreenDarkness.screenObstruction == 0.0)
return;
Color color = new Color(0, 0, 120) * ScreenDarkness.screenObstruction * 0.3f;
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
}
}
}

View file

@ -0,0 +1,49 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.GameContent.Events.ScreenObstruction
// 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;
namespace Terraria.GameContent.Events
{
public class ScreenObstruction
{
public static float screenObstruction;
public static void Update()
{
float num = 0.0f;
float amount = 0.1f;
if (Main.player[Main.myPlayer].headcovered)
{
num = 0.95f;
amount = 0.3f;
}
ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, num, amount);
}
public static void Draw(SpriteBatch spriteBatch)
{
if ((double) ScreenObstruction.screenObstruction == 0.0)
return;
Color color = Color.Black * ScreenObstruction.screenObstruction;
int width = Main.extraTexture[49].Width;
int num = 10;
Rectangle rect = Main.player[Main.myPlayer].getRect();
rect.Inflate((width - rect.Width) / 2, (width - rect.Height) / 2 + num / 2);
rect.Offset(-(int) Main.screenPosition.X, -(int) Main.screenPosition.Y + (int) Main.player[Main.myPlayer].gfxOffY - num);
Rectangle destinationRectangle1 = Rectangle.Union(new Rectangle(0, 0, 1, 1), new Rectangle(rect.Right - 1, rect.Top - 1, 1, 1));
Rectangle destinationRectangle2 = Rectangle.Union(new Rectangle(Main.screenWidth - 1, 0, 1, 1), new Rectangle(rect.Right, rect.Bottom - 1, 1, 1));
Rectangle destinationRectangle3 = Rectangle.Union(new Rectangle(Main.screenWidth - 1, Main.screenHeight - 1, 1, 1), new Rectangle(rect.Left, rect.Bottom, 1, 1));
Rectangle destinationRectangle4 = Rectangle.Union(new Rectangle(0, Main.screenHeight - 1, 1, 1), new Rectangle(rect.Left - 1, rect.Top, 1, 1));
spriteBatch.Draw(Main.magicPixel, destinationRectangle1, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
spriteBatch.Draw(Main.magicPixel, destinationRectangle2, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
spriteBatch.Draw(Main.magicPixel, destinationRectangle3, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
spriteBatch.Draw(Main.magicPixel, destinationRectangle4, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
spriteBatch.Draw(Main.extraTexture[49], rect, color);
}
}
}