Version 1.2.0.3.1
Decompiled with IlSpy Fixes Source Code
This commit is contained in:
parent
fd93a0ee5e
commit
0462173018
38 changed files with 243391 additions and 0 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -106,3 +106,7 @@ Generated_Code #added for RIA/Silverlight projects
|
|||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
|
||||
# Temp Data
|
||||
*.orig
|
||||
*temp.cs
|
||||
|
|
1
LICENSE
1
LICENSE
|
@ -0,0 +1 @@
|
|||
Only for educational use.
|
1
Microsoft.Xna.Framework.RuntimeProfile
Normal file
1
Microsoft.Xna.Framework.RuntimeProfile
Normal file
|
@ -0,0 +1 @@
|
|||
Windows.v4.0.Reach
|
|
@ -1,2 +1,5 @@
|
|||
Terraria-Source-Code
|
||||
====================
|
||||
Terraria Source Code 1.2.0.3.1
|
||||
|
||||
Only for educational use.
|
73
Terraria.csproj
Normal file
73
Terraria.csproj
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>916B1896-36A0-41DC-9D70-87D6E8DD2179</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AssemblyName>Terraria</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Xna.Framework.Game" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="Microsoft.Xna.Framework" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Graphics" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.Xna.Framework.Xact" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Terraria\ChatLine.cs" />
|
||||
<Compile Include="Terraria\Chest.cs" />
|
||||
<Compile Include="Terraria\ClientSock.cs" />
|
||||
<Compile Include="Terraria\Cloud.cs" />
|
||||
<Compile Include="Terraria\Collision.cs" />
|
||||
<Compile Include="Terraria\CombatText.cs" />
|
||||
<Compile Include="Terraria\Dust.cs" />
|
||||
<Compile Include="Terraria\Gore.cs" />
|
||||
<Compile Include="Terraria\Item.cs" />
|
||||
<Compile Include="Terraria\ItemText.cs" />
|
||||
<Compile Include="Terraria\keyBoardInput.cs" />
|
||||
<Compile Include="Terraria\Lang.cs" />
|
||||
<Compile Include="Terraria\Lighting.cs" />
|
||||
<Compile Include="Terraria\Liquid.cs" />
|
||||
<Compile Include="Terraria\LiquidBuffer.cs" />
|
||||
<Compile Include="Terraria\Main.cs" />
|
||||
<Compile Include="Terraria\Map.cs" />
|
||||
<Compile Include="Terraria\messageBuffer.cs" />
|
||||
<Compile Include="Terraria\NetMessage.cs" />
|
||||
<Compile Include="Terraria\Netplay.cs" />
|
||||
<Compile Include="Terraria\NPC.cs" />
|
||||
<Compile Include="Terraria\Player.cs" />
|
||||
<Compile Include="Terraria\Program.cs" />
|
||||
<Compile Include="Terraria\Projectile.cs" />
|
||||
<Compile Include="Terraria\Rain.cs" />
|
||||
<Compile Include="Terraria\Recipe.cs" />
|
||||
<Compile Include="Terraria\ServerSock.cs" />
|
||||
<Compile Include="Terraria\Sign.cs" />
|
||||
<Compile Include="Terraria\Star.cs" />
|
||||
<Compile Include="Terraria\Steam.cs" />
|
||||
<Compile Include="Terraria\Tile.cs" />
|
||||
<Compile Include="Terraria\WorldGen.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Microsoft.Xna.Framework.RuntimeProfile" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
18
Terraria.sln
Normal file
18
Terraria.sln
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
# SharpDevelop 4.3
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Terraria", "Terraria.csproj", "916B1896-36A0-41DC-9D70-87D6E8DD2179"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
916B1896-36A0-41DC-9D70-87D6E8DD2179.Debug|x86.Build.0 = Debug|x86
|
||||
916B1896-36A0-41DC-9D70-87D6E8DD2179.Debug|x86.ActiveCfg = Debug|x86
|
||||
916B1896-36A0-41DC-9D70-87D6E8DD2179.Release|x86.Build.0 = Release|x86
|
||||
916B1896-36A0-41DC-9D70-87D6E8DD2179.Release|x86.ActiveCfg = Release|x86
|
||||
EndGlobalSection
|
||||
EndGlobal
|
11
Terraria/ChatLine.cs
Normal file
11
Terraria/ChatLine.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
namespace Terraria
|
||||
{
|
||||
public class ChatLine
|
||||
{
|
||||
public Color color = Color.White;
|
||||
public int showTime;
|
||||
public string text = "";
|
||||
}
|
||||
}
|
869
Terraria/Chest.cs
Normal file
869
Terraria/Chest.cs
Normal file
|
@ -0,0 +1,869 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
namespace Terraria
|
||||
{
|
||||
public class Chest
|
||||
{
|
||||
public static int maxItems = 40;
|
||||
public Item[] item = new Item[Chest.maxItems];
|
||||
public int x;
|
||||
public int y;
|
||||
public object Clone()
|
||||
{
|
||||
return base.MemberwiseClone();
|
||||
}
|
||||
public static void Unlock(int X, int Y)
|
||||
{
|
||||
Main.PlaySound(22, X * 16, Y * 16, 1);
|
||||
for (int i = X; i <= X + 1; i++)
|
||||
{
|
||||
for (int j = Y; j <= Y + 1; j++)
|
||||
{
|
||||
if (Main.tile[i, j] == null)
|
||||
{
|
||||
Main.tile[i, j] = new Tile();
|
||||
}
|
||||
if ((Main.tile[i, j].frameX >= 72 && Main.tile[i, j].frameX <= 106) || (Main.tile[i, j].frameX >= 144 && Main.tile[i, j].frameX <= 178))
|
||||
{
|
||||
Tile expr_A3 = Main.tile[i, j];
|
||||
expr_A3.frameX -= 36;
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 11, 0f, 0f, 0, default(Color), 1f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.tile[i, j].frameX >= 828 && Main.tile[i, j].frameX <= 990)
|
||||
{
|
||||
Tile expr_134 = Main.tile[i, j];
|
||||
expr_134.frameX -= 180;
|
||||
for (int l = 0; l < 4; l++)
|
||||
{
|
||||
Dust.NewDust(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16, 11, 0f, 0f, 0, default(Color), 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int UsingChest(int i)
|
||||
{
|
||||
if (Main.chest[i] != null)
|
||||
{
|
||||
for (int j = 0; j < 255; j++)
|
||||
{
|
||||
if (Main.player[j].active && Main.player[j].chest == i)
|
||||
{
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static int FindChest(int X, int Y)
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (Main.chest[i] != null && Main.chest[i].x == X && Main.chest[i].y == Y)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static int CreateChest(int X, int Y)
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (Main.chest[i] != null && Main.chest[i].x == X && Main.chest[i].y == Y)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 1000; j++)
|
||||
{
|
||||
if (Main.chest[j] == null)
|
||||
{
|
||||
Main.chest[j] = new Chest();
|
||||
Main.chest[j].x = X;
|
||||
Main.chest[j].y = Y;
|
||||
for (int k = 0; k < Chest.maxItems; k++)
|
||||
{
|
||||
Main.chest[j].item[k] = new Item();
|
||||
}
|
||||
return j;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public static bool DestroyChest(int X, int Y)
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (Main.chest[i] != null && Main.chest[i].x == X && Main.chest[i].y == Y)
|
||||
{
|
||||
for (int j = 0; j < Chest.maxItems; j++)
|
||||
{
|
||||
if (Main.chest[i].item[j].type > 0 && Main.chest[i].item[j].stack > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Main.chest[i] = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void AddShop(Item newItem)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < 39)
|
||||
{
|
||||
if (this.item[i] == null || this.item[i].type == 0)
|
||||
{
|
||||
this.item[i] = (Item)newItem.Clone();
|
||||
this.item[i].buyOnce = true;
|
||||
if (this.item[i].value <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this.item[i].value = this.item[i].value / 5;
|
||||
if (this.item[i].value < 1)
|
||||
{
|
||||
this.item[i].value = 1;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void SetupShop(int type)
|
||||
{
|
||||
for (int i = 0; i < Chest.maxItems; i++)
|
||||
{
|
||||
this.item[i] = new Item();
|
||||
}
|
||||
int num = 0;
|
||||
if (type == 1)
|
||||
{
|
||||
this.item[num].SetDefaults("Mining Helmet");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Piggy Bank");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Iron Anvil");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Copper Pickaxe");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Copper Axe");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Torch");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Lesser Healing Potion");
|
||||
num++;
|
||||
if (Main.player[Main.myPlayer].statManaMax == 200)
|
||||
{
|
||||
this.item[num].SetDefaults("Lesser Mana Potion");
|
||||
num++;
|
||||
}
|
||||
this.item[num].SetDefaults("Wooden Arrow");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Shuriken");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Rope");
|
||||
num++;
|
||||
if (Main.player[Main.myPlayer].zoneSnow)
|
||||
{
|
||||
this.item[num].SetDefaults(967, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
this.item[num].SetDefaults("Throwing Knife");
|
||||
num++;
|
||||
}
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults("Glowstick");
|
||||
num++;
|
||||
}
|
||||
if (NPC.downedBoss3)
|
||||
{
|
||||
this.item[num].SetDefaults("Safe");
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(488, false);
|
||||
num++;
|
||||
}
|
||||
for (int j = 0; j < 58; j++)
|
||||
{
|
||||
if (Main.player[Main.myPlayer].inventory[j].type == 930)
|
||||
{
|
||||
this.item[num].SetDefaults(931, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1614, false);
|
||||
num++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1348, false);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 2)
|
||||
{
|
||||
this.item[num].SetDefaults("Musket Ball");
|
||||
num++;
|
||||
if (Main.bloodMoon || Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults("Silver Bullet");
|
||||
num++;
|
||||
}
|
||||
if ((NPC.downedBoss2 && !Main.dayTime) || Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(47, false);
|
||||
num++;
|
||||
}
|
||||
this.item[num].SetDefaults("Flintlock Pistol");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Minishark");
|
||||
num++;
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults(324, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(534, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1432, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].HasItem(1258))
|
||||
{
|
||||
this.item[num].SetDefaults(1261, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 3)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
this.item[num].SetDefaults(67, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(59, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults("Purification Powder");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Grass Seeds");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Sunflower");
|
||||
num++;
|
||||
}
|
||||
this.item[num].SetDefaults("Acorn");
|
||||
num++;
|
||||
this.item[num].SetDefaults(114, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(745, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(747, false);
|
||||
num++;
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(746, false);
|
||||
}
|
||||
num++;
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(369, false);
|
||||
}
|
||||
num++;
|
||||
if (Main.shroomTiles > 50)
|
||||
{
|
||||
this.item[num].SetDefaults(194, false);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 4)
|
||||
{
|
||||
this.item[num].SetDefaults("Grenade");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Bomb");
|
||||
num++;
|
||||
this.item[num].SetDefaults("Dynamite");
|
||||
num++;
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults("Hellfire Arrow");
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode && NPC.downedGolemBoss && NPC.downedPirates)
|
||||
{
|
||||
this.item[num].SetDefaults(937, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1347, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 5)
|
||||
{
|
||||
this.item[num].SetDefaults(254, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(981, false);
|
||||
num++;
|
||||
if (Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults(242, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.moonPhase == 0)
|
||||
{
|
||||
this.item[num].SetDefaults(245, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(246, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.moonPhase == 1)
|
||||
{
|
||||
this.item[num].SetDefaults(325, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(326, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
this.item[num].SetDefaults(269, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(270, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(271, false);
|
||||
num++;
|
||||
if (NPC.downedClown)
|
||||
{
|
||||
this.item[num].SetDefaults(503, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(504, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(505, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
this.item[num].SetDefaults(322, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneSnow)
|
||||
{
|
||||
this.item[num].SetDefaults(1429, false);
|
||||
}
|
||||
num++;
|
||||
if (Main.hardMode)
|
||||
{
|
||||
if (Main.moonPhase == 2)
|
||||
{
|
||||
this.item[num].SetDefaults(869, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.moonPhase == 4)
|
||||
{
|
||||
this.item[num].SetDefaults(864, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(865, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.moonPhase == 6)
|
||||
{
|
||||
this.item[num].SetDefaults(873, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(874, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(875, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (NPC.downedFrost)
|
||||
{
|
||||
this.item[num].SetDefaults(1275, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1276, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 6)
|
||||
{
|
||||
this.item[num].SetDefaults(128, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(486, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(398, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(84, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(407, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(161, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 7)
|
||||
{
|
||||
this.item[num].SetDefaults(487, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(496, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(500, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(507, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(508, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(531, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(576, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 8)
|
||||
{
|
||||
this.item[num].SetDefaults(509, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(850, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(851, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(510, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(530, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(513, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(538, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(529, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(541, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(542, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(543, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(852, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(853, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(849, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 9)
|
||||
{
|
||||
this.item[num].SetDefaults(588, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(589, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(590, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(597, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(598, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(596, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 10)
|
||||
{
|
||||
this.item[num].SetDefaults(756, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(787, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(868, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1551, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1181, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(783, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 11)
|
||||
{
|
||||
this.item[num].SetDefaults(779, false);
|
||||
num++;
|
||||
if (Main.moonPhase >= 4)
|
||||
{
|
||||
this.item[num].SetDefaults(748, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults(839, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(840, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(841, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults(998, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults(995, false);
|
||||
num++;
|
||||
}
|
||||
this.item[num].SetDefaults(1263, false);
|
||||
num++;
|
||||
if (Main.eclipse || Main.bloodMoon)
|
||||
{
|
||||
if (WorldGen.crimson)
|
||||
{
|
||||
this.item[num].SetDefaults(784, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults(782, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.player[Main.myPlayer].zoneHoly)
|
||||
{
|
||||
this.item[num].SetDefaults(781, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults(780, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1344, false);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 12)
|
||||
{
|
||||
this.item[num].SetDefaults(1037, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1120, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 13)
|
||||
{
|
||||
this.item[num].SetDefaults(1000, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1168, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1449, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1345, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1450, false);
|
||||
num++;
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(970, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(971, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(972, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(973, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 14)
|
||||
{
|
||||
this.item[num].SetDefaults(771, false);
|
||||
num++;
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
this.item[num].SetDefaults(772, false);
|
||||
num++;
|
||||
}
|
||||
if (!Main.dayTime || Main.eclipse)
|
||||
{
|
||||
this.item[num].SetDefaults(773, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.eclipse)
|
||||
{
|
||||
this.item[num].SetDefaults(774, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(760, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1346, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 15)
|
||||
{
|
||||
this.item[num].SetDefaults(1071, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1072, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1100, false);
|
||||
num++;
|
||||
for (int k = 1073; k <= 1084; k++)
|
||||
{
|
||||
this.item[num].SetDefaults(k, false);
|
||||
num++;
|
||||
}
|
||||
this.item[num].SetDefaults(1097, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1099, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1098, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1490, false);
|
||||
num++;
|
||||
if (Main.moonPhase <= 1)
|
||||
{
|
||||
this.item[num].SetDefaults(1481, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.moonPhase <= 3)
|
||||
{
|
||||
this.item[num].SetDefaults(1482, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.moonPhase <= 5)
|
||||
{
|
||||
this.item[num].SetDefaults(1483, false);
|
||||
num++;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.item[num].SetDefaults(1484, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneBlood)
|
||||
{
|
||||
this.item[num].SetDefaults(1492, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneEvil)
|
||||
{
|
||||
this.item[num].SetDefaults(1488, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneHoly)
|
||||
{
|
||||
this.item[num].SetDefaults(1489, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneJungle)
|
||||
{
|
||||
this.item[num].SetDefaults(1486, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneSnow)
|
||||
{
|
||||
this.item[num].SetDefaults(1487, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.sandTiles > 1000)
|
||||
{
|
||||
this.item[num].SetDefaults(1491, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
this.item[num].SetDefaults(1493, false);
|
||||
num++;
|
||||
}
|
||||
if ((double)(Main.player[Main.myPlayer].position.Y / 16f) < Main.worldSurface * 0.34999999403953552)
|
||||
{
|
||||
this.item[num].SetDefaults(1485, false);
|
||||
num++;
|
||||
}
|
||||
if ((double)(Main.player[Main.myPlayer].position.Y / 16f) < Main.worldSurface * 0.34999999403953552 && Main.hardMode)
|
||||
{
|
||||
this.item[num].SetDefaults(1494, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 16)
|
||||
{
|
||||
this.item[num].SetDefaults(1430, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(986, false);
|
||||
num++;
|
||||
if (Main.hardMode && NPC.downedPlantBoss)
|
||||
{
|
||||
if (Main.player[Main.myPlayer].HasItem(1157))
|
||||
{
|
||||
this.item[num].SetDefaults(1159, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1160, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1161, false);
|
||||
num++;
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults(1158, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].zoneJungle)
|
||||
{
|
||||
this.item[num].SetDefaults(1167, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
this.item[num].SetDefaults(1339, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode && Main.player[Main.myPlayer].zoneJungle)
|
||||
{
|
||||
this.item[num].SetDefaults(1171, false);
|
||||
num++;
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
this.item[num].SetDefaults(1162, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if (Main.hardMode && NPC.downedGolemBoss)
|
||||
{
|
||||
this.item[num].SetDefaults(909, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(910, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(940, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(941, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(942, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(943, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(944, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(945, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.player[Main.myPlayer].HasItem(1258))
|
||||
{
|
||||
this.item[num].SetDefaults(1261, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == 17)
|
||||
{
|
||||
this.item[num].SetDefaults(928, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(929, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(876, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(877, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(878, false);
|
||||
num++;
|
||||
int num2 = (int)((Main.screenPosition.X + (float)(Main.screenWidth / 2)) / 16f);
|
||||
if ((double)(Main.screenPosition.Y / 16f) < Main.worldSurface + 10.0 && (num2 < 380 || num2 > Main.maxTilesX - 380))
|
||||
{
|
||||
this.item[num].SetDefaults(1180, false);
|
||||
num++;
|
||||
}
|
||||
if (Main.hardMode && NPC.downedMechBossAny && NPC.AnyNPCs(208))
|
||||
{
|
||||
this.item[num].SetDefaults(1337, false);
|
||||
num++;
|
||||
this.item[num].SetDefaults(1338, false);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Main.player[Main.myPlayer].discount)
|
||||
{
|
||||
for (int l = 0; l < num; l++)
|
||||
{
|
||||
this.item[l].value = (int)((float)this.item[l].value * 0.8f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
Terraria/ClientSock.cs
Normal file
53
Terraria/ClientSock.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
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 num = this.networkStream.EndRead(ar);
|
||||
if (num == 0)
|
||||
{
|
||||
Netplay.disconnect = true;
|
||||
Main.statusText = "Lost connection";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.ignoreErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
NetMessage.RecieveBytes(this.readBuffer, num, 256);
|
||||
goto IL_59;
|
||||
}
|
||||
catch
|
||||
{
|
||||
goto IL_59;
|
||||
}
|
||||
}
|
||||
NetMessage.RecieveBytes(this.readBuffer, num, 256);
|
||||
}
|
||||
}
|
||||
IL_59:
|
||||
this.locked = false;
|
||||
}
|
||||
}
|
||||
}
|
342
Terraria/Cloud.cs
Normal file
342
Terraria/Cloud.cs
Normal file
|
@ -0,0 +1,342 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
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 SpriteEffects spriteDir;
|
||||
public int type;
|
||||
public int width;
|
||||
public int height;
|
||||
public float Alpha;
|
||||
public bool kill;
|
||||
private static Random rand = new Random();
|
||||
public static void resetClouds()
|
||||
{
|
||||
if (Main.dedServ)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Main.cloudLimit < 10)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Main.windSpeed = Main.windSpeedSet;
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
Main.cloud[i].active = false;
|
||||
}
|
||||
for (int j = 0; j < Main.numClouds; j++)
|
||||
{
|
||||
Cloud.addCloud();
|
||||
Main.cloud[j].Alpha = 1f;
|
||||
}
|
||||
for (int k = 0; k < 200; k++)
|
||||
{
|
||||
Main.cloud[k].Alpha = 1f;
|
||||
}
|
||||
}
|
||||
public static void addCloud()
|
||||
{
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = -1;
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
if (!Main.cloud[i].active)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num >= 0)
|
||||
{
|
||||
Main.cloud[num].kill = false;
|
||||
Main.cloud[num].rSpeed = 0f;
|
||||
Main.cloud[num].sSpeed = 0f;
|
||||
Main.cloud[num].scale = (float)Cloud.rand.Next(70, 131) * 0.01f;
|
||||
Main.cloud[num].rotation = (float)Cloud.rand.Next(-10, 11) * 0.01f;
|
||||
Main.cloud[num].width = (int)((float)Main.cloudTexture[Main.cloud[num].type].Width * Main.cloud[num].scale);
|
||||
Main.cloud[num].height = (int)((float)Main.cloudTexture[Main.cloud[num].type].Height * Main.cloud[num].scale);
|
||||
Main.cloud[num].Alpha = 0f;
|
||||
Main.cloud[num].spriteDir = SpriteEffects.None;
|
||||
if (Cloud.rand.Next(2) == 0)
|
||||
{
|
||||
Main.cloud[num].spriteDir = SpriteEffects.FlipHorizontally;
|
||||
}
|
||||
float num2 = Main.windSpeed;
|
||||
if (!Main.gameMenu)
|
||||
{
|
||||
num2 = Main.windSpeed - Main.player[Main.myPlayer].velocity.X * 0.1f;
|
||||
}
|
||||
int num3 = 0;
|
||||
int num4 = 0;
|
||||
if (num2 > 0f)
|
||||
{
|
||||
num3 -= 200;
|
||||
}
|
||||
if (num2 < 0f)
|
||||
{
|
||||
num4 += 200;
|
||||
}
|
||||
int num5 = 300;
|
||||
float x = (float)WorldGen.genRand.Next(num3 - num5, Main.screenWidth + num4 + num5);
|
||||
Main.cloud[num].Alpha = 0f;
|
||||
Main.cloud[num].position.Y = (float)Cloud.rand.Next((int)((float)(-(float)Main.screenHeight) * 0.25f), (int)((float)Main.screenHeight * 0.25f));
|
||||
Cloud expr_211_cp_0 = Main.cloud[num];
|
||||
expr_211_cp_0.position.Y = expr_211_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.15f));
|
||||
Cloud expr_241_cp_0 = Main.cloud[num];
|
||||
expr_241_cp_0.position.Y = expr_241_cp_0.position.Y - (float)Cloud.rand.Next((int)((float)Main.screenHeight * 0.15f));
|
||||
Main.cloud[num].type = Cloud.rand.Next(4);
|
||||
if (Main.rand == null)
|
||||
{
|
||||
Main.rand = new Random();
|
||||
}
|
||||
if ((Main.cloudAlpha > 0f && Cloud.rand.Next(4) != 0) || (Main.cloudBGActive >= 1f && Main.rand.Next(2) == 0))
|
||||
{
|
||||
Main.cloud[num].type = Cloud.rand.Next(18, 22);
|
||||
if ((double)Main.cloud[num].scale >= 1.15)
|
||||
{
|
||||
Cloud expr_303_cp_0 = Main.cloud[num];
|
||||
expr_303_cp_0.position.Y = expr_303_cp_0.position.Y - 150f;
|
||||
}
|
||||
if (Main.cloud[num].scale >= 1f)
|
||||
{
|
||||
Cloud expr_336_cp_0 = Main.cloud[num];
|
||||
expr_336_cp_0.position.Y = expr_336_cp_0.position.Y - 150f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (((Main.cloudBGActive <= 0f && Main.cloudAlpha == 0f && Main.cloud[num].scale < 1f && Main.cloud[num].position.Y < (float)(-(float)Main.screenHeight) * 0.2f) || Main.cloud[num].position.Y < (float)(-(float)Main.screenHeight) * 0.2f) && (double)Main.numClouds < 50.0)
|
||||
{
|
||||
Main.cloud[num].type = Cloud.rand.Next(9, 14);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((((double)Main.cloud[num].scale < 1.15 && Main.cloud[num].position.Y < (float)(-(float)Main.screenHeight) * 0.3f) || ((double)Main.cloud[num].scale < 0.85 && Main.cloud[num].position.Y < (float)Main.screenHeight * 0.15f)) && ((double)Main.numClouds > 70.0 || Main.cloudBGActive >= 1f))
|
||||
{
|
||||
Main.cloud[num].type = Cloud.rand.Next(4, 9);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.cloud[num].position.Y > (float)(-(float)Main.screenHeight) * 0.15f && Cloud.rand.Next(2) == 0 && (double)Main.numClouds > 20.0)
|
||||
{
|
||||
Main.cloud[num].type = Cloud.rand.Next(14, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((double)Main.cloud[num].scale > 1.2)
|
||||
{
|
||||
Cloud expr_50A_cp_0 = Main.cloud[num];
|
||||
expr_50A_cp_0.position.Y = expr_50A_cp_0.position.Y + 100f;
|
||||
}
|
||||
if ((double)Main.cloud[num].scale > 1.3)
|
||||
{
|
||||
Main.cloud[num].scale = 1.3f;
|
||||
}
|
||||
if ((double)Main.cloud[num].scale < 0.7)
|
||||
{
|
||||
Main.cloud[num].scale = 0.7f;
|
||||
}
|
||||
Main.cloud[num].active = true;
|
||||
Main.cloud[num].position.X = x;
|
||||
if (Main.cloud[num].position.X > (float)(Main.screenWidth + 100))
|
||||
{
|
||||
Main.cloud[num].Alpha = 1f;
|
||||
}
|
||||
if (Main.cloud[num].position.X + (float)Main.cloudTexture[Main.cloud[num].type].Width * Main.cloud[num].scale < -100f)
|
||||
{
|
||||
Main.cloud[num].Alpha = 1f;
|
||||
}
|
||||
Rectangle rectangle = new Rectangle((int)Main.cloud[num].position.X, (int)Main.cloud[num].position.Y, Main.cloud[num].width, Main.cloud[num].height);
|
||||
for (int j = 0; j < 200; j++)
|
||||
{
|
||||
if (num != j && Main.cloud[j].active)
|
||||
{
|
||||
Rectangle value = new Rectangle((int)Main.cloud[j].position.X, (int)Main.cloud[j].position.Y, Main.cloud[j].width, Main.cloud[j].height);
|
||||
if (rectangle.Intersects(value))
|
||||
{
|
||||
Main.cloud[num].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public Color cloudColor(Color bgColor)
|
||||
{
|
||||
float num = this.scale * this.Alpha;
|
||||
if (num > 1f)
|
||||
{
|
||||
num = 1f;
|
||||
}
|
||||
float num2 = (float)((int)((float)bgColor.R * num));
|
||||
float num3 = (float)((int)((float)bgColor.G * num));
|
||||
float num4 = (float)((int)((float)bgColor.B * num));
|
||||
float num5 = (float)((int)((float)bgColor.A * num));
|
||||
return new Color((int)((byte)num2), (int)((byte)num3), (int)((byte)num4), (int)((byte)num5));
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
return base.MemberwiseClone();
|
||||
}
|
||||
public static void UpdateClouds()
|
||||
{
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = 0;
|
||||
for (int i = 0; i < 200; i++)
|
||||
{
|
||||
if (Main.cloud[i].active)
|
||||
{
|
||||
Main.cloud[i].Update();
|
||||
if (!Main.cloud[i].kill)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 200; j++)
|
||||
{
|
||||
if (Main.cloud[j].active)
|
||||
{
|
||||
if (j > 1 && (!Main.cloud[j - 1].active || (double)Main.cloud[j - 1].scale > (double)Main.cloud[j].scale + 0.02))
|
||||
{
|
||||
Cloud cloud = (Cloud)Main.cloud[j - 1].Clone();
|
||||
Main.cloud[j - 1] = (Cloud)Main.cloud[j].Clone();
|
||||
Main.cloud[j] = cloud;
|
||||
}
|
||||
if (j < 199 && (!Main.cloud[j].active || (double)Main.cloud[j + 1].scale < (double)Main.cloud[j].scale - 0.02))
|
||||
{
|
||||
Cloud cloud2 = (Cloud)Main.cloud[j + 1].Clone();
|
||||
Main.cloud[j + 1] = (Cloud)Main.cloud[j].Clone();
|
||||
Main.cloud[j] = cloud2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num < Main.numClouds)
|
||||
{
|
||||
Cloud.addCloud();
|
||||
return;
|
||||
}
|
||||
if (num > Main.numClouds)
|
||||
{
|
||||
int num2 = Main.rand.Next(num);
|
||||
int num3 = 0;
|
||||
while (Main.cloud[num2].kill && num3 < 100)
|
||||
{
|
||||
num3++;
|
||||
num2 = Main.rand.Next(num);
|
||||
}
|
||||
Main.cloud[num2].kill = true;
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
this.position.X = this.position.X + Main.windSpeed * this.scale * 3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.scale == 1f)
|
||||
{
|
||||
this.scale -= 0.0001f;
|
||||
}
|
||||
if ((double)this.scale == 1.15)
|
||||
{
|
||||
this.scale -= 0.0001f;
|
||||
}
|
||||
float num;
|
||||
if (this.scale < 1f)
|
||||
{
|
||||
num = 0.07f;
|
||||
float num2 = this.scale + 0.15f;
|
||||
num2 = (num2 + 1f) / 2f;
|
||||
num2 *= num2;
|
||||
num *= num2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((double)this.scale <= 1.15)
|
||||
{
|
||||
num = 0.17f;
|
||||
float num3 = this.scale - 0.075f;
|
||||
num3 *= num3;
|
||||
num *= num3;
|
||||
}
|
||||
else
|
||||
{
|
||||
num = 0.23f;
|
||||
float num4 = this.scale - 0.15f - 0.075f;
|
||||
num4 *= num4;
|
||||
num *= num4;
|
||||
}
|
||||
}
|
||||
this.position.X = this.position.X + Main.windSpeed * num * 5f * (float)Main.dayRate;
|
||||
float num5 = Main.screenPosition.X - Main.screenLastPosition.X;
|
||||
this.position.X = this.position.X - num5 * num;
|
||||
}
|
||||
float num6 = 600f;
|
||||
if (!this.kill)
|
||||
{
|
||||
if (this.Alpha < 1f)
|
||||
{
|
||||
this.Alpha += 0.001f * (float)Main.dayRate;
|
||||
if (this.Alpha > 1f)
|
||||
{
|
||||
this.Alpha = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Alpha -= 0.001f * (float)Main.dayRate;
|
||||
if (this.Alpha <= 0f)
|
||||
{
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
if (this.position.X + (float)Main.cloudTexture[this.type].Width * this.scale < -num6 || this.position.X > (float)Main.screenWidth + num6)
|
||||
{
|
||||
this.active = false;
|
||||
}
|
||||
this.rSpeed += (float)Cloud.rand.Next(-10, 11) * 2E-05f;
|
||||
if ((double)this.rSpeed > 0.0002)
|
||||
{
|
||||
this.rSpeed = 0.0002f;
|
||||
}
|
||||
if ((double)this.rSpeed < -0.0002)
|
||||
{
|
||||
this.rSpeed = -0.0002f;
|
||||
}
|
||||
if ((double)this.rotation > 0.02)
|
||||
{
|
||||
this.rotation = 0.02f;
|
||||
}
|
||||
if ((double)this.rotation < -0.02)
|
||||
{
|
||||
this.rotation = -0.02f;
|
||||
}
|
||||
this.rotation += this.rSpeed;
|
||||
this.width = (int)((float)Main.cloudTexture[this.type].Width * this.scale);
|
||||
this.height = (int)((float)Main.cloudTexture[this.type].Height * this.scale);
|
||||
if (this.type >= 9 && this.type <= 13 && (Main.cloudAlpha > 0f || Main.cloudBGActive >= 1f))
|
||||
{
|
||||
this.kill = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1380
Terraria/Collision.cs
Normal file
1380
Terraria/Collision.cs
Normal file
File diff suppressed because it is too large
Load diff
178
Terraria/CombatText.cs
Normal file
178
Terraria/CombatText.cs
Normal file
|
@ -0,0 +1,178 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
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 bool dot;
|
||||
public static void NewText(Rectangle location, Color color, string text, bool Crit = false, bool dot = false)
|
||||
{
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
if (!Main.combatText[i].active)
|
||||
{
|
||||
int num = 0;
|
||||
if (Crit)
|
||||
{
|
||||
num = 1;
|
||||
}
|
||||
Vector2 vector = Main.fontCombatText[num].MeasureString(text);
|
||||
Main.combatText[i].alpha = 1f;
|
||||
Main.combatText[i].alphaDir = -1;
|
||||
Main.combatText[i].active = true;
|
||||
Main.combatText[i].scale = 0f;
|
||||
Main.combatText[i].rotation = 0f;
|
||||
Main.combatText[i].position.X = (float)location.X + (float)location.Width * 0.5f - vector.X * 0.5f;
|
||||
Main.combatText[i].position.Y = (float)location.Y + (float)location.Height * 0.25f - vector.Y * 0.5f;
|
||||
CombatText expr_FB_cp_0 = Main.combatText[i];
|
||||
expr_FB_cp_0.position.X = expr_FB_cp_0.position.X + (float)Main.rand.Next(-(int)((double)location.Width * 0.5), (int)((double)location.Width * 0.5) + 1);
|
||||
CombatText expr_147_cp_0 = Main.combatText[i];
|
||||
expr_147_cp_0.position.Y = expr_147_cp_0.position.Y + (float)Main.rand.Next(-(int)((double)location.Height * 0.5), (int)((double)location.Height * 0.5) + 1);
|
||||
Main.combatText[i].color = color;
|
||||
Main.combatText[i].text = text;
|
||||
Main.combatText[i].velocity.Y = -7f;
|
||||
if (Main.player[Main.myPlayer].gravDir == -1f)
|
||||
{
|
||||
CombatText expr_1DA_cp_0 = Main.combatText[i];
|
||||
expr_1DA_cp_0.velocity.Y = expr_1DA_cp_0.velocity.Y * -1f;
|
||||
Main.combatText[i].position.Y = (float)location.Y + (float)location.Height * 0.75f + vector.Y * 0.5f;
|
||||
}
|
||||
Main.combatText[i].lifeTime = 60;
|
||||
Main.combatText[i].crit = Crit;
|
||||
Main.combatText[i].dot = dot;
|
||||
if (Crit)
|
||||
{
|
||||
Main.combatText[i].text = text;
|
||||
Main.combatText[i].color = new Color(255, 100, 30, 255);
|
||||
Main.combatText[i].lifeTime *= 2;
|
||||
CombatText expr_29C_cp_0 = Main.combatText[i];
|
||||
expr_29C_cp_0.velocity.Y = expr_29C_cp_0.velocity.Y * 2f;
|
||||
Main.combatText[i].velocity.X = (float)Main.rand.Next(-25, 26) * 0.05f;
|
||||
Main.combatText[i].rotation = (float)(Main.combatText[i].lifeTime / 2) * 0.002f;
|
||||
if (Main.combatText[i].velocity.X < 0f)
|
||||
{
|
||||
Main.combatText[i].rotation *= -1f;
|
||||
}
|
||||
}
|
||||
if (dot)
|
||||
{
|
||||
Main.combatText[i].velocity.Y = -4f;
|
||||
Main.combatText[i].lifeTime = 40;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (this.active)
|
||||
{
|
||||
this.alpha += (float)this.alphaDir * 0.05f;
|
||||
if ((double)this.alpha <= 0.6)
|
||||
{
|
||||
this.alphaDir = 1;
|
||||
}
|
||||
if (this.alpha >= 1f)
|
||||
{
|
||||
this.alpha = 1f;
|
||||
this.alphaDir = -1;
|
||||
}
|
||||
if (this.dot)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y + 0.15f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.92f;
|
||||
if (this.crit)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.92f;
|
||||
}
|
||||
}
|
||||
this.velocity.X = 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)
|
||||
{
|
||||
this.alphaDir = -1;
|
||||
this.scale += 0.07f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.crit)
|
||||
{
|
||||
if (this.velocity.X < 0f)
|
||||
{
|
||||
this.rotation += 0.001f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.rotation -= 0.001f;
|
||||
}
|
||||
}
|
||||
if (this.dot)
|
||||
{
|
||||
this.scale += 0.5f;
|
||||
if ((double)this.scale > 0.8)
|
||||
{
|
||||
this.scale = 0.8f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.scale < 1f)
|
||||
{
|
||||
this.scale += 0.1f;
|
||||
}
|
||||
if (this.scale > 1f)
|
||||
{
|
||||
this.scale = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void UpdateCombatText()
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
if (Main.combatText[i].active)
|
||||
{
|
||||
Main.combatText[i].Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1772
Terraria/Dust.cs
Normal file
1772
Terraria/Dust.cs
Normal file
File diff suppressed because it is too large
Load diff
342
Terraria/Gore.cs
Normal file
342
Terraria/Gore.cs
Normal file
|
@ -0,0 +1,342 @@
|
|||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.active)
|
||||
{
|
||||
if (this.type >= 276 && this.type <= 282)
|
||||
{
|
||||
this.velocity.X = this.velocity.X * 0.98f;
|
||||
this.velocity.Y = this.velocity.Y * 0.98f;
|
||||
if (this.velocity.Y < this.scale)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y + 0.05f;
|
||||
}
|
||||
if ((double)this.velocity.Y > 0.1)
|
||||
{
|
||||
if (this.velocity.X > 0f)
|
||||
{
|
||||
this.rotation += 0.01f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.rotation -= 0.01f;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.type == 11 || this.type == 12 || this.type == 13 || this.type == 61 || this.type == 62 || this.type == 63 || this.type == 99 || this.type == 220 || this.type == 221 || this.type == 222 || (this.type >= 375 && this.type <= 377) || (this.type >= 435 && this.type <= 437))
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.98f;
|
||||
this.velocity.X = this.velocity.X * 0.98f;
|
||||
this.scale -= 0.007f;
|
||||
if ((double)this.scale < 0.1)
|
||||
{
|
||||
this.scale = 0.1f;
|
||||
this.alpha = 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.type == 16 || this.type == 17)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.98f;
|
||||
this.velocity.X = this.velocity.X * 0.98f;
|
||||
this.scale -= 0.01f;
|
||||
if ((double)this.scale < 0.1)
|
||||
{
|
||||
this.scale = 0.1f;
|
||||
this.alpha = 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.type == 331)
|
||||
{
|
||||
this.alpha += 5;
|
||||
this.velocity.Y = this.velocity.Y * 0.95f;
|
||||
this.velocity.X = this.velocity.X * 0.95f;
|
||||
this.rotation = this.velocity.X * 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.type < 411 || this.type > 430)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y + 0.2f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.rotation += this.velocity.X * 0.1f;
|
||||
if (this.type >= 411 && this.type <= 430)
|
||||
{
|
||||
this.alpha = 50;
|
||||
this.velocity.X = (this.velocity.X * 50f + Main.windSpeed * 2f + (float)Main.rand.Next(-10, 11) * 0.1f) / 51f;
|
||||
this.velocity.Y = (this.velocity.Y * 50f + -0.25f + (float)Main.rand.Next(-10, 11) * 0.2f) / 51f;
|
||||
this.rotation = this.velocity.X * 0.3f;
|
||||
if (Main.goreLoaded[this.type])
|
||||
{
|
||||
Rectangle rectangle = new Rectangle((int)this.position.X, (int)this.position.Y, (int)((float)Main.goreTexture[this.type].Width * this.scale), (int)((float)Main.goreTexture[this.type].Height * this.scale));
|
||||
for (int i = 0; i < 255; i++)
|
||||
{
|
||||
if (Main.player[i].active && !Main.player[i].dead)
|
||||
{
|
||||
Rectangle value = new Rectangle((int)Main.player[i].position.X, (int)Main.player[i].position.Y, Main.player[i].width, Main.player[i].height);
|
||||
if (rectangle.Intersects(value))
|
||||
{
|
||||
this.timeLeft = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Collision.SolidCollision(this.position, (int)((float)Main.goreTexture[this.type].Width * this.scale), (int)((float)Main.goreTexture[this.type].Height * this.scale)))
|
||||
{
|
||||
this.timeLeft = 0;
|
||||
}
|
||||
}
|
||||
if (this.timeLeft > 0)
|
||||
{
|
||||
if (Main.rand.Next(2) == 0)
|
||||
{
|
||||
this.timeLeft--;
|
||||
}
|
||||
if (Main.rand.Next(50) == 0)
|
||||
{
|
||||
this.timeLeft -= 5;
|
||||
}
|
||||
if (Main.rand.Next(100) == 0)
|
||||
{
|
||||
this.timeLeft -= 10;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alpha = 255;
|
||||
if (Main.goreLoaded[this.type])
|
||||
{
|
||||
float num = (float)Main.goreTexture[this.type].Width * this.scale * 0.8f;
|
||||
float x = this.position.X;
|
||||
float y = this.position.Y;
|
||||
float num2 = (float)Main.goreTexture[this.type].Width * this.scale;
|
||||
float num3 = (float)Main.goreTexture[this.type].Height * this.scale;
|
||||
int num4 = 176;
|
||||
if (this.type >= 416 && this.type <= 420)
|
||||
{
|
||||
num4 = 177;
|
||||
}
|
||||
if (this.type >= 421 && this.type <= 425)
|
||||
{
|
||||
num4 = 178;
|
||||
}
|
||||
if (this.type >= 426 && this.type <= 430)
|
||||
{
|
||||
num4 = 179;
|
||||
}
|
||||
int num5 = 0;
|
||||
while ((float)num5 < num)
|
||||
{
|
||||
int num6 = Dust.NewDust(new Vector2(x, y), (int)num2, (int)num3, num4, 0f, 0f, 0, default(Color), 1f);
|
||||
Main.dust[num6].noGravity = true;
|
||||
Main.dust[num6].alpha = 100;
|
||||
Main.dust[num6].scale = this.scale;
|
||||
num5++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.sticky)
|
||||
{
|
||||
int num7 = 32;
|
||||
if (Main.goreLoaded[this.type])
|
||||
{
|
||||
num7 = Main.goreTexture[this.type].Width;
|
||||
if (Main.goreTexture[this.type].Height < num7)
|
||||
{
|
||||
num7 = Main.goreTexture[this.type].Height;
|
||||
}
|
||||
}
|
||||
num7 = (int)((float)num7 * 0.9f);
|
||||
this.velocity = Collision.TileCollision(this.position, this.velocity, (int)((float)num7 * this.scale), (int)((float)num7 * this.scale), false, false);
|
||||
if (this.velocity.Y == 0f)
|
||||
{
|
||||
this.velocity.X = this.velocity.X * 0.97f;
|
||||
if ((double)this.velocity.X > -0.01 && (double)this.velocity.X < 0.01)
|
||||
{
|
||||
this.velocity.X = 0f;
|
||||
}
|
||||
}
|
||||
if (this.timeLeft > 0)
|
||||
{
|
||||
this.timeLeft--;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alpha++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.alpha += 2;
|
||||
}
|
||||
}
|
||||
this.position += this.velocity;
|
||||
if (this.alpha >= 255)
|
||||
{
|
||||
this.active = false;
|
||||
}
|
||||
if (this.light > 0f)
|
||||
{
|
||||
float num8 = this.light * this.scale;
|
||||
float num9 = this.light * this.scale;
|
||||
float num10 = this.light * this.scale;
|
||||
if (this.type == 16)
|
||||
{
|
||||
num10 *= 0.3f;
|
||||
num9 *= 0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.type == 17)
|
||||
{
|
||||
num9 *= 0.6f;
|
||||
num8 *= 0.3f;
|
||||
}
|
||||
}
|
||||
if (Main.goreLoaded[this.type])
|
||||
{
|
||||
Lighting.addLight((int)((this.position.X + (float)Main.goreTexture[this.type].Width * this.scale / 2f) / 16f), (int)((this.position.Y + (float)Main.goreTexture[this.type].Height * this.scale / 2f) / 16f), num8, num9, num10);
|
||||
return;
|
||||
}
|
||||
Lighting.addLight((int)((this.position.X + 32f * this.scale / 2f) / 16f), (int)((this.position.Y + 32f * this.scale / 2f) / 16f), num8, num9, num10);
|
||||
}
|
||||
}
|
||||
}
|
||||
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 num = 500;
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
if (!Main.gore[i].active)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num == 500)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
Main.gore[num].light = 0f;
|
||||
Main.gore[num].position = Position;
|
||||
Main.gore[num].velocity = Velocity;
|
||||
Gore expr_84_cp_0 = Main.gore[num];
|
||||
expr_84_cp_0.velocity.Y = expr_84_cp_0.velocity.Y - (float)Main.rand.Next(10, 31) * 0.1f;
|
||||
Gore expr_B1_cp_0 = Main.gore[num];
|
||||
expr_B1_cp_0.velocity.X = expr_B1_cp_0.velocity.X + (float)Main.rand.Next(-20, 21) * 0.1f;
|
||||
Main.gore[num].type = Type;
|
||||
Main.gore[num].active = true;
|
||||
Main.gore[num].alpha = 0;
|
||||
Main.gore[num].rotation = 0f;
|
||||
Main.gore[num].scale = Scale;
|
||||
if (Gore.goreTime == 0 || Type == 11 || Type == 12 || Type == 13 || Type == 16 || Type == 17 || Type == 61 || Type == 62 || Type == 63 || Type == 99 || Type == 220 || Type == 221 || Type == 222 || Type == 435 || Type == 436 || Type == 437)
|
||||
{
|
||||
Main.gore[num].sticky = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Type >= 375 && Type <= 377)
|
||||
{
|
||||
Main.gore[num].sticky = false;
|
||||
Main.gore[num].alpha = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.gore[num].sticky = true;
|
||||
Main.gore[num].timeLeft = Gore.goreTime;
|
||||
}
|
||||
}
|
||||
if (Type == 16 || Type == 17)
|
||||
{
|
||||
Main.gore[num].alpha = 100;
|
||||
Main.gore[num].scale = 0.7f;
|
||||
Main.gore[num].light = 1f;
|
||||
}
|
||||
if (Type >= 411 && Type <= 430 && Main.goreLoaded[Type])
|
||||
{
|
||||
Main.gore[num].position.X = Position.X - (float)(Main.goreTexture[Type].Width / 2) * Scale;
|
||||
Main.gore[num].position.Y = Position.Y - (float)Main.goreTexture[Type].Height * Scale;
|
||||
Gore expr_28F_cp_0 = Main.gore[num];
|
||||
expr_28F_cp_0.velocity.Y = expr_28F_cp_0.velocity.Y * ((float)Main.rand.Next(90, 150) * 0.01f);
|
||||
Gore expr_2BF_cp_0 = Main.gore[num];
|
||||
expr_2BF_cp_0.velocity.X = expr_2BF_cp_0.velocity.X * ((float)Main.rand.Next(40, 90) * 0.01f);
|
||||
int num2 = Main.rand.Next(4) * 5;
|
||||
Main.gore[num].type += num2;
|
||||
Main.gore[num].timeLeft = Main.rand.Next(Gore.goreTime / 2, Gore.goreTime * 2);
|
||||
}
|
||||
return num;
|
||||
}
|
||||
public Color GetAlpha(Color newColor)
|
||||
{
|
||||
float num = (float)(255 - this.alpha) / 255f;
|
||||
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
|
||||
{
|
||||
if (this.type == 331)
|
||||
{
|
||||
return new Color(255, 255, 255, 50);
|
||||
}
|
||||
r = (int)((float)newColor.R * num);
|
||||
g = (int)((float)newColor.G * num);
|
||||
b = (int)((float)newColor.B * num);
|
||||
}
|
||||
int num2 = (int)newColor.A - this.alpha;
|
||||
if (num2 < 0)
|
||||
{
|
||||
num2 = 0;
|
||||
}
|
||||
if (num2 > 255)
|
||||
{
|
||||
num2 = 255;
|
||||
}
|
||||
return new Color(r, g, b, num2);
|
||||
}
|
||||
}
|
||||
}
|
29064
Terraria/Item.cs
Normal file
29064
Terraria/Item.cs
Normal file
File diff suppressed because it is too large
Load diff
311
Terraria/ItemText.cs
Normal file
311
Terraria/ItemText.cs
Normal file
|
@ -0,0 +1,311 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (newItem.name == null || !newItem.active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (Main.itemText[i].active && Main.itemText[i].name == newItem.name)
|
||||
{
|
||||
string text = string.Concat(new object[]
|
||||
{
|
||||
newItem.name,
|
||||
" (",
|
||||
Main.itemText[i].stack + stack,
|
||||
")"
|
||||
});
|
||||
string text2 = newItem.name;
|
||||
if (Main.itemText[i].stack > 1)
|
||||
{
|
||||
object obj = text2;
|
||||
text2 = string.Concat(new object[]
|
||||
{
|
||||
obj,
|
||||
" (",
|
||||
Main.itemText[i].stack,
|
||||
")"
|
||||
});
|
||||
}
|
||||
Vector2 vector = Main.fontMouseText.MeasureString(text2);
|
||||
vector = Main.fontMouseText.MeasureString(text);
|
||||
if (Main.itemText[i].lifeTime < 0)
|
||||
{
|
||||
Main.itemText[i].scale = 1f;
|
||||
}
|
||||
Main.itemText[i].lifeTime = 60;
|
||||
Main.itemText[i].stack += stack;
|
||||
Main.itemText[i].scale = 0f;
|
||||
Main.itemText[i].rotation = 0f;
|
||||
Main.itemText[i].position.X = newItem.position.X + (float)newItem.width * 0.5f - vector.X * 0.5f;
|
||||
Main.itemText[i].position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector.Y * 0.5f;
|
||||
Main.itemText[i].velocity.Y = -7f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
int num = -1;
|
||||
for (int j = 0; j < 20; j++)
|
||||
{
|
||||
if (!Main.itemText[j].active)
|
||||
{
|
||||
num = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
double num2 = (double)Main.bottomWorld;
|
||||
for (int k = 0; k < 20; k++)
|
||||
{
|
||||
if (num2 > (double)Main.itemText[k].position.Y)
|
||||
{
|
||||
num = k;
|
||||
num2 = (double)Main.itemText[k].position.Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num >= 0)
|
||||
{
|
||||
string text3 = newItem.AffixName();
|
||||
if (stack > 1)
|
||||
{
|
||||
object obj2 = text3;
|
||||
text3 = string.Concat(new object[]
|
||||
{
|
||||
obj2,
|
||||
" (",
|
||||
stack,
|
||||
")"
|
||||
});
|
||||
}
|
||||
Vector2 vector2 = Main.fontMouseText.MeasureString(text3);
|
||||
Main.itemText[num].alpha = 1f;
|
||||
Main.itemText[num].alphaDir = -1;
|
||||
Main.itemText[num].active = true;
|
||||
Main.itemText[num].scale = 0f;
|
||||
Main.itemText[num].rotation = 0f;
|
||||
Main.itemText[num].position.X = newItem.position.X + (float)newItem.width * 0.5f - vector2.X * 0.5f;
|
||||
Main.itemText[num].position.Y = newItem.position.Y + (float)newItem.height * 0.25f - vector2.Y * 0.5f;
|
||||
Main.itemText[num].color = Color.White;
|
||||
if (newItem.rare == 1)
|
||||
{
|
||||
Main.itemText[num].color = new Color(150, 150, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 2)
|
||||
{
|
||||
Main.itemText[num].color = new Color(150, 255, 150);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 3)
|
||||
{
|
||||
Main.itemText[num].color = new Color(255, 200, 150);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 4)
|
||||
{
|
||||
Main.itemText[num].color = new Color(255, 150, 150);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 5)
|
||||
{
|
||||
Main.itemText[num].color = new Color(255, 150, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == -1)
|
||||
{
|
||||
Main.itemText[num].color = new Color(130, 130, 130);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 6)
|
||||
{
|
||||
Main.itemText[num].color = new Color(210, 160, 255);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 7)
|
||||
{
|
||||
Main.itemText[num].color = new Color(150, 255, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare == 8)
|
||||
{
|
||||
Main.itemText[num].color = new Color(255, 255, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newItem.rare >= 9)
|
||||
{
|
||||
Main.itemText[num].color = new Color(5, 200, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Main.itemText[num].name = newItem.AffixName();
|
||||
Main.itemText[num].stack = stack;
|
||||
Main.itemText[num].velocity.Y = -7f;
|
||||
Main.itemText[num].lifeTime = 60;
|
||||
}
|
||||
}
|
||||
public void Update(int whoAmI)
|
||||
{
|
||||
if (this.active)
|
||||
{
|
||||
this.alpha += (float)this.alphaDir * 0.01f;
|
||||
if ((double)this.alpha <= 0.7)
|
||||
{
|
||||
this.alpha = 0.7f;
|
||||
this.alphaDir = 1;
|
||||
}
|
||||
if (this.alpha >= 1f)
|
||||
{
|
||||
this.alpha = 1f;
|
||||
this.alphaDir = -1;
|
||||
}
|
||||
bool flag = false;
|
||||
string text = this.name;
|
||||
if (this.stack > 1)
|
||||
{
|
||||
object obj = text;
|
||||
text = string.Concat(new object[]
|
||||
{
|
||||
obj,
|
||||
" (",
|
||||
this.stack,
|
||||
")"
|
||||
});
|
||||
}
|
||||
Vector2 value = Main.fontMouseText.MeasureString(text);
|
||||
value *= this.scale;
|
||||
value.Y *= 0.8f;
|
||||
Rectangle rectangle = new Rectangle((int)(this.position.X - value.X / 2f), (int)(this.position.Y - value.Y / 2f), (int)value.X, (int)value.Y);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (Main.itemText[i].active && i != whoAmI)
|
||||
{
|
||||
string text2 = Main.itemText[i].name;
|
||||
if (Main.itemText[i].stack > 1)
|
||||
{
|
||||
object obj2 = text2;
|
||||
text2 = string.Concat(new object[]
|
||||
{
|
||||
obj2,
|
||||
" (",
|
||||
Main.itemText[i].stack,
|
||||
")"
|
||||
});
|
||||
}
|
||||
Vector2 value2 = Main.fontMouseText.MeasureString(text2);
|
||||
value2 *= Main.itemText[i].scale;
|
||||
value2.Y *= 0.8f;
|
||||
Rectangle value3 = new Rectangle((int)(Main.itemText[i].position.X - value2.X / 2f), (int)(Main.itemText[i].position.Y - value2.Y / 2f), (int)value2.X, (int)value2.Y);
|
||||
if (rectangle.Intersects(value3) && (this.position.Y < Main.itemText[i].position.Y || (this.position.Y == Main.itemText[i].position.Y && whoAmI < i)))
|
||||
{
|
||||
flag = true;
|
||||
int num = ItemText.numActive;
|
||||
if (num > 3)
|
||||
{
|
||||
num = 3;
|
||||
}
|
||||
Main.itemText[i].lifeTime = ItemText.activeTime + 15 * num;
|
||||
this.lifeTime = ItemText.activeTime + 15 * num;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.86f;
|
||||
if (this.scale == 1f)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.4f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.velocity.Y > -6f)
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y - 0.2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.velocity.Y = this.velocity.Y * 0.86f;
|
||||
}
|
||||
}
|
||||
this.velocity.X = 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;
|
||||
return;
|
||||
}
|
||||
if (this.scale < 1f)
|
||||
{
|
||||
this.scale += 0.1f;
|
||||
}
|
||||
if (this.scale > 1f)
|
||||
{
|
||||
this.scale = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void UpdateItemText()
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (Main.itemText[i].active)
|
||||
{
|
||||
num++;
|
||||
Main.itemText[i].Update(i);
|
||||
}
|
||||
}
|
||||
ItemText.numActive = num;
|
||||
}
|
||||
}
|
||||
}
|
28510
Terraria/Lang.cs
Normal file
28510
Terraria/Lang.cs
Normal file
File diff suppressed because it is too large
Load diff
3500
Terraria/Lighting.cs
Normal file
3500
Terraria/Lighting.cs
Normal file
File diff suppressed because it is too large
Load diff
1357
Terraria/Liquid.cs
Normal file
1357
Terraria/Liquid.cs
Normal file
File diff suppressed because it is too large
Load diff
32
Terraria/LiquidBuffer.cs
Normal file
32
Terraria/LiquidBuffer.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (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;
|
||||
}
|
||||
}
|
||||
}
|
36316
Terraria/Main.cs
Normal file
36316
Terraria/Main.cs
Normal file
File diff suppressed because it is too large
Load diff
2370
Terraria/Map.cs
Normal file
2370
Terraria/Map.cs
Normal file
File diff suppressed because it is too large
Load diff
40617
Terraria/NPC.cs
Normal file
40617
Terraria/NPC.cs
Normal file
File diff suppressed because it is too large
Load diff
2531
Terraria/NetMessage.cs
Normal file
2531
Terraria/NetMessage.cs
Normal file
File diff suppressed because it is too large
Load diff
740
Terraria/Netplay.cs
Normal file
740
Terraria/Netplay.cs
Normal file
|
@ -0,0 +1,740 @@
|
|||
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 string portForwardIP;
|
||||
public static int portForwardPort;
|
||||
public static bool portForwardOpen;
|
||||
public static bool uPNP = true;
|
||||
public static bool ServerUp = false;
|
||||
public static void openPort()
|
||||
{
|
||||
Netplay.portForwardIP = Netplay.LocalIPAddress();
|
||||
Netplay.portForwardPort = Netplay.serverPort;
|
||||
}
|
||||
public static void closePort()
|
||||
{
|
||||
}
|
||||
public static string LocalIPAddress()
|
||||
{
|
||||
string result = "";
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
|
||||
IPAddress[] addressList = hostEntry.AddressList;
|
||||
for (int i = 0; i < addressList.Length; i++)
|
||||
{
|
||||
IPAddress iPAddress = addressList[i];
|
||||
if (iPAddress.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
result = iPAddress.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static void ResetNetDiag()
|
||||
{
|
||||
Main.rxMsg = 0;
|
||||
Main.rxData = 0;
|
||||
Main.txMsg = 0;
|
||||
Main.txData = 0;
|
||||
for (int i = 0; i < Main.maxMsg; i++)
|
||||
{
|
||||
Main.rxMsgType[i] = 0;
|
||||
Main.rxDataType[i] = 0;
|
||||
Main.txMsgType[i] = 0;
|
||||
Main.txDataType[i] = 0;
|
||||
}
|
||||
}
|
||||
public static void ResetSections()
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
for (int j = 0; j < Main.maxSectionsX; j++)
|
||||
{
|
||||
for (int k = 0; k < Main.maxSectionsY; k++)
|
||||
{
|
||||
Netplay.serverSock[i].tileSection[j, k] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void AddBan(int plr)
|
||||
{
|
||||
string text = Netplay.serverSock[plr].tcpClient.Client.RemoteEndPoint.ToString();
|
||||
string value = text;
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (text.Substring(i, 1) == ":")
|
||||
{
|
||||
value = text.Substring(0, i);
|
||||
}
|
||||
}
|
||||
using (StreamWriter streamWriter = new StreamWriter(Netplay.banFile, true))
|
||||
{
|
||||
streamWriter.WriteLine("//" + Main.player[plr].name);
|
||||
streamWriter.WriteLine(value);
|
||||
}
|
||||
}
|
||||
public static bool CheckBan(string ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
string b = ip;
|
||||
for (int i = 0; i < ip.Length; i++)
|
||||
{
|
||||
if (ip.Substring(i, 1) == ":")
|
||||
{
|
||||
b = ip.Substring(0, i);
|
||||
}
|
||||
}
|
||||
if (File.Exists(Netplay.banFile))
|
||||
{
|
||||
using (StreamReader streamReader = new StreamReader(Netplay.banFile))
|
||||
{
|
||||
string a;
|
||||
while ((a = streamReader.ReadLine()) != null)
|
||||
{
|
||||
if (a == b)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static void newRecent()
|
||||
{
|
||||
for (int i = 0; i < Main.maxMP; i++)
|
||||
{
|
||||
if (Main.recentIP[i] == Netplay.serverIP.ToString() && Main.recentPort[i] == Netplay.serverPort)
|
||||
{
|
||||
for (int j = i; j < Main.maxMP - 1; j++)
|
||||
{
|
||||
Main.recentIP[j] = Main.recentIP[j + 1];
|
||||
Main.recentPort[j] = Main.recentPort[j + 1];
|
||||
Main.recentWorld[j] = Main.recentWorld[j + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int k = Main.maxMP - 1; k > 0; k--)
|
||||
{
|
||||
Main.recentIP[k] = Main.recentIP[k - 1];
|
||||
Main.recentPort[k] = Main.recentPort[k - 1];
|
||||
Main.recentWorld[k] = Main.recentWorld[k - 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();
|
||||
Main.ServerSideCharacter = false;
|
||||
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 i = 0; i < 255; i++)
|
||||
{
|
||||
if (i != Main.myPlayer)
|
||||
{
|
||||
Main.player[i] = new Player();
|
||||
}
|
||||
}
|
||||
Main.menuMode = 10;
|
||||
Main.menuMode = 14;
|
||||
if (!Main.autoPass)
|
||||
{
|
||||
Main.statusText = "Connecting to " + 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 && 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(256);
|
||||
}
|
||||
Netplay.clientSock.active = true;
|
||||
if (Netplay.clientSock.state == 0)
|
||||
{
|
||||
Main.statusText = "Found server";
|
||||
Netplay.clientSock.state = 1;
|
||||
NetMessage.SendData(1, -1, -1, "", 0, 0f, 0f, 0f, 0);
|
||||
}
|
||||
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;
|
||||
if (Main.cloudBGActive >= 1f)
|
||||
{
|
||||
Main.cloudBGAlpha = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.cloudBGAlpha = 0f;
|
||||
}
|
||||
Main.windSpeed = Main.windSpeedSet;
|
||||
Cloud.resetClouds();
|
||||
Main.cloudAlpha = Main.maxRaining;
|
||||
WorldGen.clearWorld();
|
||||
if (Main.mapEnabled)
|
||||
{
|
||||
Map.loadMap();
|
||||
}
|
||||
}
|
||||
if (Netplay.clientSock.state == 5 && Main.loadMapLock)
|
||||
{
|
||||
float num2 = (float)Main.loadMapLastX / (float)Main.maxTilesX;
|
||||
Main.statusText = string.Concat(new object[]
|
||||
{
|
||||
Lang.gen[68],
|
||||
" ",
|
||||
(int)(num2 * 100f + 1f),
|
||||
"%"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.clientSock.state == 5 && WorldGen.worldCleared)
|
||||
{
|
||||
Netplay.clientSock.state = 6;
|
||||
Main.player[Main.myPlayer].FindSpawn();
|
||||
NetMessage.SendData(8, -1, -1, "", Main.player[Main.myPlayer].SpawnX, (float)Main.player[Main.myPlayer].SpawnY, 0f, 0f, 0);
|
||||
}
|
||||
}
|
||||
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), 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 = string.Concat(new object[]
|
||||
{
|
||||
Netplay.clientSock.statusText,
|
||||
": ",
|
||||
(int)((float)Netplay.clientSock.statusCount / (float)Netplay.clientSock.statusMax * 100f),
|
||||
"%"
|
||||
});
|
||||
}
|
||||
}
|
||||
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 = 255;
|
||||
Netplay.serverIP = IPAddress.Any;
|
||||
Netplay.serverListenIP = Netplay.serverIP;
|
||||
Main.menuMode = 14;
|
||||
Main.statusText = "Starting server...";
|
||||
Main.netMode = 2;
|
||||
Netplay.disconnect = false;
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
Netplay.serverSock[i] = new ServerSock();
|
||||
Netplay.serverSock[i].Reset();
|
||||
Netplay.serverSock[i].whoAmI = i;
|
||||
Netplay.serverSock[i].tcpClient = new TcpClient();
|
||||
Netplay.serverSock[i].tcpClient.NoDelay = true;
|
||||
Netplay.serverSock[i].readBuffer = new byte[1024];
|
||||
Netplay.serverSock[i].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), 1);
|
||||
Main.statusText = "Server started";
|
||||
}
|
||||
if (Netplay.uPNP)
|
||||
{
|
||||
try
|
||||
{
|
||||
Netplay.openPort();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
int num = 0;
|
||||
while (!Netplay.disconnect)
|
||||
{
|
||||
if (Netplay.stopListen)
|
||||
{
|
||||
int num2 = -1;
|
||||
for (int j = 0; j < Main.maxNetPlayers; j++)
|
||||
{
|
||||
if (!Netplay.serverSock[j].tcpClient.Connected)
|
||||
{
|
||||
num2 = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num2 >= 0)
|
||||
{
|
||||
if (Main.ignoreErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
Netplay.tcpListener.Start();
|
||||
Netplay.stopListen = false;
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), 1);
|
||||
goto IL_219;
|
||||
}
|
||||
catch
|
||||
{
|
||||
goto IL_219;
|
||||
}
|
||||
}
|
||||
Netplay.tcpListener.Start();
|
||||
Netplay.stopListen = false;
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ListenForClients), 1);
|
||||
}
|
||||
}
|
||||
IL_219:
|
||||
int num3 = 0;
|
||||
for (int k = 0; k < 256; k++)
|
||||
{
|
||||
if (NetMessage.buffer[k].checkBytes)
|
||||
{
|
||||
NetMessage.CheckBytes(k);
|
||||
}
|
||||
if (Netplay.serverSock[k].kill)
|
||||
{
|
||||
Netplay.serverSock[k].Reset();
|
||||
NetMessage.syncPlayers();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].tcpClient.Connected)
|
||||
{
|
||||
if (!Netplay.serverSock[k].active)
|
||||
{
|
||||
Netplay.serverSock[k].state = 0;
|
||||
}
|
||||
Netplay.serverSock[k].active = true;
|
||||
num3++;
|
||||
if (!Netplay.serverSock[k].locked)
|
||||
{
|
||||
try
|
||||
{
|
||||
Netplay.serverSock[k].networkStream = Netplay.serverSock[k].tcpClient.GetStream();
|
||||
if (Netplay.serverSock[k].networkStream.DataAvailable)
|
||||
{
|
||||
Netplay.serverSock[k].locked = true;
|
||||
Netplay.serverSock[k].networkStream.BeginRead(Netplay.serverSock[k].readBuffer, 0, Netplay.serverSock[k].readBuffer.Length, new AsyncCallback(Netplay.serverSock[k].ServerReadCallBack), Netplay.serverSock[k].networkStream);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Netplay.serverSock[k].kill = true;
|
||||
}
|
||||
}
|
||||
if (Netplay.serverSock[k].statusMax > 0 && Netplay.serverSock[k].statusText2 != "")
|
||||
{
|
||||
if (Netplay.serverSock[k].statusCount >= Netplay.serverSock[k].statusMax)
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" ",
|
||||
Netplay.serverSock[k].statusText2,
|
||||
": Complete!"
|
||||
});
|
||||
Netplay.serverSock[k].statusText2 = "";
|
||||
Netplay.serverSock[k].statusMax = 0;
|
||||
Netplay.serverSock[k].statusCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" ",
|
||||
Netplay.serverSock[k].statusText2,
|
||||
": ",
|
||||
(int)((float)Netplay.serverSock[k].statusCount / (float)Netplay.serverSock[k].statusMax * 100f),
|
||||
"%"
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].state == 0)
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" is connecting..."
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].state == 1)
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" is sending player data..."
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].state == 2)
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" requested world information"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].state != 3 && Netplay.serverSock[k].state == 10)
|
||||
{
|
||||
Netplay.serverSock[k].statusText = string.Concat(new object[]
|
||||
{
|
||||
"(",
|
||||
Netplay.serverSock[k].tcpClient.Client.RemoteEndPoint,
|
||||
") ",
|
||||
Netplay.serverSock[k].name,
|
||||
" is playing"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Netplay.serverSock[k].active)
|
||||
{
|
||||
Netplay.serverSock[k].kill = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Netplay.serverSock[k].statusText2 = "";
|
||||
if (k < 255)
|
||||
{
|
||||
Main.player[k].active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
num++;
|
||||
if (num > 10)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
num = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(0);
|
||||
}
|
||||
if (!WorldGen.saveLock && !Main.dedServ)
|
||||
{
|
||||
if (num3 == 0)
|
||||
{
|
||||
Main.statusText = "Waiting for clients...";
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.statusText = num3 + " clients connected";
|
||||
}
|
||||
}
|
||||
if (num3 == 0)
|
||||
{
|
||||
Netplay.anyClients = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Netplay.anyClients = true;
|
||||
}
|
||||
Netplay.ServerUp = true;
|
||||
}
|
||||
Netplay.tcpListener.Stop();
|
||||
try
|
||||
{
|
||||
Netplay.closePort();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
for (int l = 0; l < 256; l++)
|
||||
{
|
||||
Netplay.serverSock[l].Reset();
|
||||
}
|
||||
if (Main.menuMode != 15)
|
||||
{
|
||||
Main.netMode = 0;
|
||||
Main.menuMode = 10;
|
||||
WorldGen.saveWorld(false);
|
||||
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 num = -1;
|
||||
for (int i = 0; i < Main.maxNetPlayers; i++)
|
||||
{
|
||||
if (!Netplay.serverSock[i].tcpClient.Connected)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num >= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Netplay.serverSock[num].tcpClient = Netplay.tcpListener.AcceptTcpClient();
|
||||
Netplay.serverSock[num].tcpClient.NoDelay = true;
|
||||
Console.WriteLine(Netplay.serverSock[num].tcpClient.Client.RemoteEndPoint + " is connecting...");
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!Netplay.disconnect)
|
||||
{
|
||||
Main.menuMode = 15;
|
||||
Main.statusText = ex.ToString();
|
||||
Netplay.disconnect = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Netplay.stopListen = true;
|
||||
Netplay.tcpListener.Stop();
|
||||
}
|
||||
}
|
||||
public static void StartClient()
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ClientLoop), 1);
|
||||
}
|
||||
public static void StartServer()
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(new WaitCallback(Netplay.ServerLoop), 1);
|
||||
}
|
||||
public static bool SetIP(string newIP)
|
||||
{
|
||||
try
|
||||
{
|
||||
Netplay.serverIP = IPAddress.Parse(newIP);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static bool SetIP2(string newIP)
|
||||
{
|
||||
bool result;
|
||||
try
|
||||
{
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(newIP);
|
||||
IPAddress[] addressList = hostEntry.AddressList;
|
||||
for (int i = 0; i < addressList.Length; i++)
|
||||
{
|
||||
if (addressList[i].AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
Netplay.serverIP = addressList[i];
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
for (int i = 0; i < 257; i++)
|
||||
{
|
||||
if (i < 256)
|
||||
{
|
||||
Netplay.serverSock[i] = new ServerSock();
|
||||
Netplay.serverSock[i].tcpClient.NoDelay = true;
|
||||
}
|
||||
NetMessage.buffer[i] = new messageBuffer();
|
||||
NetMessage.buffer[i].whoAmI = i;
|
||||
}
|
||||
Netplay.clientSock.tcpClient.NoDelay = true;
|
||||
}
|
||||
public static int GetSectionX(int x)
|
||||
{
|
||||
return x / 200;
|
||||
}
|
||||
public static int GetSectionY(int y)
|
||||
{
|
||||
return y / 150;
|
||||
}
|
||||
}
|
||||
}
|
18178
Terraria/Player.cs
Normal file
18178
Terraria/Player.cs
Normal file
File diff suppressed because it is too large
Load diff
85
Terraria/Program.cs
Normal file
85
Terraria/Program.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
namespace Terraria
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
using (Main main = new Main())
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
if (args[i].ToLower() == "-port" || args[i].ToLower() == "-p")
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
int serverPort = Convert.ToInt32(args[i]);
|
||||
Netplay.serverPort = serverPort;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (args[i].ToLower() == "-join" || args[i].ToLower() == "-j")
|
||||
{
|
||||
i++;
|
||||
try
|
||||
{
|
||||
main.AutoJoin(args[i]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
if (args[i].ToLower() == "-pass" || args[i].ToLower() == "-password")
|
||||
{
|
||||
i++;
|
||||
Netplay.password = args[i];
|
||||
main.AutoPass();
|
||||
}
|
||||
if (args[i].ToLower() == "-host")
|
||||
{
|
||||
main.AutoHost();
|
||||
}
|
||||
if (args[i].ToLower() == "-loadlib")
|
||||
{
|
||||
i++;
|
||||
string path = args[i];
|
||||
main.loadLib(path);
|
||||
}
|
||||
}
|
||||
Steam.Init();
|
||||
if (Steam.SteamInit)
|
||||
{
|
||||
main.Run();
|
||||
}
|
||||
else
|
||||
{
|
||||
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(DateTime.Now);
|
||||
streamWriter.WriteLine(ex);
|
||||
streamWriter.WriteLine("/n");
|
||||
}
|
||||
MessageBox.Show(ex.ToString(), "Terraria: Error");
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19182
Terraria/Projectile.cs
Normal file
19182
Terraria/Projectile.cs
Normal file
File diff suppressed because it is too large
Load diff
123
Terraria/Rain.cs
Normal file
123
Terraria/Rain.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
namespace Terraria
|
||||
{
|
||||
public class Rain
|
||||
{
|
||||
public Vector2 position;
|
||||
public Vector2 velocity;
|
||||
public float scale;
|
||||
public int alpha;
|
||||
public bool active;
|
||||
public byte type;
|
||||
public static void MakeRain()
|
||||
{
|
||||
if ((double)Main.screenPosition.Y > Main.worldSurface * 16.0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Main.gameMenu)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float num = (float)Main.screenWidth / 1920f;
|
||||
num *= 25f;
|
||||
num *= 0.25f + 1f * Main.cloudAlpha;
|
||||
int num2 = 0;
|
||||
while ((float)num2 < num)
|
||||
{
|
||||
int num3 = 600;
|
||||
if (Main.player[Main.myPlayer].velocity.Y < 0f)
|
||||
{
|
||||
num3 += (int)(Math.Abs(Main.player[Main.myPlayer].velocity.Y) * 30f);
|
||||
}
|
||||
Vector2 vector;
|
||||
vector.X = (float)Main.rand.Next((int)Main.screenPosition.X - num3, (int)Main.screenPosition.X + Main.screenWidth + num3);
|
||||
vector.Y = Main.screenPosition.Y - (float)Main.rand.Next(20, 100);
|
||||
vector.X -= Main.windSpeed * 15f * 40f;
|
||||
vector.X += Main.player[Main.myPlayer].velocity.X * 40f;
|
||||
if (vector.X < 0f)
|
||||
{
|
||||
vector.X = 0f;
|
||||
}
|
||||
if (vector.X > (float)((Main.maxTilesX - 1) * 16))
|
||||
{
|
||||
vector.X = (float)((Main.maxTilesX - 1) * 16);
|
||||
}
|
||||
int num4 = (int)vector.X / 16;
|
||||
int num5 = (int)vector.Y / 16;
|
||||
if (num4 < 0)
|
||||
{
|
||||
num4 = 0;
|
||||
}
|
||||
if (num4 > Main.maxTilesX - 1)
|
||||
{
|
||||
num4 = Main.maxTilesX - 1;
|
||||
}
|
||||
if (Main.gameMenu || (!WorldGen.SolidTile(num4, num5) && Main.tile[num4, num5].wall <= 0))
|
||||
{
|
||||
Vector2 vector2 = new Vector2(Main.windSpeed * 12f, 14f);
|
||||
Rain.NewRain(vector, vector2);
|
||||
}
|
||||
num2++;
|
||||
}
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
this.position += this.velocity;
|
||||
if (Collision.SolidCollision(this.position, 2, 2) || this.position.Y > Main.screenPosition.Y + (float)Main.screenHeight + 100f || Collision.WetCollision(this.position, 2, 2))
|
||||
{
|
||||
this.active = false;
|
||||
if ((float)Main.rand.Next(100) < Main.gfxQuality * 100f)
|
||||
{
|
||||
int num = Dust.NewDust(this.position - this.velocity, 2, 2, 154, 0f, 0f, 0, default(Color), 1f);
|
||||
Dust expr_C3_cp_0 = Main.dust[num];
|
||||
expr_C3_cp_0.position.X = expr_C3_cp_0.position.X - 2f;
|
||||
Main.dust[num].alpha = 38;
|
||||
Main.dust[num].velocity *= 0.1f;
|
||||
Main.dust[num].velocity += -this.velocity * 0.025f;
|
||||
Main.dust[num].scale = 0.75f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int NewRain(Vector2 Position, Vector2 Velocity)
|
||||
{
|
||||
int num = -1;
|
||||
int num2 = (int)((float)Main.maxRain * Main.cloudAlpha);
|
||||
if (num2 > Main.maxRain)
|
||||
{
|
||||
num2 = Main.maxRain;
|
||||
}
|
||||
float num3 = (1f + Main.gfxQuality) / 2f;
|
||||
if ((double)num3 < 0.9)
|
||||
{
|
||||
num2 = (int)((float)num2 * num3);
|
||||
}
|
||||
float num4 = (float)(800 - Main.snowTiles);
|
||||
if (num4 < 0f)
|
||||
{
|
||||
num4 = 0f;
|
||||
}
|
||||
num4 /= 800f;
|
||||
num2 = (int)((float)num2 * num4);
|
||||
for (int i = 0; i < num2; i++)
|
||||
{
|
||||
if (!Main.rain[i].active)
|
||||
{
|
||||
num = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num == -1)
|
||||
{
|
||||
return Main.maxRain;
|
||||
}
|
||||
Main.rain[num].active = true;
|
||||
Main.rain[num].position = Position;
|
||||
Main.rain[num].scale = 1f + (float)Main.rand.Next(-20, 21) * 0.01f;
|
||||
Main.rain[num].velocity = Velocity * Main.rain[num].scale;
|
||||
Main.rain[num].type = (byte)Main.rand.Next(3);
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
4892
Terraria/Recipe.cs
Normal file
4892
Terraria/Recipe.cs
Normal file
File diff suppressed because it is too large
Load diff
230
Terraria/ServerSock.cs
Normal file
230
Terraria/ServerSock.cs
Normal file
|
@ -0,0 +1,230 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
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 = 0f;
|
||||
this.spamDelBlock = 0f;
|
||||
this.spamAddBlock = 0f;
|
||||
this.spamWater = 0f;
|
||||
return;
|
||||
}
|
||||
if (this.spamProjectile > this.spamProjectileMax)
|
||||
{
|
||||
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Projectile spam");
|
||||
}
|
||||
if (this.spamAddBlock > this.spamAddBlockMax)
|
||||
{
|
||||
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Add tile spam");
|
||||
}
|
||||
if (this.spamDelBlock > this.spamDelBlockMax)
|
||||
{
|
||||
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Remove tile spam");
|
||||
}
|
||||
if (this.spamWater > this.spamWaterMax)
|
||||
{
|
||||
NetMessage.BootPlayer(this.whoAmI, "Cheating attempt detected: Liquid spam");
|
||||
}
|
||||
this.spamProjectile -= 0.4f;
|
||||
if (this.spamProjectile < 0f)
|
||||
{
|
||||
this.spamProjectile = 0f;
|
||||
}
|
||||
this.spamAddBlock -= 0.3f;
|
||||
if (this.spamAddBlock < 0f)
|
||||
{
|
||||
this.spamAddBlock = 0f;
|
||||
}
|
||||
this.spamDelBlock -= 5f;
|
||||
if (this.spamDelBlock < 0f)
|
||||
{
|
||||
this.spamDelBlock = 0f;
|
||||
}
|
||||
this.spamWater -= 0.2f;
|
||||
if (this.spamWater < 0f)
|
||||
{
|
||||
this.spamWater = 0f;
|
||||
}
|
||||
}
|
||||
public void SpamClear()
|
||||
{
|
||||
this.spamProjectile = 0f;
|
||||
this.spamAddBlock = 0f;
|
||||
this.spamDelBlock = 0f;
|
||||
this.spamWater = 0f;
|
||||
}
|
||||
public static void CheckSection(int who, Vector2 position)
|
||||
{
|
||||
int sectionX = Netplay.GetSectionX((int)(position.X / 16f));
|
||||
int sectionY = Netplay.GetSectionY((int)(position.Y / 16f));
|
||||
int num = 0;
|
||||
for (int i = sectionX - 1; i < sectionX + 2; i++)
|
||||
{
|
||||
for (int j = sectionY - 1; j < sectionY + 2; j++)
|
||||
{
|
||||
if (i >= 0 && i < Main.maxSectionsX && j >= 0 && j < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[i, j])
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
int num2 = num * 150;
|
||||
NetMessage.SendData(9, who, -1, "Receiving tile data", num2, 0f, 0f, 0f, 0);
|
||||
Netplay.serverSock[who].statusText2 = "is receiving tile data";
|
||||
Netplay.serverSock[who].statusMax += num2;
|
||||
for (int k = sectionX - 1; k < sectionX + 2; k++)
|
||||
{
|
||||
for (int l = sectionY - 1; l < sectionY + 2; l++)
|
||||
{
|
||||
if (k >= 0 && k < Main.maxSectionsX && l >= 0 && l < Main.maxSectionsY && !Netplay.serverSock[who].tileSection[k, l])
|
||||
{
|
||||
NetMessage.SendSection(who, k, l);
|
||||
NetMessage.SendData(11, who, -1, "", k, (float)l, (float)k, (float)l, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool SectionRange(int size, int firstX, int firstY)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int num = firstX;
|
||||
int num2 = firstY;
|
||||
if (i == 1)
|
||||
{
|
||||
num += size;
|
||||
}
|
||||
if (i == 2)
|
||||
{
|
||||
num2 += size;
|
||||
}
|
||||
if (i == 3)
|
||||
{
|
||||
num += size;
|
||||
num2 += size;
|
||||
}
|
||||
int sectionX = Netplay.GetSectionX(num);
|
||||
int sectionY = Netplay.GetSectionY(num2);
|
||||
if (this.tileSection[sectionX, sectionY])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
for (int i = 0; i < Main.maxSectionsX; i++)
|
||||
{
|
||||
for (int j = 0; j < Main.maxSectionsY; j++)
|
||||
{
|
||||
this.tileSection[i, j] = false;
|
||||
}
|
||||
}
|
||||
if (this.whoAmI < 255)
|
||||
{
|
||||
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)
|
||||
{
|
||||
this.tcpClient.Close();
|
||||
}
|
||||
}
|
||||
public void ServerWriteCallBack(IAsyncResult ar)
|
||||
{
|
||||
NetMessage.buffer[this.whoAmI].spamCount--;
|
||||
if (this.statusMax > 0)
|
||||
{
|
||||
this.statusCount++;
|
||||
}
|
||||
}
|
||||
public void ServerReadCallBack(IAsyncResult ar)
|
||||
{
|
||||
int num = 0;
|
||||
if (!Netplay.disconnect)
|
||||
{
|
||||
try
|
||||
{
|
||||
num = this.networkStream.EndRead(ar);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
this.kill = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.ignoreErrors)
|
||||
{
|
||||
try
|
||||
{
|
||||
NetMessage.RecieveBytes(this.readBuffer, num, this.whoAmI);
|
||||
goto IL_57;
|
||||
}
|
||||
catch
|
||||
{
|
||||
goto IL_57;
|
||||
}
|
||||
}
|
||||
NetMessage.RecieveBytes(this.readBuffer, num, this.whoAmI);
|
||||
}
|
||||
}
|
||||
IL_57:
|
||||
this.locked = false;
|
||||
}
|
||||
}
|
||||
}
|
75
Terraria/Sign.cs
Normal file
75
Terraria/Sign.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
namespace Terraria
|
||||
{
|
||||
public class Sign
|
||||
{
|
||||
public const int maxSigns = 1000;
|
||||
public int x;
|
||||
public int y;
|
||||
public string text;
|
||||
public object Clone()
|
||||
{
|
||||
return base.MemberwiseClone();
|
||||
}
|
||||
public static void KillSign(int x, int y)
|
||||
{
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
if (Main.sign[i] != null && Main.sign[i].x == x && Main.sign[i].y == y)
|
||||
{
|
||||
Main.sign[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static int ReadSign(int i, int j)
|
||||
{
|
||||
int k = (int)(Main.tile[i, j].frameX / 18);
|
||||
int num = (int)(Main.tile[i, j].frameY / 18);
|
||||
while (k > 1)
|
||||
{
|
||||
k -= 2;
|
||||
}
|
||||
int num2 = i - k;
|
||||
int num3 = j - num;
|
||||
if (Main.tile[num2, num3].type != 55 && Main.tile[num2, num3].type != 85)
|
||||
{
|
||||
Sign.KillSign(num2, num3);
|
||||
return -1;
|
||||
}
|
||||
int num4 = -1;
|
||||
for (int l = 0; l < 1000; l++)
|
||||
{
|
||||
if (Main.sign[l] != null && Main.sign[l].x == num2 && Main.sign[l].y == num3)
|
||||
{
|
||||
num4 = l;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num4 < 0)
|
||||
{
|
||||
for (int m = 0; m < 1000; m++)
|
||||
{
|
||||
if (Main.sign[m] == null)
|
||||
{
|
||||
num4 = m;
|
||||
Main.sign[m] = new Sign();
|
||||
Main.sign[m].x = num2;
|
||||
Main.sign[m].y = num3;
|
||||
Main.sign[m].text = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return num4;
|
||||
}
|
||||
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 != 55 && Main.tile[Main.sign[i].x, Main.sign[i].y].type != 85))
|
||||
{
|
||||
Main.sign[i] = null;
|
||||
return;
|
||||
}
|
||||
Main.sign[i].text = text;
|
||||
}
|
||||
}
|
||||
}
|
69
Terraria/Star.cs
Normal file
69
Terraria/Star.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
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 i = 0; i < Main.numStars; i++)
|
||||
{
|
||||
Main.star[i] = new Star();
|
||||
Main.star[i].position.X = (float)Main.rand.Next(-12, Main.screenWidth + 1);
|
||||
Main.star[i].position.Y = (float)Main.rand.Next(-12, Main.screenHeight);
|
||||
Main.star[i].rotation = (float)Main.rand.Next(628) * 0.01f;
|
||||
Main.star[i].scale = (float)Main.rand.Next(50, 120) * 0.01f;
|
||||
Main.star[i].type = Main.rand.Next(0, 5);
|
||||
Main.star[i].twinkle = (float)Main.rand.Next(101) * 0.01f;
|
||||
Main.star[i].twinkleSpeed = (float)Main.rand.Next(40, 100) * 0.0001f;
|
||||
if (Main.rand.Next(2) == 0)
|
||||
{
|
||||
Main.star[i].twinkleSpeed *= -1f;
|
||||
}
|
||||
Main.star[i].rotationSpeed = (float)Main.rand.Next(10, 40) * 0.0001f;
|
||||
if (Main.rand.Next(2) == 0)
|
||||
{
|
||||
Main.star[i].rotationSpeed *= -1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void UpdateStars()
|
||||
{
|
||||
for (int i = 0; i < Main.numStars; i++)
|
||||
{
|
||||
Main.star[i].twinkle += Main.star[i].twinkleSpeed;
|
||||
if (Main.star[i].twinkle > 1f)
|
||||
{
|
||||
Main.star[i].twinkle = 1f;
|
||||
Main.star[i].twinkleSpeed *= -1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((double)Main.star[i].twinkle < 0.5)
|
||||
{
|
||||
Main.star[i].twinkle = 0.5f;
|
||||
Main.star[i].twinkleSpeed *= -1f;
|
||||
}
|
||||
}
|
||||
Main.star[i].rotation += Main.star[i].rotationSpeed;
|
||||
if ((double)Main.star[i].rotation > 6.28)
|
||||
{
|
||||
Main.star[i].rotation -= 6.28f;
|
||||
}
|
||||
if (Main.star[i].rotation < 0f)
|
||||
{
|
||||
Main.star[i].rotation += 6.28f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
Terraria/Steam.cs
Normal file
21
Terraria/Steam.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
571
Terraria/Tile.cs
Normal file
571
Terraria/Tile.cs
Normal file
|
@ -0,0 +1,571 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
namespace Terraria
|
||||
{
|
||||
public class Tile
|
||||
{
|
||||
public byte type;
|
||||
public byte wall;
|
||||
public byte liquid;
|
||||
public byte tileHeader;
|
||||
public byte tileHeader2;
|
||||
public byte tileHeader3;
|
||||
public byte tileHeader4;
|
||||
public byte tileHeader5;
|
||||
public short frameX;
|
||||
public short frameY;
|
||||
public object Clone()
|
||||
{
|
||||
return base.MemberwiseClone();
|
||||
}
|
||||
public bool isTheSameAs(Tile compTile)
|
||||
{
|
||||
if (compTile == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.active() != compTile.active())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.active())
|
||||
{
|
||||
if (this.type != compTile.type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Main.tileFrameImportant[(int)this.type])
|
||||
{
|
||||
if (this.frameX != compTile.frameX)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (this.frameY != compTile.frameY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.wall == compTile.wall && this.liquid == compTile.liquid && this.lava() == compTile.lava() && this.honey() == compTile.honey() && this.wire() == compTile.wire() && this.wire2() == compTile.wire2() && this.wire3() == compTile.wire3() && this.halfBrick() == compTile.halfBrick() && this.actuator() == compTile.actuator() && this.inActive() == compTile.inActive() && this.wallColor() == compTile.wallColor() && this.color() == compTile.color() && this.slope() == compTile.slope();
|
||||
}
|
||||
public byte wallFrameX()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader4 & 16) == 16)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader4 & 32) == 32)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
if ((this.tileHeader4 & 64) == 64)
|
||||
{
|
||||
b += 4;
|
||||
}
|
||||
if ((this.tileHeader4 & 128) == 128)
|
||||
{
|
||||
b += 8;
|
||||
}
|
||||
return (byte)(b * 18);
|
||||
}
|
||||
public void wallFrameX(int wallFrameX)
|
||||
{
|
||||
int num = wallFrameX / 18;
|
||||
if ((num & 1) == 1)
|
||||
{
|
||||
this.tileHeader4 |= 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -17);
|
||||
}
|
||||
if ((num & 2) == 2)
|
||||
{
|
||||
this.tileHeader4 |= 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -33);
|
||||
}
|
||||
if ((num & 4) == 4)
|
||||
{
|
||||
this.tileHeader4 |= 64;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -65);
|
||||
}
|
||||
if ((num & 8) == 8)
|
||||
{
|
||||
this.tileHeader4 |= 128;
|
||||
return;
|
||||
}
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -129);
|
||||
}
|
||||
public byte wallFrameY()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader5 & 1) == 1)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader5 & 2) == 2)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
if ((this.tileHeader5 & 4) == 4)
|
||||
{
|
||||
b += 4;
|
||||
}
|
||||
return (byte)(b * 18);
|
||||
}
|
||||
public void wallFrameY(int wallFrameX)
|
||||
{
|
||||
int num = wallFrameX / 18;
|
||||
if ((num & 1) == 1)
|
||||
{
|
||||
this.tileHeader5 |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader5 = (byte)((int)this.tileHeader5 & -2);
|
||||
}
|
||||
if ((num & 2) == 2)
|
||||
{
|
||||
this.tileHeader5 |= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader5 = (byte)((int)this.tileHeader5 & -3);
|
||||
}
|
||||
if ((num & 4) == 4)
|
||||
{
|
||||
this.tileHeader5 |= 4;
|
||||
return;
|
||||
}
|
||||
this.tileHeader5 = (byte)((int)this.tileHeader5 & -5);
|
||||
}
|
||||
public byte frameNumber()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader4 & 1) == 1)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader4 & 2) == 2)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public void frameNumber(byte frameNumber)
|
||||
{
|
||||
if ((frameNumber & 1) == 1)
|
||||
{
|
||||
this.tileHeader4 |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -2);
|
||||
}
|
||||
if ((frameNumber & 2) == 2)
|
||||
{
|
||||
this.tileHeader4 |= 2;
|
||||
return;
|
||||
}
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -3);
|
||||
}
|
||||
public byte wallFrameNumber()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader4 & 4) == 4)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader4 & 8) == 8)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public void wallFrameNumber(byte wallFrameNumber)
|
||||
{
|
||||
if ((wallFrameNumber & 4) == 4)
|
||||
{
|
||||
this.tileHeader4 |= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -5);
|
||||
}
|
||||
if ((wallFrameNumber & 8) == 8)
|
||||
{
|
||||
this.tileHeader4 |= 8;
|
||||
return;
|
||||
}
|
||||
this.tileHeader4 = (byte)((int)this.tileHeader4 & -9);
|
||||
}
|
||||
public byte slope()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader3 & 16) == 16)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader3 & 32) == 32)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public void slope(byte slope)
|
||||
{
|
||||
if ((slope & 1) == 1)
|
||||
{
|
||||
this.tileHeader3 |= 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -17);
|
||||
}
|
||||
if ((slope & 2) == 2)
|
||||
{
|
||||
this.tileHeader3 |= 32;
|
||||
return;
|
||||
}
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -33);
|
||||
}
|
||||
public byte color()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader2 & 4) == 4)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader2 & 8) == 8)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
if ((this.tileHeader2 & 16) == 16)
|
||||
{
|
||||
b += 4;
|
||||
}
|
||||
if ((this.tileHeader2 & 32) == 32)
|
||||
{
|
||||
b += 8;
|
||||
}
|
||||
if ((this.tileHeader2 & 64) == 64)
|
||||
{
|
||||
b += 16;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public void color(byte color)
|
||||
{
|
||||
if (color > 27)
|
||||
{
|
||||
color = 27;
|
||||
}
|
||||
if ((color & 1) == 1)
|
||||
{
|
||||
this.tileHeader2 |= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -5);
|
||||
}
|
||||
if ((color & 2) == 2)
|
||||
{
|
||||
this.tileHeader2 |= 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -9);
|
||||
}
|
||||
if ((color & 4) == 4)
|
||||
{
|
||||
this.tileHeader2 |= 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -17);
|
||||
}
|
||||
if ((color & 8) == 8)
|
||||
{
|
||||
this.tileHeader2 |= 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -33);
|
||||
}
|
||||
if ((color & 16) == 16)
|
||||
{
|
||||
this.tileHeader2 |= 64;
|
||||
return;
|
||||
}
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -65);
|
||||
}
|
||||
public byte wallColor()
|
||||
{
|
||||
byte b = 0;
|
||||
if ((this.tileHeader2 & 128) == 128)
|
||||
{
|
||||
b += 1;
|
||||
}
|
||||
if ((this.tileHeader3 & 1) == 1)
|
||||
{
|
||||
b += 2;
|
||||
}
|
||||
if ((this.tileHeader3 & 2) == 2)
|
||||
{
|
||||
b += 4;
|
||||
}
|
||||
if ((this.tileHeader3 & 4) == 4)
|
||||
{
|
||||
b += 8;
|
||||
}
|
||||
if ((this.tileHeader3 & 8) == 8)
|
||||
{
|
||||
b += 16;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
public void wallColor(byte wallColor)
|
||||
{
|
||||
if (wallColor > 27)
|
||||
{
|
||||
wallColor = 27;
|
||||
}
|
||||
if ((wallColor & 1) == 1)
|
||||
{
|
||||
this.tileHeader2 |= 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -129);
|
||||
}
|
||||
if ((wallColor & 2) == 2)
|
||||
{
|
||||
this.tileHeader3 |= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -2);
|
||||
}
|
||||
if ((wallColor & 4) == 4)
|
||||
{
|
||||
this.tileHeader3 |= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -3);
|
||||
}
|
||||
if ((wallColor & 8) == 8)
|
||||
{
|
||||
this.tileHeader3 |= 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -5);
|
||||
}
|
||||
if ((wallColor & 16) == 16)
|
||||
{
|
||||
this.tileHeader3 |= 8;
|
||||
return;
|
||||
}
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -9);
|
||||
}
|
||||
public bool lava()
|
||||
{
|
||||
return (this.tileHeader & 8) == 8;
|
||||
}
|
||||
public void lava(bool lava)
|
||||
{
|
||||
if (lava)
|
||||
{
|
||||
this.tileHeader |= 8;
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -65);
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -9);
|
||||
}
|
||||
public bool honey()
|
||||
{
|
||||
return (this.tileHeader3 & 64) == 64;
|
||||
}
|
||||
public void honey(bool honey)
|
||||
{
|
||||
if (honey)
|
||||
{
|
||||
this.tileHeader3 |= 64;
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -9);
|
||||
return;
|
||||
}
|
||||
this.tileHeader3 = (byte)((int)this.tileHeader3 & -65);
|
||||
}
|
||||
public void liquidType(int liquidType)
|
||||
{
|
||||
if (liquidType == 0)
|
||||
{
|
||||
this.honey(false);
|
||||
this.lava(false);
|
||||
}
|
||||
if (liquidType == 1)
|
||||
{
|
||||
this.honey(false);
|
||||
this.lava(true);
|
||||
}
|
||||
if (liquidType == 2)
|
||||
{
|
||||
this.honey(true);
|
||||
this.lava(false);
|
||||
}
|
||||
}
|
||||
public byte liquidType()
|
||||
{
|
||||
if (this.honey())
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (this.lava())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public bool checkingLiquid()
|
||||
{
|
||||
return (this.tileHeader & 2) == 2;
|
||||
}
|
||||
public void checkingLiquid(bool checkingLiquid)
|
||||
{
|
||||
if (checkingLiquid)
|
||||
{
|
||||
this.tileHeader |= 2;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -3);
|
||||
}
|
||||
public bool skipLiquid()
|
||||
{
|
||||
return (this.tileHeader & 4) == 4;
|
||||
}
|
||||
public void skipLiquid(bool skipLiquid)
|
||||
{
|
||||
if (skipLiquid)
|
||||
{
|
||||
this.tileHeader |= 4;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -5);
|
||||
}
|
||||
public bool wire()
|
||||
{
|
||||
return (this.tileHeader & 16) == 16;
|
||||
}
|
||||
public void wire(bool wire)
|
||||
{
|
||||
if (wire)
|
||||
{
|
||||
this.tileHeader |= 16;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -17);
|
||||
}
|
||||
public bool halfBrick()
|
||||
{
|
||||
return (this.tileHeader & 32) == 32;
|
||||
}
|
||||
public void halfBrick(bool halfBrick)
|
||||
{
|
||||
if (halfBrick)
|
||||
{
|
||||
this.tileHeader |= 32;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -33);
|
||||
}
|
||||
public bool actuator()
|
||||
{
|
||||
return (this.tileHeader & 64) == 64;
|
||||
}
|
||||
public void actuator(bool actuator)
|
||||
{
|
||||
if (actuator)
|
||||
{
|
||||
this.tileHeader |= 64;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -65);
|
||||
}
|
||||
public bool nactive()
|
||||
{
|
||||
return ((this.tileHeader & 1) != 1 || (this.tileHeader & 128) != 128) && (this.tileHeader & 1) == 1;
|
||||
}
|
||||
public bool inActive()
|
||||
{
|
||||
return (this.tileHeader & 128) == 128;
|
||||
}
|
||||
public void inActive(bool inActive)
|
||||
{
|
||||
if (inActive)
|
||||
{
|
||||
this.tileHeader |= 128;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -129);
|
||||
}
|
||||
public bool active()
|
||||
{
|
||||
return (this.tileHeader & 1) == 1;
|
||||
}
|
||||
public void active(bool active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
this.tileHeader |= 1;
|
||||
return;
|
||||
}
|
||||
this.tileHeader = (byte)((int)this.tileHeader & -2);
|
||||
}
|
||||
public bool wire2()
|
||||
{
|
||||
return (this.tileHeader2 & 1) == 1;
|
||||
}
|
||||
public void wire2(bool wire2)
|
||||
{
|
||||
if (wire2)
|
||||
{
|
||||
this.tileHeader2 |= 1;
|
||||
return;
|
||||
}
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -2);
|
||||
}
|
||||
public bool wire3()
|
||||
{
|
||||
return (this.tileHeader2 & 2) == 2;
|
||||
}
|
||||
public void wire3(bool wire3)
|
||||
{
|
||||
if (wire3)
|
||||
{
|
||||
this.tileHeader2 |= 2;
|
||||
return;
|
||||
}
|
||||
this.tileHeader2 = (byte)((int)this.tileHeader2 & -3);
|
||||
}
|
||||
public Color actColor(Color oldColor)
|
||||
{
|
||||
if (this.inActive())
|
||||
{
|
||||
float num = 0.4f;
|
||||
int r = (int)((byte)(num * (float)oldColor.R));
|
||||
int g = (int)((byte)(num * (float)oldColor.G));
|
||||
int b = (int)((byte)(num * (float)oldColor.B));
|
||||
return new Color(r, g, b, (int)oldColor.A);
|
||||
}
|
||||
return oldColor;
|
||||
}
|
||||
}
|
||||
}
|
46469
Terraria/WorldGen.cs
Normal file
46469
Terraria/WorldGen.cs
Normal file
File diff suppressed because it is too large
Load diff
41
Terraria/keyBoardInput.cs
Normal file
41
Terraria/keyBoardInput.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
namespace Terraria
|
||||
{
|
||||
public class keyBoardInput
|
||||
{
|
||||
public class inKey : IMessageFilter
|
||||
{
|
||||
public bool PreFilterMessage(ref Message m)
|
||||
{
|
||||
if (m.Msg == 258)
|
||||
{
|
||||
char c = (char)((int)m.WParam);
|
||||
Console.WriteLine(c);
|
||||
if (keyBoardInput.newKeyEvent != null)
|
||||
{
|
||||
keyBoardInput.newKeyEvent(c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m.Msg == 256)
|
||||
{
|
||||
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(m));
|
||||
Marshal.StructureToPtr(m, intPtr, true);
|
||||
keyBoardInput.TranslateMessage(intPtr);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static event Action<char> newKeyEvent;
|
||||
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
|
||||
public static extern bool TranslateMessage(IntPtr message);
|
||||
static keyBoardInput()
|
||||
{
|
||||
Application.AddMessageFilter(new keyBoardInput.inKey());
|
||||
}
|
||||
}
|
||||
}
|
3060
Terraria/messageBuffer.cs
Normal file
3060
Terraria/messageBuffer.cs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue