1.0.4.0 Source

This commit is contained in:
MikeyIsBaeYT 2021-10-26 14:55:42 -04:00
commit ff3d24ee9d
35 changed files with 101417 additions and 0 deletions

12
AssemblyInfo.cs Normal file
View file

@ -0,0 +1,12 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("Re-Logic")]
[assembly: AssemblyCopyright("Copyright © Re_Logic 2011")]
[assembly: AssemblyTitle("Terraria")]
[assembly: AssemblyProduct("Terraria")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f571b16a-2c9b-44ab-b115-7c762c9e4e7e")]
[assembly: AssemblyVersion("1.0.4.0")]

17
ChatLine.cs Normal file
View file

@ -0,0 +1,17 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.ChatLine
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria
{
public class ChatLine
{
public Color color = Color.White;
public int showTime;
public string text = "";
}
}

353
Chest.cs Normal file
View file

@ -0,0 +1,353 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Chest
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria
{
public class Chest
{
public static int maxItems = 20;
public Item[] item = new Item[Chest.maxItems];
public int x;
public int y;
public object Clone() => this.MemberwiseClone();
public static void Unlock(int X, int Y)
{
Main.PlaySound(22, X * 16, Y * 16);
for (int index1 = X; index1 <= X + 1; ++index1)
{
for (int index2 = Y; index2 <= Y + 1; ++index2)
{
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
if (Main.tile[index1, index2].frameX >= (short) 72 && Main.tile[index1, index2].frameX <= (short) 106 || Main.tile[index1, index2].frameX >= (short) 144 && Main.tile[index1, index2].frameX <= (short) 178)
{
Main.tile[index1, index2].frameX -= (short) 36;
for (int index3 = 0; index3 < 4; ++index3)
Dust.NewDust(new Vector2((float) (index1 * 16), (float) (index2 * 16)), 16, 16, 11);
}
}
}
}
public static int UsingChest(int i)
{
if (Main.chest[i] != null)
{
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && Main.player[index].chest == i)
return index;
}
}
return -1;
}
public static int FindChest(int X, int Y)
{
for (int index = 0; index < 1000; ++index)
{
if (Main.chest[index] != null && Main.chest[index].x == X && Main.chest[index].y == Y)
return index;
}
return -1;
}
public static int CreateChest(int X, int Y)
{
for (int index = 0; index < 1000; ++index)
{
if (Main.chest[index] != null && Main.chest[index].x == X && Main.chest[index].y == Y)
return -1;
}
for (int index1 = 0; index1 < 1000; ++index1)
{
if (Main.chest[index1] == null)
{
Main.chest[index1] = new Chest();
Main.chest[index1].x = X;
Main.chest[index1].y = Y;
for (int index2 = 0; index2 < Chest.maxItems; ++index2)
Main.chest[index1].item[index2] = new Item();
return index1;
}
}
return -1;
}
public static bool DestroyChest(int X, int Y)
{
for (int index1 = 0; index1 < 1000; ++index1)
{
if (Main.chest[index1] != null && Main.chest[index1].x == X && Main.chest[index1].y == Y)
{
for (int index2 = 0; index2 < Chest.maxItems; ++index2)
{
if (Main.chest[index1].item[index2].type > 0 && Main.chest[index1].item[index2].stack > 0)
return false;
}
Main.chest[index1] = (Chest) null;
return true;
}
}
return true;
}
public void AddShop(Item newItem)
{
for (int index = 0; index < 19; ++index)
{
if (this.item[index] == null || this.item[index].type == 0)
{
this.item[index] = (Item) newItem.Clone();
this.item[index].buyOnce = true;
if (this.item[index].value <= 0)
break;
this.item[index].value /= 5;
if (this.item[index].value >= 1)
break;
this.item[index].value = 1;
break;
}
}
}
public void SetupShop(int type)
{
for (int index = 0; index < Chest.maxItems; ++index)
this.item[index] = new Item();
switch (type)
{
case 1:
int index1 = 0;
this.item[index1].SetDefaults("Mining Helmet");
int index2 = index1 + 1;
this.item[index2].SetDefaults("Piggy Bank");
int index3 = index2 + 1;
this.item[index3].SetDefaults("Iron Anvil");
int index4 = index3 + 1;
this.item[index4].SetDefaults("Copper Pickaxe");
int index5 = index4 + 1;
this.item[index5].SetDefaults("Copper Axe");
int index6 = index5 + 1;
this.item[index6].SetDefaults("Torch");
int index7 = index6 + 1;
this.item[index7].SetDefaults("Lesser Healing Potion");
int index8 = index7 + 1;
if (Main.player[Main.myPlayer].statManaMax == 200)
{
this.item[index8].SetDefaults("Lesser Mana Potion");
++index8;
}
this.item[index8].SetDefaults("Wooden Arrow");
int index9 = index8 + 1;
this.item[index9].SetDefaults("Shuriken");
int index10 = index9 + 1;
if (Main.bloodMoon)
{
this.item[index10].SetDefaults("Throwing Knife");
++index10;
}
if (!Main.dayTime)
{
this.item[index10].SetDefaults("Glowstick");
++index10;
}
if (NPC.downedBoss3)
{
this.item[index10].SetDefaults("Safe");
++index10;
}
if (!Main.hardMode)
break;
this.item[index10].SetDefaults(488);
int num1 = index10 + 1;
break;
case 2:
int index11 = 0;
this.item[index11].SetDefaults("Musket Ball");
int index12 = index11 + 1;
if (Main.bloodMoon || Main.hardMode)
{
this.item[index12].SetDefaults("Silver Bullet");
++index12;
}
if (NPC.downedBoss2 && !Main.dayTime || Main.hardMode)
{
this.item[index12].SetDefaults(47);
++index12;
}
this.item[index12].SetDefaults("Flintlock Pistol");
int index13 = index12 + 1;
this.item[index13].SetDefaults("Minishark");
int index14 = index13 + 1;
if (!Main.dayTime)
{
this.item[index14].SetDefaults(324);
++index14;
}
if (Main.hardMode)
this.item[index14].SetDefaults(534);
int num2 = index14 + 1;
break;
case 3:
int index15 = 0;
int index16;
if (Main.bloodMoon)
{
this.item[index15].SetDefaults(67);
int index17 = index15 + 1;
this.item[index17].SetDefaults(59);
index16 = index17 + 1;
}
else
{
this.item[index15].SetDefaults("Purification Powder");
int index18 = index15 + 1;
this.item[index18].SetDefaults("Grass Seeds");
int index19 = index18 + 1;
this.item[index19].SetDefaults("Sunflower");
index16 = index19 + 1;
}
this.item[index16].SetDefaults("Acorn");
int index20 = index16 + 1;
this.item[index20].SetDefaults(114);
int index21 = index20 + 1;
if (Main.hardMode)
this.item[index21].SetDefaults(369);
int num3 = index21 + 1;
break;
case 4:
int index22 = 0;
this.item[index22].SetDefaults("Grenade");
int index23 = index22 + 1;
this.item[index23].SetDefaults("Bomb");
int index24 = index23 + 1;
this.item[index24].SetDefaults("Dynamite");
int index25 = index24 + 1;
if (Main.hardMode)
this.item[index25].SetDefaults("Hellfire Arrow");
int num4 = index25 + 1;
break;
case 5:
int index26 = 0;
this.item[index26].SetDefaults(254);
int index27 = index26 + 1;
if (Main.dayTime)
{
this.item[index27].SetDefaults(242);
++index27;
}
switch (Main.moonPhase)
{
case 0:
this.item[index27].SetDefaults(245);
int index28 = index27 + 1;
this.item[index28].SetDefaults(246);
index27 = index28 + 1;
break;
case 1:
this.item[index27].SetDefaults(325);
int index29 = index27 + 1;
this.item[index29].SetDefaults(326);
index27 = index29 + 1;
break;
}
this.item[index27].SetDefaults(269);
int index30 = index27 + 1;
this.item[index30].SetDefaults(270);
int index31 = index30 + 1;
this.item[index31].SetDefaults(271);
int index32 = index31 + 1;
if (NPC.downedClown)
{
this.item[index32].SetDefaults(503);
int index33 = index32 + 1;
this.item[index33].SetDefaults(504);
int index34 = index33 + 1;
this.item[index34].SetDefaults(505);
index32 = index34 + 1;
}
if (!Main.bloodMoon)
break;
this.item[index32].SetDefaults(322);
int num5 = index32 + 1;
break;
case 6:
int index35 = 0;
this.item[index35].SetDefaults(128);
int index36 = index35 + 1;
this.item[index36].SetDefaults(486);
int index37 = index36 + 1;
this.item[index37].SetDefaults(398);
int index38 = index37 + 1;
this.item[index38].SetDefaults(84);
int index39 = index38 + 1;
this.item[index39].SetDefaults(407);
int index40 = index39 + 1;
this.item[index40].SetDefaults(161);
int num6 = index40 + 1;
break;
case 7:
int index41 = 0;
this.item[index41].SetDefaults(487);
int index42 = index41 + 1;
this.item[index42].SetDefaults(496);
int index43 = index42 + 1;
this.item[index43].SetDefaults(500);
int index44 = index43 + 1;
this.item[index44].SetDefaults(507);
int index45 = index44 + 1;
this.item[index45].SetDefaults(508);
int index46 = index45 + 1;
this.item[index46].SetDefaults(531);
int index47 = index46 + 1;
this.item[index47].SetDefaults(576);
int num7 = index47 + 1;
break;
case 8:
int index48 = 0;
this.item[index48].SetDefaults(509);
int index49 = index48 + 1;
this.item[index49].SetDefaults(510);
int index50 = index49 + 1;
this.item[index50].SetDefaults(530);
int index51 = index50 + 1;
this.item[index51].SetDefaults(513);
int index52 = index51 + 1;
this.item[index52].SetDefaults(538);
int index53 = index52 + 1;
this.item[index53].SetDefaults(529);
int index54 = index53 + 1;
this.item[index54].SetDefaults(541);
int index55 = index54 + 1;
this.item[index55].SetDefaults(542);
int index56 = index55 + 1;
this.item[index56].SetDefaults(543);
int num8 = index56 + 1;
break;
case 9:
int index57 = 0;
this.item[index57].SetDefaults(588);
int index58 = index57 + 1;
this.item[index58].SetDefaults(589);
int index59 = index58 + 1;
this.item[index59].SetDefaults(590);
int index60 = index59 + 1;
this.item[index60].SetDefaults(597);
int index61 = index60 + 1;
this.item[index61].SetDefaults(598);
int index62 = index61 + 1;
this.item[index62].SetDefaults(596);
int num9 = index62 + 1;
break;
}
}
}
}

54
ClientSock.cs Normal file
View file

@ -0,0 +1,54 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.ClientSock
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.Net.Sockets;
namespace Terraria
{
public class ClientSock
{
public TcpClient tcpClient = new TcpClient();
public NetworkStream networkStream;
public string statusText;
public int statusCount;
public int statusMax;
public int timeOut;
public byte[] readBuffer;
public byte[] writeBuffer;
public bool active;
public bool locked;
public int state;
public void ClientWriteCallBack(IAsyncResult ar) => --NetMessage.buffer[256].spamCount;
public void ClientReadCallBack(IAsyncResult ar)
{
if (!Netplay.disconnect)
{
int streamLength = this.networkStream.EndRead(ar);
if (streamLength == 0)
{
Netplay.disconnect = true;
Main.statusText = "Lost connection";
}
else if (Main.ignoreErrors)
{
try
{
NetMessage.RecieveBytes(this.readBuffer, streamLength);
}
catch
{
}
}
else
NetMessage.RecieveBytes(this.readBuffer, streamLength);
}
this.locked = false;
}
}
}

185
Cloud.cs Normal file
View file

@ -0,0 +1,185 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Cloud
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria
{
public class Cloud
{
public Vector2 position;
public float scale;
public float rotation;
public float rSpeed;
public float sSpeed;
public bool active;
public int type;
public int width;
public int height;
private static Random rand = new Random();
public static void resetClouds()
{
if (Main.cloudLimit < 10)
return;
Main.numClouds = Cloud.rand.Next(10, Main.cloudLimit);
Main.windSpeed = 0.0f;
while ((double) Main.windSpeed == 0.0)
Main.windSpeed = (float) Cloud.rand.Next(-100, 101) * 0.01f;
for (int index = 0; index < 100; ++index)
Main.cloud[index].active = false;
for (int index = 0; index < Main.numClouds; ++index)
Cloud.addCloud();
for (int index = 0; index < Main.numClouds; ++index)
{
if ((double) Main.windSpeed < 0.0)
Main.cloud[index].position.X -= (float) (Main.screenWidth * 2);
else
Main.cloud[index].position.X += (float) (Main.screenWidth * 2);
}
}
public static void addCloud()
{
int index1 = -1;
for (int index2 = 0; index2 < 100; ++index2)
{
if (!Main.cloud[index2].active)
{
index1 = index2;
break;
}
}
if (index1 < 0)
return;
Main.cloud[index1].rSpeed = 0.0f;
Main.cloud[index1].sSpeed = 0.0f;
Main.cloud[index1].type = Cloud.rand.Next(4);
Main.cloud[index1].scale = (float) Cloud.rand.Next(70, 131) * 0.01f;
Main.cloud[index1].rotation = (float) Cloud.rand.Next(-10, 11) * 0.01f;
Main.cloud[index1].width = (int) ((double) Main.cloudTexture[Main.cloud[index1].type].Width * (double) Main.cloud[index1].scale);
Main.cloud[index1].height = (int) ((double) Main.cloudTexture[Main.cloud[index1].type].Height * (double) Main.cloud[index1].scale);
float num = Main.windSpeed;
if (!Main.gameMenu)
num = Main.windSpeed - Main.player[Main.myPlayer].velocity.X * 0.1f;
Main.cloud[index1].position.X = (double) num <= 0.0 ? (float) (Main.screenWidth + Main.cloudTexture[Main.cloud[index1].type].Width + Cloud.rand.Next(Main.screenWidth * 2)) : (float) (-Main.cloud[index1].width - Main.cloudTexture[Main.cloud[index1].type].Width - Cloud.rand.Next(Main.screenWidth * 2));
Main.cloud[index1].position.Y = (float) Cloud.rand.Next((int) ((double) -Main.screenHeight * 0.25), (int) ((double) Main.screenHeight * 0.25));
Main.cloud[index1].position.Y -= (float) Cloud.rand.Next((int) ((double) Main.screenHeight * 0.150000005960464));
Main.cloud[index1].position.Y -= (float) Cloud.rand.Next((int) ((double) Main.screenHeight * 0.150000005960464));
if ((double) Main.cloud[index1].scale > 1.3)
Main.cloud[index1].scale = 1.3f;
if ((double) Main.cloud[index1].scale < 0.7)
Main.cloud[index1].scale = 0.7f;
Main.cloud[index1].active = true;
Rectangle rectangle1 = new Rectangle((int) Main.cloud[index1].position.X, (int) Main.cloud[index1].position.Y, Main.cloud[index1].width, Main.cloud[index1].height);
for (int index3 = 0; index3 < 100; ++index3)
{
if (index1 != index3 && Main.cloud[index3].active)
{
Rectangle rectangle2 = new Rectangle((int) Main.cloud[index3].position.X, (int) Main.cloud[index3].position.Y, Main.cloud[index3].width, Main.cloud[index3].height);
if (rectangle1.Intersects(rectangle2))
Main.cloud[index1].active = false;
}
}
}
public Color cloudColor(Color bgColor)
{
float num1 = (float) (((double) this.scale - 0.400000005960464) * 0.899999976158142);
float num2 = 1.1f;
float num3 = (float) ((double) byte.MaxValue - (double) ((int) byte.MaxValue - (int) bgColor.R) * (double) num2);
float num4 = (float) ((double) byte.MaxValue - (double) ((int) byte.MaxValue - (int) bgColor.G) * (double) num2);
float num5 = (float) ((double) byte.MaxValue - (double) ((int) byte.MaxValue - (int) bgColor.B) * (double) num2);
float maxValue = (float) byte.MaxValue;
float num6 = num3 * num1;
float num7 = num4 * num1;
float num8 = num5 * num1;
float num9 = maxValue * num1;
if ((double) num6 < 0.0)
num6 = 0.0f;
if ((double) num7 < 0.0)
num7 = 0.0f;
if ((double) num8 < 0.0)
num8 = 0.0f;
if ((double) num9 < 0.0)
num9 = 0.0f;
return new Color((int) (byte) num6, (int) (byte) num7, (int) (byte) num8, (int) (byte) num9);
}
public object Clone() => this.MemberwiseClone();
public static void UpdateClouds()
{
int num = 0;
for (int index = 0; index < 100; ++index)
{
if (Main.cloud[index].active)
{
Main.cloud[index].rotation = 0.0f;
Main.cloud[index].Update();
++num;
}
}
for (int index = 0; index < 100; ++index)
{
if (Main.cloud[index].active)
{
if (index > 1 && (!Main.cloud[index - 1].active || (double) Main.cloud[index - 1].scale > (double) Main.cloud[index].scale + 0.02))
{
Cloud cloud = (Cloud) Main.cloud[index - 1].Clone();
Main.cloud[index - 1] = (Cloud) Main.cloud[index].Clone();
Main.cloud[index] = cloud;
}
if (index < 99 && (!Main.cloud[index].active || (double) Main.cloud[index + 1].scale < (double) Main.cloud[index].scale - 0.02))
{
Cloud cloud = (Cloud) Main.cloud[index + 1].Clone();
Main.cloud[index + 1] = (Cloud) Main.cloud[index].Clone();
Main.cloud[index] = cloud;
}
}
}
if (num >= Main.numClouds)
return;
Cloud.addCloud();
}
public void Update()
{
if (Main.gameMenu)
{
this.position.X += (float) ((double) Main.windSpeed * (double) this.scale * 3.0);
}
else
{
float num1 = Main.player[Main.myPlayer].velocity.X * 0.18f;
float num2 = (float) (((double) Main.screenPosition.X - (double) Main.screenLastPosition.X) * 0.180000007152557);
if (Main.player[Main.myPlayer].dead)
num2 = 0.0f;
this.position.X += (Main.windSpeed - num2) * this.scale;
}
if ((double) Main.windSpeed > 0.0)
{
if ((double) this.position.X - (double) Main.cloudTexture[this.type].Width > (double) (Main.screenWidth + 200))
this.active = false;
}
else if ((double) this.position.X + (double) this.width + (double) Main.cloudTexture[this.type].Width < -200.0)
this.active = false;
this.rSpeed += (float) Cloud.rand.Next(-10, 11) * 2E-05f;
if ((double) this.rSpeed > 0.0007)
this.rSpeed = 0.0007f;
if ((double) this.rSpeed < -0.0007)
this.rSpeed = -0.0007f;
if ((double) this.rotation > 0.05)
this.rotation = 0.05f;
if ((double) this.rotation < -0.05)
this.rotation = -0.05f;
this.rotation += this.rSpeed;
this.width = (int) ((double) Main.cloudTexture[this.type].Width * (double) this.scale);
this.height = (int) ((double) Main.cloudTexture[this.type].Height * (double) this.scale);
}
}
}

668
Collision.cs Normal file
View file

@ -0,0 +1,668 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Collision
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria
{
public class Collision
{
public static bool up;
public static bool down;
public static bool CanHit(
Vector2 Position1,
int Width1,
int Height1,
Vector2 Position2,
int Width2,
int Height2)
{
int index1 = (int) (((double) Position1.X + (double) (Width1 / 2)) / 16.0);
int index2 = (int) (((double) Position1.Y + (double) (Height1 / 2)) / 16.0);
int num1 = (int) (((double) Position2.X + (double) (Width2 / 2)) / 16.0);
int num2 = (int) (((double) Position2.Y + (double) (Height2 / 2)) / 16.0);
try
{
do
{
int num3 = Math.Abs(index1 - num1);
int num4 = Math.Abs(index2 - num2);
if (index1 == num1 && index2 == num2)
return true;
if (num3 > num4)
{
if (index1 < num1)
++index1;
else
--index1;
if (Main.tile[index1, index2 - 1] == null)
Main.tile[index1, index2 - 1] = new Tile();
if (Main.tile[index1, index2 + 1] == null)
Main.tile[index1, index2 + 1] = new Tile();
if (Main.tile[index1, index2 - 1].active && Main.tileSolid[(int) Main.tile[index1, index2 - 1].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2 - 1].type] && Main.tile[index1, index2 + 1].active && Main.tileSolid[(int) Main.tile[index1, index2 + 1].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2 + 1].type])
return false;
}
else
{
if (index2 < num2)
++index2;
else
--index2;
if (Main.tile[index1 - 1, index2] == null)
Main.tile[index1 - 1, index2] = new Tile();
if (Main.tile[index1 + 1, index2] == null)
Main.tile[index1 + 1, index2] = new Tile();
if (Main.tile[index1 - 1, index2].active && Main.tileSolid[(int) Main.tile[index1 - 1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1 - 1, index2].type] && Main.tile[index1 + 1, index2].active && Main.tileSolid[(int) Main.tile[index1 + 1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1 + 1, index2].type])
return false;
}
if (Main.tile[index1, index2] == null)
Main.tile[index1, index2] = new Tile();
}
while (!Main.tile[index1, index2].active || !Main.tileSolid[(int) Main.tile[index1, index2].type] || Main.tileSolidTop[(int) Main.tile[index1, index2].type]);
return false;
}
catch
{
return false;
}
}
public static bool EmptyTile(int i, int j, bool ignoreTiles = false)
{
Rectangle rectangle = new Rectangle(i * 16, j * 16, 16, 16);
if (Main.tile[i, j].active && !ignoreTiles)
return false;
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (Main.player[index].active && rectangle.Intersects(new Rectangle((int) Main.player[index].position.X, (int) Main.player[index].position.Y, Main.player[index].width, Main.player[index].height)))
return false;
}
for (int index = 0; index < 200; ++index)
{
if (Main.npc[index].active && rectangle.Intersects(new Rectangle((int) Main.npc[index].position.X, (int) Main.npc[index].position.Y, Main.npc[index].width, Main.npc[index].height)))
return false;
}
return true;
}
public static bool DrownCollision(Vector2 Position, int Width, int Height, float gravDir = -1f)
{
Vector2 vector2_1 = new Vector2(Position.X + (float) (Width / 2), Position.Y + (float) (Height / 2));
int num1 = 10;
int num2 = 12;
if (num1 > Width)
num1 = Width;
if (num2 > Height)
num2 = Height;
vector2_1 = new Vector2(vector2_1.X - (float) (num1 / 2), Position.Y - 2f);
if ((double) gravDir == -1.0)
vector2_1.Y += (float) (Height / 2 - 6);
int num3 = (int) ((double) Position.X / 16.0) - 1;
int num4 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num5 = (int) ((double) Position.Y / 16.0) - 1;
int num6 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int index1 = num3; index1 < num4; ++index1)
{
for (int index2 = num5; index2 < num6; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].liquid > (byte) 0)
{
Vector2 vector2_2;
vector2_2.X = (float) (index1 * 16);
vector2_2.Y = (float) (index2 * 16);
int num7 = 16;
float num8 = (float) (256 - (int) Main.tile[index1, index2].liquid) / 32f;
vector2_2.Y += num8 * 2f;
int num9 = num7 - (int) ((double) num8 * 2.0);
if ((double) vector2_1.X + (double) num1 > (double) vector2_2.X && (double) vector2_1.X < (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) num2 > (double) vector2_2.Y && (double) vector2_1.Y < (double) vector2_2.Y + (double) num9)
return true;
}
}
}
return false;
}
public static bool WetCollision(Vector2 Position, int Width, int Height)
{
Vector2 vector2_1 = new Vector2(Position.X + (float) (Width / 2), Position.Y + (float) (Height / 2));
int num1 = 10;
int num2 = Height / 2;
if (num1 > Width)
num1 = Width;
if (num2 > Height)
num2 = Height;
vector2_1 = new Vector2(vector2_1.X - (float) (num1 / 2), vector2_1.Y - (float) (num2 / 2));
int num3 = (int) ((double) Position.X / 16.0) - 1;
int num4 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num5 = (int) ((double) Position.Y / 16.0) - 1;
int num6 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesX)
num4 = Main.maxTilesX;
if (num5 < 0)
num5 = 0;
if (num6 > Main.maxTilesY)
num6 = Main.maxTilesY;
for (int index1 = num3; index1 < num4; ++index1)
{
for (int index2 = num5; index2 < num6; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].liquid > (byte) 0)
{
Vector2 vector2_2;
vector2_2.X = (float) (index1 * 16);
vector2_2.Y = (float) (index2 * 16);
int num7 = 16;
float num8 = (float) (256 - (int) Main.tile[index1, index2].liquid) / 32f;
vector2_2.Y += num8 * 2f;
int num9 = num7 - (int) ((double) num8 * 2.0);
if ((double) vector2_1.X + (double) num1 > (double) vector2_2.X && (double) vector2_1.X < (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) num2 > (double) vector2_2.Y && (double) vector2_1.Y < (double) vector2_2.Y + (double) num9)
return true;
}
}
}
return false;
}
public static bool LavaCollision(Vector2 Position, int Width, int Height)
{
int num1 = Height;
int num2 = (int) ((double) Position.X / 16.0) - 1;
int num3 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num4 = (int) ((double) Position.Y / 16.0) - 1;
int num5 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num2 < 0)
num2 = 0;
if (num3 > Main.maxTilesX)
num3 = Main.maxTilesX;
if (num4 < 0)
num4 = 0;
if (num5 > Main.maxTilesY)
num5 = Main.maxTilesY;
for (int index1 = num2; index1 < num3; ++index1)
{
for (int index2 = num4; index2 < num5; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].liquid > (byte) 0 && Main.tile[index1, index2].lava)
{
Vector2 vector2;
vector2.X = (float) (index1 * 16);
vector2.Y = (float) (index2 * 16);
int num6 = 16;
float num7 = (float) (256 - (int) Main.tile[index1, index2].liquid) / 32f;
vector2.Y += num7 * 2f;
int num8 = num6 - (int) ((double) num7 * 2.0);
if ((double) Position.X + (double) Width > (double) vector2.X && (double) Position.X < (double) vector2.X + 16.0 && (double) Position.Y + (double) num1 > (double) vector2.Y && (double) Position.Y < (double) vector2.Y + (double) num8)
return true;
}
}
}
return false;
}
public static Vector2 TileCollision(
Vector2 Position,
Vector2 Velocity,
int Width,
int Height,
bool fallThrough = false,
bool fall2 = false)
{
Collision.up = false;
Collision.down = false;
Vector2 vector2_1 = Velocity;
Vector2 vector2_2 = Velocity;
Vector2 vector2_3 = Position + Velocity;
Vector2 vector2_4 = Position;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
int num5 = -1;
int num6 = -1;
int num7 = -1;
int num8 = -1;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].active && (Main.tileSolid[(int) Main.tile[index1, index2].type] || Main.tileSolidTop[(int) Main.tile[index1, index2].type] && Main.tile[index1, index2].frameY == (short) 0))
{
Vector2 vector2_5;
vector2_5.X = (float) (index1 * 16);
vector2_5.Y = (float) (index2 * 16);
if ((double) vector2_3.X + (double) Width > (double) vector2_5.X && (double) vector2_3.X < (double) vector2_5.X + 16.0 && (double) vector2_3.Y + (double) Height > (double) vector2_5.Y && (double) vector2_3.Y < (double) vector2_5.Y + 16.0)
{
if ((double) vector2_4.Y + (double) Height <= (double) vector2_5.Y)
{
Collision.down = true;
if (!Main.tileSolidTop[(int) Main.tile[index1, index2].type] || !fallThrough || (double) Velocity.Y > 1.0 && !fall2)
{
num7 = index1;
num8 = index2;
if (num7 != num5)
vector2_1.Y = vector2_5.Y - (vector2_4.Y + (float) Height);
}
}
else if ((double) vector2_4.X + (double) Width <= (double) vector2_5.X && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
num5 = index1;
num6 = index2;
if (num6 != num8)
vector2_1.X = vector2_5.X - (vector2_4.X + (float) Width);
if (num7 == num5)
vector2_1.Y = vector2_2.Y;
}
else if ((double) vector2_4.X >= (double) vector2_5.X + 16.0 && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
num5 = index1;
num6 = index2;
if (num6 != num8)
vector2_1.X = vector2_5.X + 16f - vector2_4.X;
if (num7 == num5)
vector2_1.Y = vector2_2.Y;
}
else if ((double) vector2_4.Y >= (double) vector2_5.Y + 16.0 && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
Collision.up = true;
num7 = index1;
num8 = index2;
vector2_1.Y = vector2_5.Y + 16f - vector2_4.Y;
if (num8 == num6)
vector2_1.X = vector2_2.X;
}
}
}
}
}
return vector2_1;
}
public static bool SolidCollision(Vector2 Position, int Width, int Height)
{
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].active && Main.tileSolid[(int) Main.tile[index1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
Vector2 vector2;
vector2.X = (float) (index1 * 16);
vector2.Y = (float) (index2 * 16);
if ((double) Position.X + (double) Width > (double) vector2.X && (double) Position.X < (double) vector2.X + 16.0 && (double) Position.Y + (double) Height > (double) vector2.Y && (double) Position.Y < (double) vector2.Y + 16.0)
return true;
}
}
}
return false;
}
public static Vector2 WaterCollision(
Vector2 Position,
Vector2 Velocity,
int Width,
int Height,
bool fallThrough = false,
bool fall2 = false)
{
Vector2 vector2_1 = Velocity;
Vector2 vector2_2 = Position + Velocity;
Vector2 vector2_3 = Position;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].liquid > (byte) 0)
{
int num5 = (int) Math.Round((double) ((float) Main.tile[index1, index2].liquid / 32f)) * 2;
Vector2 vector2_4;
vector2_4.X = (float) (index1 * 16);
vector2_4.Y = (float) (index2 * 16 + 16 - num5);
if ((double) vector2_2.X + (double) Width > (double) vector2_4.X && (double) vector2_2.X < (double) vector2_4.X + 16.0 && (double) vector2_2.Y + (double) Height > (double) vector2_4.Y && (double) vector2_2.Y < (double) vector2_4.Y + (double) num5 && (double) vector2_3.Y + (double) Height <= (double) vector2_4.Y && !fallThrough)
vector2_1.Y = vector2_4.Y - (vector2_3.Y + (float) Height);
}
}
}
return vector2_1;
}
public static Vector2 AnyCollision(
Vector2 Position,
Vector2 Velocity,
int Width,
int Height)
{
Vector2 vector2_1 = Velocity;
Vector2 vector2_2 = Velocity;
Vector2 vector2_3 = Position + Velocity;
Vector2 vector2_4 = Position;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
int num5 = -1;
int num6 = -1;
int num7 = -1;
int num8 = -1;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].active)
{
Vector2 vector2_5;
vector2_5.X = (float) (index1 * 16);
vector2_5.Y = (float) (index2 * 16);
if ((double) vector2_3.X + (double) Width > (double) vector2_5.X && (double) vector2_3.X < (double) vector2_5.X + 16.0 && (double) vector2_3.Y + (double) Height > (double) vector2_5.Y && (double) vector2_3.Y < (double) vector2_5.Y + 16.0)
{
if ((double) vector2_4.Y + (double) Height <= (double) vector2_5.Y)
{
num7 = index1;
num8 = index2;
if (num7 != num5)
vector2_1.Y = vector2_5.Y - (vector2_4.Y + (float) Height);
}
else if ((double) vector2_4.X + (double) Width <= (double) vector2_5.X && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
num5 = index1;
num6 = index2;
if (num6 != num8)
vector2_1.X = vector2_5.X - (vector2_4.X + (float) Width);
if (num7 == num5)
vector2_1.Y = vector2_2.Y;
}
else if ((double) vector2_4.X >= (double) vector2_5.X + 16.0 && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
num5 = index1;
num6 = index2;
if (num6 != num8)
vector2_1.X = vector2_5.X + 16f - vector2_4.X;
if (num7 == num5)
vector2_1.Y = vector2_2.Y;
}
else if ((double) vector2_4.Y >= (double) vector2_5.Y + 16.0 && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
{
num7 = index1;
num8 = index2;
vector2_1.Y = (float) ((double) vector2_5.Y + 16.0 - (double) vector2_4.Y + 0.00999999977648258);
if (num8 == num6)
vector2_1.X = vector2_2.X + 0.01f;
}
}
}
}
}
return vector2_1;
}
public static void HitTiles(Vector2 Position, Vector2 Velocity, int Width, int Height)
{
Vector2 vector2_1 = Position + Velocity;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int i = num1; i < num2; ++i)
{
for (int j = num3; j < num4; ++j)
{
if (Main.tile[i, j] != null && Main.tile[i, j].active && (Main.tileSolid[(int) Main.tile[i, j].type] || Main.tileSolidTop[(int) Main.tile[i, j].type] && Main.tile[i, j].frameY == (short) 0))
{
Vector2 vector2_2;
vector2_2.X = (float) (i * 16);
vector2_2.Y = (float) (j * 16);
if ((double) vector2_1.X + (double) Width >= (double) vector2_2.X && (double) vector2_1.X <= (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) Height >= (double) vector2_2.Y && (double) vector2_1.Y <= (double) vector2_2.Y + 16.0)
WorldGen.KillTile(i, j, true, true);
}
}
}
}
public static Vector2 HurtTiles(
Vector2 Position,
Vector2 Velocity,
int Width,
int Height,
bool fireImmune = false)
{
Vector2 vector2_1 = Position;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int i = num1; i < num2; ++i)
{
for (int j = num3; j < num4; ++j)
{
if (Main.tile[i, j] != null && Main.tile[i, j].active && (Main.tile[i, j].type == (byte) 32 || Main.tile[i, j].type == (byte) 37 || Main.tile[i, j].type == (byte) 48 || Main.tile[i, j].type == (byte) 53 || Main.tile[i, j].type == (byte) 57 || Main.tile[i, j].type == (byte) 58 || Main.tile[i, j].type == (byte) 69 || Main.tile[i, j].type == (byte) 76 || Main.tile[i, j].type == (byte) 112 || Main.tile[i, j].type == (byte) 116 || Main.tile[i, j].type == (byte) 123))
{
Vector2 vector2_2;
vector2_2.X = (float) (i * 16);
vector2_2.Y = (float) (j * 16);
int num5 = 0;
int type = (int) Main.tile[i, j].type;
switch (type)
{
case 32:
case 69:
case 80:
if ((double) vector2_1.X + (double) Width > (double) vector2_2.X && (double) vector2_1.X < (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) Height > (double) vector2_2.Y && (double) vector2_1.Y < (double) vector2_2.Y + 16.01)
{
int num6 = 1;
if ((double) vector2_1.X + (double) (Width / 2) < (double) vector2_2.X + 8.0)
num6 = -1;
int num7 = 10;
switch (type)
{
case 69:
num7 = 17;
break;
case 80:
num7 = 6;
break;
}
if (type == 32 || type == 69)
{
WorldGen.KillTile(i, j);
if (Main.netMode == 1 && !Main.tile[i, j].active && Main.netMode == 1)
NetMessage.SendData(17, number: 4, number2: ((float) i), number3: ((float) j));
}
return new Vector2((float) num6, (float) num7);
}
continue;
case 53:
case 112:
case 116:
case 123:
if ((double) vector2_1.X + (double) Width - 2.0 >= (double) vector2_2.X && (double) vector2_1.X + 2.0 <= (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) Height - 2.0 >= (double) vector2_2.Y && (double) vector2_1.Y + 2.0 <= (double) vector2_2.Y + 16.0)
{
int num8 = 1;
if ((double) vector2_1.X + (double) (Width / 2) < (double) vector2_2.X + 8.0)
num8 = -1;
int num9 = 20;
return new Vector2((float) num8, (float) num9);
}
continue;
default:
if ((double) vector2_1.X + (double) Width >= (double) vector2_2.X && (double) vector2_1.X <= (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) Height >= (double) vector2_2.Y && (double) vector2_1.Y <= (double) vector2_2.Y + 16.01)
{
int num10 = 1;
if ((double) vector2_1.X + (double) (Width / 2) < (double) vector2_2.X + 8.0)
num10 = -1;
if (!fireImmune && (type == 37 || type == 58 || type == 76))
num5 = 20;
if (type == 48)
num5 = 40;
return new Vector2((float) num10, (float) num5);
}
continue;
}
}
}
}
return new Vector2();
}
public static bool SwitchTiles(Vector2 Position, int Width, int Height, Vector2 oldPosition)
{
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index = num1; index < num2; ++index)
{
for (int j = num3; j < num4; ++j)
{
if (Main.tile[index, j] != null && Main.tile[index, j].active && Main.tile[index, j].type == (byte) 135)
{
Vector2 vector2;
vector2.X = (float) (index * 16);
vector2.Y = (float) (j * 16 + 12);
if ((double) Position.X + (double) Width > (double) vector2.X && (double) Position.X < (double) vector2.X + 16.0 && (double) Position.Y + (double) Height > (double) vector2.Y && (double) Position.Y < (double) vector2.Y + 4.01 && ((double) oldPosition.X + (double) Width <= (double) vector2.X || (double) oldPosition.X >= (double) vector2.X + 16.0 || (double) oldPosition.Y + (double) Height <= (double) vector2.Y || (double) oldPosition.Y >= (double) vector2.Y + 16.01))
{
WorldGen.hitSwitch(index, j);
NetMessage.SendData(59, number: index, number2: ((float) j));
return true;
}
}
}
}
return false;
}
public static Vector2 StickyTiles(
Vector2 Position,
Vector2 Velocity,
int Width,
int Height)
{
Vector2 vector2_1 = Position;
int num1 = (int) ((double) Position.X / 16.0) - 1;
int num2 = (int) (((double) Position.X + (double) Width) / 16.0) + 2;
int num3 = (int) ((double) Position.Y / 16.0) - 1;
int num4 = (int) (((double) Position.Y + (double) Height) / 16.0) + 2;
if (num1 < 0)
num1 = 0;
if (num2 > Main.maxTilesX)
num2 = Main.maxTilesX;
if (num3 < 0)
num3 = 0;
if (num4 > Main.maxTilesY)
num4 = Main.maxTilesY;
for (int index1 = num1; index1 < num2; ++index1)
{
for (int index2 = num3; index2 < num4; ++index2)
{
if (Main.tile[index1, index2] != null && Main.tile[index1, index2].active && Main.tile[index1, index2].type == (byte) 51)
{
Vector2 vector2_2;
vector2_2.X = (float) (index1 * 16);
vector2_2.Y = (float) (index2 * 16);
if ((double) vector2_1.X + (double) Width > (double) vector2_2.X && (double) vector2_1.X < (double) vector2_2.X + 16.0 && (double) vector2_1.Y + (double) Height > (double) vector2_2.Y && (double) vector2_1.Y < (double) vector2_2.Y + 16.01)
{
if ((double) Math.Abs(Velocity.X) + (double) Math.Abs(Velocity.Y) > 0.7 && Main.rand.Next(30) == 0)
Dust.NewDust(new Vector2((float) (index1 * 16), (float) (index2 * 16)), 16, 16, 30);
return new Vector2((float) index1, (float) index2);
}
}
}
}
return new Vector2(-1f, -1f);
}
public static bool SolidTiles(int startX, int endX, int startY, int endY)
{
if (startX < 0 || endX >= Main.maxTilesX || startY < 0 || endY >= Main.maxTilesY)
return true;
for (int index1 = startX; index1 < endX + 1; ++index1)
{
for (int index2 = startY; index2 < endY + 1; ++index2)
{
if (Main.tile[index1, index2] == null)
return false;
if (Main.tile[index1, index2].active && Main.tileSolid[(int) Main.tile[index1, index2].type] && !Main.tileSolidTop[(int) Main.tile[index1, index2].type])
return true;
}
}
return false;
}
}
}

122
CombatText.cs Normal file
View file

@ -0,0 +1,122 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.CombatText
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria
{
public class CombatText
{
public Vector2 position;
public Vector2 velocity;
public float alpha;
public int alphaDir = 1;
public string text;
public float scale = 1f;
public float rotation;
public Color color;
public bool active;
public int lifeTime;
public bool crit;
public static void NewText(Rectangle location, Color color, string text, bool Crit = false)
{
if (Main.netMode == 2)
return;
for (int index1 = 0; index1 < 100; ++index1)
{
if (!Main.combatText[index1].active)
{
int index2 = 0;
if (Crit)
index2 = 1;
Vector2 vector2 = Main.fontCombatText[index2].MeasureString(text);
Main.combatText[index1].alpha = 1f;
Main.combatText[index1].alphaDir = -1;
Main.combatText[index1].active = true;
Main.combatText[index1].scale = 0.0f;
Main.combatText[index1].rotation = 0.0f;
Main.combatText[index1].position.X = (float) ((double) location.X + (double) location.Width * 0.5 - (double) vector2.X * 0.5);
Main.combatText[index1].position.Y = (float) ((double) location.Y + (double) location.Height * 0.25 - (double) vector2.Y * 0.5);
Main.combatText[index1].position.X += (float) Main.rand.Next(-(int) ((double) location.Width * 0.5), (int) ((double) location.Width * 0.5) + 1);
Main.combatText[index1].position.Y += (float) Main.rand.Next(-(int) ((double) location.Height * 0.5), (int) ((double) location.Height * 0.5) + 1);
Main.combatText[index1].color = color;
Main.combatText[index1].text = text;
Main.combatText[index1].velocity.Y = -7f;
Main.combatText[index1].lifeTime = 60;
Main.combatText[index1].crit = Crit;
if (!Crit)
break;
Main.combatText[index1].text = text;
Main.combatText[index1].color = new Color((int) byte.MaxValue, 100, 30, (int) byte.MaxValue);
Main.combatText[index1].lifeTime *= 2;
Main.combatText[index1].velocity.Y *= 2f;
Main.combatText[index1].velocity.X = (float) Main.rand.Next(-25, 26) * 0.05f;
Main.combatText[index1].rotation = (float) (Main.combatText[index1].lifeTime / 2) * (1f / 500f);
if ((double) Main.combatText[index1].velocity.X >= 0.0)
break;
Main.combatText[index1].rotation *= -1f;
break;
}
}
}
public void Update()
{
if (!this.active)
return;
this.alpha += (float) this.alphaDir * 0.05f;
if ((double) this.alpha <= 0.6)
this.alphaDir = 1;
if ((double) this.alpha >= 1.0)
{
this.alpha = 1f;
this.alphaDir = -1;
}
this.velocity.Y *= 0.92f;
if (this.crit)
this.velocity.Y *= 0.92f;
this.velocity.X *= 0.93f;
this.position += this.velocity;
--this.lifeTime;
if (this.lifeTime <= 0)
{
this.scale -= 0.1f;
if ((double) this.scale < 0.1)
this.active = false;
this.lifeTime = 0;
if (!this.crit)
return;
this.alphaDir = -1;
this.scale += 0.07f;
}
else
{
if (this.crit)
{
if ((double) this.velocity.X < 0.0)
this.rotation += 1f / 1000f;
else
this.rotation -= 1f / 1000f;
}
if ((double) this.scale < 1.0)
this.scale += 0.1f;
if ((double) this.scale <= 1.0)
return;
this.scale = 1f;
}
}
public static void UpdateCombatText()
{
for (int index = 0; index < 100; ++index)
{
if (Main.combatText[index].active)
Main.combatText[index].Update();
}
}
}
}

597
Dust.cs Normal file
View file

@ -0,0 +1,597 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Dust
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria
{
public class Dust
{
public Vector2 position;
public Vector2 velocity;
public static int lavaBubbles;
public float fadeIn;
public bool noGravity;
public float scale;
public float rotation;
public bool noLight;
public bool active;
public int type;
public Color color;
public int alpha;
public Rectangle frame;
public static int NewDust(
Vector2 Position,
int Width,
int Height,
int Type,
float SpeedX = 0.0f,
float SpeedY = 0.0f,
int Alpha = 0,
Color newColor = default (Color),
float Scale = 1f)
{
if (Main.gameMenu)
return 0;
if (Main.rand == null)
Main.rand = new Random((int) DateTime.Now.Ticks);
if (Main.gamePaused || WorldGen.gen || Main.netMode == 2)
return 0;
if (!new Rectangle((int) ((double) Main.player[Main.myPlayer].position.X - (double) (Main.screenWidth / 2) - 100.0), (int) ((double) Main.player[Main.myPlayer].position.Y - (double) (Main.screenHeight / 2) - 100.0), Main.screenWidth + 200, Main.screenHeight + 200).Intersects(new Rectangle((int) Position.X, (int) Position.Y, 10, 10)))
return 2000;
int num1 = 2000;
for (int index = 0; index < 2000; ++index)
{
if (!Main.dust[index].active)
{
int num2 = Width;
int num3 = Height;
if (num2 < 5)
num2 = 5;
if (num3 < 5)
num3 = 5;
num1 = index;
Main.dust[index].fadeIn = 0.0f;
Main.dust[index].active = true;
Main.dust[index].type = Type;
Main.dust[index].noGravity = false;
Main.dust[index].color = newColor;
Main.dust[index].alpha = Alpha;
Main.dust[index].position.X = (float) ((double) Position.X + (double) Main.rand.Next(num2 - 4) + 4.0);
Main.dust[index].position.Y = (float) ((double) Position.Y + (double) Main.rand.Next(num3 - 4) + 4.0);
Main.dust[index].velocity.X = (float) Main.rand.Next(-20, 21) * 0.1f + SpeedX;
Main.dust[index].velocity.Y = (float) Main.rand.Next(-20, 21) * 0.1f + SpeedY;
Main.dust[index].frame.X = 10 * Type;
Main.dust[index].frame.Y = 10 * Main.rand.Next(3);
Main.dust[index].frame.Width = 8;
Main.dust[index].frame.Height = 8;
Main.dust[index].rotation = 0.0f;
Main.dust[index].scale = (float) (1.0 + (double) Main.rand.Next(-20, 21) * 0.00999999977648258);
Main.dust[index].scale *= Scale;
Main.dust[index].noLight = false;
if (Main.dust[index].type == 6 || Main.dust[index].type == 75 || Main.dust[index].type == 29 || Main.dust[index].type >= 59 && Main.dust[index].type <= 65)
{
Main.dust[index].velocity.Y = (float) Main.rand.Next(-10, 6) * 0.1f;
Main.dust[index].velocity.X *= 0.3f;
Main.dust[index].scale *= 0.7f;
}
if (Main.dust[index].type == 33 || Main.dust[index].type == 52)
{
Main.dust[index].alpha = 170;
Main.dust[index].velocity *= 0.5f;
++Main.dust[index].velocity.Y;
}
if (Main.dust[index].type == 41)
Main.dust[index].velocity *= 0.0f;
if (Main.dust[index].type == 34 || Main.dust[index].type == 35)
{
Main.dust[index].velocity *= 0.1f;
Main.dust[index].velocity.Y = -0.5f;
if (Main.dust[index].type == 34 && !Collision.WetCollision(new Vector2(Main.dust[index].position.X, Main.dust[index].position.Y - 8f), 4, 4))
{
Main.dust[index].active = false;
break;
}
break;
}
break;
}
}
return num1;
}
public static void UpdateDust()
{
Dust.lavaBubbles = 0;
Main.snowDust = 0;
for (int index = 0; index < 2000; ++index)
{
if (index < Main.numDust)
{
if (Main.dust[index].active)
{
if (Main.dust[index].type == 35)
++Dust.lavaBubbles;
Main.dust[index].position += Main.dust[index].velocity;
if (Main.dust[index].type == 6 || Main.dust[index].type == 75 || Main.dust[index].type == 29 || Main.dust[index].type >= 59 && Main.dust[index].type <= 65)
{
if (!Main.dust[index].noGravity)
Main.dust[index].velocity.Y += 0.05f;
if (!Main.dust[index].noLight)
{
float num1 = Main.dust[index].scale * 1.4f;
if (Main.dust[index].type == 29)
{
if ((double) num1 > 1.0)
num1 = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num1 * 0.1f, num1 * 0.4f, num1);
}
if (Main.dust[index].type == 75)
{
if ((double) num1 > 1.0)
num1 = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num1 * 0.7f, num1, num1 * 0.2f);
}
else if (Main.dust[index].type >= 59 && Main.dust[index].type <= 65)
{
if ((double) num1 > 0.800000011920929)
num1 = 0.8f;
int num2 = Main.dust[index].type - 58;
float num3 = 1f;
float num4 = 1f;
float num5 = 1f;
switch (num2)
{
case 1:
num3 = 0.0f;
num4 = 0.1f;
num5 = 1.3f;
break;
case 2:
num3 = 1f;
num4 = 0.1f;
num5 = 0.1f;
break;
case 3:
num3 = 0.0f;
num4 = 1f;
num5 = 0.1f;
break;
case 4:
num3 = 0.9f;
num4 = 0.0f;
num5 = 0.9f;
break;
case 5:
num3 = 1.3f;
num4 = 1.3f;
num5 = 1.3f;
break;
case 6:
num3 = 0.9f;
num4 = 0.9f;
num5 = 0.0f;
break;
case 7:
num3 = (float) (0.5 * (double) Main.demonTorch + 1.0 * (1.0 - (double) Main.demonTorch));
num4 = 0.3f;
num5 = (float) (1.0 * (double) Main.demonTorch + 0.5 * (1.0 - (double) Main.demonTorch));
break;
}
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num1 * num3, num1 * num4, num1 * num5);
}
else
{
if ((double) num1 > 0.600000023841858)
num1 = 0.6f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num1, num1 * 0.65f, num1 * 0.4f);
}
}
}
else if (Main.dust[index].type == 14 || Main.dust[index].type == 16 || Main.dust[index].type == 31 || Main.dust[index].type == 46)
{
Main.dust[index].velocity.Y *= 0.98f;
Main.dust[index].velocity.X *= 0.98f;
if (Main.dust[index].type == 31 && Main.dust[index].noGravity)
{
Main.dust[index].velocity *= 1.02f;
Main.dust[index].scale += 0.02f;
Main.dust[index].alpha += 4;
if (Main.dust[index].alpha > (int) byte.MaxValue)
{
Main.dust[index].scale = 0.0001f;
Main.dust[index].alpha = (int) byte.MaxValue;
}
}
}
else if (Main.dust[index].type == 32)
{
Main.dust[index].scale -= 0.01f;
Main.dust[index].velocity.X *= 0.96f;
Main.dust[index].velocity.Y += 0.1f;
}
else if (Main.dust[index].type == 43)
{
Main.dust[index].rotation += 0.1f * Main.dust[index].scale;
Color color = Lighting.GetColor((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0));
float num6 = (float) color.R / 270f;
float num7 = (float) color.G / 270f;
float num8 = (float) color.B / 270f;
float R = num6 * (Main.dust[index].scale * 1.07f);
float G = num7 * (Main.dust[index].scale * 1.07f);
float B = num8 * (Main.dust[index].scale * 1.07f);
if (Main.dust[index].alpha < (int) byte.MaxValue)
{
Main.dust[index].scale += 0.09f;
if ((double) Main.dust[index].scale >= 1.0)
{
Main.dust[index].scale = 1f;
Main.dust[index].alpha = (int) byte.MaxValue;
}
}
else
{
if ((double) Main.dust[index].scale < 0.8)
Main.dust[index].scale -= 0.01f;
if ((double) Main.dust[index].scale < 0.5)
Main.dust[index].scale -= 0.01f;
}
if ((double) R < 0.05 && (double) G < 0.05 && (double) B < 0.05)
Main.dust[index].active = false;
else
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), R, G, B);
}
else if (Main.dust[index].type == 15 || Main.dust[index].type == 57 || Main.dust[index].type == 58)
{
Main.dust[index].velocity.Y *= 0.98f;
Main.dust[index].velocity.X *= 0.98f;
float num = Main.dust[index].scale;
if (Main.dust[index].type != 15)
num = Main.dust[index].scale * 0.8f;
if (Main.dust[index].noLight)
Main.dust[index].velocity *= 0.95f;
if ((double) num > 1.0)
num = 1f;
if (Main.dust[index].type == 15)
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num * 0.45f, num * 0.55f, num);
else if (Main.dust[index].type == 57)
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num * 0.95f, num * 0.95f, num * 0.45f);
else if (Main.dust[index].type == 58)
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num, num * 0.55f, num * 0.75f);
}
else if (Main.dust[index].type == 66)
{
if ((double) Main.dust[index].velocity.X < 0.0)
--Main.dust[index].rotation;
else
++Main.dust[index].rotation;
Main.dust[index].velocity.Y *= 0.98f;
Main.dust[index].velocity.X *= 0.98f;
Main.dust[index].scale += 0.02f;
float num = Main.dust[index].scale;
if (Main.dust[index].type != 15)
num = Main.dust[index].scale * 0.8f;
if ((double) num > 1.0)
num = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num * ((float) Main.dust[index].color.R / (float) byte.MaxValue), num * ((float) Main.dust[index].color.G / (float) byte.MaxValue), num * ((float) Main.dust[index].color.B / (float) byte.MaxValue));
}
else if (Main.dust[index].type == 20 || Main.dust[index].type == 21)
{
Main.dust[index].scale += 0.005f;
Main.dust[index].velocity.Y *= 0.94f;
Main.dust[index].velocity.X *= 0.94f;
float B1 = Main.dust[index].scale * 0.8f;
if ((double) B1 > 1.0)
B1 = 1f;
if (Main.dust[index].type == 21)
{
float B2 = Main.dust[index].scale * 0.4f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B2 * 0.8f, B2 * 0.3f, B2);
}
else
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B1 * 0.3f, B1 * 0.6f, B1);
}
else if (Main.dust[index].type == 27 || Main.dust[index].type == 45)
{
Main.dust[index].velocity *= 0.94f;
Main.dust[index].scale += 1f / 500f;
float B = Main.dust[index].scale;
if (Main.dust[index].noLight)
{
B *= 0.1f;
Main.dust[index].scale -= 0.06f;
if ((double) Main.dust[index].scale < 1.0)
Main.dust[index].scale -= 0.06f;
if (Main.player[Main.myPlayer].wet)
Main.dust[index].position += Main.player[Main.myPlayer].velocity * 0.5f;
else
Main.dust[index].position += Main.player[Main.myPlayer].velocity;
}
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B * 0.6f, B * 0.2f, B);
}
else if (Main.dust[index].type == 55 || Main.dust[index].type == 56 || Main.dust[index].type == 73 || Main.dust[index].type == 74)
{
Main.dust[index].velocity *= 0.98f;
float num = Main.dust[index].scale * 0.8f;
if (Main.dust[index].type == 55)
{
if ((double) num > 1.0)
num = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num, num, num * 0.6f);
}
else if (Main.dust[index].type == 73)
{
if ((double) num > 1.0)
num = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num, num * 0.35f, num * 0.5f);
}
else if (Main.dust[index].type == 74)
{
if ((double) num > 1.0)
num = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num * 0.35f, num, num * 0.5f);
}
else
{
float B = Main.dust[index].scale * 1.2f;
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B * 0.35f, B * 0.5f, B);
}
}
else if (Main.dust[index].type == 71 || Main.dust[index].type == 72)
{
Main.dust[index].velocity *= 0.98f;
float num = Main.dust[index].scale;
if ((double) num > 1.0)
num = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), num * 0.2f, 0.0f, num * 0.1f);
}
else if (Main.dust[index].type == 76)
{
++Main.snowDust;
Main.dust[index].scale += 0.009f;
Main.dust[index].position += Main.player[Main.myPlayer].velocity * 0.2f;
}
else if (!Main.dust[index].noGravity && Main.dust[index].type != 41 && Main.dust[index].type != 44)
Main.dust[index].velocity.Y += 0.1f;
if (Main.dust[index].type == 5 && Main.dust[index].noGravity)
Main.dust[index].scale -= 0.04f;
if (Main.dust[index].type == 33 || Main.dust[index].type == 52)
{
if ((double) Main.dust[index].velocity.X == 0.0)
{
if (Collision.SolidCollision(Main.dust[index].position, 2, 2))
Main.dust[index].scale = 0.0f;
Main.dust[index].rotation += 0.5f;
Main.dust[index].scale -= 0.01f;
}
if (Collision.WetCollision(new Vector2(Main.dust[index].position.X, Main.dust[index].position.Y), 4, 4))
{
Main.dust[index].alpha += 20;
Main.dust[index].scale -= 0.1f;
}
Main.dust[index].alpha += 2;
Main.dust[index].scale -= 0.005f;
if (Main.dust[index].alpha > (int) byte.MaxValue)
Main.dust[index].scale = 0.0f;
Main.dust[index].velocity.X *= 0.93f;
if ((double) Main.dust[index].velocity.Y > 4.0)
Main.dust[index].velocity.Y = 4f;
if (Main.dust[index].noGravity)
{
if ((double) Main.dust[index].velocity.X < 0.0)
Main.dust[index].rotation -= 0.2f;
else
Main.dust[index].rotation += 0.2f;
Main.dust[index].scale += 0.03f;
Main.dust[index].velocity.X *= 1.05f;
Main.dust[index].velocity.Y += 0.15f;
}
}
if (Main.dust[index].type == 35 && Main.dust[index].noGravity)
{
Main.dust[index].scale += 0.03f;
if ((double) Main.dust[index].scale < 1.0)
Main.dust[index].velocity.Y += 0.075f;
Main.dust[index].velocity.X *= 1.08f;
if ((double) Main.dust[index].velocity.X > 0.0)
Main.dust[index].rotation += 0.01f;
else
Main.dust[index].rotation -= 0.01f;
float R = Main.dust[index].scale * 0.6f;
if ((double) R > 1.0)
R = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0 + 1.0), R, R * 0.3f, R * 0.1f);
}
else if (Main.dust[index].type == 67)
{
float B = Main.dust[index].scale;
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), 0.0f, B * 0.8f, B);
}
else if (Main.dust[index].type == 34 || Main.dust[index].type == 35)
{
if (!Collision.WetCollision(new Vector2(Main.dust[index].position.X, Main.dust[index].position.Y - 8f), 4, 4))
{
Main.dust[index].scale = 0.0f;
}
else
{
Main.dust[index].alpha += Main.rand.Next(2);
if (Main.dust[index].alpha > (int) byte.MaxValue)
Main.dust[index].scale = 0.0f;
Main.dust[index].velocity.Y = -0.5f;
if (Main.dust[index].type == 34)
{
Main.dust[index].scale += 0.005f;
}
else
{
++Main.dust[index].alpha;
Main.dust[index].scale -= 0.01f;
Main.dust[index].velocity.Y = -0.2f;
}
Main.dust[index].velocity.X += (float) Main.rand.Next(-10, 10) * (1f / 500f);
if ((double) Main.dust[index].velocity.X < -0.25)
Main.dust[index].velocity.X = -0.25f;
if ((double) Main.dust[index].velocity.X > 0.25)
Main.dust[index].velocity.X = 0.25f;
}
if (Main.dust[index].type == 35)
{
float R = (float) ((double) Main.dust[index].scale * 0.300000011920929 + 0.400000005960464);
if ((double) R > 1.0)
R = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), R, R * 0.5f, R * 0.3f);
}
}
if (Main.dust[index].type == 68)
{
float B = Main.dust[index].scale * 0.3f;
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B * 0.1f, B * 0.2f, B);
}
if (Main.dust[index].type == 70)
{
float B = Main.dust[index].scale * 0.3f;
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B * 0.5f, 0.0f, B);
}
if (Main.dust[index].type == 41)
{
Main.dust[index].velocity.X += (float) Main.rand.Next(-10, 11) * 0.01f;
Main.dust[index].velocity.Y += (float) Main.rand.Next(-10, 11) * 0.01f;
if ((double) Main.dust[index].velocity.X > 0.75)
Main.dust[index].velocity.X = 0.75f;
if ((double) Main.dust[index].velocity.X < -0.75)
Main.dust[index].velocity.X = -0.75f;
if ((double) Main.dust[index].velocity.Y > 0.75)
Main.dust[index].velocity.Y = 0.75f;
if ((double) Main.dust[index].velocity.Y < -0.75)
Main.dust[index].velocity.Y = -0.75f;
Main.dust[index].scale += 0.007f;
float B = Main.dust[index].scale * 0.7f;
if ((double) B > 1.0)
B = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), B * 0.4f, B * 0.9f, B);
}
else if (Main.dust[index].type == 44)
{
Main.dust[index].velocity.X += (float) Main.rand.Next(-10, 11) * (3f / 1000f);
Main.dust[index].velocity.Y += (float) Main.rand.Next(-10, 11) * (3f / 1000f);
if ((double) Main.dust[index].velocity.X > 0.35)
Main.dust[index].velocity.X = 0.35f;
if ((double) Main.dust[index].velocity.X < -0.35)
Main.dust[index].velocity.X = -0.35f;
if ((double) Main.dust[index].velocity.Y > 0.35)
Main.dust[index].velocity.Y = 0.35f;
if ((double) Main.dust[index].velocity.Y < -0.35)
Main.dust[index].velocity.Y = -0.35f;
Main.dust[index].scale += 0.0085f;
float G = Main.dust[index].scale * 0.7f;
if ((double) G > 1.0)
G = 1f;
Lighting.addLight((int) ((double) Main.dust[index].position.X / 16.0), (int) ((double) Main.dust[index].position.Y / 16.0), G * 0.7f, G, G * 0.8f);
}
else
Main.dust[index].velocity.X *= 0.99f;
if (Main.dust[index].type != 79)
Main.dust[index].rotation += Main.dust[index].velocity.X * 0.5f;
if ((double) Main.dust[index].fadeIn > 0.0)
{
if (Main.dust[index].type == 46)
Main.dust[index].scale += 0.1f;
else
Main.dust[index].scale += 0.03f;
if ((double) Main.dust[index].scale > (double) Main.dust[index].fadeIn)
Main.dust[index].fadeIn = 0.0f;
}
else
Main.dust[index].scale -= 0.01f;
if (Main.dust[index].noGravity)
{
Main.dust[index].velocity *= 0.92f;
if ((double) Main.dust[index].fadeIn == 0.0)
Main.dust[index].scale -= 0.04f;
}
if ((double) Main.dust[index].position.Y > (double) Main.screenPosition.Y + (double) Main.screenHeight)
Main.dust[index].active = false;
if ((double) Main.dust[index].scale < 0.1)
Main.dust[index].active = false;
}
}
else
Main.dust[index].active = false;
}
}
public Color GetAlpha(Color newColor)
{
float num = (float) ((int) byte.MaxValue - this.alpha) / (float) byte.MaxValue;
if (this.type == 6 || this.type == 75 || this.type == 20 || this.type == 21)
return new Color((int) newColor.R, (int) newColor.G, (int) newColor.B, 25);
if ((this.type == 68 || this.type == 70) && this.noGravity)
return new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, 0);
if (this.type == 15 || this.type == 20 || this.type == 21 || this.type == 29 || this.type == 35 || this.type == 41 || this.type == 44 || this.type == 27 || this.type == 45 || this.type == 55 || this.type == 56 || this.type == 57 || this.type == 58 || this.type == 73 || this.type == 74)
num = (float) (((double) num + 3.0) / 4.0);
else if (this.type == 43)
{
num = (float) (((double) num + 9.0) / 10.0);
}
else
{
if (this.type == 66)
return new Color((int) newColor.R, (int) newColor.G, (int) newColor.B, 0);
if (this.type == 71)
return new Color(200, 200, 200, 0);
if (this.type == 72)
return new Color(200, 200, 200, 200);
}
int r = (int) ((double) newColor.R * (double) num);
int g = (int) ((double) newColor.G * (double) num);
int b = (int) ((double) newColor.B * (double) num);
int a = (int) newColor.A - this.alpha;
if (a < 0)
a = 0;
if (a > (int) byte.MaxValue)
a = (int) byte.MaxValue;
return new Color(r, g, b, a);
}
public Color GetColor(Color newColor)
{
int r = (int) this.color.R - ((int) byte.MaxValue - (int) newColor.R);
int g = (int) this.color.G - ((int) byte.MaxValue - (int) newColor.G);
int b = (int) this.color.B - ((int) byte.MaxValue - (int) newColor.B);
int a = (int) this.color.A - ((int) byte.MaxValue - (int) newColor.A);
if (r < 0)
r = 0;
if (r > (int) byte.MaxValue)
r = (int) byte.MaxValue;
if (g < 0)
g = 0;
if (g > (int) byte.MaxValue)
g = (int) byte.MaxValue;
if (b < 0)
b = 0;
if (b > (int) byte.MaxValue)
b = (int) byte.MaxValue;
if (a < 0)
a = 0;
if (a > (int) byte.MaxValue)
a = (int) byte.MaxValue;
return new Color(r, g, b, a);
}
}
}

167
Gore.cs Normal file
View file

@ -0,0 +1,167 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Gore
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
using System;
namespace Terraria
{
public class Gore
{
public static int goreTime = 600;
public Vector2 position;
public Vector2 velocity;
public float rotation;
public float scale;
public int alpha;
public int type;
public float light;
public bool active;
public bool sticky = true;
public int timeLeft = Gore.goreTime;
public void Update()
{
if (Main.netMode == 2 || !this.active)
return;
if (this.type == 11 || this.type == 12 || this.type == 13 || this.type == 61 || this.type == 62 || this.type == 63 || this.type == 99)
{
this.velocity.Y *= 0.98f;
this.velocity.X *= 0.98f;
this.scale -= 0.007f;
if ((double) this.scale < 0.1)
{
this.scale = 0.1f;
this.alpha = (int) byte.MaxValue;
}
}
else if (this.type == 16 || this.type == 17)
{
this.velocity.Y *= 0.98f;
this.velocity.X *= 0.98f;
this.scale -= 0.01f;
if ((double) this.scale < 0.1)
{
this.scale = 0.1f;
this.alpha = (int) byte.MaxValue;
}
}
else
this.velocity.Y += 0.2f;
this.rotation += this.velocity.X * 0.1f;
if (this.sticky)
{
int num1 = Main.goreTexture[this.type].Width;
if (Main.goreTexture[this.type].Height < num1)
num1 = Main.goreTexture[this.type].Height;
int num2 = (int) ((double) num1 * 0.899999976158142);
this.velocity = Collision.TileCollision(this.position, this.velocity, (int) ((double) num2 * (double) this.scale), (int) ((double) num2 * (double) this.scale));
if ((double) this.velocity.Y == 0.0)
{
this.velocity.X *= 0.97f;
if ((double) this.velocity.X > -0.01 && (double) this.velocity.X < 0.01)
this.velocity.X = 0.0f;
}
if (this.timeLeft > 0)
--this.timeLeft;
else
++this.alpha;
}
else
this.alpha += 2;
this.position += this.velocity;
if (this.alpha >= (int) byte.MaxValue)
this.active = false;
if ((double) this.light <= 0.0)
return;
float R = this.light * this.scale;
float G = this.light * this.scale;
float B = this.light * this.scale;
if (this.type == 16)
{
B *= 0.3f;
G *= 0.8f;
}
else if (this.type == 17)
{
G *= 0.6f;
R *= 0.3f;
}
Lighting.addLight((int) (((double) this.position.X + (double) Main.goreTexture[this.type].Width * (double) this.scale / 2.0) / 16.0), (int) (((double) this.position.Y + (double) Main.goreTexture[this.type].Height * (double) this.scale / 2.0) / 16.0), R, G, B);
}
public static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale = 1f)
{
if (Main.rand == null)
Main.rand = new Random();
if (Main.netMode == 2)
return 0;
int index1 = 200;
for (int index2 = 0; index2 < 200; ++index2)
{
if (!Main.gore[index2].active)
{
index1 = index2;
break;
}
}
if (index1 == 200)
return index1;
Main.gore[index1].light = 0.0f;
Main.gore[index1].position = Position;
Main.gore[index1].velocity = Velocity;
Main.gore[index1].velocity.Y -= (float) Main.rand.Next(10, 31) * 0.1f;
Main.gore[index1].velocity.X += (float) Main.rand.Next(-20, 21) * 0.1f;
Main.gore[index1].type = Type;
Main.gore[index1].active = true;
Main.gore[index1].alpha = 0;
Main.gore[index1].rotation = 0.0f;
Main.gore[index1].scale = Scale;
if (Gore.goreTime == 0 || Type == 11 || Type == 12 || Type == 13 || Type == 16 || Type == 17 || Type == 61 || Type == 62 || Type == 63 || Type == 99)
{
Main.gore[index1].sticky = false;
}
else
{
Main.gore[index1].sticky = true;
Main.gore[index1].timeLeft = Gore.goreTime;
}
if (Type == 16 || Type == 17)
{
Main.gore[index1].alpha = 100;
Main.gore[index1].scale = 0.7f;
Main.gore[index1].light = 1f;
}
return index1;
}
public Color GetAlpha(Color newColor)
{
float num = (float) ((int) byte.MaxValue - this.alpha) / (float) byte.MaxValue;
int r;
int g;
int b;
if (this.type == 16 || this.type == 17)
{
r = (int) newColor.R;
g = (int) newColor.G;
b = (int) newColor.B;
}
else
{
r = (int) ((double) newColor.R * (double) num);
g = (int) ((double) newColor.G * (double) num);
b = (int) ((double) newColor.B * (double) num);
}
int a = (int) newColor.A - this.alpha;
if (a < 0)
a = 0;
if (a > (int) byte.MaxValue)
a = (int) byte.MaxValue;
return new Color(r, g, b, a);
}
}
}

11240
Item.cs Normal file

File diff suppressed because it is too large Load diff

196
ItemText.cs Normal file
View file

@ -0,0 +1,196 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.ItemText
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria
{
public class ItemText
{
public Vector2 position;
public Vector2 velocity;
public float alpha;
public int alphaDir = 1;
public string name;
public int stack;
public float scale = 1f;
public float rotation;
public Color color;
public bool active;
public int lifeTime;
public static int activeTime = 60;
public static int numActive;
public static void NewText(Item newItem, int stack)
{
if (!Main.showItemText || newItem.name == null || !newItem.active || Main.netMode == 2)
return;
for (int index = 0; index < 20; ++index)
{
if (Main.itemText[index].active && Main.itemText[index].name == newItem.name)
{
string text1 = newItem.name + " (" + (object) (Main.itemText[index].stack + stack) + ")";
string text2 = newItem.name;
if (Main.itemText[index].stack > 1)
text2 = text2 + " (" + (object) Main.itemText[index].stack + ")";
Main.fontMouseText.MeasureString(text2);
Vector2 vector2 = Main.fontMouseText.MeasureString(text1);
if (Main.itemText[index].lifeTime < 0)
Main.itemText[index].scale = 1f;
Main.itemText[index].lifeTime = 60;
Main.itemText[index].stack += stack;
Main.itemText[index].scale = 0.0f;
Main.itemText[index].rotation = 0.0f;
Main.itemText[index].position.X = (float) ((double) newItem.position.X + (double) newItem.width * 0.5 - (double) vector2.X * 0.5);
Main.itemText[index].position.Y = (float) ((double) newItem.position.Y + (double) newItem.height * 0.25 - (double) vector2.Y * 0.5);
Main.itemText[index].velocity.Y = -7f;
return;
}
}
int index1 = -1;
for (int index2 = 0; index2 < 20; ++index2)
{
if (!Main.itemText[index2].active)
{
index1 = index2;
break;
}
}
if (index1 == -1)
{
double num = (double) Main.bottomWorld;
for (int index3 = 0; index3 < 20; ++index3)
{
if (num > (double) Main.itemText[index3].position.Y)
{
index1 = index3;
num = (double) Main.itemText[index3].position.Y;
}
}
}
if (index1 < 0)
return;
string text = newItem.AffixName();
if (stack > 1)
text = text + " (" + (object) stack + ")";
Vector2 vector2_1 = Main.fontMouseText.MeasureString(text);
Main.itemText[index1].alpha = 1f;
Main.itemText[index1].alphaDir = -1;
Main.itemText[index1].active = true;
Main.itemText[index1].scale = 0.0f;
Main.itemText[index1].rotation = 0.0f;
Main.itemText[index1].position.X = (float) ((double) newItem.position.X + (double) newItem.width * 0.5 - (double) vector2_1.X * 0.5);
Main.itemText[index1].position.Y = (float) ((double) newItem.position.Y + (double) newItem.height * 0.25 - (double) vector2_1.Y * 0.5);
Main.itemText[index1].color = Color.White;
if (newItem.rare == 1)
Main.itemText[index1].color = new Color(150, 150, (int) byte.MaxValue);
else if (newItem.rare == 2)
Main.itemText[index1].color = new Color(150, (int) byte.MaxValue, 150);
else if (newItem.rare == 3)
Main.itemText[index1].color = new Color((int) byte.MaxValue, 200, 150);
else if (newItem.rare == 4)
Main.itemText[index1].color = new Color((int) byte.MaxValue, 150, 150);
else if (newItem.rare == 5)
Main.itemText[index1].color = new Color((int) byte.MaxValue, 150, (int) byte.MaxValue);
else if (newItem.rare == -1)
Main.itemText[index1].color = new Color(130, 130, 130);
else if (newItem.rare == 6)
Main.itemText[index1].color = new Color(210, 160, (int) byte.MaxValue);
Main.itemText[index1].name = newItem.AffixName();
Main.itemText[index1].stack = stack;
Main.itemText[index1].velocity.Y = -7f;
Main.itemText[index1].lifeTime = 60;
}
public void Update(int whoAmI)
{
if (!this.active)
return;
this.alpha += (float) this.alphaDir * 0.01f;
if ((double) this.alpha <= 0.7)
{
this.alpha = 0.7f;
this.alphaDir = 1;
}
if ((double) this.alpha >= 1.0)
{
this.alpha = 1f;
this.alphaDir = -1;
}
bool flag = false;
string text1 = this.name;
if (this.stack > 1)
text1 = text1 + " (" + (object) this.stack + ")";
Vector2 vector2_1 = Main.fontMouseText.MeasureString(text1) * this.scale;
vector2_1.Y *= 0.8f;
Rectangle rectangle1 = new Rectangle((int) ((double) this.position.X - (double) vector2_1.X / 2.0), (int) ((double) this.position.Y - (double) vector2_1.Y / 2.0), (int) vector2_1.X, (int) vector2_1.Y);
for (int index = 0; index < 20; ++index)
{
if (Main.itemText[index].active && index != whoAmI)
{
string text2 = Main.itemText[index].name;
if (Main.itemText[index].stack > 1)
text2 = text2 + " (" + (object) Main.itemText[index].stack + ")";
Vector2 vector2_2 = Main.fontMouseText.MeasureString(text2);
vector2_2 *= Main.itemText[index].scale;
vector2_2.Y *= 0.8f;
Rectangle rectangle2 = new Rectangle((int) ((double) Main.itemText[index].position.X - (double) vector2_2.X / 2.0), (int) ((double) Main.itemText[index].position.Y - (double) vector2_2.Y / 2.0), (int) vector2_2.X, (int) vector2_2.Y);
if (rectangle1.Intersects(rectangle2) && ((double) this.position.Y < (double) Main.itemText[index].position.Y || (double) this.position.Y == (double) Main.itemText[index].position.Y && whoAmI < index))
{
flag = true;
int num = ItemText.numActive;
if (num > 3)
num = 3;
Main.itemText[index].lifeTime = ItemText.activeTime + 15 * num;
this.lifeTime = ItemText.activeTime + 15 * num;
}
}
}
if (!flag)
{
this.velocity.Y *= 0.86f;
if ((double) this.scale == 1.0)
this.velocity.Y *= 0.4f;
}
else if ((double) this.velocity.Y > -6.0)
this.velocity.Y -= 0.2f;
else
this.velocity.Y *= 0.86f;
this.velocity.X *= 0.93f;
this.position += this.velocity;
--this.lifeTime;
if (this.lifeTime <= 0)
{
this.scale -= 0.03f;
if ((double) this.scale < 0.1)
this.active = false;
this.lifeTime = 0;
}
else
{
if ((double) this.scale < 1.0)
this.scale += 0.1f;
if ((double) this.scale <= 1.0)
return;
this.scale = 1f;
}
}
public static void UpdateItemText()
{
int num = 0;
for (int whoAmI = 0; whoAmI < 20; ++whoAmI)
{
if (Main.itemText[whoAmI].active)
{
++num;
Main.itemText[whoAmI].Update(whoAmI);
}
}
ItemText.numActive = num;
}
}
}

15901
Lang.cs Normal file

File diff suppressed because it is too large Load diff

1934
Lighting.cs Normal file

File diff suppressed because it is too large Load diff

814
Liquid.cs Normal file
View file

@ -0,0 +1,814 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Liquid
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
namespace Terraria
{
public class Liquid
{
public static int skipCount = 0;
public static int stuckCount = 0;
public static int stuckAmount = 0;
public static int cycles = 10;
public static int resLiquid = 5000;
public static int maxLiquid = 5000;
public static int numLiquid;
public static bool stuck = false;
public static bool quickFall = false;
public static bool quickSettle = false;
private static int wetCounter;
public static int panicCounter = 0;
public static bool panicMode = false;
public static int panicY = 0;
public int x;
public int y;
public int kill;
public int delay;
public static double QuickWater(int verbose = 0, int minY = -1, int maxY = -1)
{
int num1 = 0;
if (minY == -1)
minY = 3;
if (maxY == -1)
maxY = Main.maxTilesY - 3;
for (int index1 = maxY; index1 >= minY; --index1)
{
if (verbose > 0)
{
float num2 = (float) (maxY - index1) / (float) (maxY - minY + 1) / (float) verbose;
Main.statusText = Lang.gen[27] + " " + (object) (int) ((double) num2 * 100.0 + 1.0) + "%";
}
else if (verbose < 0)
{
float num3 = (float) (maxY - index1) / (float) (maxY - minY + 1) / (float) -verbose;
Main.statusText = Lang.gen[18] + " " + (object) (int) ((double) num3 * 100.0 + 1.0) + "%";
}
for (int index2 = 0; index2 < 2; ++index2)
{
int num4 = 2;
int num5 = Main.maxTilesX - 2;
int num6 = 1;
if (index2 == 1)
{
num4 = Main.maxTilesX - 2;
num5 = 2;
num6 = -1;
}
for (int index3 = num4; index3 != num5; index3 += num6)
{
if (Main.tile[index3, index1].liquid > (byte) 0)
{
int num7 = -num6;
bool flag1 = false;
int x = index3;
int y = index1;
bool flag2 = Main.tile[index3, index1].lava;
byte liquid = Main.tile[index3, index1].liquid;
Main.tile[index3, index1].liquid = (byte) 0;
bool flag3 = true;
int num8 = 0;
while (flag3 && x > 3 && x < Main.maxTilesX - 3 && y < Main.maxTilesY - 3)
{
flag3 = false;
while (Main.tile[x, y + 1].liquid == (byte) 0 && y < Main.maxTilesY - 5 && (!Main.tile[x, y + 1].active || !Main.tileSolid[(int) Main.tile[x, y + 1].type] || Main.tileSolidTop[(int) Main.tile[x, y + 1].type]))
{
flag1 = true;
num7 = num6;
num8 = 0;
flag3 = true;
++y;
if (y > WorldGen.waterLine)
flag2 = true;
}
if (Main.tile[x, y + 1].liquid > (byte) 0 && Main.tile[x, y + 1].liquid < byte.MaxValue && Main.tile[x, y + 1].lava == flag2)
{
int num9 = (int) byte.MaxValue - (int) Main.tile[x, y + 1].liquid;
if (num9 > (int) liquid)
num9 = (int) liquid;
Main.tile[x, y + 1].liquid += (byte) num9;
liquid -= (byte) num9;
if (liquid <= (byte) 0)
{
++num1;
break;
}
}
if (num8 == 0)
{
if (Main.tile[x + num7, y].liquid == (byte) 0 && (!Main.tile[x + num7, y].active || !Main.tileSolid[(int) Main.tile[x + num7, y].type] || Main.tileSolidTop[(int) Main.tile[x + num7, y].type]))
num8 = num7;
else if (Main.tile[x - num7, y].liquid == (byte) 0 && (!Main.tile[x - num7, y].active || !Main.tileSolid[(int) Main.tile[x - num7, y].type] || Main.tileSolidTop[(int) Main.tile[x - num7, y].type]))
num8 = -num7;
}
if (num8 != 0 && Main.tile[x + num8, y].liquid == (byte) 0 && (!Main.tile[x + num8, y].active || !Main.tileSolid[(int) Main.tile[x + num8, y].type] || Main.tileSolidTop[(int) Main.tile[x + num8, y].type]))
{
flag3 = true;
x += num8;
}
if (flag1 && !flag3)
{
flag1 = false;
flag3 = true;
num7 = -num6;
num8 = 0;
}
}
if (index3 != x && index1 != y)
++num1;
Main.tile[x, y].liquid = liquid;
Main.tile[x, y].lava = flag2;
if (Main.tile[x - 1, y].liquid > (byte) 0 && Main.tile[x - 1, y].lava != flag2)
{
if (flag2)
Liquid.LavaCheck(x, y);
else
Liquid.LavaCheck(x - 1, y);
}
else if (Main.tile[x + 1, y].liquid > (byte) 0 && Main.tile[x + 1, y].lava != flag2)
{
if (flag2)
Liquid.LavaCheck(x, y);
else
Liquid.LavaCheck(x + 1, y);
}
else if (Main.tile[x, y - 1].liquid > (byte) 0 && Main.tile[x, y - 1].lava != flag2)
{
if (flag2)
Liquid.LavaCheck(x, y);
else
Liquid.LavaCheck(x, y - 1);
}
else if (Main.tile[x, y + 1].liquid > (byte) 0 && Main.tile[x, y + 1].lava != flag2)
{
if (flag2)
Liquid.LavaCheck(x, y);
else
Liquid.LavaCheck(x, y + 1);
}
}
}
}
}
return (double) num1;
}
public void Update()
{
if (Main.tile[this.x, this.y].active && Main.tileSolid[(int) Main.tile[this.x, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x, this.y].type])
{
int type = (int) Main.tile[this.x, this.y].type;
this.kill = 9;
}
else
{
byte liquid = Main.tile[this.x, this.y].liquid;
if (this.y > Main.maxTilesY - 200 && !Main.tile[this.x, this.y].lava && Main.tile[this.x, this.y].liquid > (byte) 0)
{
byte num = 2;
if ((int) Main.tile[this.x, this.y].liquid < (int) num)
num = Main.tile[this.x, this.y].liquid;
Main.tile[this.x, this.y].liquid -= num;
}
if (Main.tile[this.x, this.y].liquid == (byte) 0)
{
this.kill = 9;
}
else
{
if (Main.tile[this.x, this.y].lava)
{
Liquid.LavaCheck(this.x, this.y);
if (!Liquid.quickFall)
{
if (this.delay < 5)
{
++this.delay;
return;
}
this.delay = 0;
}
}
else
{
if (Main.tile[this.x - 1, this.y].lava)
Liquid.AddWater(this.x - 1, this.y);
if (Main.tile[this.x + 1, this.y].lava)
Liquid.AddWater(this.x + 1, this.y);
if (Main.tile[this.x, this.y - 1].lava)
Liquid.AddWater(this.x, this.y - 1);
if (Main.tile[this.x, this.y + 1].lava)
Liquid.AddWater(this.x, this.y + 1);
}
if ((!Main.tile[this.x, this.y + 1].active || !Main.tileSolid[(int) Main.tile[this.x, this.y + 1].type] || Main.tileSolidTop[(int) Main.tile[this.x, this.y + 1].type]) && (Main.tile[this.x, this.y + 1].liquid <= (byte) 0 || Main.tile[this.x, this.y + 1].lava == Main.tile[this.x, this.y].lava) && Main.tile[this.x, this.y + 1].liquid < byte.MaxValue)
{
float num = (float) ((int) byte.MaxValue - (int) Main.tile[this.x, this.y + 1].liquid);
if ((double) num > (double) Main.tile[this.x, this.y].liquid)
num = (float) Main.tile[this.x, this.y].liquid;
Main.tile[this.x, this.y].liquid -= (byte) num;
Main.tile[this.x, this.y + 1].liquid += (byte) num;
Main.tile[this.x, this.y + 1].lava = Main.tile[this.x, this.y].lava;
Liquid.AddWater(this.x, this.y + 1);
Main.tile[this.x, this.y + 1].skipLiquid = true;
Main.tile[this.x, this.y].skipLiquid = true;
if (Main.tile[this.x, this.y].liquid > (byte) 250)
{
Main.tile[this.x, this.y].liquid = byte.MaxValue;
}
else
{
Liquid.AddWater(this.x - 1, this.y);
Liquid.AddWater(this.x + 1, this.y);
}
}
if (Main.tile[this.x, this.y].liquid > (byte) 0)
{
bool flag1 = true;
bool flag2 = true;
bool flag3 = true;
bool flag4 = true;
if (Main.tile[this.x - 1, this.y].active && Main.tileSolid[(int) Main.tile[this.x - 1, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x - 1, this.y].type])
flag1 = false;
else if (Main.tile[this.x - 1, this.y].liquid > (byte) 0 && Main.tile[this.x - 1, this.y].lava != Main.tile[this.x, this.y].lava)
flag1 = false;
else if (Main.tile[this.x - 2, this.y].active && Main.tileSolid[(int) Main.tile[this.x - 2, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x - 2, this.y].type])
flag3 = false;
else if (Main.tile[this.x - 2, this.y].liquid == (byte) 0)
flag3 = false;
else if (Main.tile[this.x - 2, this.y].liquid > (byte) 0 && Main.tile[this.x - 2, this.y].lava != Main.tile[this.x, this.y].lava)
flag3 = false;
if (Main.tile[this.x + 1, this.y].active && Main.tileSolid[(int) Main.tile[this.x + 1, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x + 1, this.y].type])
flag2 = false;
else if (Main.tile[this.x + 1, this.y].liquid > (byte) 0 && Main.tile[this.x + 1, this.y].lava != Main.tile[this.x, this.y].lava)
flag2 = false;
else if (Main.tile[this.x + 2, this.y].active && Main.tileSolid[(int) Main.tile[this.x + 2, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x + 2, this.y].type])
flag4 = false;
else if (Main.tile[this.x + 2, this.y].liquid == (byte) 0)
flag4 = false;
else if (Main.tile[this.x + 2, this.y].liquid > (byte) 0 && Main.tile[this.x + 2, this.y].lava != Main.tile[this.x, this.y].lava)
flag4 = false;
int num1 = 0;
if (Main.tile[this.x, this.y].liquid < (byte) 3)
num1 = -1;
if (flag1 && flag2)
{
if (flag3 && flag4)
{
bool flag5 = true;
bool flag6 = true;
if (Main.tile[this.x - 3, this.y].active && Main.tileSolid[(int) Main.tile[this.x - 3, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x - 3, this.y].type])
flag5 = false;
else if (Main.tile[this.x - 3, this.y].liquid == (byte) 0)
flag5 = false;
else if (Main.tile[this.x - 3, this.y].lava != Main.tile[this.x, this.y].lava)
flag5 = false;
if (Main.tile[this.x + 3, this.y].active && Main.tileSolid[(int) Main.tile[this.x + 3, this.y].type] && !Main.tileSolidTop[(int) Main.tile[this.x + 3, this.y].type])
flag6 = false;
else if (Main.tile[this.x + 3, this.y].liquid == (byte) 0)
flag6 = false;
else if (Main.tile[this.x + 3, this.y].lava != Main.tile[this.x, this.y].lava)
flag6 = false;
if (flag5 && flag6)
{
float num2 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x - 2, this.y].liquid + (int) Main.tile[this.x + 2, this.y].liquid + (int) Main.tile[this.x - 3, this.y].liquid + (int) Main.tile[this.x + 3, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 7.0);
int num3 = 0;
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x - 1, this.y].liquid = (byte) num2;
}
else
++num3;
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x + 1, this.y].liquid = (byte) num2;
}
else
++num3;
Main.tile[this.x - 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 2, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x - 2, this.y);
Main.tile[this.x - 2, this.y].liquid = (byte) num2;
}
else
++num3;
Main.tile[this.x + 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 2, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x + 2, this.y);
Main.tile[this.x + 2, this.y].liquid = (byte) num2;
}
else
++num3;
Main.tile[this.x - 3, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 3, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x - 3, this.y);
Main.tile[this.x - 3, this.y].liquid = (byte) num2;
}
else
++num3;
Main.tile[this.x + 3, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 3, this.y].liquid != (int) (byte) num2)
{
Liquid.AddWater(this.x + 3, this.y);
Main.tile[this.x + 3, this.y].liquid = (byte) num2;
}
else
++num3;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x - 1, this.y);
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x + 1, this.y);
if ((int) Main.tile[this.x - 2, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x - 2, this.y);
if ((int) Main.tile[this.x + 2, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x + 2, this.y);
if ((int) Main.tile[this.x - 3, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x - 3, this.y);
if ((int) Main.tile[this.x + 3, this.y].liquid != (int) (byte) num2 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num2)
Liquid.AddWater(this.x + 3, this.y);
if (num3 != 6 || Main.tile[this.x, this.y - 1].liquid <= (byte) 0)
Main.tile[this.x, this.y].liquid = (byte) num2;
}
else
{
int num4 = 0;
float num5 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x - 2, this.y].liquid + (int) Main.tile[this.x + 2, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 5.0);
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num5)
{
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x - 1, this.y].liquid = (byte) num5;
}
else
++num4;
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num5)
{
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x + 1, this.y].liquid = (byte) num5;
}
else
++num4;
Main.tile[this.x - 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 2, this.y].liquid != (int) (byte) num5)
{
Liquid.AddWater(this.x - 2, this.y);
Main.tile[this.x - 2, this.y].liquid = (byte) num5;
}
else
++num4;
Main.tile[this.x + 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 2, this.y].liquid != (int) (byte) num5)
{
Liquid.AddWater(this.x + 2, this.y);
Main.tile[this.x + 2, this.y].liquid = (byte) num5;
}
else
++num4;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num5 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num5)
Liquid.AddWater(this.x - 1, this.y);
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num5 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num5)
Liquid.AddWater(this.x + 1, this.y);
if ((int) Main.tile[this.x - 2, this.y].liquid != (int) (byte) num5 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num5)
Liquid.AddWater(this.x - 2, this.y);
if ((int) Main.tile[this.x + 2, this.y].liquid != (int) (byte) num5 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num5)
Liquid.AddWater(this.x + 2, this.y);
if (num4 != 4 || Main.tile[this.x, this.y - 1].liquid <= (byte) 0)
Main.tile[this.x, this.y].liquid = (byte) num5;
}
}
else if (flag3)
{
float num6 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x - 2, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 4.0 + 0.001);
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num6 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num6)
{
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x - 1, this.y].liquid = (byte) num6;
}
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num6 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num6)
{
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x + 1, this.y].liquid = (byte) num6;
}
Main.tile[this.x - 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 2, this.y].liquid != (int) (byte) num6 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num6)
{
Main.tile[this.x - 2, this.y].liquid = (byte) num6;
Liquid.AddWater(this.x - 2, this.y);
}
Main.tile[this.x, this.y].liquid = (byte) num6;
}
else if (flag4)
{
float num7 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x + 2, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 4.0 + 0.001);
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num7 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num7)
{
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x - 1, this.y].liquid = (byte) num7;
}
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num7 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num7)
{
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x + 1, this.y].liquid = (byte) num7;
}
Main.tile[this.x + 2, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 2, this.y].liquid != (int) (byte) num7 || (int) Main.tile[this.x, this.y].liquid != (int) (byte) num7)
{
Main.tile[this.x + 2, this.y].liquid = (byte) num7;
Liquid.AddWater(this.x + 2, this.y);
}
Main.tile[this.x, this.y].liquid = (byte) num7;
}
else
{
float num8 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 3.0 + 0.001);
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num8)
Main.tile[this.x - 1, this.y].liquid = (byte) num8;
if ((int) Main.tile[this.x, this.y].liquid != (int) (byte) num8 || (int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num8)
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num8)
Main.tile[this.x + 1, this.y].liquid = (byte) num8;
if ((int) Main.tile[this.x, this.y].liquid != (int) (byte) num8 || (int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num8)
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x, this.y].liquid = (byte) num8;
}
}
else if (flag1)
{
float num9 = (float) Math.Round((double) ((int) Main.tile[this.x - 1, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 2.0 + 0.001);
if ((int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num9)
Main.tile[this.x - 1, this.y].liquid = (byte) num9;
Main.tile[this.x - 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x, this.y].liquid != (int) (byte) num9 || (int) Main.tile[this.x - 1, this.y].liquid != (int) (byte) num9)
Liquid.AddWater(this.x - 1, this.y);
Main.tile[this.x, this.y].liquid = (byte) num9;
}
else if (flag2)
{
float num10 = (float) Math.Round((double) ((int) Main.tile[this.x + 1, this.y].liquid + (int) Main.tile[this.x, this.y].liquid + num1) / 2.0 + 0.001);
if ((int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num10)
Main.tile[this.x + 1, this.y].liquid = (byte) num10;
Main.tile[this.x + 1, this.y].lava = Main.tile[this.x, this.y].lava;
if ((int) Main.tile[this.x, this.y].liquid != (int) (byte) num10 || (int) Main.tile[this.x + 1, this.y].liquid != (int) (byte) num10)
Liquid.AddWater(this.x + 1, this.y);
Main.tile[this.x, this.y].liquid = (byte) num10;
}
}
if ((int) Main.tile[this.x, this.y].liquid != (int) liquid)
{
if (Main.tile[this.x, this.y].liquid == (byte) 254 && liquid == byte.MaxValue)
{
Main.tile[this.x, this.y].liquid = byte.MaxValue;
++this.kill;
}
else
{
Liquid.AddWater(this.x, this.y - 1);
this.kill = 0;
}
}
else
++this.kill;
}
}
}
public static void StartPanic()
{
if (Liquid.panicMode)
return;
WorldGen.waterLine = Main.maxTilesY;
Liquid.numLiquid = 0;
LiquidBuffer.numLiquidBuffer = 0;
Liquid.panicCounter = 0;
Liquid.panicMode = true;
Liquid.panicY = Main.maxTilesY - 3;
if (!Main.dedServ)
return;
Console.WriteLine("Forcing water to settle.");
}
public static void UpdateLiquid()
{
if (Main.netMode == 2)
{
Liquid.cycles = 30;
Liquid.maxLiquid = 6000;
}
if (!WorldGen.gen)
{
if (!Liquid.panicMode)
{
if (Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > 4000)
{
++Liquid.panicCounter;
if (Liquid.panicCounter > 1800 || Liquid.numLiquid + LiquidBuffer.numLiquidBuffer > 13500)
Liquid.StartPanic();
}
else
Liquid.panicCounter = 0;
}
if (Liquid.panicMode)
{
int num = 0;
while (Liquid.panicY >= 3 && num < 5)
{
++num;
Liquid.QuickWater(minY: Liquid.panicY, maxY: Liquid.panicY);
--Liquid.panicY;
if (Liquid.panicY < 3)
{
Console.WriteLine("Water has been settled.");
Liquid.panicCounter = 0;
Liquid.panicMode = false;
WorldGen.WaterCheck();
if (Main.netMode == 2)
{
for (int index1 = 0; index1 < (int) byte.MaxValue; ++index1)
{
for (int index2 = 0; index2 < Main.maxSectionsX; ++index2)
{
for (int index3 = 0; index3 < Main.maxSectionsY; ++index3)
Netplay.serverSock[index1].tileSection[index2, index3] = false;
}
}
}
}
}
return;
}
}
Liquid.quickFall = Liquid.quickSettle || Liquid.numLiquid > 2000;
++Liquid.wetCounter;
int num1 = Liquid.maxLiquid / Liquid.cycles;
int num2 = num1 * (Liquid.wetCounter - 1);
int num3 = num1 * Liquid.wetCounter;
if (Liquid.wetCounter == Liquid.cycles)
num3 = Liquid.numLiquid;
if (num3 > Liquid.numLiquid)
{
num3 = Liquid.numLiquid;
int netMode = Main.netMode;
Liquid.wetCounter = Liquid.cycles;
}
if (Liquid.quickFall)
{
for (int index = num2; index < num3; ++index)
{
Main.liquid[index].delay = 10;
Main.liquid[index].Update();
Main.tile[Main.liquid[index].x, Main.liquid[index].y].skipLiquid = false;
}
}
else
{
for (int index = num2; index < num3; ++index)
{
if (!Main.tile[Main.liquid[index].x, Main.liquid[index].y].skipLiquid)
Main.liquid[index].Update();
else
Main.tile[Main.liquid[index].x, Main.liquid[index].y].skipLiquid = false;
}
}
if (Liquid.wetCounter < Liquid.cycles)
return;
Liquid.wetCounter = 0;
for (int l = Liquid.numLiquid - 1; l >= 0; --l)
{
if (Main.liquid[l].kill > 3)
Liquid.DelWater(l);
}
int num4 = Liquid.maxLiquid - (Liquid.maxLiquid - Liquid.numLiquid);
if (num4 > LiquidBuffer.numLiquidBuffer)
num4 = LiquidBuffer.numLiquidBuffer;
for (int index = 0; index < num4; ++index)
{
Main.tile[Main.liquidBuffer[0].x, Main.liquidBuffer[0].y].checkingLiquid = false;
Liquid.AddWater(Main.liquidBuffer[0].x, Main.liquidBuffer[0].y);
LiquidBuffer.DelBuffer(0);
}
if (Liquid.numLiquid > 0 && Liquid.numLiquid > Liquid.stuckAmount - 50 && Liquid.numLiquid < Liquid.stuckAmount + 50)
{
++Liquid.stuckCount;
if (Liquid.stuckCount < 10000)
return;
Liquid.stuck = true;
for (int l = Liquid.numLiquid - 1; l >= 0; --l)
Liquid.DelWater(l);
Liquid.stuck = false;
Liquid.stuckCount = 0;
}
else
{
Liquid.stuckCount = 0;
Liquid.stuckAmount = Liquid.numLiquid;
}
}
public static void AddWater(int x, int y)
{
if (Main.tile[x, y].checkingLiquid || x >= Main.maxTilesX - 5 || y >= Main.maxTilesY - 5 || x < 5 || y < 5 || Main.tile[x, y] == null || Main.tile[x, y].liquid == (byte) 0)
return;
if (Liquid.numLiquid >= Liquid.maxLiquid - 1)
{
LiquidBuffer.AddBuffer(x, y);
}
else
{
Main.tile[x, y].checkingLiquid = true;
Main.liquid[Liquid.numLiquid].kill = 0;
Main.liquid[Liquid.numLiquid].x = x;
Main.liquid[Liquid.numLiquid].y = y;
Main.liquid[Liquid.numLiquid].delay = 0;
Main.tile[x, y].skipLiquid = false;
++Liquid.numLiquid;
if (Main.netMode == 2 && Liquid.numLiquid < Liquid.maxLiquid / 3)
NetMessage.sendWater(x, y);
if (!Main.tile[x, y].active || !Main.tileWaterDeath[(int) Main.tile[x, y].type] && (!Main.tile[x, y].lava || !Main.tileLavaDeath[(int) Main.tile[x, y].type]) || Main.tile[x, y].type == (byte) 4 && Main.tile[x, y].frameY == (short) 176)
return;
if (WorldGen.gen)
{
Main.tile[x, y].active = false;
}
else
{
WorldGen.KillTile(x, y);
if (Main.netMode != 2)
return;
NetMessage.SendData(17, number2: ((float) x), number3: ((float) y));
}
}
}
public static void LavaCheck(int x, int y)
{
if (Main.tile[x - 1, y].liquid > (byte) 0 && !Main.tile[x - 1, y].lava || Main.tile[x + 1, y].liquid > (byte) 0 && !Main.tile[x + 1, y].lava || Main.tile[x, y - 1].liquid > (byte) 0 && !Main.tile[x, y - 1].lava)
{
int num = 0;
if (!Main.tile[x - 1, y].lava)
{
num += (int) Main.tile[x - 1, y].liquid;
Main.tile[x - 1, y].liquid = (byte) 0;
}
if (!Main.tile[x + 1, y].lava)
{
num += (int) Main.tile[x + 1, y].liquid;
Main.tile[x + 1, y].liquid = (byte) 0;
}
if (!Main.tile[x, y - 1].lava)
{
num += (int) Main.tile[x, y - 1].liquid;
Main.tile[x, y - 1].liquid = (byte) 0;
}
if (num < 32 || Main.tile[x, y].active)
return;
Main.tile[x, y].liquid = (byte) 0;
Main.tile[x, y].lava = false;
WorldGen.PlaceTile(x, y, 56, true, true);
WorldGen.SquareTileFrame(x, y);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, x - 1, y - 1, 3);
}
else
{
if (Main.tile[x, y + 1].liquid <= (byte) 0 || Main.tile[x, y + 1].lava || Main.tile[x, y + 1].active)
return;
Main.tile[x, y].liquid = (byte) 0;
Main.tile[x, y].lava = false;
Main.tile[x, y + 1].liquid = (byte) 0;
WorldGen.PlaceTile(x, y + 1, 56, true, true);
WorldGen.SquareTileFrame(x, y + 1);
if (Main.netMode != 2)
return;
NetMessage.SendTileSquare(-1, x - 1, y, 3);
}
}
public static void NetAddWater(int x, int y)
{
if (x >= Main.maxTilesX - 5 || y >= Main.maxTilesY - 5 || x < 5 || y < 5 || Main.tile[x, y] == null || Main.tile[x, y].liquid == (byte) 0)
return;
for (int index = 0; index < Liquid.numLiquid; ++index)
{
if (Main.liquid[index].x == x && Main.liquid[index].y == y)
{
Main.liquid[index].kill = 0;
Main.tile[x, y].skipLiquid = true;
return;
}
}
if (Liquid.numLiquid >= Liquid.maxLiquid - 1)
{
LiquidBuffer.AddBuffer(x, y);
}
else
{
Main.tile[x, y].checkingLiquid = true;
Main.tile[x, y].skipLiquid = true;
Main.liquid[Liquid.numLiquid].kill = 0;
Main.liquid[Liquid.numLiquid].x = x;
Main.liquid[Liquid.numLiquid].y = y;
++Liquid.numLiquid;
int netMode = Main.netMode;
if (!Main.tile[x, y].active || !Main.tileWaterDeath[(int) Main.tile[x, y].type] && (!Main.tile[x, y].lava || !Main.tileLavaDeath[(int) Main.tile[x, y].type]))
return;
WorldGen.KillTile(x, y);
if (Main.netMode != 2)
return;
NetMessage.SendData(17, number2: ((float) x), number3: ((float) y));
}
}
public static void DelWater(int l)
{
int x = Main.liquid[l].x;
int y = Main.liquid[l].y;
if (Main.tile[x, y].liquid < (byte) 2)
{
Main.tile[x, y].liquid = (byte) 0;
if (Main.tile[x - 1, y].liquid < (byte) 2)
Main.tile[x - 1, y].liquid = (byte) 0;
if (Main.tile[x + 1, y].liquid < (byte) 2)
Main.tile[x + 1, y].liquid = (byte) 0;
}
else if (Main.tile[x, y].liquid < (byte) 20)
{
if ((int) Main.tile[x - 1, y].liquid < (int) Main.tile[x, y].liquid && (!Main.tile[x - 1, y].active || !Main.tileSolid[(int) Main.tile[x - 1, y].type] || Main.tileSolidTop[(int) Main.tile[x - 1, y].type]) || (int) Main.tile[x + 1, y].liquid < (int) Main.tile[x, y].liquid && (!Main.tile[x + 1, y].active || !Main.tileSolid[(int) Main.tile[x + 1, y].type] || Main.tileSolidTop[(int) Main.tile[x + 1, y].type]) || Main.tile[x, y + 1].liquid < byte.MaxValue && (!Main.tile[x, y + 1].active || !Main.tileSolid[(int) Main.tile[x, y + 1].type] || Main.tileSolidTop[(int) Main.tile[x, y + 1].type]))
Main.tile[x, y].liquid = (byte) 0;
}
else if (Main.tile[x, y + 1].liquid < byte.MaxValue && (!Main.tile[x, y + 1].active || !Main.tileSolid[(int) Main.tile[x, y + 1].type] || Main.tileSolidTop[(int) Main.tile[x, y + 1].type]) && !Liquid.stuck)
{
Main.liquid[l].kill = 0;
return;
}
if (Main.tile[x, y].liquid < (byte) 250 && Main.tile[x, y - 1].liquid > (byte) 0)
Liquid.AddWater(x, y - 1);
if (Main.tile[x, y].liquid == (byte) 0)
{
Main.tile[x, y].lava = false;
}
else
{
if (Main.tile[x + 1, y].liquid > (byte) 0 && Main.tile[x + 1, y + 1].liquid < (byte) 250 && !Main.tile[x + 1, y + 1].active || Main.tile[x - 1, y].liquid > (byte) 0 && Main.tile[x - 1, y + 1].liquid < (byte) 250 && !Main.tile[x - 1, y + 1].active)
{
Liquid.AddWater(x - 1, y);
Liquid.AddWater(x + 1, y);
}
if (Main.tile[x, y].lava)
{
Liquid.LavaCheck(x, y);
for (int i = x - 1; i <= x + 1; ++i)
{
for (int j = y - 1; j <= y + 1; ++j)
{
if (Main.tile[i, j].active)
{
if (Main.tile[i, j].type == (byte) 2 || Main.tile[i, j].type == (byte) 23 || Main.tile[i, j].type == (byte) 109)
{
Main.tile[i, j].type = (byte) 0;
WorldGen.SquareTileFrame(i, j);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 3);
}
else if (Main.tile[i, j].type == (byte) 60 || Main.tile[i, j].type == (byte) 70)
{
Main.tile[i, j].type = (byte) 59;
WorldGen.SquareTileFrame(i, j);
if (Main.netMode == 2)
NetMessage.SendTileSquare(-1, x, y, 3);
}
}
}
}
}
}
if (Main.netMode == 2)
NetMessage.sendWater(x, y);
--Liquid.numLiquid;
Main.tile[Main.liquid[l].x, Main.liquid[l].y].checkingLiquid = false;
Main.liquid[l].x = Main.liquid[Liquid.numLiquid].x;
Main.liquid[l].y = Main.liquid[Liquid.numLiquid].y;
Main.liquid[l].kill = Main.liquid[Liquid.numLiquid].kill;
if (!Main.tileAlch[(int) Main.tile[x, y].type])
return;
WorldGen.CheckAlch(x, y);
}
}
}

33
LiquidBuffer.cs Normal file
View file

@ -0,0 +1,33 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.LiquidBuffer
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria
{
public class LiquidBuffer
{
public const int maxLiquidBuffer = 10000;
public static int numLiquidBuffer;
public int x;
public int y;
public static void AddBuffer(int x, int y)
{
if (LiquidBuffer.numLiquidBuffer == 9999 || Main.tile[x, y].checkingLiquid)
return;
Main.tile[x, y].checkingLiquid = true;
Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].x = x;
Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].y = y;
++LiquidBuffer.numLiquidBuffer;
}
public static void DelBuffer(int l)
{
--LiquidBuffer.numLiquidBuffer;
Main.liquidBuffer[l].x = Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].x;
Main.liquidBuffer[l].y = Main.liquidBuffer[LiquidBuffer.numLiquidBuffer].y;
}
}
}

17042
Main.cs Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
Windows.v4.0.Reach

16603
NPC.cs Normal file

File diff suppressed because it is too large Load diff

1633
NetMessage.cs Normal file

File diff suppressed because it is too large Load diff

526
Netplay.cs Normal file
View file

@ -0,0 +1,526 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Netplay
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace Terraria
{
public class Netplay
{
public const int bufferSize = 1024;
public const int maxConnections = 256;
public static bool stopListen = false;
public static ServerSock[] serverSock = new ServerSock[256];
public static ClientSock clientSock = new ClientSock();
public static TcpListener tcpListener;
public static IPAddress serverListenIP;
public static IPAddress serverIP;
public static int serverPort = 7777;
public static bool disconnect = false;
public static string password = "";
public static string banFile = "banlist.txt";
public static bool spamCheck = false;
public static bool anyClients = false;
public static bool ServerUp = false;
public static void ResetNetDiag()
{
Main.rxMsg = 0;
Main.rxData = 0;
Main.txMsg = 0;
Main.txData = 0;
for (int index = 0; index < Main.maxMsg; ++index)
{
Main.rxMsgType[index] = 0;
Main.rxDataType[index] = 0;
Main.txMsgType[index] = 0;
Main.txDataType[index] = 0;
}
}
public static void ResetSections()
{
for (int index1 = 0; index1 < 256; ++index1)
{
for (int index2 = 0; index2 < Main.maxSectionsX; ++index2)
{
for (int index3 = 0; index3 < Main.maxSectionsY; ++index3)
Netplay.serverSock[index1].tileSection[index2, index3] = false;
}
}
}
public static void AddBan(int plr)
{
string str1 = Netplay.serverSock[plr].tcpClient.Client.RemoteEndPoint.ToString();
string str2 = str1;
for (int index = 0; index < str1.Length; ++index)
{
if (str1.Substring(index, 1) == ":")
str2 = str1.Substring(0, index);
}
using (StreamWriter streamWriter = new StreamWriter(Netplay.banFile, true))
{
streamWriter.WriteLine("//" + Main.player[plr].name);
streamWriter.WriteLine(str2);
}
}
public static bool CheckBan(string ip)
{
try
{
string str1 = ip;
for (int index = 0; index < ip.Length; ++index)
{
if (ip.Substring(index, 1) == ":")
str1 = ip.Substring(0, index);
}
if (System.IO.File.Exists(Netplay.banFile))
{
using (StreamReader streamReader = new StreamReader(Netplay.banFile))
{
string str2;
while ((str2 = streamReader.ReadLine()) != null)
{
if (str2 == str1)
return true;
}
}
}
}
catch
{
}
return false;
}
public static void newRecent()
{
for (int index1 = 0; index1 < Main.maxMP; ++index1)
{
if (Main.recentIP[index1] == Netplay.serverIP.ToString() && Main.recentPort[index1] == Netplay.serverPort)
{
for (int index2 = index1; index2 < Main.maxMP - 1; ++index2)
{
Main.recentIP[index2] = Main.recentIP[index2 + 1];
Main.recentPort[index2] = Main.recentPort[index2 + 1];
Main.recentWorld[index2] = Main.recentWorld[index2 + 1];
}
}
}
for (int index = Main.maxMP - 1; index > 0; --index)
{
Main.recentIP[index] = Main.recentIP[index - 1];
Main.recentPort[index] = Main.recentPort[index - 1];
Main.recentWorld[index] = Main.recentWorld[index - 1];
}
Main.recentIP[0] = Netplay.serverIP.ToString();
Main.recentPort[0] = Netplay.serverPort;
Main.recentWorld[0] = Main.worldName;
Main.SaveRecent();
}
public static void ClientLoop(object threadContext)
{
Netplay.ResetNetDiag();
if (Main.rand == null)
Main.rand = new Random((int) DateTime.Now.Ticks);
if (WorldGen.genRand == null)
WorldGen.genRand = new Random((int) DateTime.Now.Ticks);
Main.player[Main.myPlayer].hostile = false;
Main.clientPlayer = (Player) Main.player[Main.myPlayer].clientClone();
for (int index = 0; index < (int) byte.MaxValue; ++index)
{
if (index != Main.myPlayer)
Main.player[index] = new Player();
}
Main.menuMode = 10;
Main.menuMode = 14;
if (!Main.autoPass)
Main.statusText = "Connecting to " + (object) Netplay.serverIP;
Main.netMode = 1;
Netplay.disconnect = false;
Netplay.clientSock = new ClientSock();
Netplay.clientSock.tcpClient.NoDelay = true;
Netplay.clientSock.readBuffer = new byte[1024];
Netplay.clientSock.writeBuffer = new byte[1024];
bool flag = true;
while (flag)
{
flag = false;
try
{
Netplay.clientSock.tcpClient.Connect(Netplay.serverIP, Netplay.serverPort);
Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
flag = false;
}
catch
{
if (!Netplay.disconnect)
{
if (Main.gameMenu)
flag = true;
}
}
}
NetMessage.buffer[256].Reset();
int num = -1;
while (!Netplay.disconnect)
{
if (Netplay.clientSock.tcpClient.Connected)
{
if (NetMessage.buffer[256].checkBytes)
NetMessage.CheckBytes();
Netplay.clientSock.active = true;
if (Netplay.clientSock.state == 0)
{
Main.statusText = "Found server";
Netplay.clientSock.state = 1;
NetMessage.SendData(1);
}
if (Netplay.clientSock.state == 2 && num != Netplay.clientSock.state)
Main.statusText = "Sending player data...";
if (Netplay.clientSock.state == 3 && num != Netplay.clientSock.state)
Main.statusText = "Requesting world information";
if (Netplay.clientSock.state == 4)
{
WorldGen.worldCleared = false;
Netplay.clientSock.state = 5;
WorldGen.clearWorld();
}
if (Netplay.clientSock.state == 5 && WorldGen.worldCleared)
{
Netplay.clientSock.state = 6;
Main.player[Main.myPlayer].FindSpawn();
NetMessage.SendData(8, number: Main.player[Main.myPlayer].SpawnX, number2: ((float) Main.player[Main.myPlayer].SpawnY));
}
if (Netplay.clientSock.state == 6 && num != Netplay.clientSock.state)
Main.statusText = "Requesting tile data";
if (!Netplay.clientSock.locked && !Netplay.disconnect && Netplay.clientSock.networkStream.DataAvailable)
{
Netplay.clientSock.locked = true;
Netplay.clientSock.networkStream.BeginRead(Netplay.clientSock.readBuffer, 0, Netplay.clientSock.readBuffer.Length, new AsyncCallback(Netplay.clientSock.ClientReadCallBack), (object) Netplay.clientSock.networkStream);
}
if (Netplay.clientSock.statusMax > 0 && Netplay.clientSock.statusText != "")
{
if (Netplay.clientSock.statusCount >= Netplay.clientSock.statusMax)
{
Main.statusText = Netplay.clientSock.statusText + ": Complete!";
Netplay.clientSock.statusText = "";
Netplay.clientSock.statusMax = 0;
Netplay.clientSock.statusCount = 0;
}
else
Main.statusText = Netplay.clientSock.statusText + ": " + (object) (int) ((double) Netplay.clientSock.statusCount / (double) Netplay.clientSock.statusMax * 100.0) + "%";
}
Thread.Sleep(1);
}
else if (Netplay.clientSock.active)
{
Main.statusText = "Lost connection";
Netplay.disconnect = true;
}
num = Netplay.clientSock.state;
}
try
{
Netplay.clientSock.networkStream.Close();
Netplay.clientSock.networkStream = Netplay.clientSock.tcpClient.GetStream();
}
catch
{
}
if (!Main.gameMenu)
{
Main.netMode = 0;
Player.SavePlayer(Main.player[Main.myPlayer], Main.playerPathName);
Main.gameMenu = true;
Main.menuMode = 14;
}
NetMessage.buffer[256].Reset();
if (Main.menuMode == 15 && Main.statusText == "Lost connection")
Main.menuMode = 14;
if (Netplay.clientSock.statusText != "" && Netplay.clientSock.statusText != null)
Main.statusText = "Lost connection";
Netplay.clientSock.statusCount = 0;
Netplay.clientSock.statusMax = 0;
Netplay.clientSock.statusText = "";
Main.netMode = 0;
}
public static void ServerLoop(object threadContext)
{
Netplay.ResetNetDiag();
if (Main.rand == null)
Main.rand = new Random((int) DateTime.Now.Ticks);
if (WorldGen.genRand == null)
WorldGen.genRand = new Random((int) DateTime.Now.Ticks);
Main.myPlayer = (int) byte.MaxValue;
Netplay.serverIP = IPAddress.Any;
Netplay.serverListenIP = Netplay.serverIP;
Main.menuMode = 14;
Main.statusText = "Starting server...";
Main.netMode = 2;
Netplay.disconnect = false;
for (int index = 0; index < 256; ++index)
{
Netplay.serverSock[index] = new ServerSock();
Netplay.serverSock[index].Reset();
Netplay.serverSock[index].whoAmI = index;
Netplay.serverSock[index].tcpClient = new TcpClient();
Netplay.serverSock[index].tcpClient.NoDelay = true;
Netplay.serverSock[index].readBuffer = new byte[1024];
Netplay.serverSock[index].writeBuffer = new byte[1024];
}
Netplay.tcpListener = new TcpListener(Netplay.serverListenIP, Netplay.serverPort);
try
{
Netplay.tcpListener.Start();
}
catch (Exception ex)
{
Main.menuMode = 15;
Main.statusText = ex.ToString();
Netplay.disconnect = true;
}
if (!Netplay.disconnect)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), (object) 1);
Main.statusText = "Server started";
}
int num1 = 0;
while (!Netplay.disconnect)
{
if (Netplay.stopListen)
{
int num2 = -1;
for (int index = 0; index < Main.maxNetPlayers; ++index)
{
if (!Netplay.serverSock[index].tcpClient.Connected)
{
num2 = index;
break;
}
}
if (num2 >= 0)
{
if (Main.ignoreErrors)
{
try
{
Netplay.tcpListener.Start();
Netplay.stopListen = false;
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), (object) 1);
}
catch
{
}
}
else
{
Netplay.tcpListener.Start();
Netplay.stopListen = false;
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), (object) 1);
}
}
}
int num3 = 0;
for (int i = 0; i < 256; ++i)
{
if (NetMessage.buffer[i].checkBytes)
NetMessage.CheckBytes(i);
if (Netplay.serverSock[i].kill)
{
Netplay.serverSock[i].Reset();
NetMessage.syncPlayers();
}
else if (Netplay.serverSock[i].tcpClient.Connected)
{
if (!Netplay.serverSock[i].active)
Netplay.serverSock[i].state = 0;
Netplay.serverSock[i].active = true;
++num3;
if (!Netplay.serverSock[i].locked)
{
try
{
Netplay.serverSock[i].networkStream = Netplay.serverSock[i].tcpClient.GetStream();
if (Netplay.serverSock[i].networkStream.DataAvailable)
{
Netplay.serverSock[i].locked = true;
Netplay.serverSock[i].networkStream.BeginRead(Netplay.serverSock[i].readBuffer, 0, Netplay.serverSock[i].readBuffer.Length, new AsyncCallback(Netplay.serverSock[i].ServerReadCallBack), (object) Netplay.serverSock[i].networkStream);
}
}
catch
{
Netplay.serverSock[i].kill = true;
}
}
if (Netplay.serverSock[i].statusMax > 0 && Netplay.serverSock[i].statusText2 != "")
{
if (Netplay.serverSock[i].statusCount >= Netplay.serverSock[i].statusMax)
{
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " " + Netplay.serverSock[i].statusText2 + ": Complete!";
Netplay.serverSock[i].statusText2 = "";
Netplay.serverSock[i].statusMax = 0;
Netplay.serverSock[i].statusCount = 0;
}
else
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " " + Netplay.serverSock[i].statusText2 + ": " + (object) (int) ((double) Netplay.serverSock[i].statusCount / (double) Netplay.serverSock[i].statusMax * 100.0) + "%";
}
else if (Netplay.serverSock[i].state == 0)
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " is connecting...";
else if (Netplay.serverSock[i].state == 1)
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " is sending player data...";
else if (Netplay.serverSock[i].state == 2)
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " requested world information";
else if (Netplay.serverSock[i].state != 3 && Netplay.serverSock[i].state == 10)
Netplay.serverSock[i].statusText = "(" + (object) Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint + ") " + Netplay.serverSock[i].name + " is playing";
}
else if (Netplay.serverSock[i].active)
{
Netplay.serverSock[i].kill = true;
}
else
{
Netplay.serverSock[i].statusText2 = "";
if (i < (int) byte.MaxValue)
Main.player[i].active = false;
}
}
++num1;
if (num1 > 10)
{
Thread.Sleep(1);
num1 = 0;
}
else
Thread.Sleep(0);
if (!WorldGen.saveLock && !Main.dedServ)
Main.statusText = num3 != 0 ? num3.ToString() + " clients connected" : "Waiting for clients...";
Netplay.anyClients = num3 != 0;
Netplay.ServerUp = true;
}
Netplay.tcpListener.Stop();
for (int index = 0; index < 256; ++index)
Netplay.serverSock[index].Reset();
if (Main.menuMode != 15)
{
Main.netMode = 0;
Main.menuMode = 10;
WorldGen.saveWorld();
do
;
while (WorldGen.saveLock);
Main.menuMode = 0;
}
else
Main.netMode = 0;
Main.myPlayer = 0;
}
public static void ListenForClients(object threadContext)
{
while (!Netplay.disconnect && !Netplay.stopListen)
{
int index1 = -1;
for (int index2 = 0; index2 < Main.maxNetPlayers; ++index2)
{
if (!Netplay.serverSock[index2].tcpClient.Connected)
{
index1 = index2;
break;
}
}
if (index1 >= 0)
{
try
{
Netplay.serverSock[index1].tcpClient = Netplay.tcpListener.AcceptTcpClient();
Netplay.serverSock[index1].tcpClient.NoDelay = true;
Console.WriteLine(Netplay.serverSock[index1].tcpClient.Client.RemoteEndPoint.ToString() + " is connecting...");
}
catch (Exception ex)
{
if (!Netplay.disconnect)
{
Main.menuMode = 15;
Main.statusText = ex.ToString();
Netplay.disconnect = true;
}
}
}
else
{
Netplay.stopListen = true;
Netplay.tcpListener.Stop();
}
}
}
public static void StartClient() => ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ClientLoop), (object) 1);
public static void StartServer() => ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ServerLoop), (object) 1);
public static bool SetIP(string newIP)
{
try
{
Netplay.serverIP = IPAddress.Parse(newIP);
}
catch
{
return false;
}
return true;
}
public static bool SetIP2(string newIP)
{
try
{
IPAddress[] addressList = Dns.GetHostEntry(newIP).AddressList;
for (int index = 0; index < addressList.Length; ++index)
{
if (addressList[index].AddressFamily == AddressFamily.InterNetwork)
{
Netplay.serverIP = addressList[index];
return true;
}
}
return false;
}
catch
{
return false;
}
}
public static void Init()
{
for (int index = 0; index < 257; ++index)
{
if (index < 256)
{
Netplay.serverSock[index] = new ServerSock();
Netplay.serverSock[index].tcpClient.NoDelay = true;
}
NetMessage.buffer[index] = new messageBuffer();
NetMessage.buffer[index].whoAmI = index;
}
Netplay.clientSock.tcpClient.NoDelay = true;
}
public static int GetSectionX(int x) => x / 200;
public static int GetSectionY(int y) => y / 150;
}
}

4384
Player.cs Normal file

File diff suppressed because it is too large Load diff

89
Program.cs Normal file
View file

@ -0,0 +1,89 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Program
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.IO;
using System.Windows.Forms;
namespace Terraria
{
internal static class Program
{
private static void Main(string[] args)
{
using (Terraria.Main main = new Terraria.Main())
{
try
{
for (int index = 0; index < args.Length; ++index)
{
if (args[index].ToLower() == "-port" || args[index].ToLower() == "-p")
{
++index;
try
{
Netplay.serverPort = Convert.ToInt32(args[index]);
}
catch
{
}
}
if (args[index].ToLower() == "-join" || args[index].ToLower() == "-j")
{
++index;
try
{
main.AutoJoin(args[index]);
}
catch
{
}
}
if (args[index].ToLower() == "-pass" || args[index].ToLower() == "-password")
{
++index;
Netplay.password = args[index];
main.AutoPass();
}
if (args[index].ToLower() == "-host")
main.AutoHost();
if (args[index].ToLower() == "-loadlib")
{
++index;
string path = args[index];
main.loadLib(path);
}
}
Steam.Init();
if (Steam.SteamInit)
{
main.Run();
}
else
{
int num = (int) MessageBox.Show("Please launch the game from your Steam client.", "Error");
}
}
catch (Exception ex)
{
try
{
using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", true))
{
streamWriter.WriteLine((object) DateTime.Now);
streamWriter.WriteLine((object) ex);
streamWriter.WriteLine("");
}
int num = (int) MessageBox.Show(ex.ToString(), "Terraria: Error");
}
catch
{
}
}
}
}
}
}

5267
Projectile.cs Normal file

File diff suppressed because it is too large Load diff

2219
Recipe.cs Normal file

File diff suppressed because it is too large Load diff

172
ServerSock.cs Normal file
View file

@ -0,0 +1,172 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.ServerSock
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.Net.Sockets;
namespace Terraria
{
public class ServerSock
{
public Socket clientSocket;
public NetworkStream networkStream;
public TcpClient tcpClient = new TcpClient();
public int whoAmI;
public string statusText2;
public int statusCount;
public int statusMax;
public bool[,] tileSection = new bool[Main.maxTilesX / 200 + 1, Main.maxTilesY / 150 + 1];
public string statusText = "";
public bool active;
public bool locked;
public bool kill;
public int timeOut;
public bool announced;
public string name = "Anonymous";
public string oldName = "";
public int state;
public float spamProjectile;
public float spamAddBlock;
public float spamDelBlock;
public float spamWater;
public float spamProjectileMax = 100f;
public float spamAddBlockMax = 100f;
public float spamDelBlockMax = 500f;
public float spamWaterMax = 50f;
public byte[] readBuffer;
public byte[] writeBuffer;
public void SpamUpdate()
{
if (!Netplay.spamCheck)
{
this.spamProjectile = 0.0f;
this.spamDelBlock = 0.0f;
this.spamAddBlock = 0.0f;
this.spamWater = 0.0f;
}
else
{
if ((double) this.spamProjectile > (double) this.spamProjectileMax)
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Projectile spam");
if ((double) this.spamAddBlock > (double) this.spamAddBlockMax)
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Add tile spam");
if ((double) this.spamDelBlock > (double) this.spamDelBlockMax)
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Remove tile spam");
if ((double) this.spamWater > (double) this.spamWaterMax)
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam");
this.spamProjectile -= 0.4f;
if ((double) this.spamProjectile < 0.0)
this.spamProjectile = 0.0f;
this.spamAddBlock -= 0.3f;
if ((double) this.spamAddBlock < 0.0)
this.spamAddBlock = 0.0f;
this.spamDelBlock -= 5f;
if ((double) this.spamDelBlock < 0.0)
this.spamDelBlock = 0.0f;
this.spamWater -= 0.2f;
if ((double) this.spamWater >= 0.0)
return;
this.spamWater = 0.0f;
}
}
public void SpamClear()
{
this.spamProjectile = 0.0f;
this.spamAddBlock = 0.0f;
this.spamDelBlock = 0.0f;
this.spamWater = 0.0f;
}
public bool SectionRange(int size, int firstX, int firstY)
{
for (int index = 0; index < 4; ++index)
{
int x = firstX;
int y = firstY;
if (index == 1)
x += size;
if (index == 2)
y += size;
if (index == 3)
{
x += size;
y += size;
}
if (this.tileSection[Netplay.GetSectionX(x), Netplay.GetSectionY(y)])
return true;
}
return false;
}
public void Reset()
{
for (int index1 = 0; index1 < Main.maxSectionsX; ++index1)
{
for (int index2 = 0; index2 < Main.maxSectionsY; ++index2)
this.tileSection[index1, index2] = false;
}
if (this.whoAmI < (int) byte.MaxValue)
Main.player[this.whoAmI] = new Player();
this.timeOut = 0;
this.statusCount = 0;
this.statusMax = 0;
this.statusText2 = "";
this.statusText = "";
this.name = "Anonymous";
this.state = 0;
this.locked = false;
this.kill = false;
this.SpamClear();
this.active = false;
NetMessage.buffer[this.whoAmI].Reset();
if (this.networkStream != null)
this.networkStream.Close();
if (this.tcpClient == null)
return;
this.tcpClient.Close();
}
public void ServerWriteCallBack(IAsyncResult ar)
{
--NetMessage.buffer[this.whoAmI].spamCount;
if (this.statusMax <= 0)
return;
++this.statusCount;
}
public void ServerReadCallBack(IAsyncResult ar)
{
int streamLength = 0;
if (!Netplay.disconnect)
{
try
{
streamLength = this.networkStream.EndRead(ar);
}
catch
{
}
if (streamLength == 0)
this.kill = true;
else if (Main.ignoreErrors)
{
try
{
NetMessage.RecieveBytes(this.readBuffer, streamLength, this.whoAmI);
}
catch
{
}
}
else
NetMessage.RecieveBytes(this.readBuffer, streamLength, this.whoAmI);
}
this.locked = false;
}
}
}

75
Sign.cs Normal file
View file

@ -0,0 +1,75 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Sign
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria
{
public class Sign
{
public const int maxSigns = 1000;
public int x;
public int y;
public string text;
public object Clone() => this.MemberwiseClone();
public static void KillSign(int x, int y)
{
for (int index = 0; index < 1000; ++index)
{
if (Main.sign[index] != null && Main.sign[index].x == x && Main.sign[index].y == y)
Main.sign[index] = (Sign) null;
}
}
public static int ReadSign(int i, int j)
{
int num1 = (int) Main.tile[i, j].frameX / 18;
int num2 = (int) Main.tile[i, j].frameY / 18;
while (num1 > 1)
num1 -= 2;
int x = i - num1;
int y = j - num2;
if (Main.tile[x, y].type != (byte) 55 && Main.tile[x, y].type != (byte) 85)
{
Sign.KillSign(x, y);
return -1;
}
int num3 = -1;
for (int index = 0; index < 1000; ++index)
{
if (Main.sign[index] != null && Main.sign[index].x == x && Main.sign[index].y == y)
{
num3 = index;
break;
}
}
if (num3 < 0)
{
for (int index = 0; index < 1000; ++index)
{
if (Main.sign[index] == null)
{
num3 = index;
Main.sign[index] = new Sign();
Main.sign[index].x = x;
Main.sign[index].y = y;
Main.sign[index].text = "";
break;
}
}
}
return num3;
}
public static void TextSign(int i, string text)
{
if (Main.tile[Main.sign[i].x, Main.sign[i].y] == null || !Main.tile[Main.sign[i].x, Main.sign[i].y].active || Main.tile[Main.sign[i].x, Main.sign[i].y].type != (byte) 55 && Main.tile[Main.sign[i].x, Main.sign[i].y].type != (byte) 85)
Main.sign[i] = (Sign) null;
else
Main.sign[i].text = text;
}
}
}

66
Star.cs Normal file
View file

@ -0,0 +1,66 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Star
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using Microsoft.Xna.Framework;
namespace Terraria
{
public class Star
{
public Vector2 position;
public float scale;
public float rotation;
public int type;
public float twinkle;
public float twinkleSpeed;
public float rotationSpeed;
public static void SpawnStars()
{
Main.numStars = Main.rand.Next(65, 130);
Main.numStars = 130;
for (int index = 0; index < Main.numStars; ++index)
{
Main.star[index] = new Star();
Main.star[index].position.X = (float) Main.rand.Next(-12, Main.screenWidth + 1);
Main.star[index].position.Y = (float) Main.rand.Next(-12, Main.screenHeight);
Main.star[index].rotation = (float) Main.rand.Next(628) * 0.01f;
Main.star[index].scale = (float) Main.rand.Next(50, 120) * 0.01f;
Main.star[index].type = Main.rand.Next(0, 5);
Main.star[index].twinkle = (float) Main.rand.Next(101) * 0.01f;
Main.star[index].twinkleSpeed = (float) Main.rand.Next(40, 100) * 0.0001f;
if (Main.rand.Next(2) == 0)
Main.star[index].twinkleSpeed *= -1f;
Main.star[index].rotationSpeed = (float) Main.rand.Next(10, 40) * 0.0001f;
if (Main.rand.Next(2) == 0)
Main.star[index].rotationSpeed *= -1f;
}
}
public static void UpdateStars()
{
for (int index = 0; index < Main.numStars; ++index)
{
Main.star[index].twinkle += Main.star[index].twinkleSpeed;
if ((double) Main.star[index].twinkle > 1.0)
{
Main.star[index].twinkle = 1f;
Main.star[index].twinkleSpeed *= -1f;
}
else if ((double) Main.star[index].twinkle < 0.5)
{
Main.star[index].twinkle = 0.5f;
Main.star[index].twinkleSpeed *= -1f;
}
Main.star[index].rotation += Main.star[index].rotationSpeed;
if ((double) Main.star[index].rotation > 6.28)
Main.star[index].rotation -= 6.28f;
if ((double) Main.star[index].rotation < 0.0)
Main.star[index].rotation += 6.28f;
}
}
}
}

25
Steam.cs Normal file
View file

@ -0,0 +1,25 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Steam
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System.Runtime.InteropServices;
namespace Terraria
{
public class Steam
{
public static bool SteamInit;
[DllImport("steam_api.dll")]
private static extern bool SteamAPI_Init();
[DllImport("steam_api.dll")]
private static extern bool SteamAPI_Shutdown();
public static void Init() => Steam.SteamInit = Steam.SteamAPI_Init();
public static void Kill() => Steam.SteamAPI_Shutdown();
}
}

80
Terraria.csproj Normal file
View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--Project was exported from assembly: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe-->
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{121CC93B-1056-4FF3-8747-712B3DC8C7B3}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AssemblyName>Terraria</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<ApplicationVersion>1.0.4.0</ApplicationVersion>
<FileAlignment>512</FileAlignment>
<RootNamespace>Terraria</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework" />
<Reference Include="Microsoft.Xna.Framework.Game" />
<Reference Include="Microsoft.Xna.Framework.Graphics" />
<Reference Include="Microsoft.Xna.Framework.Xact" />
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Projectile.cs" />
<Compile Include="Cloud.cs" />
<Compile Include="Star.cs" />
<Compile Include="CombatText.cs" />
<Compile Include="ItemText.cs" />
<Compile Include="ServerSock.cs" />
<Compile Include="ClientSock.cs" />
<Compile Include="Netplay.cs" />
<Compile Include="ChatLine.cs" />
<Compile Include="Main.cs" />
<Compile Include="Program.cs" />
<Compile Include="WorldGen.cs" />
<Compile Include="Sign.cs" />
<Compile Include="LiquidBuffer.cs" />
<Compile Include="Liquid.cs" />
<Compile Include="Lighting.cs" />
<Compile Include="Lang.cs" />
<Compile Include="keyBoardInput.cs" />
<Compile Include="Recipe.cs" />
<Compile Include="NPC.cs" />
<Compile Include="Gore.cs" />
<Compile Include="Tile.cs" />
<Compile Include="Item.cs" />
<Compile Include="Chest.cs" />
<Compile Include="Collision.cs" />
<Compile Include="messageBuffer.cs" />
<Compile Include="NetMessage.cs" />
<Compile Include="Dust.cs" />
<Compile Include="Player.cs" />
<Compile Include="Steam.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Microsoft\Xna\Framework.RuntimeProfile" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

BIN
Terraria.pdb Normal file

Binary file not shown.

20
Terraria.sln Normal file
View file

@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terraria", "Terraria.csproj", "{121CC93B-1056-4FF3-8747-712B3DC8C7B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{121CC93B-1056-4FF3-8747-712B3DC8C7B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{121CC93B-1056-4FF3-8747-712B3DC8C7B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{121CC93B-1056-4FF3-8747-712B3DC8C7B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{121CC93B-1056-4FF3-8747-712B3DC8C7B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

30
Tile.cs Normal file
View file

@ -0,0 +1,30 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.Tile
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
namespace Terraria
{
public class Tile
{
public bool active;
public byte type;
public byte wall;
public byte wallFrameX;
public byte wallFrameY;
public byte wallFrameNumber;
public bool wire;
public byte liquid;
public bool checkingLiquid;
public bool skipLiquid;
public bool lava;
public byte frameNumber;
public short frameX;
public short frameY;
public object Clone() => this.MemberwiseClone();
public bool isTheSameAs(Tile compTile) => this.active == compTile.active && (!this.active || (int) this.type == (int) compTile.type && (!Main.tileFrameImportant[(int) this.type] || (int) this.frameX == (int) compTile.frameX && (int) this.frameY == (int) compTile.frameY)) && (int) this.wall == (int) compTile.wall && (int) this.liquid == (int) compTile.liquid && this.lava == compTile.lava && this.wire == compTile.wire;
}
}

19138
WorldGen.cs Normal file

File diff suppressed because it is too large Load diff

43
keyBoardInput.cs Normal file
View file

@ -0,0 +1,43 @@
// Decompiled with JetBrains decompiler
// Type: Terraria.keyBoardInput
// Assembly: Terraria, Version=1.0.4.0, Culture=neutral, PublicKeyToken=null
// MVID: FF258283-FE37-4E8A-A035-CB1E6DC74C3C
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Terraria
{
public class keyBoardInput
{
public static event Action<char> newKeyEvent;
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern bool TranslateMessage(IntPtr message);
static keyBoardInput() => Application.AddMessageFilter((IMessageFilter) new keyBoardInput.inKey());
public class inKey : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 258)
{
char wparam = (char) (int) m.WParam;
Console.WriteLine(wparam);
if (keyBoardInput.newKeyEvent != null)
keyBoardInput.newKeyEvent(wparam);
}
else if (m.Msg == 256)
{
IntPtr num = Marshal.AllocHGlobal(Marshal.SizeOf((object) m));
Marshal.StructureToPtr((object) m, num, true);
keyBoardInput.TranslateMessage(num);
}
return false;
}
}
}
}

1711
messageBuffer.cs Normal file

File diff suppressed because it is too large Load diff