Skip to content

Instantly share code, notes, and snippets.

@DartPower
Created December 29, 2025 11:11
Show Gist options
  • Select an option

  • Save DartPower/288c6b25b0bcb99811ffc4b22eb1329e to your computer and use it in GitHub Desktop.

Select an option

Save DartPower/288c6b25b0bcb99811ffc4b22eb1329e to your computer and use it in GitHub Desktop.
Main.cs GMod1061
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Terraria;
public class Main : Game
{
public const double dayLength = 54000.0;
public const int maxBackgrounds = 7;
public const int maxBuffs = 27;
public const int maxChests = 1000;
public const int maxClouds = 100;
public const int maxCloudTypes = 4;
public const int maxCombatText = 100;
public const int maxDust = 1000;
public const int maxGore = 200;
public const int maxGoreTypes = 99;
public const int maxHair = 36;
public const int maxInventory = 44;
public const int maxItems = 200;
public const int maxItemSounds = 21;
public const int maxItemText = 100;
public const int maxItemTypes = 364;
public const int maxLiquidTypes = 2;
public const int maxMusic = 9;
public const int maxNPCHitSounds = 3;
public const int maxNPCKilledSounds = 5;
public const int maxNPCs = 1000;
public const int maxNPCTypes = 74;
public const int maxPlayers = 255;
public const int maxProjectiles = 1000;
public const int maxProjectileTypes = 56;
public const int maxStars = 130;
public const int maxStarTypes = 5;
public const int maxTileSets = 107;
public const int maxWallTypes = 21;
private const int MF_BYPOSITION = 1024;
public const double nightLength = 32400.0;
public const int numArmorBody = 17;
public const int numArmorHead = 29;
public const int numArmorLegs = 16;
public const int sectionHeight = 150;
public const int sectionWidth = 200;
private static int accSlotCount = 0;
public static Texture2D antLionTexture;
public static float armorAlpha = 1f;
public static Texture2D[] armorArmTexture = new Texture2D[17];
public static Texture2D[] armorBodyTexture = new Texture2D[17];
public static Texture2D[] armorHeadTexture = new Texture2D[29];
public static bool armorHide = false;
public static Texture2D[] armorLegTexture = new Texture2D[16];
public static bool autoGen = false;
public static bool autoJoin = false;
public static bool autoPass = false;
public static bool autoPause = false;
public static bool autoSave = true;
public static bool autoShutdown = false;
public static int[] availableRecipe = new int[Recipe.maxRecipes];
public static float[] availableRecipeY = new float[Recipe.maxRecipes];
public static int background = 0;
public static int[] backgroundHeight = new int[7];
public static Texture2D[] backgroundTexture = new Texture2D[7];
public static int[] backgroundWidth = new int[7];
private static int backSpaceCount = 0;
private int bgScroll;
public static Texture2D blackTileTexture;
public static bool bloodMoon = false;
public static Texture2D boneArmTexture;
public static float bottomWorld = 38400f;
public static Texture2D bubbleTexture;
public static float[] buffAlpha = new float[27];
public static string[] buffName = new string[27];
public static string buffString = "";
public static Texture2D[] buffTexture = new Texture2D[27];
public static string[] buffTip = new string[27];
public static float caveParrallax = 1f;
public static string cBuff = "B";
public static string cDown = "S";
public static Texture2D cdTexture;
public static Texture2D chain2Texture;
public static Texture2D chain3Texture;
public static Texture2D chain4Texture;
public static Texture2D chain5Texture;
public static Texture2D chain6Texture;
public static Texture2D chainTexture;
public static Texture2D chat2Texture;
public static Texture2D chatBackTexture;
public static int chatLength = 600;
public static int numChatLines = 30;
public static ChatLine[] chatLine = new ChatLine[numChatLines];
public static bool chatMode = false;
public static bool chatRelease = false;
public static string chatText = "";
public static Texture2D chatTexture;
public static string cHeal = "H";
public static int checkForSpawns = 0;
public static Chest[] chest = new Chest[1000];
public bool chestDepositHover;
public float chestDepositScale = 1f;
public bool chestLootHover;
public float chestLootScale = 1f;
public bool chestStackHover;
public float chestStackScale = 1f;
public static string chestText = "Chest";
public static string cHook = "E";
public static string cInv = "Escape";
public static string cJump = "Space";
public static string cLeft = "A";
public static Player clientPlayer = new Player();
public static Cloud[] cloud = new Cloud[100];
public static int cloudLimit = 100;
public static Texture2D[] cloudTexture = new Texture2D[4];
public static string cMana = "M";
private int colorDelay;
public static CombatText[] combatText = new CombatText[100];
public static bool craftGuide = false;
public static float craftingAlpha = 1f;
public static bool craftingHide = false;
public static string cRight = "D";
public static string cThrowItem = "Q";
public static string cUp = "W";
public int curMusic;
public static int curRelease = 22;
public static float cursorAlpha = 0f;
public static Color cursorColor = Color.White;
public static int cursorColorDirection = 1;
public static float cursorScale = 0f;
public static Texture2D cursorTexture;
public static bool dayTime = true;
public static bool[] debuff = new bool[27];
public static bool dedServ = false;
public static string defaultIP = "";
private int[] displayHeight = new int[99];
private int[] displayWidth = new int[99];
public static int drawTime = 0;
public static int dungeonTiles;
public static int dungeonX;
public static int dungeonY;
public static Dust[] dust = new Dust[1001];
public static Texture2D dustTexture;
public static bool editSign = false;
public static AudioEngine engine;
public static int evilTiles;
private static float exitScale = 0.8f;
public static int fadeCounter = 0;
public static Texture2D fadeTexture;
public static bool fixedTiming = false;
private int focusColor;
private int focusMenu = -1;
public static int focusRecipe;
public static SpriteFont[] fontCombatText = new SpriteFont[2];
public static SpriteFont fontDeathText;
public static SpriteFont fontItemStack;
public static SpriteFont fontMouseText;
public static int frameRate = 0;
public static bool frameRelease = false;
public static bool gameMenu = true;
public static bool gamePaused = false;
public static string getIP = defaultIP;
public static string getPort = Convert.ToString(Netplay.serverPort);
public static Texture2D ghostTexture;
public static Gore[] gore = new Gore[201];
public static Texture2D[] goreTexture = new Texture2D[99];
public static bool grabSky = false;
private GraphicsDeviceManager graphics;
public static Item guideItem = new Item();
public static bool hasFocus = true;
public static Texture2D[] HBLockTexture = new Texture2D[2];
public static Color hcColor = new Color(200, 125, 255);
public static Texture2D heartTexture;
public static int helpText = 0;
public static bool hideUI = false;
public static float[] hotbarScale = new float[10] { 1f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f };
public static bool ignoreErrors = true;
private static KeyboardState inputText;
public static bool inputTextEnter = false;
public static float invAlpha = 1f;
public static int invasionDelay = 0;
public static int invasionSize = 0;
public static int invasionType = 0;
public static int invasionWarn = 0;
public static double invasionX = 0.0;
public static float invDir = 1f;
public static Texture2D inventoryBack10Texture;
public static Texture2D inventoryBack2Texture;
public static Texture2D inventoryBack3Texture;
public static Texture2D inventoryBack4Texture;
public static Texture2D inventoryBack5Texture;
public static Texture2D inventoryBack6Texture;
public static Texture2D inventoryBack7Texture;
public static Texture2D inventoryBack8Texture;
public static Texture2D inventoryBack9Texture;
public static Texture2D inventoryBackTexture;
private static float inventoryScale = 0.75f;
public static float iS = 1f;
public static Item[] item = new Item[201];
public static string[] itemName = new string[364];
public static ItemText[] itemText = new ItemText[100];
public static Texture2D[] itemTexture = new Texture2D[364];
public static int jungleTiles;
public static KeyboardState keyState = Keyboard.GetState();
public static int lastItemUpdate;
public static int lastNPCUpdate;
public static float leftWorld = 0f;
public static string libPath = "";
public static Liquid[] liquid = new Liquid[Liquid.resLiquid];
public static LiquidBuffer[] liquidBuffer = new LiquidBuffer[10000];
public static Texture2D[] liquidTexture = new Texture2D[2];
public static Player[] loadPlayer = new Player[5];
public static string[] loadPlayerPath = new string[5];
public static string[] loadWorld = new string[999];
public static string[] loadWorldPath = new string[999];
private float logoRotation;
private float logoRotationDirection = 1f;
private float logoRotationSpeed = 1f;
private float logoScale = 1f;
private float logoScaleDirection = 1f;
private float logoScaleSpeed = 1f;
public static Texture2D logoTexture;
public static int magmaBGFrame = 0;
public static int magmaBGFrameCounter = 0;
public static Texture2D manaTexture;
public static int maxItemUpdates = 10;
private static int maxMenuItems = 14;
public static int maxMP = 10;
public static int maxNetPlayers = 255;
public static int maxNPCUpdates = 15;
public static int maxScreenH = 1200;
public static int maxScreenW = 1920;
public static int maxSectionsX = maxTilesX / 200;
public static int maxSectionsY = maxTilesY / 150;
public static float rightWorld = 134400f;
public static int maxTilesX = (int)rightWorld / 16 + 1;
public static int maxTilesY = (int)bottomWorld / 16 + 1;
public static Color mcColor = new Color(125, 125, 255);
public static int menuFocus = 0;
private float[] menuItemScale = new float[maxMenuItems];
public static int menuMode = 0;
public static bool menuMultiplayer = false;
public static bool menuServer = false;
public static int meteorTiles;
public static int minScreenH = 600;
public static int minScreenW = 800;
public static short moonModY = 0;
public static int moonPhase = 0;
public static Texture2D moonTexture;
public static string motd = "";
public static Color mouseColor = new Color(255, 50, 95);
private static bool mouseExit = false;
public static bool mouseHC = false;
public static Item mouseItem = new Item();
public static bool mouseLeftRelease = false;
public static bool mouseRightRelease = false;
public static MouseState mouseState = Mouse.GetState();
public static byte mouseTextColor = 0;
public static int mouseTextColorChange = 1;
public static Cue[] music = new Cue[9];
public static float[] musicFade = new float[9];
public static float musicVolume = 0.75f;
public static int myPlayer = 0;
public static int netMode = 0;
public static int netPlayCounter;
public int newMusic;
public static string newWorldName = "";
public static Texture2D ninjaTexture;
public static NPC[] npc = new NPC[1001];
public static bool npcChatFocus1 = false;
public static bool npcChatFocus2 = false;
public static bool npcChatFocus3 = false;
public static bool npcChatRelease = false;
public static string npcChatText = "";
public static int[] npcFrameCount = new int[74]
{
1, 2, 2, 3, 6, 2, 2, 1, 1, 1,
1, 1, 1, 1, 1, 1, 2, 16, 14, 16,
14, 15, 16, 2, 10, 1, 16, 16, 16, 3,
1, 15, 3, 1, 3, 1, 1, 16, 16, 1,
1, 1, 3, 3, 15, 3, 7, 7, 4, 5,
5, 5, 3, 3, 16, 6, 3, 6, 6, 2,
5, 3, 2, 7, 7, 4, 2, 8, 1, 5,
1, 2, 4, 16
};
public static int npcShop = 0;
public static Texture2D[] npcTexture = new Texture2D[74];
public static int numAvailableRecipes;
public static int numClouds = cloudLimit;
private int numDisplayModes;
public static int numDust = 1000;
private static int numLoadPlayers = 0;
private static int numLoadWorlds = 0;
public static int numStars;
private static KeyboardState oldInputText;
public static MouseState oldMouseState = Mouse.GetState();
public static string oldStatusText = "";
public static Player[] player = new Player[256];
public static Texture2D playerBeltTexture;
public static Texture2D playerEyesTexture;
public static Texture2D playerEyeWhitesTexture;
public static Texture2D[] playerHairTexture = new Texture2D[36];
public static Texture2D playerHands2Texture;
public static Texture2D playerHandsTexture;
public static Texture2D playerHeadTexture;
public static bool playerInventory = false;
public static Texture2D playerPantsTexture;
public static string SavePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\My Games\\Terraria";
public static string PlayerPath = SavePath + "\\Players";
public static string playerPathName;
public static Texture2D playerShirtTexture;
public static Texture2D playerShoesTexture;
public static Texture2D playerUnderShirt2Texture;
public static Texture2D playerUnderShirtTexture;
public static Projectile[] projectile = new Projectile[1001];
public static Texture2D[] projectileTexture = new Texture2D[56];
[ThreadStatic]
public static Random rand;
public static Texture2D raTexture;
public static string[] recentIP = new string[maxMP];
public static int[] recentPort = new int[maxMP];
public static string[] recentWorld = new string[maxMP];
public static Recipe[] recipe = new Recipe[Recipe.maxRecipes];
public static bool releaseUI = false;
public static bool resetClouds = true;
public static Texture2D reTexture;
public static double rockLayer;
private static Stopwatch saveTime = new Stopwatch();
public static int saveTimer = 0;
public static int screenHeight = 600;
public static Vector2 screenLastPosition;
public static Vector2 screenPosition;
public static int screenWidth = 800;
private Color selColor = Color.White;
private int selectedMenu = -1;
private int selectedMenu2 = -1;
private int selectedPlayer;
private int selectedWorld;
public static bool serverStarting = false;
private int setKey = -1;
public Chest[] shop = new Chest[6];
public static bool showFrameRate = false;
public static bool showItemOwner = false;
public static bool showItemText = true;
public static bool showSpam = false;
public static bool showSplash = true;
public static Texture2D shroomCapTexture;
public static Sign[] sign = new Sign[1000];
public static bool signBubble = false;
public static string signText = "";
public static int signX = 0;
public static int signY = 0;
public static bool skipMenu = false;
public static SoundBank soundBank;
public static SoundEffect soundChat;
public static SoundEffect soundCoins;
public static SoundEffect[] soundDig = new SoundEffect[3];
public static SoundEffect soundDoorClosed;
public static SoundEffect soundDoorOpen;
public static SoundEffect soundDoubleJump;
public static SoundEffect soundDrown;
public static SoundEffect[] soundFemaleHit = new SoundEffect[3];
public static SoundEffect soundGrab;
public static SoundEffect soundGrass;
public static SoundEffectInstance soundInstanceChat;
public static SoundEffectInstance soundInstanceCoins;
public static SoundEffectInstance[] soundInstanceDig = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstanceDoorClosed;
public static SoundEffectInstance soundInstanceDoorOpen;
public static SoundEffectInstance soundInstanceDoubleJump;
public static SoundEffectInstance soundInstanceDrown;
public static SoundEffectInstance[] soundInstanceFemaleHit = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstanceGrab;
public static SoundEffectInstance soundInstanceGrass;
public static SoundEffectInstance[] soundInstanceItem = new SoundEffectInstance[22];
public static SoundEffectInstance soundInstanceMaxMana;
public static SoundEffectInstance soundInstanceMenuClose;
public static SoundEffectInstance soundInstanceMenuOpen;
public static SoundEffectInstance soundInstanceMenuTick;
public static SoundEffectInstance[] soundInstanceNPCHit = new SoundEffectInstance[4];
public static SoundEffectInstance[] soundInstanceNPCKilled = new SoundEffectInstance[6];
public static SoundEffectInstance[] soundInstancePlayerHit = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstancePlayerKilled;
public static SoundEffectInstance[] soundInstanceRoar = new SoundEffectInstance[2];
public static SoundEffectInstance soundInstanceRun;
public static SoundEffectInstance soundInstanceShatter;
public static SoundEffectInstance[] soundInstanceSplash = new SoundEffectInstance[2];
public static SoundEffectInstance[] soundInstanceTink = new SoundEffectInstance[3];
public static SoundEffectInstance soundInstanceUnlock;
public static SoundEffectInstance[] soundInstanceZombie = new SoundEffectInstance[3];
public static SoundEffect[] soundItem = new SoundEffect[22];
public static SoundEffect soundMaxMana;
public static SoundEffect soundMenuClose;
public static SoundEffect soundMenuOpen;
public static SoundEffect soundMenuTick;
public static SoundEffect[] soundNPCHit = new SoundEffect[4];
public static SoundEffect[] soundNPCKilled = new SoundEffect[6];
public static SoundEffect[] soundPlayerHit = new SoundEffect[3];
public static SoundEffect soundPlayerKilled;
public static SoundEffect[] soundRoar = new SoundEffect[2];
public static SoundEffect soundRun;
public static SoundEffect soundShatter;
public static SoundEffect[] soundSplash = new SoundEffect[2];
public static SoundEffect[] soundTink = new SoundEffect[3];
public static SoundEffect soundUnlock;
public static float soundVolume = 1f;
public static SoundEffect[] soundZombie = new SoundEffect[3];
public static int spamCount = 0;
public static int spawnTileX;
public static int spawnTileY;
public static Texture2D spikeBaseTexture;
private int splashCounter;
public static Texture2D splashTexture;
private SpriteBatch spriteBatch;
public static int stackCounter = 0;
public static int stackDelay = 7;
public static int stackSplit;
public static Star[] star = new Star[130];
public static Texture2D[] starTexture = new Texture2D[5];
public static string statusText = "";
public static bool stopTimeOuts = false;
public static Texture2D sun2Texture;
public static short sunModY = 0;
public static Texture2D sunTexture;
public static Color[] teamColor = new Color[5];
public static int teamCooldown = 0;
public static int teamCooldownLen = 300;
public static Texture2D teamTexture;
public static Texture2D textBackTexture;
private int textBlinkerCount;
private int textBlinkerState;
public static Tile[,] tile = new Tile[maxTilesX, maxTilesY];
public static bool[] tileAlch = new bool[107];
public static bool[] tileBlockLight = new bool[107];
public static Color tileColor;
public static bool[] tileCut = new bool[107];
public static bool[] tileDungeon = new bool[107];
public static bool[] tileFrameImportant = new bool[107];
public static bool[] tileLavaDeath = new bool[107];
public static bool[] tileMergeDirt = new bool[107];
public static string[] tileName = new string[107];
public static bool[] tileNoAttach = new bool[107];
public static bool[] tileNoFail = new bool[107];
public static int[] tileShine = new int[107];
public static bool tilesLoaded = false;
public static bool[] tileSolid = new bool[107];
public static bool[] tileSolidTop = new bool[107];
public static bool[] tileStone = new bool[107];
public static bool[] tileTable = new bool[107];
public static Texture2D[] tileTexture = new Texture2D[107];
public static bool[] tileWaterDeath = new bool[107];
public static double time = 13500.0;
public static int timeOut = 120;
public bool toggleFullscreen;
private static Item toolTip = new Item();
public static float topWorld = 0f;
public static Item trashItem = new Item();
public static Texture2D trashTexture;
public static Texture2D[] treeBranchTexture = new Texture2D[3];
public static Texture2D[] treeTopTexture = new Texture2D[3];
private Process tServer = new Process();
public static int updateTime = 0;
public static bool[] wallHouse = new bool[21];
public static Texture2D[] wallTexture = new Texture2D[21];
public static WaveBank waveBank;
public static bool verboseNetplay = false;
public static string versionNumber = "v1.0.6.1";
public static string versionNumber2 = "v1.0.6.1";
public static float windSpeed = 0f;
public static float windSpeedSpeed = 0f;
public static int worldID;
public static string worldName = "";
public static string WorldPath = SavePath + "\\Worlds";
public static string worldPathName;
public static double worldSurface;
public Main()
{
graphics = new GraphicsDeviceManager(this);
base.Content.RootDirectory = "Content";
}
private static bool AccCheck(Item newItem)
{
for (int i = 0; i < player[myPlayer].armor.Length; i++)
{
if (newItem.IsTheSameAs(player[myPlayer].armor[i]))
{
return true;
}
}
return false;
}
public static Item armorSwap(Item newItem)
{
if (newItem.headSlot == -1 && newItem.bodySlot == -1 && newItem.legSlot == -1 && !newItem.accessory)
{
return newItem;
}
Item result = newItem;
if (newItem.headSlot != -1)
{
result = (Item)player[myPlayer].armor[0].Clone();
player[myPlayer].armor[0] = (Item)newItem.Clone();
}
else if (newItem.bodySlot != -1)
{
result = (Item)player[myPlayer].armor[1].Clone();
player[myPlayer].armor[1] = (Item)newItem.Clone();
}
else if (newItem.legSlot != -1)
{
result = (Item)player[myPlayer].armor[2].Clone();
player[myPlayer].armor[2] = (Item)newItem.Clone();
}
else if (newItem.accessory)
{
if (AccCheck(newItem))
{
return result;
}
for (int i = 3; i < 8; i++)
{
if (player[myPlayer].armor[i].type == 0)
{
accSlotCount = i - 3;
break;
}
}
result = (Item)player[myPlayer].armor[3 + accSlotCount].Clone();
player[myPlayer].armor[3 + accSlotCount] = (Item)newItem.Clone();
accSlotCount++;
if (accSlotCount >= 5)
{
accSlotCount = 0;
}
}
PlaySound(7);
Recipe.FindRecipes();
return result;
}
public void autoCreate(string newOpt)
{
switch (newOpt)
{
case "0":
autoGen = false;
break;
case "1":
maxTilesX = 4200;
maxTilesY = 1200;
autoGen = true;
break;
case "2":
maxTilesX = 6300;
maxTilesY = 1800;
autoGen = true;
break;
case "3":
maxTilesX = 8400;
maxTilesY = 2400;
autoGen = true;
break;
}
}
public void AutoHost()
{
menuMultiplayer = true;
menuServer = true;
menuMode = 1;
}
public void AutoJoin(string IP)
{
defaultIP = IP;
getIP = IP;
Netplay.SetIP(defaultIP);
autoJoin = true;
}
public void AutoPass()
{
autoPass = true;
}
public void autoShut()
{
autoShutdown = true;
}
public static void BankCoins()
{
for (int i = 0; i < 20; i++)
{
if (player[myPlayer].bank[i].type < 71 || player[myPlayer].bank[i].type > 73 || player[myPlayer].bank[i].stack != player[myPlayer].bank[i].maxStack)
{
continue;
}
player[myPlayer].bank[i].SetDefaults(player[myPlayer].bank[i].type + 1);
for (int j = 0; j < 20; j++)
{
if (j != i && player[myPlayer].bank[j].type == player[myPlayer].bank[i].type && player[myPlayer].bank[j].stack < player[myPlayer].bank[j].maxStack)
{
Item item = player[myPlayer].bank[j];
item.stack++;
player[myPlayer].bank[i].SetDefaults(0);
BankCoins();
}
}
}
}
private static Color buffColor(Color newColor, float R, float G, float B, float A)
{
newColor.R = (byte)((float)(int)newColor.R * R);
newColor.G = (byte)((float)(int)newColor.G * G);
newColor.B = (byte)((float)(int)newColor.B * B);
newColor.A = (byte)((float)(int)newColor.A * A);
return newColor;
}
public static double CalculateDamage(int Damage, int Defense)
{
double num = (double)Damage - (double)Defense * 0.5;
if (num < 1.0)
{
num = 1.0;
}
return num;
}
public static void ChestCoins()
{
for (int i = 0; i < 20; i++)
{
if (chest[player[myPlayer].chest].item[i].type < 71 || chest[player[myPlayer].chest].item[i].type > 73 || chest[player[myPlayer].chest].item[i].stack != chest[player[myPlayer].chest].item[i].maxStack)
{
continue;
}
chest[player[myPlayer].chest].item[i].SetDefaults(chest[player[myPlayer].chest].item[i].type + 1);
for (int j = 0; j < 20; j++)
{
if (j != i && chest[player[myPlayer].chest].item[j].type == chest[player[myPlayer].chest].item[i].type && chest[player[myPlayer].chest].item[j].stack < chest[player[myPlayer].chest].item[j].maxStack)
{
Item item = chest[player[myPlayer].chest].item[j];
item.stack++;
chest[player[myPlayer].chest].item[i].SetDefaults(0);
ChestCoins();
}
}
}
}
public static void CursorColor()
{
cursorAlpha += (float)cursorColorDirection * 0.015f;
if (cursorAlpha >= 1f)
{
cursorAlpha = 1f;
cursorColorDirection = -1;
}
if ((double)cursorAlpha <= 0.6)
{
cursorAlpha = 0.6f;
cursorColorDirection = 1;
}
float num = cursorAlpha * 0.3f + 0.7f;
byte r = (byte)((float)(int)mouseColor.R * cursorAlpha);
byte g = (byte)((float)(int)mouseColor.G * cursorAlpha);
byte b = (byte)((float)(int)mouseColor.B * cursorAlpha);
byte a = (byte)(255f * num);
cursorColor = new Color(r, g, b, a);
cursorScale = cursorAlpha * 0.3f + 0.7f + 0.1f;
}
public static int DamageVar(float dmg)
{
float num = dmg * (1f + (float)rand.Next(-15, 16) * 0.01f);
return (int)Math.Round(num);
}
public void DedServ()
{
rand = new Random();
if (autoShutdown)
{
string lpWindowName = (Console.Title = "terraria" + rand.Next(int.MaxValue));
IntPtr intPtr = FindWindow(null, lpWindowName);
if (intPtr != IntPtr.Zero)
{
ShowWindow(intPtr, 0);
}
}
else
{
Console.Title = "Terraria Server " + versionNumber2;
}
dedServ = true;
showSplash = false;
Initialize();
while (worldPathName == null || worldPathName == "")
{
LoadWorlds();
bool flag = true;
while (flag)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
for (int i = 0; i < numLoadWorlds; i++)
{
Console.WriteLine(string.Concat(i + 1, '\t', '\t', loadWorld[i]));
}
Console.WriteLine("n" + '\t' + '\t' + "New World");
Console.WriteLine("d <number>" + '\t' + "Delete World");
Console.WriteLine("");
Console.Write("Choose World: ");
string text2 = Console.ReadLine();
try
{
Console.Clear();
}
catch
{
}
if (text2.Length >= 2 && text2.Substring(0, 2).ToLower() == "d ")
{
try
{
int num = Convert.ToInt32(text2.Substring(2)) - 1;
if (num < numLoadWorlds)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("Really delete " + loadWorld[num] + "?");
Console.Write("(y/n): ");
if (Console.ReadLine().ToLower() == "y")
{
EraseWorld(num);
}
}
}
catch
{
}
try
{
Console.Clear();
}
catch
{
}
continue;
}
if (text2 == "n" || text2 == "N")
{
bool flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.WriteLine("1" + '\t' + "Small");
Console.WriteLine("2" + '\t' + "Medium");
Console.WriteLine("3" + '\t' + "Large");
Console.WriteLine("");
Console.Write("Choose size: ");
string value = Console.ReadLine();
try
{
switch (Convert.ToInt32(value))
{
case 1:
maxTilesX = 4200;
maxTilesY = 1200;
flag2 = false;
break;
case 2:
maxTilesX = 6300;
maxTilesY = 1800;
flag2 = false;
break;
case 3:
maxTilesX = 8400;
maxTilesY = 2400;
flag2 = false;
break;
}
}
catch
{
}
try
{
Console.Clear();
}
catch
{
}
}
flag2 = true;
while (flag2)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Enter world name: ");
newWorldName = Console.ReadLine();
if (newWorldName != "" && newWorldName != " " && newWorldName != null)
{
flag2 = false;
}
try
{
Console.Clear();
}
catch
{
}
}
worldName = newWorldName;
worldPathName = nextLoadWorld();
menuMode = 10;
WorldGen.CreateNewWorld();
flag2 = false;
while (menuMode == 10)
{
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
}
try
{
Console.Clear();
}
catch
{
}
continue;
}
try
{
int num2 = Convert.ToInt32(text2) - 1;
if (num2 < 0 || num2 >= numLoadWorlds)
{
continue;
}
bool flag3 = true;
while (flag3)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Max players (press enter for 8): ");
string text3 = Console.ReadLine();
try
{
if (text3 == "")
{
text3 = "8";
}
int num3 = Convert.ToInt32(text3);
if (num3 <= 255 && num3 >= 1)
{
maxNetPlayers = num3;
flag3 = false;
}
flag3 = false;
}
catch
{
}
try
{
Console.Clear();
}
catch
{
}
}
flag3 = true;
while (flag3)
{
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Server port (press enter for 7777): ");
string text4 = Console.ReadLine();
try
{
if (text4 == "")
{
text4 = "7777";
}
int num4 = Convert.ToInt32(text4);
if (num4 <= 65535)
{
Netplay.serverPort = num4;
flag3 = false;
}
}
catch
{
}
try
{
Console.Clear();
}
catch
{
}
}
Console.WriteLine("Terraria Server " + versionNumber2);
Console.WriteLine("");
Console.Write("Server password (press enter for none): ");
Netplay.password = Console.ReadLine();
worldPathName = loadWorldPath[num2];
flag = false;
try
{
Console.Clear();
}
catch
{
}
}
catch
{
}
}
}
try
{
Console.Clear();
}
catch
{
}
WorldGen.serverLoadWorld();
Console.WriteLine("Terraria Server " + versionNumber);
Console.WriteLine("");
while (!Netplay.ServerUp)
{
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
}
try
{
Console.Clear();
}
catch
{
}
Console.WriteLine("Terraria Server " + versionNumber);
Console.WriteLine("");
Console.WriteLine("Listening on port " + Netplay.serverPort);
Console.WriteLine("Type 'help' for a list of commands.");
Console.WriteLine("");
Console.Title = "Terraria Server: " + worldName;
Stopwatch stopwatch = new Stopwatch();
if (!autoShutdown)
{
startDedInput();
}
stopwatch.Start();
double num5 = 16.666666666666668;
double num6 = 0.0;
while (!Netplay.disconnect)
{
double num7 = stopwatch.ElapsedMilliseconds;
if (num7 + num6 >= num5)
{
num6 += num7 - num5;
stopwatch.Reset();
stopwatch.Start();
if (oldStatusText != statusText)
{
oldStatusText = statusText;
Console.WriteLine(statusText);
}
if (num6 > 1000.0)
{
num6 = 1000.0;
}
if (Netplay.anyClients)
{
Update(new GameTime());
}
double num8 = (double)stopwatch.ElapsedMilliseconds + num6;
if (num8 < num5)
{
int num9 = (int)(num5 - num8) - 1;
if (num9 > 1)
{
Thread.Sleep(num9);
if (!Netplay.anyClients)
{
num6 = 0.0;
Thread.Sleep(10);
}
}
}
}
Thread.Sleep(0);
}
}
protected override void Draw(GameTime gameTime)
{
if (!dedServ)
{
if ((screenWidth != base.GraphicsDevice.Viewport.Width || screenHeight != base.GraphicsDevice.Viewport.Height) && gamePaused)
{
Lighting.resize = true;
}
screenWidth = base.GraphicsDevice.Viewport.Width;
screenHeight = base.GraphicsDevice.Viewport.Height;
bool flag = false;
if (screenWidth > maxScreenW)
{
screenWidth = maxScreenW;
flag = true;
}
if (screenHeight > maxScreenH)
{
screenHeight = maxScreenH;
flag = true;
}
if (screenWidth < minScreenW)
{
screenWidth = minScreenW;
flag = true;
}
if (screenHeight < minScreenH)
{
screenHeight = minScreenH;
flag = true;
}
if (flag)
{
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
graphics.ApplyChanges();
}
}
CursorColor();
drawTime++;
screenLastPosition = screenPosition;
if (stackSplit == 0)
{
stackCounter = 0;
stackDelay = 7;
}
else
{
stackCounter++;
if (stackCounter >= 30)
{
stackDelay--;
if (stackDelay < 2)
{
stackDelay = 2;
}
stackCounter = 0;
}
}
mouseTextColor += (byte)mouseTextColorChange;
if (mouseTextColor >= 250)
{
mouseTextColorChange = -4;
}
if (mouseTextColor <= 175)
{
mouseTextColorChange = 4;
}
if (myPlayer >= 0)
{
player[myPlayer].mouseInterface = false;
}
toolTip = new Item();
if (!ModClass.debugMode && !gameMenu && netMode != 2)
{
int num = mouseState.X;
int num2 = mouseState.Y;
if (num < 0)
{
num = 0;
}
if (num > screenWidth)
{
num = screenWidth;
}
if (num2 < 0)
{
num2 = 0;
}
if (num2 > screenHeight)
{
num2 = screenHeight;
}
screenPosition.X = player[myPlayer].position.X + (float)player[myPlayer].width * 0.5f - (float)screenWidth * 0.5f;
screenPosition.Y = player[myPlayer].position.Y + (float)player[myPlayer].height * 0.5f - (float)screenHeight * 0.5f;
screenPosition.X = (int)screenPosition.X;
screenPosition.Y = (int)screenPosition.Y;
}
if (!gameMenu && netMode != 2)
{
if (screenPosition.X < leftWorld + 336f + 16f)
{
screenPosition.X = leftWorld + 336f + 16f;
}
else if (screenPosition.X + (float)screenWidth > rightWorld - 336f - 32f)
{
screenPosition.X = rightWorld - (float)screenWidth - 336f - 32f;
}
if (screenPosition.Y < topWorld + 336f + 16f)
{
screenPosition.Y = topWorld + 336f + 16f;
}
else if (screenPosition.Y + (float)screenHeight > bottomWorld - 336f - 32f)
{
screenPosition.Y = bottomWorld - (float)screenHeight - 336f - 32f;
}
}
if (showSplash)
{
DrawSplash(gameTime);
return;
}
base.GraphicsDevice.Clear(Color.Black);
base.Draw(gameTime);
spriteBatch.Begin();
double num3 = 0.5;
int num4 = (int)(0.0 - Math.IEEERemainder((double)screenPosition.X * num3, backgroundWidth[background])) - backgroundWidth[background] / 2;
int num5 = screenWidth / backgroundWidth[background] + 2;
int num6 = 0;
int num7 = 0;
int num8 = (int)((double)(0f - screenPosition.Y) / (worldSurface * 16.0 - 600.0) * 200.0);
if (gameMenu || netMode == 2)
{
num8 = -200;
}
Color white = Color.White;
int num9 = (int)(time / 54000.0 * (double)(screenWidth + sunTexture.Width * 2)) - sunTexture.Width;
int num10 = 0;
Color white2 = Color.White;
float num11 = 1f;
float rotation = (float)(time / 54000.0) * 2f - 7.3f;
int num12 = (int)(time / 32400.0 * (double)(screenWidth + moonTexture.Width * 2)) - moonTexture.Width;
int num13 = 0;
Color white3 = Color.White;
float num14 = 1f;
float rotation2 = (float)(time / 32400.0) * 2f - 7.3f;
float num15 = 0f;
if (dayTime)
{
double num16;
if (time < 27000.0)
{
num16 = Math.Pow(1.0 - time / 54000.0 * 2.0, 2.0);
num10 = (int)((double)num8 + num16 * 250.0 + 180.0);
}
else
{
num16 = Math.Pow((time / 54000.0 - 0.5) * 2.0, 2.0);
num10 = (int)((double)num8 + num16 * 250.0 + 180.0);
}
num11 = (float)(1.2 - num16 * 0.4);
}
else
{
double num17;
if (time < 16200.0)
{
num17 = Math.Pow(1.0 - time / 32400.0 * 2.0, 2.0);
num13 = (int)((double)num8 + num17 * 250.0 + 180.0);
}
else
{
num17 = Math.Pow((time / 32400.0 - 0.5) * 2.0, 2.0);
num13 = (int)((double)num8 + num17 * 250.0 + 180.0);
}
num14 = (float)(1.2 - num17 * 0.4);
}
if (dayTime)
{
if (time < 13500.0)
{
num15 = (float)(time / 13500.0);
white2.R = (byte)(num15 * 200f + 55f);
white2.G = (byte)(num15 * 180f + 75f);
white2.B = (byte)(num15 * 250f + 5f);
white.R = (byte)(num15 * 200f + 55f);
white.G = (byte)(num15 * 200f + 55f);
white.B = (byte)(num15 * 200f + 55f);
}
if (time > 45900.0)
{
num15 = (float)(1.0 - (time / 54000.0 - 0.85) * 6.666666666666667);
white2.R = (byte)(num15 * 120f + 55f);
white2.G = (byte)(num15 * 100f + 25f);
white2.B = (byte)(num15 * 120f + 55f);
white.R = (byte)(num15 * 200f + 55f);
white.G = (byte)(num15 * 85f + 55f);
white.B = (byte)(num15 * 135f + 55f);
}
else if (time > 37800.0)
{
num15 = (float)(1.0 - (time / 54000.0 - 0.7) * 6.666666666666667);
white2.R = (byte)(num15 * 80f + 175f);
white2.G = (byte)(num15 * 130f + 125f);
white2.B = (byte)(num15 * 100f + 155f);
white.R = (byte)(num15 * 0f + 255f);
white.G = (byte)(num15 * 115f + 140f);
white.B = (byte)(num15 * 75f + 180f);
}
}
if (!dayTime)
{
if (bloodMoon)
{
if (time < 16200.0)
{
num15 = (float)(1.0 - time / 16200.0);
white3.R = (byte)(num15 * 10f + 205f);
white3.G = (byte)(num15 * 170f + 55f);
white3.B = (byte)(num15 * 200f + 55f);
white.R = (byte)(60f - num15 * 60f + 55f);
white.G = (byte)(num15 * 40f + 15f);
white.B = (byte)(num15 * 40f + 15f);
}
else if (time >= 16200.0)
{
num15 = (float)((time / 32400.0 - 0.5) * 2.0);
white3.R = (byte)(num15 * 50f + 205f);
white3.G = (byte)(num15 * 100f + 155f);
white3.B = (byte)(num15 * 100f + 155f);
white3.R = (byte)(num15 * 10f + 205f);
white3.G = (byte)(num15 * 170f + 55f);
white3.B = (byte)(num15 * 200f + 55f);
white.R = (byte)(60f - num15 * 60f + 55f);
white.G = (byte)(num15 * 40f + 15f);
white.B = (byte)(num15 * 40f + 15f);
}
}
else if (time < 16200.0)
{
num15 = (float)(1.0 - time / 16200.0);
white3.R = (byte)(num15 * 10f + 205f);
white3.G = (byte)(num15 * 70f + 155f);
white3.B = (byte)(num15 * 100f + 155f);
white.R = (byte)(num15 * 40f + 15f);
white.G = (byte)(num15 * 40f + 15f);
white.B = (byte)(num15 * 40f + 15f);
}
else if (time >= 16200.0)
{
num15 = (float)((time / 32400.0 - 0.5) * 2.0);
white3.R = (byte)(num15 * 50f + 205f);
white3.G = (byte)(num15 * 100f + 155f);
white3.B = (byte)(num15 * 100f + 155f);
white.R = (byte)(num15 * 40f + 15f);
white.G = (byte)(num15 * 40f + 15f);
white.B = (byte)(num15 * 40f + 15f);
}
}
if (gameMenu || netMode == 2)
{
num8 = 0;
if (!dayTime)
{
white.R = 55;
white.G = 55;
white.B = 55;
}
}
if (evilTiles > 0)
{
float num18 = (float)evilTiles / 500f;
if (num18 > 1f)
{
num18 = 1f;
}
int r = white.R;
int g = white.G;
int b = white.B;
r += (int)(10f * num18);
g -= (int)(90f * num18 * ((float)(int)white.G / 255f));
b -= (int)(190f * num18 * ((float)(int)white.B / 255f));
if (r > 255)
{
r = 255;
}
if (g < 15)
{
g = 15;
}
if (b < 15)
{
b = 15;
}
white.R = (byte)r;
white.G = (byte)g;
white.B = (byte)b;
r = white2.R;
g = white2.G;
b = white2.B;
r -= (int)(100f * num18 * ((float)(int)white2.R / 255f));
g -= (int)(160f * num18 * ((float)(int)white2.G / 255f));
b -= (int)(170f * num18 * ((float)(int)white2.B / 255f));
if (r < 15)
{
r = 15;
}
if (g < 15)
{
g = 15;
}
if (b < 15)
{
b = 15;
}
white2.R = (byte)r;
white2.G = (byte)g;
white2.B = (byte)b;
r = white3.R;
g = white3.G;
b = white3.B;
r -= (int)(140f * num18 * ((float)(int)white3.R / 255f));
g -= (int)(170f * num18 * ((float)(int)white3.G / 255f));
b -= (int)(190f * num18 * ((float)(int)white3.B / 255f));
if (r < 15)
{
r = 15;
}
if (g < 15)
{
g = 15;
}
if (b < 15)
{
b = 15;
}
white3.R = (byte)r;
white3.G = (byte)g;
white3.B = (byte)b;
}
if (jungleTiles > 0)
{
float num19 = (float)jungleTiles / 200f;
if (num19 > 1f)
{
num19 = 1f;
}
int r2 = white.R;
int num20 = white.G;
int b2 = white.B;
r2 -= (int)(20f * num19 * ((float)(int)white.R / 255f));
b2 -= (int)(120f * num19 * ((float)(int)white.B / 255f));
if (num20 > 255)
{
num20 = 255;
}
if (num20 < 15)
{
num20 = 15;
}
if (r2 > 255)
{
r2 = 255;
}
if (r2 < 15)
{
r2 = 15;
}
if (b2 < 15)
{
b2 = 15;
}
white.R = (byte)r2;
white.G = (byte)num20;
white.B = (byte)b2;
r2 = white2.R;
num20 = white2.G;
b2 = white2.B;
num20 -= (int)(10f * num19 * ((float)(int)white2.G / 255f));
r2 -= (int)(50f * num19 * ((float)(int)white2.R / 255f));
b2 -= (int)(10f * num19 * ((float)(int)white2.B / 255f));
if (r2 < 15)
{
r2 = 15;
}
if (num20 < 15)
{
num20 = 15;
}
if (b2 < 15)
{
b2 = 15;
}
white2.R = (byte)r2;
white2.G = (byte)num20;
white2.B = (byte)b2;
r2 = white3.R;
num20 = white3.G;
b2 = white3.B;
num20 -= (int)(140f * num19 * ((float)(int)white3.R / 255f));
r2 -= (int)(170f * num19 * ((float)(int)white3.G / 255f));
b2 -= (int)(190f * num19 * ((float)(int)white3.B / 255f));
if (r2 < 15)
{
r2 = 15;
}
if (num20 < 15)
{
num20 = 15;
}
if (b2 < 15)
{
b2 = 15;
}
white3.R = (byte)r2;
white3.G = (byte)num20;
white3.B = (byte)b2;
}
tileColor.A = byte.MaxValue;
tileColor.R = (byte)((white.R + white.B + white.G) / 3);
tileColor.G = (byte)((white.R + white.B + white.G) / 3);
tileColor.B = (byte)((white.R + white.B + white.G) / 3);
if ((double)screenPosition.Y < worldSurface * 16.0 + 16.0)
{
for (int i = 0; i < num5; i++)
{
spriteBatch.Draw(backgroundTexture[background], new Rectangle(num4 + backgroundWidth[background] * i, num8, backgroundWidth[background], backgroundHeight[background]), white);
}
}
if ((double)screenPosition.Y < worldSurface * 16.0 + 16.0 && 255 - tileColor.R - 100 > 0 && netMode != 2)
{
for (int j = 0; j < numStars; j++)
{
Color color = default(Color);
float num21 = (float)evilTiles / 500f;
if (num21 > 1f)
{
num21 = 1f;
}
num21 = 1f - num21 * 0.5f;
if (evilTiles <= 0)
{
num21 = 1f;
}
int num22 = (int)((float)(255 - tileColor.R - 100) * star[j].twinkle * num21);
int num23 = (int)((float)(255 - tileColor.G - 100) * star[j].twinkle * num21);
int num24 = (int)((float)(255 - tileColor.B - 100) * star[j].twinkle * num21);
if (num22 < 0)
{
num22 = 0;
}
if (num23 < 0)
{
num23 = 0;
}
if (num24 < 0)
{
num24 = 0;
}
color.R = (byte)num22;
color.G = (byte)((float)num23 * num21);
color.B = (byte)((float)num24 * num21);
float num25 = star[j].position.X * ((float)screenWidth / 800f);
float num26 = star[j].position.Y * ((float)screenHeight / 600f);
spriteBatch.Draw(starTexture[star[j].type], new Vector2(num25 + (float)starTexture[star[j].type].Width * 0.5f, num26 + (float)starTexture[star[j].type].Height * 0.5f + (float)num8), new Rectangle(0, 0, starTexture[star[j].type].Width, starTexture[star[j].type].Height), color, star[j].rotation, new Vector2((float)starTexture[star[j].type].Width * 0.5f, (float)starTexture[star[j].type].Height * 0.5f), star[j].scale * star[j].twinkle, SpriteEffects.None, 0f);
}
}
if (dayTime)
{
if (!gameMenu && player[myPlayer].head == 12)
{
spriteBatch.Draw(sun2Texture, new Vector2(num9, num10 + sunModY), new Rectangle(0, 0, sunTexture.Width, sunTexture.Height), white2, rotation, new Vector2(sunTexture.Width / 2, sunTexture.Height / 2), num11, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(sunTexture, new Vector2(num9, num10 + sunModY), new Rectangle(0, 0, sunTexture.Width, sunTexture.Height), white2, rotation, new Vector2(sunTexture.Width / 2, sunTexture.Height / 2), num11, SpriteEffects.None, 0f);
}
}
if (!dayTime)
{
spriteBatch.Draw(moonTexture, new Vector2(num12, num13 + moonModY), new Rectangle(0, moonTexture.Width * moonPhase, moonTexture.Width, moonTexture.Width), white3, rotation2, new Vector2(moonTexture.Width / 2, moonTexture.Width / 2), num14, SpriteEffects.None, 0f);
}
Rectangle value = ((!dayTime) ? new Rectangle(num12 - (int)((double)moonTexture.Width * 0.5 * (double)num14), (int)((double)num13 - (double)moonTexture.Width * 0.5 * (double)num14 + (double)moonModY), (int)((float)moonTexture.Width * num14), (int)((float)moonTexture.Width * num14)) : new Rectangle(num9 - (int)((double)sunTexture.Width * 0.5 * (double)num11), (int)((double)num10 - (double)sunTexture.Height * 0.5 * (double)num11 + (double)sunModY), (int)((float)sunTexture.Width * num11), (int)((float)sunTexture.Width * num11)));
Rectangle rectangle = new Rectangle(mouseState.X, mouseState.Y, 1, 1);
sunModY = (short)((double)sunModY * 0.999);
moonModY = (short)((double)moonModY * 0.999);
if (gameMenu && netMode != 1)
{
if (mouseState.LeftButton == ButtonState.Pressed && hasFocus)
{
if (rectangle.Intersects(value) || grabSky)
{
if (dayTime)
{
time = 54000.0 * (double)((float)(mouseState.X + sunTexture.Width) / (float)(screenWidth + sunTexture.Width * 2));
sunModY = (short)(mouseState.Y - num10);
if (time > 53990.0)
{
time = 53990.0;
}
}
else
{
time = 32400.0 * (double)((float)(mouseState.X + moonTexture.Width) / (float)(screenWidth + moonTexture.Width * 2));
moonModY = (short)(mouseState.Y - num13);
if (time > 32390.0)
{
time = 32390.0;
}
}
if (time < 10.0)
{
time = 10.0;
}
if (netMode != 0)
{
NetMessage.SendData(18);
}
grabSky = true;
}
}
else
{
grabSky = false;
}
}
if (resetClouds)
{
Cloud.resetClouds();
resetClouds = false;
}
if (base.IsActive || netMode != 0)
{
windSpeedSpeed += (float)rand.Next(-10, 11) * 0.0001f;
if ((double)windSpeedSpeed < -0.002)
{
windSpeedSpeed = -0.002f;
}
if ((double)windSpeedSpeed > 0.002)
{
windSpeedSpeed = 0.002f;
}
windSpeed += windSpeedSpeed;
if ((double)windSpeed < -0.3)
{
windSpeed = -0.3f;
}
if ((double)windSpeed > 0.3)
{
windSpeed = 0.3f;
}
numClouds += rand.Next(-1, 2);
if (numClouds < 0)
{
numClouds = 0;
}
if (numClouds > cloudLimit)
{
numClouds = cloudLimit;
}
}
if ((double)screenPosition.Y < worldSurface * 16.0 + 16.0)
{
for (int k = 0; k < 100; k++)
{
if (cloud[k].active)
{
int num27 = (int)(40f * (2f - cloud[k].scale));
int num28 = 0;
Color color2 = default(Color);
num28 = white.R - num27;
if (num28 <= 0)
{
num28 = 0;
}
color2.R = (byte)num28;
num28 = white.G - num27;
if (num28 <= 0)
{
num28 = 0;
}
color2.G = (byte)num28;
num28 = white.B - num27;
if (num28 <= 0)
{
num28 = 0;
}
color2.B = (byte)num28;
color2.A = (byte)(255 - num27);
float num29 = cloud[k].position.Y * ((float)screenHeight / 600f);
spriteBatch.Draw(cloudTexture[cloud[k].type], new Vector2(cloud[k].position.X + (float)cloudTexture[cloud[k].type].Width * 0.5f, num29 + (float)cloudTexture[cloud[k].type].Height * 0.5f + (float)num8), new Rectangle(0, 0, cloudTexture[cloud[k].type].Width, cloudTexture[cloud[k].type].Height), color2, cloud[k].rotation, new Vector2((float)cloudTexture[cloud[k].type].Width * 0.5f, (float)cloudTexture[cloud[k].type].Height * 0.5f), cloud[k].scale, SpriteEffects.None, 0f);
}
}
}
if (gameMenu || netMode == 2)
{
DrawMenu();
return;
}
int num30 = (int)(screenPosition.X / 16f - 1f);
int num31 = (int)((screenPosition.X + (float)screenWidth) / 16f) + 2;
int num32 = (int)(screenPosition.Y / 16f - 1f);
int num33 = (int)((screenPosition.Y + (float)screenHeight) / 16f) + 2;
if (num30 < 0)
{
num30 = 0;
}
if (num31 > maxTilesX)
{
num31 = maxTilesX;
}
if (num32 < 0)
{
num32 = 0;
}
if (num33 > maxTilesY)
{
num33 = maxTilesY;
}
Lighting.LightTiles(num30, num31, num32, num33);
Color white4 = Color.White;
if (ignoreErrors)
{
try
{
DrawWater(bg: true);
}
catch
{
}
}
else
{
DrawWater(bg: true);
}
num3 = caveParrallax;
num4 = (int)(0.0 - Math.IEEERemainder((double)screenPosition.X * num3, backgroundWidth[1])) - backgroundWidth[1] / 2;
num5 = screenWidth / backgroundWidth[1] + 2;
num8 = (int)((float)((int)worldSurface * 16 - backgroundHeight[1]) - screenPosition.Y + 16f);
for (int l = 0; l < num5; l++)
{
for (int m = 0; m < 6; m++)
{
int num34 = (num4 + backgroundWidth[1] * l + m * 16) / 16;
int num35 = num8 / 16;
Color color3 = Lighting.GetColor(num34 + (int)(screenPosition.X / 16f), num35 + (int)(screenPosition.Y / 16f));
spriteBatch.Draw(backgroundTexture[1], new Vector2(num4 + backgroundWidth[1] * l + 16 * m, num8), new Rectangle(16 * m, 0, 16, 16), color3);
}
}
double num36 = maxTilesY - 230;
double num37 = (int)((num36 - worldSurface) / 6.0) * 6;
num36 = worldSurface + num37 - 5.0;
bool flag2 = false;
bool flag3 = false;
num8 = (int)((float)((int)worldSurface * 16) - screenPosition.Y + 16f);
if (worldSurface * 16.0 <= (double)(screenPosition.Y + (float)screenHeight))
{
num3 = caveParrallax;
num4 = (int)(0.0 - Math.IEEERemainder(100.0 + (double)screenPosition.X * num3, backgroundWidth[2])) - backgroundWidth[2] / 2;
num5 = screenWidth / backgroundWidth[2] + 2;
if (worldSurface * 16.0 < (double)(screenPosition.Y - 16f))
{
num6 = (int)Math.IEEERemainder(num8, backgroundHeight[2]) - backgroundHeight[2];
num7 = (screenHeight - num6) / backgroundHeight[2] + 1;
}
else
{
num6 = num8;
num7 = (screenHeight - num8) / backgroundHeight[2] + 1;
}
if (rockLayer * 16.0 < (double)(screenPosition.Y + 600f))
{
num7 = ((int)(rockLayer * 16.0 - (double)screenPosition.Y + 600.0) - num6) / backgroundHeight[2];
flag3 = true;
}
for (int n = 0; n < num5; n++)
{
for (int num38 = 0; num38 < num7; num38++)
{
spriteBatch.Draw(backgroundTexture[2], new Rectangle(num4 + backgroundWidth[2] * n, num6 + backgroundHeight[2] * num38, backgroundWidth[2], backgroundHeight[2]), Color.White);
}
}
if (flag3)
{
num3 = caveParrallax;
num4 = (int)(0.0 - Math.IEEERemainder((double)screenPosition.X * num3, backgroundWidth[1])) - backgroundWidth[1] / 2;
num5 = screenWidth / backgroundWidth[1] + 2;
num8 = num6 + num7 * backgroundHeight[2];
for (int num39 = 0; num39 < num5; num39++)
{
for (int num40 = 0; num40 < 6; num40++)
{
int num41 = (num4 + backgroundWidth[4] * num39 + num40 * 16) / 16;
int num42 = num8 / 16;
spriteBatch.Draw(backgroundTexture[4], new Vector2(num4 + backgroundWidth[4] * num39 + 16 * num40, num8), new Rectangle(16 * num40, 0, 16, 24), Color.White);
}
}
}
}
num8 = (int)((float)((int)rockLayer * 16) - screenPosition.Y + 16f + 600f);
if (rockLayer * 16.0 <= (double)(screenPosition.Y + 600f))
{
num3 = caveParrallax;
num4 = (int)(0.0 - Math.IEEERemainder(100.0 + (double)screenPosition.X * num3, backgroundWidth[3])) - backgroundWidth[3] / 2;
num5 = screenWidth / backgroundWidth[3] + 2;
if (rockLayer * 16.0 + (double)screenHeight < (double)(screenPosition.Y - 16f))
{
num6 = (int)Math.IEEERemainder(num8, backgroundHeight[3]) - backgroundHeight[3];
num7 = (screenHeight - num6) / backgroundHeight[3] + 1;
}
else
{
num6 = num8;
num7 = (screenHeight - num8) / backgroundHeight[3] + 1;
}
if (num36 * 16.0 < (double)(screenPosition.Y + 600f))
{
num7 = ((int)(num36 * 16.0 - (double)screenPosition.Y + 600.0) - num6) / backgroundHeight[2];
flag2 = true;
}
for (int num43 = 0; num43 < num5; num43++)
{
for (int num44 = 0; num44 < num7; num44++)
{
spriteBatch.Draw(backgroundTexture[3], new Rectangle(num4 + backgroundWidth[2] * num43, num6 + backgroundHeight[2] * num44, backgroundWidth[2], backgroundHeight[2]), Color.White);
}
}
if (flag2)
{
num3 = caveParrallax;
num4 = (int)(0.0 - Math.IEEERemainder((double)screenPosition.X * num3, backgroundWidth[1]) - (double)(backgroundWidth[1] / 2) - 4.0);
num5 = screenWidth / backgroundWidth[1] + 2;
num8 = num6 + num7 * backgroundHeight[2];
for (int num45 = 0; num45 < num5; num45++)
{
for (int num46 = 0; num46 < 6; num46++)
{
int num47 = (num4 + backgroundWidth[1] * num45 + num46 * 16) / 16;
int num48 = num8 / 16;
Lighting.GetColor(num47 + (int)(screenPosition.X / 16f), num48 + (int)(screenPosition.Y / 16f));
spriteBatch.Draw(backgroundTexture[6], new Vector2(num4 + backgroundWidth[1] * num45 + 16 * num46, num8), new Rectangle(16 * num46, magmaBGFrame * 24, 16, 24), Color.White);
}
}
}
}
num8 = (int)((float)((int)num36 * 16) - screenPosition.Y + 16f + 600f) + 8;
if (num36 * 16.0 <= (double)(screenPosition.Y + 600f))
{
num4 = (int)(0.0 - Math.IEEERemainder(100.0 + (double)screenPosition.X * num3, backgroundWidth[3])) - backgroundWidth[3] / 2;
num5 = screenWidth / backgroundWidth[3] + 2;
if (num36 * 16.0 + (double)screenHeight < (double)(screenPosition.Y - 16f))
{
num6 = (int)Math.IEEERemainder(num8, backgroundHeight[3]) - backgroundHeight[3];
num7 = (screenHeight - num6) / backgroundHeight[3] + 1;
}
else
{
num6 = num8;
num7 = (screenHeight - num8) / backgroundHeight[3] + 1;
}
for (int num49 = 0; num49 < num5; num49++)
{
for (int num50 = 0; num50 < num7; num50++)
{
spriteBatch.Draw(backgroundTexture[5], new Vector2(num4 + backgroundWidth[2] * num49, num6 + backgroundHeight[2] * num50), new Rectangle(0, backgroundHeight[2] * magmaBGFrame, backgroundWidth[2], backgroundHeight[2]), Color.White, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
magmaBGFrameCounter++;
if (magmaBGFrameCounter >= 8)
{
magmaBGFrameCounter = 0;
magmaBGFrame++;
if (magmaBGFrame >= 3)
{
magmaBGFrame = 0;
}
}
try
{
for (int num51 = num32; num51 < num33 + 4; num51++)
{
for (int num52 = num30 - 2; num52 < num31 + 2; num52++)
{
if (tile[num52, num51] == null)
{
tile[num52, num51] = new Tile();
}
if (Lighting.Brightness(num52, num51) * 255f < (float)(tileColor.R - 12) || (double)num51 > worldSurface)
{
spriteBatch.Draw(blackTileTexture, new Vector2(num52 * 16 - (int)screenPosition.X, num51 * 16 - (int)screenPosition.Y), new Rectangle(tile[num52, num51].frameX, tile[num52, num51].frameY, 16, 16), Lighting.GetBlackness(num52, num51), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
for (int num53 = num32; num53 < num33 + 4; num53++)
{
for (int num54 = num30 - 2; num54 < num31 + 2; num54++)
{
if (tile[num54, num53].wall > 0 && Lighting.Brightness(num54, num53) > 0f)
{
if (tile[num54, num53].wallFrameY == 18 && tile[num54, num53].wallFrameX >= 18)
{
byte wallFrameY = tile[num54, num53].wallFrameY;
}
Rectangle value2 = new Rectangle(tile[num54, num53].wallFrameX * 2, tile[num54, num53].wallFrameY * 2, 32, 32);
spriteBatch.Draw(wallTexture[tile[num54, num53].wall], new Vector2(num54 * 16 - (int)screenPosition.X - 8, num53 * 16 - (int)screenPosition.Y - 8), value2, Lighting.GetColor(num54, num53), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
if (player[myPlayer].detectCreature)
{
DrawTiles(solidOnly: false);
DrawTiles();
DrawGore();
DrawNPCs(behindTiles: true);
DrawNPCs();
}
else
{
DrawTiles(solidOnly: false);
DrawNPCs(behindTiles: true);
DrawTiles();
DrawGore();
DrawNPCs();
}
}
catch
{
}
for (int num55 = 0; num55 < 1000; num55++)
{
if (projectile[num55].active && projectile[num55].type > 0 && !projectile[num55].hide)
{
DrawProj(num55);
}
}
for (int num56 = 0; num56 < 255; num56++)
{
if (!player[num56].active)
{
continue;
}
if (player[num56].ghost)
{
Vector2 position = player[num56].position;
player[num56].position = player[num56].shadowPos[0];
player[num56].shadow = 0.5f;
DrawGhost(player[num56]);
player[num56].position = player[num56].shadowPos[1];
player[num56].shadow = 0.7f;
DrawGhost(player[num56]);
player[num56].position = player[num56].shadowPos[2];
player[num56].shadow = 0.9f;
DrawGhost(player[num56]);
player[num56].position = position;
player[num56].shadow = 0f;
DrawGhost(player[num56]);
continue;
}
if ((player[num56].head == 5 && player[num56].body == 5 && player[num56].legs == 5) || (player[num56].head == 7 && player[num56].body == 7 && player[num56].legs == 7) || (player[num56].head == 22 && player[num56].body == 14 && player[num56].legs == 14))
{
Vector2 position2 = player[num56].position;
player[num56].position = player[num56].shadowPos[0];
player[num56].shadow = 0.5f;
DrawPlayer(player[num56]);
player[num56].position = player[num56].shadowPos[1];
player[num56].shadow = 0.7f;
DrawPlayer(player[num56]);
player[num56].position = player[num56].shadowPos[2];
player[num56].shadow = 0.9f;
DrawPlayer(player[num56]);
player[num56].position = position2;
player[num56].shadow = 0f;
}
DrawPlayer(player[num56]);
}
for (int num57 = 0; num57 < 200; num57++)
{
if (!item[num57].active || item[num57].type <= 0)
{
continue;
}
int num58 = (int)((double)item[num57].position.X + (double)item[num57].width * 0.5) / 16;
int num59 = (int)((double)item[num57].position.Y + (double)item[num57].height * 0.5) / 16;
Color color4 = Lighting.GetColor((int)((double)item[num57].position.X + (double)item[num57].width * 0.5) / 16, (int)((double)item[num57].position.Y + (double)item[num57].height * 0.5) / 16);
if (!gamePaused && base.IsActive && ((item[num57].type >= 71 && item[num57].type <= 74) || item[num57].type == 58 || item[num57].type == 109) && color4.R > 60)
{
float num60 = (float)rand.Next(500) - (Math.Abs(item[num57].velocity.X) + Math.Abs(item[num57].velocity.Y)) * 10f;
if (num60 < (float)(color4.R / 50))
{
int num61 = Dust.NewDust(item[num57].position, item[num57].width, item[num57].height, 43, 0f, 0f, 254, default(Color), 0.5f);
Dust dust = Main.dust[num61];
dust.velocity *= 0f;
}
}
spriteBatch.Draw(itemTexture[item[num57].type], new Vector2(item[num57].position.X - screenPosition.X + (float)(item[num57].width / 2) - (float)(itemTexture[item[num57].type].Width / 2), item[num57].position.Y - screenPosition.Y + (float)(item[num57].height / 2) - (float)(itemTexture[item[num57].type].Height / 2)), new Rectangle(0, 0, itemTexture[item[num57].type].Width, itemTexture[item[num57].type].Height), item[num57].GetAlpha(color4), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
if (item[num57].color != default(Color))
{
spriteBatch.Draw(itemTexture[item[num57].type], new Vector2(item[num57].position.X - screenPosition.X + (float)(item[num57].width / 2) - (float)(itemTexture[item[num57].type].Width / 2), item[num57].position.Y - screenPosition.Y + (float)(item[num57].height / 2) - (float)(itemTexture[item[num57].type].Height / 2)), new Rectangle(0, 0, itemTexture[item[num57].type].Width, itemTexture[item[num57].type].Height), item[num57].GetColor(color4), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
Rectangle value3 = new Rectangle((int)screenPosition.X - 50, (int)screenPosition.Y - 50, screenWidth + 100, screenHeight + 100);
for (int num62 = 0; num62 < numDust; num62++)
{
if (!Main.dust[num62].active)
{
continue;
}
if (new Rectangle((int)Main.dust[num62].position.X, (int)Main.dust[num62].position.Y, 4, 4).Intersects(value3))
{
Color newColor = Lighting.GetColor((int)((double)Main.dust[num62].position.X + 4.0) / 16, (int)((double)Main.dust[num62].position.Y + 4.0) / 16);
if (Main.dust[num62].type == 6 || Main.dust[num62].type == 15 || Main.dust[num62].noLight)
{
newColor = Color.White;
}
newColor = Main.dust[num62].GetAlpha(newColor);
spriteBatch.Draw(dustTexture, Main.dust[num62].position - screenPosition, Main.dust[num62].frame, newColor, Main.dust[num62].rotation, new Vector2(4f, 4f), Main.dust[num62].scale, SpriteEffects.None, 0f);
if (Main.dust[num62].color != default(Color))
{
spriteBatch.Draw(dustTexture, Main.dust[num62].position - screenPosition, Main.dust[num62].frame, Main.dust[num62].GetColor(newColor), Main.dust[num62].rotation, new Vector2(4f, 4f), Main.dust[num62].scale, SpriteEffects.None, 0f);
}
if (newColor == Color.Black)
{
Main.dust[num62].active = false;
}
}
else
{
Main.dust[num62].active = false;
}
}
if (ignoreErrors)
{
try
{
DrawWater();
}
catch
{
}
}
else
{
DrawWater();
}
if (!hideUI)
{
Vector2 vector2 = default(Vector2);
for (int num63 = 0; num63 < 255; num63++)
{
if (!player[num63].active || player[num63].chatShowTime <= 0 || num63 == myPlayer || player[num63].dead)
{
continue;
}
Vector2 vector = fontMouseText.MeasureString(player[num63].chatText);
vector2.X = player[num63].position.X + (float)(player[num63].width / 2) - vector.X / 2f;
vector2.Y = player[num63].position.Y - vector.Y - 2f;
for (int num64 = 0; num64 < 5; num64++)
{
int num65 = 0;
int num66 = 0;
Color color5 = Color.Black;
switch (num64)
{
case 0:
num65 = -2;
break;
case 1:
num65 = 2;
break;
case 2:
num66 = -2;
break;
case 3:
num66 = 2;
break;
case 4:
color5 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
break;
}
spriteBatch.DrawString(fontMouseText, player[num63].chatText, new Vector2(vector2.X + (float)num65 - screenPosition.X, vector2.Y + (float)num66 - screenPosition.Y), color5, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
for (int num67 = 0; num67 < 100; num67++)
{
if (!combatText[num67].active)
{
continue;
}
int num68 = 0;
if (combatText[num67].crit)
{
num68 = 1;
}
Vector2 vector3 = fontCombatText[num68].MeasureString(combatText[num67].text);
Vector2 origin = new Vector2(vector3.X * 0.5f, vector3.Y * 0.5f);
float scale = combatText[num67].scale;
float num69 = (int)combatText[num67].color.R;
float num70 = (int)combatText[num67].color.G;
float num71 = (int)combatText[num67].color.B;
float num72 = (int)combatText[num67].color.A;
num69 *= combatText[num67].scale * combatText[num67].alpha * 0.3f;
num71 *= combatText[num67].scale * combatText[num67].alpha * 0.3f;
num70 *= combatText[num67].scale * combatText[num67].alpha * 0.3f;
num72 *= combatText[num67].scale * combatText[num67].alpha;
Color color6 = new Color((int)num69, (int)num70, (int)num71, (int)num72);
for (int num73 = 0; num73 < 5; num73++)
{
int num74 = 0;
int num75 = 0;
switch (num73)
{
case 0:
num74--;
break;
case 1:
num74++;
break;
case 2:
num75--;
break;
case 3:
num75++;
break;
default:
num69 = (float)(int)combatText[num67].color.R * combatText[num67].scale * combatText[num67].alpha;
num71 = (float)(int)combatText[num67].color.B * combatText[num67].scale * combatText[num67].alpha;
num70 = (float)(int)combatText[num67].color.G * combatText[num67].scale * combatText[num67].alpha;
num72 = (float)(int)combatText[num67].color.A * combatText[num67].scale * combatText[num67].alpha;
color6 = new Color((int)num69, (int)num70, (int)num71, (int)num72);
break;
}
spriteBatch.DrawString(fontCombatText[num68], combatText[num67].text, new Vector2(combatText[num67].position.X - screenPosition.X + (float)num74 + origin.X, combatText[num67].position.Y - screenPosition.Y + (float)num75 + origin.Y), color6, combatText[num67].rotation, origin, combatText[num67].scale, SpriteEffects.None, 0f);
}
}
for (int num76 = 0; num76 < 100; num76++)
{
if (!itemText[num76].active)
{
continue;
}
string text = itemText[num76].name;
if (itemText[num76].stack > 1)
{
text = text + " (" + itemText[num76].stack + ")";
}
Vector2 vector4 = fontMouseText.MeasureString(text);
Vector2 origin2 = new Vector2(vector4.X * 0.5f, vector4.Y * 0.5f);
float scale2 = itemText[num76].scale;
float num77 = (int)itemText[num76].color.R;
float num78 = (int)itemText[num76].color.G;
float num79 = (int)itemText[num76].color.B;
float num80 = (int)itemText[num76].color.A;
num77 *= itemText[num76].scale * itemText[num76].alpha * 0.3f;
num79 *= itemText[num76].scale * itemText[num76].alpha * 0.3f;
num78 *= itemText[num76].scale * itemText[num76].alpha * 0.3f;
num80 *= itemText[num76].scale * itemText[num76].alpha;
Color color7 = new Color((int)num77, (int)num78, (int)num79, (int)num80);
for (int num81 = 0; num81 < 5; num81++)
{
int num82 = 0;
int num83 = 0;
switch (num81)
{
case 0:
num82 -= 2;
break;
case 1:
num82 += 2;
break;
case 2:
num83 -= 2;
break;
case 3:
num83 += 2;
break;
default:
num77 = (float)(int)itemText[num76].color.R * itemText[num76].scale * itemText[num76].alpha;
num79 = (float)(int)itemText[num76].color.B * itemText[num76].scale * itemText[num76].alpha;
num78 = (float)(int)itemText[num76].color.G * itemText[num76].scale * itemText[num76].alpha;
num80 = (float)(int)itemText[num76].color.A * itemText[num76].scale * itemText[num76].alpha;
color7 = new Color((int)num77, (int)num78, (int)num79, (int)num80);
break;
}
if (num81 < 4)
{
num80 = (float)(int)itemText[num76].color.A * itemText[num76].scale * itemText[num76].alpha;
color7 = new Color(0, 0, 0, (int)num80);
}
spriteBatch.DrawString(fontMouseText, text, new Vector2(itemText[num76].position.X - screenPosition.X + (float)num82 + origin2.X, itemText[num76].position.Y - screenPosition.Y + (float)num83 + origin2.Y), color7, itemText[num76].rotation, origin2, itemText[num76].scale, SpriteEffects.None, 0f);
}
}
if (netMode == 1 && Netplay.clientSock.statusText != "" && Netplay.clientSock.statusText != null)
{
string text2 = Netplay.clientSock.statusText + ": " + (int)((float)Netplay.clientSock.statusCount / (float)Netplay.clientSock.statusMax * 100f) + "%";
spriteBatch.DrawString(fontMouseText, text2, new Vector2(628f - fontMouseText.MeasureString(text2).X * 0.5f + (float)(screenWidth - 800), 84f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
DrawFPS();
DrawInterface();
DrawBox();
DrawLoadBox();
}
spriteBatch.End();
if (mouseState.LeftButton == ButtonState.Pressed)
{
mouseLeftRelease = false;
}
else
{
mouseLeftRelease = true;
}
if (mouseState.RightButton == ButtonState.Pressed)
{
mouseRightRelease = false;
}
else
{
mouseRightRelease = true;
}
if (mouseState.RightButton != ButtonState.Pressed)
{
stackSplit = 0;
}
if (stackSplit > 0)
{
stackSplit--;
}
}
protected void DrawChat()
{
if (player[myPlayer].talkNPC < 0 && player[myPlayer].sign == -1)
{
npcChatText = "";
return;
}
Color color = new Color(200, 200, 200, 200);
int num = (mouseTextColor * 2 + 255) / 3;
Color color2 = new Color(num, num, num, num);
int num2 = 10;
int num3 = 0;
string[] array = new string[num2];
int num4 = 0;
int num5 = 0;
if (npcChatText == null)
{
npcChatText = "";
}
for (int i = 0; i < npcChatText.Length; i++)
{
if (Encoding.ASCII.GetBytes(npcChatText.Substring(i, 1))[0] == 10)
{
array[num3] = npcChatText.Substring(num4, i - num4);
num3++;
num4 = i + 1;
num5 = i + 1;
}
else if (npcChatText.Substring(i, 1) == " " || i == npcChatText.Length - 1)
{
if (fontMouseText.MeasureString(npcChatText.Substring(num4, i - num4)).X > 470f)
{
array[num3] = npcChatText.Substring(num4, num5 - num4);
num3++;
num4 = num5 + 1;
}
num5 = i;
}
if (num3 == 10)
{
npcChatText = npcChatText.Substring(0, i - 1);
num4 = i - 1;
num3 = 9;
break;
}
}
if (num3 < 10)
{
array[num3] = npcChatText.Substring(num4, npcChatText.Length - num4);
}
if (editSign)
{
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
if (textBlinkerState == 1)
{
string[] array2;
IntPtr intPtr;
(array2 = array)[(int)(intPtr = (IntPtr)num3)] = array2[(int)intPtr] + "|";
}
}
num3++;
spriteBatch.Draw(chatBackTexture, new Vector2(screenWidth / 2 - chatBackTexture.Width / 2, 100f), new Rectangle(0, 0, chatBackTexture.Width, (num3 + 1) * 30), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(chatBackTexture, new Vector2(screenWidth / 2 - chatBackTexture.Width / 2, 100 + (num3 + 1) * 30), new Rectangle(0, chatBackTexture.Height - 30, chatBackTexture.Width, 30), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
for (int j = 0; j < num3; j++)
{
for (int k = 0; k < 5; k++)
{
Color color3 = Color.Black;
int num6 = 170 + (screenWidth - 800) / 2;
int num7 = 120 + j * 30;
switch (k)
{
case 0:
num6 -= 2;
break;
case 1:
num6 += 2;
break;
case 2:
num7 -= 2;
break;
case 3:
num7 += 2;
break;
case 4:
color3 = color2;
break;
}
spriteBatch.DrawString(fontMouseText, array[j], new Vector2(num6, num7), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
num = mouseTextColor;
color2 = new Color(num, (int)((double)num / 1.1), num / 2, num);
string text = "";
string text2 = "";
int num8 = player[myPlayer].statLifeMax - player[myPlayer].statLife;
if (player[myPlayer].sign > -1)
{
text = ((!editSign) ? "Edit" : "Save");
}
else if (npc[player[myPlayer].talkNPC].type == 17 || npc[player[myPlayer].talkNPC].type == 19 || npc[player[myPlayer].talkNPC].type == 20 || npc[player[myPlayer].talkNPC].type == 38 || npc[player[myPlayer].talkNPC].type == 54)
{
text = "Shop";
}
else if (npc[player[myPlayer].talkNPC].type == 37)
{
if (!dayTime)
{
text = "Curse";
}
}
else if (npc[player[myPlayer].talkNPC].type == 22)
{
text = "Help";
text2 = "Crafting";
}
else if (npc[player[myPlayer].talkNPC].type == 18)
{
string text3 = "";
int num9 = 0;
int num10 = 0;
int num11 = 0;
int num12 = 0;
int num13 = num8;
if (num13 > 0)
{
num13 = (int)((double)num13 * 0.75);
if (num13 < 1)
{
num13 = 1;
}
}
if (num13 < 0)
{
num13 = 0;
}
num8 = num13;
if (num13 >= 1000000)
{
num9 = num13 / 1000000;
num13 -= num9 * 1000000;
}
if (num13 >= 10000)
{
num10 = num13 / 10000;
num13 -= num10 * 10000;
}
if (num13 >= 100)
{
num11 = num13 / 100;
num13 -= num11 * 100;
}
if (num13 >= 1)
{
num12 = num13;
}
if (num9 > 0)
{
text3 = text3 + num9 + " platinum ";
}
if (num10 > 0)
{
text3 = text3 + num10 + " gold ";
}
if (num11 > 0)
{
text3 = text3 + num11 + " silver ";
}
if (num12 > 0)
{
text3 = text3 + num12 + " copper ";
}
float num14 = (float)(int)mouseTextColor / 255f;
if (num9 > 0)
{
color2 = new Color((byte)(220f * num14), (byte)(220f * num14), (byte)(198f * num14), mouseTextColor);
}
else if (num10 > 0)
{
color2 = new Color((byte)(224f * num14), (byte)(201f * num14), (byte)(92f * num14), mouseTextColor);
}
else if (num11 > 0)
{
color2 = new Color((byte)(181f * num14), (byte)(192f * num14), (byte)(193f * num14), mouseTextColor);
}
else if (num12 > 0)
{
color2 = new Color((byte)(246f * num14), (byte)(138f * num14), (byte)(96f * num14), mouseTextColor);
}
text = "Heal (" + text3 + ")";
if (num13 == 0)
{
text = "Heal";
}
}
int num15 = 180 + (screenWidth - 800) / 2;
int num16 = 130 + num3 * 30;
float scale = 0.9f;
if (mouseState.X > num15 && (float)mouseState.X < (float)num15 + fontMouseText.MeasureString(text).X && mouseState.Y > num16 && (float)mouseState.Y < (float)num16 + fontMouseText.MeasureString(text).Y)
{
player[myPlayer].mouseInterface = true;
scale = 1.1f;
if (!npcChatFocus2)
{
PlaySound(12);
}
npcChatFocus2 = true;
player[myPlayer].releaseUseItem = false;
}
else
{
if (npcChatFocus2)
{
PlaySound(12);
}
npcChatFocus2 = false;
}
for (int l = 0; l < 5; l++)
{
int num17 = num15;
int num18 = num16;
Color color4 = Color.Black;
switch (l)
{
case 0:
num17 -= 2;
break;
case 1:
num17 += 2;
break;
case 2:
num18 -= 2;
break;
case 3:
num18 += 2;
break;
case 4:
color4 = color2;
break;
}
Vector2 origin = fontMouseText.MeasureString(text) * 0.5f;
spriteBatch.DrawString(fontMouseText, text, new Vector2((float)num17 + origin.X, (float)num18 + origin.Y), color4, 0f, origin, scale, SpriteEffects.None, 0f);
}
color2 = new Color(num, (int)((double)num / 1.1), num / 2, num);
num15 = num15 + (int)fontMouseText.MeasureString(text).X + 20;
num16 = 130 + num3 * 30;
scale = 0.9f;
if (mouseState.X > num15 && (float)mouseState.X < (float)num15 + fontMouseText.MeasureString("Close").X && mouseState.Y > num16 && (float)mouseState.Y < (float)num16 + fontMouseText.MeasureString("Close").Y)
{
scale = 1.1f;
if (!npcChatFocus1)
{
PlaySound(12);
}
npcChatFocus1 = true;
player[myPlayer].releaseUseItem = false;
player[myPlayer].controlUseItem = false;
}
else
{
if (npcChatFocus1)
{
PlaySound(12);
}
npcChatFocus1 = false;
}
for (int m = 0; m < 5; m++)
{
int num19 = num15;
int num20 = num16;
Color color5 = Color.Black;
switch (m)
{
case 0:
num19 -= 2;
break;
case 1:
num19 += 2;
break;
case 2:
num20 -= 2;
break;
case 3:
num20 += 2;
break;
case 4:
color5 = color2;
break;
}
Vector2 origin2 = fontMouseText.MeasureString("Close") * 0.5f;
spriteBatch.DrawString(fontMouseText, "Close", new Vector2((float)num19 + origin2.X, (float)num20 + origin2.Y), color5, 0f, origin2, scale, SpriteEffects.None, 0f);
}
if (text2 != "")
{
num15 = 296 + (screenWidth - 800) / 2;
num16 = 130 + num3 * 30;
scale = 0.9f;
if (mouseState.X > num15 && (float)mouseState.X < (float)num15 + fontMouseText.MeasureString(text2).X && mouseState.Y > num16 && (float)mouseState.Y < (float)num16 + fontMouseText.MeasureString(text2).Y)
{
player[myPlayer].mouseInterface = true;
scale = 1.1f;
if (!npcChatFocus3)
{
PlaySound(12);
}
npcChatFocus3 = true;
player[myPlayer].releaseUseItem = false;
}
else
{
if (npcChatFocus3)
{
PlaySound(12);
}
npcChatFocus3 = false;
}
for (int n = 0; n < 5; n++)
{
int num21 = num15;
int num22 = num16;
Color color6 = Color.Black;
switch (n)
{
case 0:
num21 -= 2;
break;
case 1:
num21 += 2;
break;
case 2:
num22 -= 2;
break;
case 3:
num22 += 2;
break;
case 4:
color6 = color2;
break;
}
Vector2 origin3 = fontMouseText.MeasureString(text) * 0.5f;
spriteBatch.DrawString(fontMouseText, text2, new Vector2((float)num21 + origin3.X, (float)num22 + origin3.Y), color6, 0f, origin3, scale, SpriteEffects.None, 0f);
}
}
if (mouseState.LeftButton != ButtonState.Pressed || !mouseLeftRelease)
{
return;
}
mouseLeftRelease = false;
player[myPlayer].releaseUseItem = false;
player[myPlayer].mouseInterface = true;
if (npcChatFocus1)
{
player[myPlayer].talkNPC = -1;
player[myPlayer].sign = -1;
editSign = false;
npcChatText = "";
PlaySound(11);
}
else if (npcChatFocus2)
{
if (player[myPlayer].sign == -1)
{
if (npc[player[myPlayer].talkNPC].type == 17)
{
playerInventory = true;
npcChatText = "";
npcShop = 1;
shop[npcShop].SetupShop(npcShop);
PlaySound(12);
}
else if (npc[player[myPlayer].talkNPC].type == 19)
{
playerInventory = true;
npcChatText = "";
npcShop = 2;
shop[npcShop].SetupShop(npcShop);
PlaySound(12);
}
else if (npc[player[myPlayer].talkNPC].type == 37)
{
if (netMode == 0)
{
NPC.SpawnSkeletron();
}
else
{
NetMessage.SendData(51, -1, -1, "", myPlayer, 1f);
}
npcChatText = "";
}
else if (npc[player[myPlayer].talkNPC].type == 20)
{
playerInventory = true;
npcChatText = "";
npcShop = 3;
shop[npcShop].SetupShop(npcShop);
PlaySound(12);
}
else if (npc[player[myPlayer].talkNPC].type == 38)
{
playerInventory = true;
npcChatText = "";
npcShop = 4;
shop[npcShop].SetupShop(npcShop);
PlaySound(12);
}
else if (npc[player[myPlayer].talkNPC].type == 54)
{
playerInventory = true;
npcChatText = "";
npcShop = 5;
shop[npcShop].SetupShop(npcShop);
PlaySound(12);
}
else if (npc[player[myPlayer].talkNPC].type == 22)
{
PlaySound(12);
HelpText();
}
else
{
if (npc[player[myPlayer].talkNPC].type != 18)
{
return;
}
PlaySound(12);
if (num8 <= 0)
{
switch (rand.Next(3))
{
case 0:
npcChatText = "I don't give happy endings.";
break;
case 1:
npcChatText = "I can't do anymore for you without plastic surgery.";
break;
case 2:
npcChatText = "Quit wasting my time.";
break;
}
}
else if (player[myPlayer].BuyItem(num8))
{
PlaySound(2, -1, -1, 4);
player[myPlayer].HealEffect(player[myPlayer].statLifeMax - player[myPlayer].statLife);
if ((double)player[myPlayer].statLife < (double)player[myPlayer].statLifeMax * 0.25)
{
npcChatText = "I managed to sew your face back on. Be more careful next time.";
}
else if ((double)player[myPlayer].statLife < (double)player[myPlayer].statLifeMax * 0.5)
{
npcChatText = "That's probably going to leave a scar.";
}
else if ((double)player[myPlayer].statLife < (double)player[myPlayer].statLifeMax * 0.75)
{
npcChatText = "All better. I don't want to see you jumping off anymore cliffs.";
}
else
{
npcChatText = "That didn't hurt too bad, now did it?";
}
player[myPlayer].statLife = player[myPlayer].statLifeMax;
}
else
{
switch (rand.Next(3))
{
case 0:
npcChatText = "I'm sorry, but you can't afford me.";
break;
case 1:
npcChatText = "I'm gonna need more gold than that.";
break;
case 2:
npcChatText = "I don't work for free you know.";
break;
}
}
}
}
else if (!editSign)
{
PlaySound(12);
editSign = true;
}
else
{
PlaySound(12);
int num23 = player[myPlayer].sign;
Sign.TextSign(num23, npcChatText);
editSign = false;
if (netMode == 1)
{
NetMessage.SendData(47, -1, -1, "", num23);
}
}
}
else if (npcChatFocus3 && player[myPlayer].talkNPC >= 0 && npc[player[myPlayer].talkNPC].type == 22)
{
playerInventory = true;
npcChatText = "";
PlaySound(12);
craftGuide = true;
}
}
protected void DrawFPS()
{
if (showFrameRate)
{
object obj = frameRate;
string text = string.Concat(obj, " (", Liquid.numLiquid + LiquidBuffer.numLiquidBuffer, ")");
spriteBatch.DrawString(fontMouseText, text, new Vector2(4f, screenHeight - 24), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
protected void DrawGhost(Player drawPlayer)
{
SpriteEffects spriteEffects = SpriteEffects.None;
spriteEffects = ((drawPlayer.direction != 1) ? SpriteEffects.FlipHorizontally : SpriteEffects.None);
Color immuneAlpha = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16, new Color(mouseTextColor / 2 + 100, mouseTextColor / 2 + 100, mouseTextColor / 2 + 100, mouseTextColor / 2 + 100)));
Rectangle value = new Rectangle(0, ghostTexture.Height / 4 * drawPlayer.ghostFrame, ghostTexture.Width, ghostTexture.Height / 4);
Vector2 origin = new Vector2((float)value.Width * 0.5f, (float)value.Height * 0.5f);
spriteBatch.Draw(ghostTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) + value.Width / 2, (int)(drawPlayer.position.Y - screenPosition.Y) + value.Height / 2), value, immuneAlpha, 0f, origin, 1f, spriteEffects, 0f);
}
protected void DrawGore()
{
for (int i = 0; i < 200; i++)
{
if (gore[i].active && gore[i].type > 0)
{
Color alpha = gore[i].GetAlpha(Lighting.GetColor((int)((double)gore[i].position.X + (double)goreTexture[gore[i].type].Width * 0.5) / 16, (int)(((double)gore[i].position.Y + (double)goreTexture[gore[i].type].Height * 0.5) / 16.0)));
spriteBatch.Draw(goreTexture[gore[i].type], new Vector2(gore[i].position.X - screenPosition.X + (float)(goreTexture[gore[i].type].Width / 2), gore[i].position.Y - screenPosition.Y + (float)(goreTexture[gore[i].type].Height / 2)), new Rectangle(0, 0, goreTexture[gore[i].type].Width, goreTexture[gore[i].type].Height), alpha, gore[i].rotation, new Vector2(goreTexture[gore[i].type].Width / 2, goreTexture[gore[i].type].Height / 2), gore[i].scale, SpriteEffects.None, 0f);
}
}
}
protected void DrawLoadBox()
{
int num = 0;
int num2 = ModClass.loadedTilesCor[num, 0];
int num3 = ModClass.loadedTilesCor[num, 1];
Color color = new Color(255, 255, 255, 255);
int height = 16;
int num4 = 16;
int num5 = 0;
Texture2D texture2D = new Texture2D(base.GraphicsDevice, 1, 1);
texture2D.SetData(new Color[1]
{
new Color(50, 0, 0, 0)
});
Vector2 origin = default(Vector2);
while (num3 != 0 && num2 != 0 && num < ModClass.maxTiles - 1)
{
if (ModClass.loadedTiles[num] != null && !ModClass.loadedTiles[num].active)
{
spriteBatch.Draw(tileTexture[ModClass.loadedTiles[num].type], new Vector2((float)(num2 * 16 - (int)screenPosition.X) - ((float)num4 - 16f) / 2f, num3 * 16 - (int)screenPosition.Y + num5), new Rectangle(ModClass.loadedTiles[num].frameX, ModClass.loadedTiles[num].frameY, num4, height), color, 0f, origin, 1f, SpriteEffects.None, 0f);
}
if (ModClass.loadedTiles[num] != null && ModClass.loadedTiles[num].active)
{
spriteBatch.Draw(texture2D, new Vector2((float)(num2 * 16 - (int)screenPosition.X) - ((float)num4 - 16f) / 2f, num3 * 16 - (int)screenPosition.Y + num5), new Rectangle(tile[num2, num3].frameX, tile[num2, num3].frameY, num4, height), color, 0f, origin, 1f, SpriteEffects.None, 0f);
}
num++;
num2 = ModClass.loadedTilesCor[num, 0];
num3 = ModClass.loadedTilesCor[num, 1];
}
}
protected void DrawBox()
{
int num = 0;
int num2 = ModClass.selectedTiles[num, 0];
int num3 = ModClass.selectedTiles[num, 1];
Color color = new Color(255, 255, 255, 255);
int height = 16;
int num4 = 16;
int num5 = 0;
Vector2 origin = default(Vector2);
Texture2D texture2D = new Texture2D(base.GraphicsDevice, 1, 1);
texture2D.SetData(new Color[1]
{
new Color(50, 0, 0, 0)
});
while (num3 != 0 && num2 != 0 && num < ModClass.maxTiles - 1)
{
spriteBatch.Draw(texture2D, new Vector2((float)(num2 * 16 - (int)screenPosition.X) - ((float)num4 - 16f) / 2f, num3 * 16 - (int)screenPosition.Y + num5), new Rectangle(tile[num2, num3].frameX, tile[num2, num3].frameY, num4, height), color, 0f, origin, 1f, SpriteEffects.None, 0f);
num++;
num2 = ModClass.selectedTiles[num, 0];
num3 = ModClass.selectedTiles[num, 1];
}
}
protected void DrawInterface()
{
mouseHC = false;
if (hideUI)
{
return;
}
if (signBubble)
{
int num = signX - (int)screenPosition.X;
int num2 = signY - (int)screenPosition.Y;
SpriteEffects effects = SpriteEffects.None;
if ((float)signX > player[myPlayer].position.X + (float)player[myPlayer].width)
{
effects = SpriteEffects.FlipHorizontally;
num += -8 - chat2Texture.Width;
}
else
{
num += 8;
}
num2 -= 22;
spriteBatch.Draw(chat2Texture, new Vector2(num, num2), new Rectangle(0, 0, chat2Texture.Width, chat2Texture.Height), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, effects, 0f);
signBubble = false;
}
for (int i = 0; i < 255; i++)
{
if (player[i].active && myPlayer != i && !player[i].dead)
{
new Rectangle((int)((double)player[i].position.X + (double)player[i].width * 0.5 - 16.0), (int)(player[i].position.Y + (float)player[i].height - 48f), 32, 48);
bool flag = false;
new Rectangle((int)screenPosition.X, (int)screenPosition.Y, screenWidth, screenHeight);
string text = player[i].name;
if (player[i].statLife < player[i].statLifeMax)
{
object obj = text;
text = string.Concat(obj, ": ", player[i].statLife, "/", player[i].statLifeMax);
}
Vector2 position = fontMouseText.MeasureString(text);
float num3 = 0f;
if (player[i].chatShowTime > 0)
{
num3 = 0f - position.Y;
}
float num4 = 0f;
float num5 = (float)(int)mouseTextColor / 255f;
Color color = new Color((byte)((float)(int)teamColor[player[i].team].R * num5), (byte)((float)(int)teamColor[player[i].team].G * num5), (byte)((float)(int)teamColor[player[i].team].B * num5), mouseTextColor);
Vector2 vector = new Vector2((float)(screenWidth / 2) + screenPosition.X, (float)(screenHeight / 2) + screenPosition.Y);
float num6 = player[i].position.X + (float)(player[i].width / 2) - vector.X;
float num7 = player[i].position.Y - position.Y - 2f + num3 - vector.Y;
float num8 = (float)Math.Sqrt(num6 * num6 + num7 * num7);
int num9 = screenHeight;
if (screenHeight > screenWidth)
{
num9 = screenWidth;
}
num9 = num9 / 2 - 30;
if (num9 < 100)
{
num9 = 100;
}
if (num8 < (float)num9)
{
position.X = player[i].position.X + (float)(player[i].width / 2) - position.X / 2f - screenPosition.X;
position.Y = player[i].position.Y - position.Y - 2f + num3 - screenPosition.Y;
}
else
{
num4 = num8;
num8 = (float)num9 / num8;
position.X = (float)(screenWidth / 2) + num6 * num8 - position.X / 2f;
position.Y = (float)(screenHeight / 2) + num7 * num8;
}
if (num4 > 0f)
{
string text2 = "(" + (int)(num4 / 16f * 2f) + " ft)";
Vector2 position2 = fontMouseText.MeasureString(text2);
position2.X = position.X + fontMouseText.MeasureString(text).X / 2f - position2.X / 2f;
position2.Y = position.Y + fontMouseText.MeasureString(text).Y / 2f - position2.Y / 2f - 20f;
spriteBatch.DrawString(fontMouseText, text2, new Vector2(position2.X - 2f, position2.Y), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text2, new Vector2(position2.X + 2f, position2.Y), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text2, new Vector2(position2.X, position2.Y - 2f), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text2, new Vector2(position2.X, position2.Y + 2f), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text2, position2, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
spriteBatch.DrawString(fontMouseText, text, new Vector2(position.X - 2f, position.Y), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text, new Vector2(position.X + 2f, position.Y), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text, new Vector2(position.X, position.Y - 2f), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text, new Vector2(position.X, position.Y + 2f), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, text, position, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
if (playerInventory)
{
npcChatText = "";
player[myPlayer].sign = -1;
}
if (ignoreErrors)
{
try
{
if (npcChatText != "" || player[myPlayer].sign != -1)
{
DrawChat();
}
}
catch
{
}
}
else if (npcChatText != "" || player[myPlayer].sign != -1)
{
DrawChat();
}
Color color2 = new Color(220, 220, 220, 220);
invAlpha += invDir * 0.2f;
if (invAlpha > 240f)
{
invAlpha = 240f;
invDir = -1f;
}
if (invAlpha < 180f)
{
invAlpha = 180f;
invDir = 1f;
}
color2 = new Color((byte)invAlpha, (byte)invAlpha, (byte)invAlpha, (byte)invAlpha);
bool flag2 = false;
int rare = 0;
int num10 = screenWidth - 800;
int num11 = player[myPlayer].statLifeMax / 20;
if (num11 >= 10)
{
num11 = 10;
}
string text3 = "Life: " + player[myPlayer].statLifeMax + "/" + player[myPlayer].statLifeMax;
Vector2 vector2 = fontMouseText.MeasureString(text3);
if (!player[myPlayer].ghost)
{
spriteBatch.DrawString(fontMouseText, "Life: ", new Vector2((float)(500 + 13 * num11) - vector2.X * 0.5f + (float)num10, 6f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, player[myPlayer].statLife + "/" + player[myPlayer].statLifeMax, new Vector2((float)(500 + 13 * num11) + vector2.X * 0.5f + (float)num10, 6f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, new Vector2(fontMouseText.MeasureString(player[myPlayer].statLife + "/" + player[myPlayer].statLifeMax).X, 0f), 1f, SpriteEffects.None, 0f);
}
int num12 = 20;
for (int j = 1; j < player[myPlayer].statLifeMax / num12 + 1; j++)
{
int num13 = 255;
float num14 = 1f;
bool flag3 = false;
if (player[myPlayer].statLife >= j * num12)
{
num13 = 255;
if (player[myPlayer].statLife == j * num12)
{
flag3 = true;
}
}
else
{
float num15 = (float)(player[myPlayer].statLife - (j - 1) * num12) / (float)num12;
num13 = (int)(30f + 225f * num15);
if (num13 < 30)
{
num13 = 30;
}
num14 = num15 / 4f + 0.75f;
if ((double)num14 < 0.75)
{
num14 = 0.75f;
}
if (num15 > 0f)
{
flag3 = true;
}
}
if (flag3)
{
num14 += cursorScale - 1f;
}
int num16 = 0;
int num17 = 0;
if (j > 10)
{
num16 -= 260;
num17 += 26;
}
int a = (int)((double)num13 * 0.9);
if (!player[myPlayer].ghost)
{
spriteBatch.Draw(heartTexture, new Vector2(500 + 26 * (j - 1) + num16 + num10 + heartTexture.Width / 2, 32f + ((float)heartTexture.Height - (float)heartTexture.Height * num14) / 2f + (float)num17 + (float)(heartTexture.Height / 2)), new Rectangle(0, 0, heartTexture.Width, heartTexture.Height), new Color(num13, num13, num13, a), 0f, new Vector2(heartTexture.Width / 2, heartTexture.Height / 2), num14, SpriteEffects.None, 0f);
}
}
int num18 = 20;
if (player[myPlayer].statManaMax2 > 0)
{
int num19 = player[myPlayer].statManaMax2 / 20;
spriteBatch.DrawString(fontMouseText, "Mana", new Vector2(750 + num10, 6f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
for (int k = 1; k < player[myPlayer].statManaMax2 / num18 + 1; k++)
{
int num20 = 255;
bool flag4 = false;
float num21 = 1f;
if (player[myPlayer].statMana >= k * num18)
{
num20 = 255;
if (player[myPlayer].statMana == k * num18)
{
flag4 = true;
}
}
else
{
float num22 = (float)(player[myPlayer].statMana - (k - 1) * num18) / (float)num18;
num20 = (int)(30f + 225f * num22);
if (num20 < 30)
{
num20 = 30;
}
num21 = num22 / 4f + 0.75f;
if ((double)num21 < 0.75)
{
num21 = 0.75f;
}
if (num22 > 0f)
{
flag4 = true;
}
}
if (flag4)
{
num21 += cursorScale - 1f;
}
int a2 = (int)((double)num20 * 0.9);
spriteBatch.Draw(manaTexture, new Vector2(775 + num10, (float)(30 + manaTexture.Height / 2) + ((float)manaTexture.Height - (float)manaTexture.Height * num21) / 2f + (float)(28 * (k - 1))), new Rectangle(0, 0, manaTexture.Width, manaTexture.Height), new Color(num20, num20, num20, a2), 0f, new Vector2(manaTexture.Width / 2, manaTexture.Height / 2), num21, SpriteEffects.None, 0f);
}
}
if (player[myPlayer].breath < player[myPlayer].breathMax && !player[myPlayer].ghost)
{
int num23 = 76;
int num24 = player[myPlayer].breathMax / 20;
spriteBatch.DrawString(fontMouseText, "Breath", new Vector2((float)(500 + 13 * num11) - fontMouseText.MeasureString("Breath").X * 0.5f + (float)num10, 6 + num23), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
int num25 = 20;
for (int l = 1; l < player[myPlayer].breathMax / num25 + 1; l++)
{
int num26 = 255;
float num27 = 1f;
if (player[myPlayer].breath >= l * num25)
{
num26 = 255;
}
else
{
float num28 = (float)(player[myPlayer].breath - (l - 1) * num25) / (float)num25;
num26 = (int)(30f + 225f * num28);
if (num26 < 30)
{
num26 = 30;
}
num27 = num28 / 4f + 0.75f;
if ((double)num27 < 0.75)
{
num27 = 0.75f;
}
}
int num29 = 0;
int num30 = 0;
if (l > 10)
{
num29 -= 260;
num30 += 26;
}
spriteBatch.Draw(bubbleTexture, new Vector2(500 + 26 * (l - 1) + num29 + num10, 32f + ((float)bubbleTexture.Height - (float)bubbleTexture.Height * num27) / 2f + (float)num30 + (float)num23), new Rectangle(0, 0, bubbleTexture.Width, bubbleTexture.Height), new Color(num26, num26, num26, num26), 0f, default(Vector2), num27, SpriteEffects.None, 0f);
}
}
buffString = "";
if (!playerInventory)
{
int num31 = -1;
for (int m = 0; m < 10; m++)
{
if (player[myPlayer].buffType[m] > 0)
{
int num32 = player[myPlayer].buffType[m];
int num33 = 32 + m * 38;
int num34 = 76;
Color color3 = new Color(buffAlpha[m], buffAlpha[m], buffAlpha[m], buffAlpha[m]);
spriteBatch.Draw(buffTexture[num32], new Vector2(num33, num34), new Rectangle(0, 0, buffTexture[num32].Width, buffTexture[num32].Height), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
string text4 = "0 s";
text4 = ((player[myPlayer].buffTime[m] / 60 < 60) ? (Math.Round((double)player[myPlayer].buffTime[m] / 60.0) + " s") : (Math.Round((double)(player[myPlayer].buffTime[m] / 60) / 60.0) + " m"));
spriteBatch.DrawString(fontItemStack, text4, new Vector2(num33, num34 + buffTexture[num32].Height), color3, 0f, default(Vector2), 0.8f, SpriteEffects.None, 0f);
if (mouseState.X < num33 + buffTexture[num32].Width && mouseState.Y < num34 + buffTexture[num32].Height && mouseState.X > num33 && mouseState.Y > num34)
{
num31 = m;
buffAlpha[m] += 0.1f;
if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && !debuff[num32])
{
PlaySound(12);
player[myPlayer].DelBuff(m);
}
}
else
{
buffAlpha[m] -= 0.05f;
}
if (buffAlpha[m] > 1f)
{
buffAlpha[m] = 1f;
}
else if ((double)buffAlpha[m] < 0.4)
{
buffAlpha[m] = 0.4f;
}
}
else
{
buffAlpha[m] = 0.4f;
}
}
if (num31 >= 0)
{
int num35 = player[myPlayer].buffType[num31];
if (num35 > 0)
{
buffString = buffTip[num35];
MouseText(buffName[num35], 0, 0);
}
}
}
if (player[myPlayer].dead)
{
playerInventory = false;
}
if (!playerInventory)
{
player[myPlayer].chest = -1;
craftGuide = false;
}
string text5 = "";
if (!playerInventory)
{
bool flag5 = false;
bool flag6 = false;
for (int n = 0; n < 3; n++)
{
string text6 = "";
if (player[myPlayer].accDepthMeter > 0 && !flag6)
{
int num36 = (int)((double)((player[myPlayer].position.Y + (float)player[myPlayer].height) * 2f / 16f) - worldSurface * 2.0);
if (num36 > 0)
{
text6 = "Depth: " + num36 + " feet below";
if (num36 == 1)
{
text6 = "Depth: " + num36 + " foot below";
}
}
else if (num36 < 0)
{
num36 *= -1;
text6 = "Depth: " + num36 + " feet above";
if (num36 == 1)
{
text6 = "Depth: " + num36 + " foot above";
}
}
else
{
text6 = "Depth: Level";
}
flag6 = true;
}
else if (player[myPlayer].accWatch > 0 && !flag5)
{
string text7 = "AM";
double num37 = time;
if (!dayTime)
{
num37 += 54000.0;
}
num37 = num37 / 86400.0 * 24.0;
double num38 = 7.5;
num37 = num37 - num38 - 12.0;
if (num37 < 0.0)
{
num37 += 24.0;
}
if (num37 >= 12.0)
{
text7 = "PM";
}
int num39 = (int)num37;
double num40 = num37 - (double)num39;
num40 = (int)(num40 * 60.0);
string text8 = num40.ToString();
if (num40 < 10.0)
{
text8 = "0" + text8;
}
if (num39 > 12)
{
num39 -= 12;
}
if (num39 == 0)
{
num39 = 12;
}
if (player[myPlayer].accWatch == 1)
{
text8 = "00";
}
else if (player[myPlayer].accWatch == 2)
{
text8 = ((!(num40 < 30.0)) ? "30" : "00");
}
text6 = "Time: " + num39 + ":" + text8 + " " + text7;
flag5 = true;
}
if (!(text6 != ""))
{
continue;
}
for (int num41 = 0; num41 < 5; num41++)
{
int num42 = 0;
int num43 = 0;
Color color4 = Color.Black;
switch (num41)
{
case 0:
num42 = -2;
break;
case 1:
num42 = 2;
break;
case 2:
num43 = -2;
break;
case 3:
num43 = 2;
break;
case 4:
color4 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
break;
}
spriteBatch.DrawString(fontMouseText, text6, new Vector2(22 + num42, 74 + 22 * n + num43 + 48), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
else
{
if (netMode == 1)
{
int num44 = 675 + screenWidth - 800;
int num45 = 114;
if (player[myPlayer].hostile)
{
spriteBatch.Draw(itemTexture[4], new Vector2(num44 - 2, num45), new Rectangle(0, 0, itemTexture[4].Width, itemTexture[4].Height), teamColor[player[myPlayer].team], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture[4], new Vector2(num44 + 2, num45), new Rectangle(0, 0, itemTexture[4].Width, itemTexture[4].Height), teamColor[player[myPlayer].team], 0f, default(Vector2), 1f, SpriteEffects.FlipHorizontally, 0f);
}
else
{
spriteBatch.Draw(itemTexture[4], new Vector2(num44 - 16, num45 + 14), new Rectangle(0, 0, itemTexture[4].Width, itemTexture[4].Height), teamColor[player[myPlayer].team], -0.785f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture[4], new Vector2(num44 + 2, num45 + 14), new Rectangle(0, 0, itemTexture[4].Width, itemTexture[4].Height), teamColor[player[myPlayer].team], -0.785f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
if (mouseState.X > num44 && mouseState.X < num44 + 34 && mouseState.Y > num45 - 2 && mouseState.Y < num45 + 34)
{
player[myPlayer].mouseInterface = true;
if (mouseState.LeftButton == ButtonState.Pressed && mouseLeftRelease)
{
if (teamCooldown == 0)
{
teamCooldown = teamCooldownLen;
PlaySound(12);
if (player[myPlayer].hostile)
{
player[myPlayer].hostile = false;
}
else
{
player[myPlayer].hostile = true;
}
NetMessage.SendData(30, -1, -1, "", myPlayer);
}
else
{
NewText("You must wait " + (teamCooldown / 60 + 1) + " seconds.", byte.MaxValue, 0, 0);
}
}
}
num44 -= 3;
Rectangle value = new Rectangle(mouseState.X, mouseState.Y, 1, 1);
int width = teamTexture.Width;
int height = teamTexture.Height;
for (int num46 = 0; num46 < 5; num46++)
{
Rectangle rectangle = default(Rectangle);
switch (num46)
{
case 0:
rectangle = new Rectangle(num44 + 50, num45 - 20, width, height);
break;
case 1:
rectangle = new Rectangle(num44 + 40, num45, width, height);
break;
case 2:
rectangle = new Rectangle(num44 + 60, num45, width, height);
break;
case 3:
rectangle = new Rectangle(num44 + 40, num45 + 20, width, height);
break;
case 4:
rectangle = new Rectangle(num44 + 60, num45 + 20, width, height);
break;
}
if (!rectangle.Intersects(value))
{
continue;
}
player[myPlayer].mouseInterface = true;
if (mouseState.LeftButton == ButtonState.Pressed && mouseLeftRelease && player[myPlayer].team != num46)
{
if (teamCooldown == 0)
{
teamCooldown = teamCooldownLen;
PlaySound(12);
player[myPlayer].team = num46;
NetMessage.SendData(45, -1, -1, "", myPlayer);
}
else
{
NewText("You must wait " + (teamCooldown / 60 + 1) + " seconds.", byte.MaxValue, 0, 0);
}
}
}
spriteBatch.Draw(teamTexture, new Vector2(num44 + 50, num45 - 20), new Rectangle(0, 0, teamTexture.Width, teamTexture.Height), teamColor[0], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(teamTexture, new Vector2(num44 + 40, num45), new Rectangle(0, 0, teamTexture.Width, teamTexture.Height), teamColor[1], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(teamTexture, new Vector2(num44 + 60, num45), new Rectangle(0, 0, teamTexture.Width, teamTexture.Height), teamColor[2], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(teamTexture, new Vector2(num44 + 40, num45 + 20), new Rectangle(0, 0, teamTexture.Width, teamTexture.Height), teamColor[3], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(teamTexture, new Vector2(num44 + 60, num45 + 20), new Rectangle(0, 0, teamTexture.Width, teamTexture.Height), teamColor[4], 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
bool flag7 = false;
if (keyState.IsKeyDown(Keys.LeftShift))
{
flag7 = true;
}
inventoryScale = 0.85f;
int num47 = 448;
int num48 = 210;
Color color5 = new Color(150, 150, 150, 150);
if (mouseState.X >= num47 && (float)mouseState.X <= (float)num47 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num48 && (float)mouseState.Y <= (float)num48 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (mouseItem.type != 0)
{
trashItem.SetDefaults(0);
}
Item item = mouseItem;
mouseItem = trashItem;
trashItem = item;
if (trashItem.type == 0 || trashItem.stack < 1)
{
trashItem = new Item();
}
if (mouseItem.IsTheSameAs(trashItem) && trashItem.stack != trashItem.maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + trashItem.stack <= mouseItem.maxStack)
{
trashItem.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num49 = mouseItem.maxStack - trashItem.stack;
trashItem.stack += num49;
mouseItem.stack -= num49;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || trashItem.type > 0)
{
PlaySound(7);
}
}
if (!flag7)
{
text5 = trashItem.name;
if (trashItem.stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", trashItem.stack, ")");
}
toolTip = (Item)trashItem.Clone();
if (text5 == null)
{
text5 = "Trash Can";
}
}
else
{
text5 = "Trash Can";
}
}
spriteBatch.Draw(inventoryBack7Texture, new Vector2(num47, num48), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color5 = Color.White;
if (trashItem.type == 0 || trashItem.stack == 0 || flag7)
{
color5 = new Color(100, 100, 100, 100);
float num50 = inventoryScale;
spriteBatch.Draw(trashTexture, new Vector2((float)num47 + 26f * inventoryScale - (float)trashTexture.Width * 0.5f * num50, (float)num48 + 26f * inventoryScale - (float)trashTexture.Height * 0.5f * num50), new Rectangle(0, 0, trashTexture.Width, trashTexture.Height), color5, 0f, default(Vector2), num50, SpriteEffects.None, 0f);
}
else
{
float num51 = 1f;
if (itemTexture[trashItem.type].Width > 32 || itemTexture[trashItem.type].Height > 32)
{
num51 = ((itemTexture[trashItem.type].Width <= itemTexture[trashItem.type].Height) ? (32f / (float)itemTexture[trashItem.type].Height) : (32f / (float)itemTexture[trashItem.type].Width));
}
num51 *= inventoryScale;
spriteBatch.Draw(itemTexture[trashItem.type], new Vector2((float)num47 + 26f * inventoryScale - (float)itemTexture[trashItem.type].Width * 0.5f * num51, (float)num48 + 26f * inventoryScale - (float)itemTexture[trashItem.type].Height * 0.5f * num51), new Rectangle(0, 0, itemTexture[trashItem.type].Width, itemTexture[trashItem.type].Height), trashItem.GetAlpha(color5), 0f, default(Vector2), num51, SpriteEffects.None, 0f);
if (trashItem.color != default(Color))
{
spriteBatch.Draw(itemTexture[trashItem.type], new Vector2((float)num47 + 26f * inventoryScale - (float)itemTexture[trashItem.type].Width * 0.5f * num51, (float)num48 + 26f * inventoryScale - (float)itemTexture[trashItem.type].Height * 0.5f * num51), new Rectangle(0, 0, itemTexture[trashItem.type].Width, itemTexture[trashItem.type].Height), trashItem.GetColor(color5), 0f, default(Vector2), num51, SpriteEffects.None, 0f);
}
if (trashItem.stack > 1)
{
spriteBatch.DrawString(fontItemStack, trashItem.stack.ToString(), new Vector2((float)num47 + 10f * inventoryScale, (float)num48 + 26f * inventoryScale), color5, 0f, default(Vector2), num51, SpriteEffects.None, 0f);
}
}
spriteBatch.DrawString(fontMouseText, "Inventory", new Vector2(40f, 0f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
inventoryScale = 0.85f;
if (mouseState.X > 20 && mouseState.X < (int)(20f + 560f * inventoryScale) && mouseState.Y > 20 && mouseState.Y < (int)(20f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num52 = 0; num52 < 10; num52++)
{
for (int num53 = 0; num53 < 4; num53++)
{
int num54 = (int)(20f + (float)(num52 * 56) * inventoryScale);
int num55 = (int)(20f + (float)(num53 * 56) * inventoryScale);
int num56 = num52 + num53 * 10;
Color color6 = new Color(100, 100, 100, 100);
if (mouseState.X >= num54 && (float)mouseState.X <= (float)num54 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num55 && (float)mouseState.Y <= (float)num55 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (keyState.IsKeyDown(Keys.LeftShift))
{
if (player[myPlayer].inventory[num56].type > 0)
{
if (npcShop > 0)
{
if (player[myPlayer].SellItem(player[myPlayer].inventory[num56].value, player[myPlayer].inventory[num56].stack))
{
shop[npcShop].AddShop(player[myPlayer].inventory[num56]);
player[myPlayer].inventory[num56].SetDefaults(0);
PlaySound(18);
}
else if (mouseItem.value == 0)
{
shop[npcShop].AddShop(player[myPlayer].inventory[num56]);
player[myPlayer].inventory[num56].SetDefaults(0);
PlaySound(7);
}
}
else
{
Recipe.FindRecipes();
PlaySound(7);
trashItem = (Item)player[myPlayer].inventory[num56].Clone();
player[myPlayer].inventory[num56].SetDefaults(0);
}
}
}
else if (player[myPlayer].selectedItem != num56 || player[myPlayer].itemAnimation <= 0)
{
Item item2 = mouseItem;
mouseItem = player[myPlayer].inventory[num56];
player[myPlayer].inventory[num56] = item2;
if (player[myPlayer].inventory[num56].type == 0 || player[myPlayer].inventory[num56].stack < 1)
{
player[myPlayer].inventory[num56] = new Item();
}
if (mouseItem.IsTheSameAs(player[myPlayer].inventory[num56]) && player[myPlayer].inventory[num56].stack != player[myPlayer].inventory[num56].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + player[myPlayer].inventory[num56].stack <= mouseItem.maxStack)
{
Item item3 = player[myPlayer].inventory[num56];
item3.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num57 = mouseItem.maxStack - player[myPlayer].inventory[num56].stack;
Item item4 = player[myPlayer].inventory[num56];
item4.stack += num57;
mouseItem.stack -= num57;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].inventory[num56].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
}
else if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && player[myPlayer].inventory[num56].maxStack == 1)
{
player[myPlayer].inventory[num56] = armorSwap(player[myPlayer].inventory[num56]);
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && player[myPlayer].inventory[num56].maxStack > 1 && player[myPlayer].inventory[num56].type > 0 && (mouseItem.IsTheSameAs(player[myPlayer].inventory[num56]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)player[myPlayer].inventory[num56].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item5 = player[myPlayer].inventory[num56];
item5.stack--;
if (player[myPlayer].inventory[num56].stack <= 0)
{
player[myPlayer].inventory[num56] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
text5 = player[myPlayer].inventory[num56].name;
toolTip = (Item)player[myPlayer].inventory[num56].Clone();
if (player[myPlayer].inventory[num56].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].inventory[num56].stack, ")");
}
}
if (num53 != 0)
{
spriteBatch.Draw(inventoryBackTexture, new Vector2(num54, num55), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(inventoryBack9Texture, new Vector2(num54, num55), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
}
color6 = Color.White;
if (player[myPlayer].inventory[num56].type > 0 && player[myPlayer].inventory[num56].stack > 0)
{
float num58 = 1f;
if (itemTexture[player[myPlayer].inventory[num56].type].Width > 32 || itemTexture[player[myPlayer].inventory[num56].type].Height > 32)
{
num58 = ((itemTexture[player[myPlayer].inventory[num56].type].Width <= itemTexture[player[myPlayer].inventory[num56].type].Height) ? (32f / (float)itemTexture[player[myPlayer].inventory[num56].type].Height) : (32f / (float)itemTexture[player[myPlayer].inventory[num56].type].Width));
}
num58 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num56].type], new Vector2((float)num54 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num56].type].Width * 0.5f * num58, (float)num55 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num56].type].Height * 0.5f * num58), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num56].type].Width, itemTexture[player[myPlayer].inventory[num56].type].Height), player[myPlayer].inventory[num56].GetAlpha(color6), 0f, default(Vector2), num58, SpriteEffects.None, 0f);
if (player[myPlayer].inventory[num56].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num56].type], new Vector2((float)num54 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num56].type].Width * 0.5f * num58, (float)num55 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num56].type].Height * 0.5f * num58), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num56].type].Width, itemTexture[player[myPlayer].inventory[num56].type].Height), player[myPlayer].inventory[num56].GetColor(color6), 0f, default(Vector2), num58, SpriteEffects.None, 0f);
}
if (player[myPlayer].inventory[num56].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].inventory[num56].stack.ToString(), new Vector2((float)num54 + 10f * inventoryScale, (float)num55 + 26f * inventoryScale), color6, 0f, default(Vector2), num58, SpriteEffects.None, 0f);
}
}
if (num53 == 0)
{
string text9 = (num56 + 1).ToString();
if (text9 == "10")
{
text9 = "0";
}
spriteBatch.DrawString(fontItemStack, text9, new Vector2(num54 + 6, num55 + 4), color2, 0f, default(Vector2), inventoryScale * 0.8f, SpriteEffects.None, 0f);
}
}
}
int num59 = 0;
int num60 = 2;
int num61 = 32;
if (!player[myPlayer].hbLocked)
{
num59 = 1;
}
spriteBatch.Draw(HBLockTexture[num59], new Vector2(num60, num61), new Rectangle(0, 0, HBLockTexture[num59].Width, HBLockTexture[num59].Height), color2, 0f, default(Vector2), 0.9f, SpriteEffects.None, 0f);
if (mouseState.X > num60 && (float)mouseState.X < (float)num60 + (float)HBLockTexture[num59].Width * 0.9f && mouseState.Y > num61 && (float)mouseState.Y < (float)num61 + (float)HBLockTexture[num59].Height * 0.9f)
{
player[myPlayer].mouseInterface = true;
if (!player[myPlayer].hbLocked)
{
MouseText("Hotbar unlocked", 0, 0);
flag2 = true;
}
else
{
MouseText("Hotbar locked", 0, 0);
flag2 = true;
}
if (mouseState.LeftButton == ButtonState.Pressed && mouseLeftRelease)
{
PlaySound(22);
if (!player[myPlayer].hbLocked)
{
player[myPlayer].hbLocked = true;
}
else
{
player[myPlayer].hbLocked = false;
}
}
}
if (armorHide)
{
armorAlpha -= 0.1f;
if (armorAlpha < 0f)
{
armorAlpha = 0f;
}
}
else
{
armorAlpha += 0.025f;
if (armorAlpha > 1f)
{
armorAlpha = 1f;
}
}
Color color7 = new Color((byte)((float)(int)mouseTextColor * armorAlpha), (byte)((float)(int)mouseTextColor * armorAlpha), (byte)((float)(int)mouseTextColor * armorAlpha), (byte)((float)(int)mouseTextColor * armorAlpha));
armorHide = false;
spriteBatch.DrawString(fontMouseText, "Equip", new Vector2(screenWidth - 64 - 28 + 4, 152f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 0.8f, SpriteEffects.None, 0f);
if (mouseState.X > screenWidth - 64 - 28 && mouseState.X < screenWidth - 64 - 28 + (int)(56f * inventoryScale) && mouseState.Y > 174 && mouseState.Y < (int)(174f + 448f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num62 = 0; num62 < 8; num62++)
{
int num63 = screenWidth - 64 - 28;
int num64 = (int)(174f + (float)(num62 * 56) * inventoryScale);
Color color8 = new Color(100, 100, 100, 100);
string text10 = "";
switch (num62)
{
case 3:
text10 = "Accessories";
break;
case 7:
text10 = player[myPlayer].statDefense + " Defense";
break;
}
Vector2 vector3 = fontMouseText.MeasureString(text10);
spriteBatch.DrawString(fontMouseText, text10, new Vector2((float)num63 - vector3.X - 10f, (float)num64 + (float)inventoryBackTexture.Height * 0.5f - vector3.Y * 0.5f), color7, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
if (mouseState.X >= num63 && (float)mouseState.X <= (float)num63 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num64 && (float)mouseState.Y <= (float)num64 + (float)inventoryBackTexture.Height * inventoryScale)
{
armorHide = true;
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed && (mouseItem.type == 0 || (mouseItem.headSlot > -1 && num62 == 0) || (mouseItem.bodySlot > -1 && num62 == 1) || (mouseItem.legSlot > -1 && num62 == 2) || (mouseItem.accessory && num62 > 2 && !AccCheck(mouseItem))))
{
Item item6 = mouseItem;
mouseItem = player[myPlayer].armor[num62];
player[myPlayer].armor[num62] = item6;
if (player[myPlayer].armor[num62].type == 0 || player[myPlayer].armor[num62].stack < 1)
{
player[myPlayer].armor[num62] = new Item();
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].armor[num62].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
text5 = player[myPlayer].armor[num62].name;
toolTip = (Item)player[myPlayer].armor[num62].Clone();
if (num62 <= 2)
{
toolTip.wornArmor = true;
}
if (player[myPlayer].armor[num62].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].armor[num62].stack, ")");
}
}
spriteBatch.Draw(inventoryBack3Texture, new Vector2(num63, num64), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color8 = Color.White;
if (player[myPlayer].armor[num62].type > 0 && player[myPlayer].armor[num62].stack > 0)
{
float num65 = 1f;
if (itemTexture[player[myPlayer].armor[num62].type].Width > 32 || itemTexture[player[myPlayer].armor[num62].type].Height > 32)
{
num65 = ((itemTexture[player[myPlayer].armor[num62].type].Width <= itemTexture[player[myPlayer].armor[num62].type].Height) ? (32f / (float)itemTexture[player[myPlayer].armor[num62].type].Height) : (32f / (float)itemTexture[player[myPlayer].armor[num62].type].Width));
}
num65 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].armor[num62].type], new Vector2((float)num63 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num62].type].Width * 0.5f * num65, (float)num64 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num62].type].Height * 0.5f * num65), new Rectangle(0, 0, itemTexture[player[myPlayer].armor[num62].type].Width, itemTexture[player[myPlayer].armor[num62].type].Height), player[myPlayer].armor[num62].GetAlpha(color8), 0f, default(Vector2), num65, SpriteEffects.None, 0f);
if (player[myPlayer].armor[num62].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].armor[num62].type], new Vector2((float)num63 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num62].type].Width * 0.5f * num65, (float)num64 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num62].type].Height * 0.5f * num65), new Rectangle(0, 0, itemTexture[player[myPlayer].armor[num62].type].Width, itemTexture[player[myPlayer].armor[num62].type].Height), player[myPlayer].armor[num62].GetColor(color8), 0f, default(Vector2), num65, SpriteEffects.None, 0f);
}
if (player[myPlayer].armor[num62].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].armor[num62].stack.ToString(), new Vector2((float)num63 + 10f * inventoryScale, (float)num64 + 26f * inventoryScale), color8, 0f, default(Vector2), num65, SpriteEffects.None, 0f);
}
}
}
spriteBatch.DrawString(fontMouseText, "Social", new Vector2(screenWidth - 64 - 28 - 44, 152f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 0.8f, SpriteEffects.None, 0f);
if (mouseState.X > screenWidth - 64 - 28 - 47 && mouseState.X < screenWidth - 64 - 20 - 47 + (int)(56f * inventoryScale) && mouseState.Y > 174 && mouseState.Y < (int)(174f + 168f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num66 = 8; num66 < 11; num66++)
{
int num67 = screenWidth - 64 - 28 - 47;
int num68 = (int)(174f + (float)((num66 - 8) * 56) * inventoryScale);
Color color9 = new Color(100, 100, 100, 100);
string text11 = "";
switch (num66)
{
case 8:
text11 = "Helmet";
break;
case 9:
text11 = "Shirt";
break;
case 10:
text11 = "Pants";
break;
}
Vector2 vector4 = fontMouseText.MeasureString(text11);
spriteBatch.DrawString(fontMouseText, text11, new Vector2((float)num67 - vector4.X - 10f, (float)num68 + (float)inventoryBackTexture.Height * 0.5f - vector4.Y * 0.5f), color7, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
if (mouseState.X >= num67 && (float)mouseState.X <= (float)num67 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num68 && (float)mouseState.Y <= (float)num68 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
armorHide = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (mouseItem.type == 0 || (mouseItem.headSlot > -1 && num66 == 8) || (mouseItem.bodySlot > -1 && num66 == 9) || (mouseItem.legSlot > -1 && num66 == 10))
{
Item item7 = mouseItem;
mouseItem = player[myPlayer].armor[num66];
player[myPlayer].armor[num66] = item7;
if (player[myPlayer].armor[num66].type == 0 || player[myPlayer].armor[num66].stack < 1)
{
player[myPlayer].armor[num66] = new Item();
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].armor[num66].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
}
else if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && player[myPlayer].armor[num66].maxStack == 1)
{
player[myPlayer].armor[num66] = armorSwap(player[myPlayer].armor[num66]);
}
text5 = player[myPlayer].armor[num66].name;
toolTip = (Item)player[myPlayer].armor[num66].Clone();
toolTip.social = true;
if (num66 <= 2)
{
toolTip.wornArmor = true;
}
if (player[myPlayer].armor[num66].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].armor[num66].stack, ")");
}
}
spriteBatch.Draw(inventoryBack8Texture, new Vector2(num67, num68), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color9 = Color.White;
if (player[myPlayer].armor[num66].type > 0 && player[myPlayer].armor[num66].stack > 0)
{
float num69 = 1f;
if (itemTexture[player[myPlayer].armor[num66].type].Width > 32 || itemTexture[player[myPlayer].armor[num66].type].Height > 32)
{
num69 = ((itemTexture[player[myPlayer].armor[num66].type].Width <= itemTexture[player[myPlayer].armor[num66].type].Height) ? (32f / (float)itemTexture[player[myPlayer].armor[num66].type].Height) : (32f / (float)itemTexture[player[myPlayer].armor[num66].type].Width));
}
num69 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].armor[num66].type], new Vector2((float)num67 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num66].type].Width * 0.5f * num69, (float)num68 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num66].type].Height * 0.5f * num69), new Rectangle(0, 0, itemTexture[player[myPlayer].armor[num66].type].Width, itemTexture[player[myPlayer].armor[num66].type].Height), player[myPlayer].armor[num66].GetAlpha(color9), 0f, default(Vector2), num69, SpriteEffects.None, 0f);
if (player[myPlayer].armor[num66].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].armor[num66].type], new Vector2((float)num67 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num66].type].Width * 0.5f * num69, (float)num68 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].armor[num66].type].Height * 0.5f * num69), new Rectangle(0, 0, itemTexture[player[myPlayer].armor[num66].type].Width, itemTexture[player[myPlayer].armor[num66].type].Height), player[myPlayer].armor[num66].GetColor(color9), 0f, default(Vector2), num69, SpriteEffects.None, 0f);
}
if (player[myPlayer].armor[num66].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].armor[num66].stack.ToString(), new Vector2((float)num67 + 10f * inventoryScale, (float)num68 + 26f * inventoryScale), color9, 0f, default(Vector2), num69, SpriteEffects.None, 0f);
}
}
}
if (craftingHide)
{
craftingAlpha -= 0.1f;
if (craftingAlpha < 0f)
{
craftingAlpha = 0f;
}
}
else
{
craftingAlpha += 0.025f;
if (craftingAlpha > 1f)
{
craftingAlpha = 1f;
}
}
Color color10 = new Color((byte)((float)(int)mouseTextColor * craftingAlpha), (byte)((float)(int)mouseTextColor * craftingAlpha), (byte)((float)(int)mouseTextColor * craftingAlpha), (byte)((float)(int)mouseTextColor * craftingAlpha));
craftingHide = false;
if (craftGuide)
{
if (player[myPlayer].chest != -1 || npcShop != 0 || player[myPlayer].talkNPC == -1)
{
craftGuide = false;
player[myPlayer].dropItemCheck();
Recipe.FindRecipes();
}
else
{
int num70 = 73;
int num71 = 331;
string text12;
if (guideItem.type <= 0)
{
text12 = "Place a material here to show recipes";
}
else
{
text12 = "Showing recipes that use " + guideItem.name;
spriteBatch.DrawString(fontMouseText, "Required objects:", new Vector2(num70, num71 + 118), color10, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
int num72 = focusRecipe;
int num73 = 0;
for (int num74 = 0; num74 < Recipe.maxRequirements; num74++)
{
int num75 = (num74 + 1) * 26;
if (recipe[availableRecipe[num72]].requiredTile[num74] == -1)
{
if (num74 == 0 && !recipe[availableRecipe[num72]].needWater)
{
spriteBatch.DrawString(fontMouseText, "None", new Vector2(num70, num71 + 118 + num75), color10, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
break;
}
num73++;
spriteBatch.DrawString(fontMouseText, tileName[recipe[availableRecipe[num72]].requiredTile[num74]], new Vector2(num70, num71 + 118 + num75), color10, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
if (recipe[availableRecipe[num72]].needWater)
{
int num76 = (num73 + 1) * 26;
spriteBatch.DrawString(fontMouseText, "Water", new Vector2(num70, num71 + 118 + num76), color10, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
spriteBatch.DrawString(fontMouseText, text12, new Vector2(num70 + 50, num71 + 12), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
Color color11 = new Color(100, 100, 100, 100);
if (mouseState.X >= num70 && (float)mouseState.X <= (float)num70 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num71 && (float)mouseState.Y <= (float)num71 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
craftingHide = true;
if (mouseItem.material || mouseItem.type == 0)
{
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
Item item8 = mouseItem;
mouseItem = guideItem;
guideItem = item8;
if (guideItem.type == 0 || guideItem.stack < 1)
{
guideItem = new Item();
}
if (mouseItem.IsTheSameAs(guideItem) && guideItem.stack != guideItem.maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + guideItem.stack <= mouseItem.maxStack)
{
guideItem.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num77 = mouseItem.maxStack - guideItem.stack;
guideItem.stack += num77;
mouseItem.stack -= num77;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || guideItem.type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && (mouseItem.IsTheSameAs(guideItem) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)guideItem.Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
guideItem.stack--;
if (guideItem.stack <= 0)
{
guideItem = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
}
text5 = guideItem.name;
toolTip = (Item)guideItem.Clone();
if (guideItem.stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", guideItem.stack, ")");
}
}
spriteBatch.Draw(inventoryBack4Texture, new Vector2(num70, num71), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color11 = Color.White;
if (guideItem.type > 0 && guideItem.stack > 0)
{
float num78 = 1f;
if (itemTexture[guideItem.type].Width > 32 || itemTexture[guideItem.type].Height > 32)
{
num78 = ((itemTexture[guideItem.type].Width <= itemTexture[guideItem.type].Height) ? (32f / (float)itemTexture[guideItem.type].Height) : (32f / (float)itemTexture[guideItem.type].Width));
}
num78 *= inventoryScale;
spriteBatch.Draw(itemTexture[guideItem.type], new Vector2((float)num70 + 26f * inventoryScale - (float)itemTexture[guideItem.type].Width * 0.5f * num78, (float)num71 + 26f * inventoryScale - (float)itemTexture[guideItem.type].Height * 0.5f * num78), new Rectangle(0, 0, itemTexture[guideItem.type].Width, itemTexture[guideItem.type].Height), guideItem.GetAlpha(color11), 0f, default(Vector2), num78, SpriteEffects.None, 0f);
if (guideItem.color != default(Color))
{
spriteBatch.Draw(itemTexture[guideItem.type], new Vector2((float)num70 + 26f * inventoryScale - (float)itemTexture[guideItem.type].Width * 0.5f * num78, (float)num71 + 26f * inventoryScale - (float)itemTexture[guideItem.type].Height * 0.5f * num78), new Rectangle(0, 0, itemTexture[guideItem.type].Width, itemTexture[guideItem.type].Height), guideItem.GetColor(color11), 0f, default(Vector2), num78, SpriteEffects.None, 0f);
}
if (guideItem.stack > 1)
{
spriteBatch.DrawString(fontItemStack, guideItem.stack.ToString(), new Vector2((float)num70 + 10f * inventoryScale, (float)num71 + 26f * inventoryScale), color11, 0f, default(Vector2), num78, SpriteEffects.None, 0f);
}
}
}
}
if (numAvailableRecipes > 0)
{
spriteBatch.DrawString(fontMouseText, "Crafting", new Vector2(76f, 414f), color10, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
for (int num79 = 0; num79 < Recipe.maxRecipes; num79++)
{
inventoryScale = 100f / (Math.Abs(availableRecipeY[num79]) + 100f);
if ((double)inventoryScale < 0.75)
{
inventoryScale = 0.75f;
}
if (availableRecipeY[num79] < (float)((num79 - focusRecipe) * 65))
{
if (availableRecipeY[num79] == 0f)
{
PlaySound(12);
}
availableRecipeY[num79] += 6.5f;
}
else if (availableRecipeY[num79] > (float)((num79 - focusRecipe) * 65))
{
if (availableRecipeY[num79] == 0f)
{
PlaySound(12);
}
availableRecipeY[num79] -= 6.5f;
}
if (num79 >= numAvailableRecipes || !(Math.Abs(availableRecipeY[num79]) <= 250f))
{
continue;
}
int num80 = (int)(46f - 26f * inventoryScale);
int num81 = (int)(410f + availableRecipeY[num79] * inventoryScale - 30f * inventoryScale);
double num82 = color2.A + 50;
double num83 = 255.0;
if (Math.Abs(availableRecipeY[num79]) > 150f)
{
num82 = (double)(150f * (100f - (Math.Abs(availableRecipeY[num79]) - 150f))) * 0.01;
num83 = (double)(255f * (100f - (Math.Abs(availableRecipeY[num79]) - 150f))) * 0.01;
}
new Color((byte)num82, (byte)num82, (byte)num82, (byte)num82);
Color color12 = new Color((byte)num83, (byte)num83, (byte)num83, (byte)num83);
if (mouseState.X >= num80 && (float)mouseState.X <= (float)num80 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num81 && (float)mouseState.Y <= (float)num81 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (focusRecipe == num79 && guideItem.type == 0)
{
if (mouseItem.type == 0 || (mouseItem.IsTheSameAs(recipe[availableRecipe[num79]].createItem) && mouseItem.stack + recipe[availableRecipe[num79]].createItem.stack <= mouseItem.maxStack))
{
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
int stack = mouseItem.stack;
mouseItem = (Item)recipe[availableRecipe[num79]].createItem.Clone();
mouseItem.stack += stack;
recipe[availableRecipe[num79]].Create();
if (mouseItem.type > 0 || recipe[availableRecipe[num79]].createItem.type > 0)
{
PlaySound(7);
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
int stack2 = mouseItem.stack;
mouseItem = (Item)recipe[availableRecipe[num79]].createItem.Clone();
mouseItem.stack += stack2;
recipe[availableRecipe[num79]].Create();
if (mouseItem.type > 0 || recipe[availableRecipe[num79]].createItem.type > 0)
{
PlaySound(7);
}
}
}
}
else if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
focusRecipe = num79;
}
craftingHide = true;
text5 = recipe[availableRecipe[num79]].createItem.name;
toolTip = (Item)recipe[availableRecipe[num79]].createItem.Clone();
if (recipe[availableRecipe[num79]].createItem.stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", recipe[availableRecipe[num79]].createItem.stack, ")");
}
}
if (numAvailableRecipes <= 0)
{
continue;
}
num82 -= 50.0;
if (num82 < 0.0)
{
num82 = 0.0;
}
spriteBatch.Draw(inventoryBack4Texture, new Vector2(num80, num81), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), new Color((byte)num82, (byte)num82, (byte)num82, (byte)num82), 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
if (recipe[availableRecipe[num79]].createItem.type > 0 && recipe[availableRecipe[num79]].createItem.stack > 0)
{
float num84 = 1f;
if (itemTexture[recipe[availableRecipe[num79]].createItem.type].Width > 32 || itemTexture[recipe[availableRecipe[num79]].createItem.type].Height > 32)
{
num84 = ((itemTexture[recipe[availableRecipe[num79]].createItem.type].Width <= itemTexture[recipe[availableRecipe[num79]].createItem.type].Height) ? (32f / (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Height) : (32f / (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Width));
}
num84 *= inventoryScale;
spriteBatch.Draw(itemTexture[recipe[availableRecipe[num79]].createItem.type], new Vector2((float)num80 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Width * 0.5f * num84, (float)num81 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Height * 0.5f * num84), new Rectangle(0, 0, itemTexture[recipe[availableRecipe[num79]].createItem.type].Width, itemTexture[recipe[availableRecipe[num79]].createItem.type].Height), recipe[availableRecipe[num79]].createItem.GetAlpha(color12), 0f, default(Vector2), num84, SpriteEffects.None, 0f);
if (recipe[availableRecipe[num79]].createItem.color != default(Color))
{
spriteBatch.Draw(itemTexture[recipe[availableRecipe[num79]].createItem.type], new Vector2((float)num80 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Width * 0.5f * num84, (float)num81 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[num79]].createItem.type].Height * 0.5f * num84), new Rectangle(0, 0, itemTexture[recipe[availableRecipe[num79]].createItem.type].Width, itemTexture[recipe[availableRecipe[num79]].createItem.type].Height), recipe[availableRecipe[num79]].createItem.GetColor(color12), 0f, default(Vector2), num84, SpriteEffects.None, 0f);
}
if (recipe[availableRecipe[num79]].createItem.stack > 1)
{
spriteBatch.DrawString(fontItemStack, recipe[availableRecipe[num79]].createItem.stack.ToString(), new Vector2((float)num80 + 10f * inventoryScale, (float)num81 + 26f * inventoryScale), color12, 0f, default(Vector2), num84, SpriteEffects.None, 0f);
}
}
}
if (numAvailableRecipes > 0)
{
for (int num85 = 0; num85 < Recipe.maxRequirements && recipe[availableRecipe[focusRecipe]].requiredItem[num85].type != 0; num85++)
{
int num86 = 80 + num85 * 40;
int num87 = 380;
double num88 = color2.A + 50;
double num89 = 255.0;
Color white = Color.White;
Color white2 = Color.White;
num88 = (float)(color2.A + 50) - Math.Abs(availableRecipeY[focusRecipe]) * 2f;
num89 = 255f - Math.Abs(availableRecipeY[focusRecipe]) * 2f;
if (num88 < 0.0)
{
num88 = 0.0;
}
if (num89 < 0.0)
{
num89 = 0.0;
}
white.R = (byte)num88;
white.G = (byte)num88;
white.B = (byte)num88;
white.A = (byte)num88;
white2.R = (byte)num89;
white2.G = (byte)num89;
white2.B = (byte)num89;
white2.A = (byte)num89;
inventoryScale = 0.6f;
if (num88 == 0.0)
{
break;
}
if (mouseState.X >= num86 && (float)mouseState.X <= (float)num86 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num87 && (float)mouseState.Y <= (float)num87 + (float)inventoryBackTexture.Height * inventoryScale)
{
craftingHide = true;
player[myPlayer].mouseInterface = true;
text5 = recipe[availableRecipe[focusRecipe]].requiredItem[num85].name;
toolTip = (Item)recipe[availableRecipe[focusRecipe]].requiredItem[num85].Clone();
if (recipe[availableRecipe[focusRecipe]].requiredItem[num85].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", recipe[availableRecipe[focusRecipe]].requiredItem[num85].stack, ")");
}
}
num88 -= 50.0;
if (num88 < 0.0)
{
num88 = 0.0;
}
spriteBatch.Draw(inventoryBack4Texture, new Vector2(num86, num87), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), new Color((byte)num88, (byte)num88, (byte)num88, (byte)num88), 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
if (recipe[availableRecipe[focusRecipe]].requiredItem[num85].type > 0 && recipe[availableRecipe[focusRecipe]].requiredItem[num85].stack > 0)
{
float num90 = 1f;
if (itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width > 32 || itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height > 32)
{
num90 = ((itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width <= itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height) ? (32f / (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height) : (32f / (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width));
}
num90 *= inventoryScale;
spriteBatch.Draw(itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type], new Vector2((float)num86 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width * 0.5f * num90, (float)num87 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height * 0.5f * num90), new Rectangle(0, 0, itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width, itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height), recipe[availableRecipe[focusRecipe]].requiredItem[num85].GetAlpha(white2), 0f, default(Vector2), num90, SpriteEffects.None, 0f);
if (recipe[availableRecipe[focusRecipe]].requiredItem[num85].color != default(Color))
{
spriteBatch.Draw(itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type], new Vector2((float)num86 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width * 0.5f * num90, (float)num87 + 26f * inventoryScale - (float)itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height * 0.5f * num90), new Rectangle(0, 0, itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Width, itemTexture[recipe[availableRecipe[focusRecipe]].requiredItem[num85].type].Height), recipe[availableRecipe[focusRecipe]].requiredItem[num85].GetColor(white2), 0f, default(Vector2), num90, SpriteEffects.None, 0f);
}
if (recipe[availableRecipe[focusRecipe]].requiredItem[num85].stack > 1)
{
spriteBatch.DrawString(fontItemStack, recipe[availableRecipe[focusRecipe]].requiredItem[num85].stack.ToString(), new Vector2((float)num86 + 10f * inventoryScale, (float)num87 + 26f * inventoryScale), white2, 0f, default(Vector2), num90, SpriteEffects.None, 0f);
}
}
}
}
spriteBatch.DrawString(fontMouseText, "Coins", new Vector2(496f, 84f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 0.75f, SpriteEffects.None, 0f);
inventoryScale = 0.6f;
for (int num91 = 0; num91 < 4; num91++)
{
int num92 = 497;
int num93 = (int)(85f + (float)(num91 * 56) * inventoryScale + 20f);
int num94 = num91 + 40;
Color color13 = new Color(100, 100, 100, 100);
if (mouseState.X >= num92 && (float)mouseState.X <= (float)num92 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num93 && (float)mouseState.Y <= (float)num93 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if ((player[myPlayer].selectedItem != num94 || player[myPlayer].itemAnimation <= 0) && (mouseItem.type == 0 || mouseItem.type == 71 || mouseItem.type == 72 || mouseItem.type == 73 || mouseItem.type == 74))
{
Item item9 = mouseItem;
mouseItem = player[myPlayer].inventory[num94];
player[myPlayer].inventory[num94] = item9;
if (player[myPlayer].inventory[num94].type == 0 || player[myPlayer].inventory[num94].stack < 1)
{
player[myPlayer].inventory[num94] = new Item();
}
if (mouseItem.IsTheSameAs(player[myPlayer].inventory[num94]) && player[myPlayer].inventory[num94].stack != player[myPlayer].inventory[num94].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + player[myPlayer].inventory[num94].stack <= mouseItem.maxStack)
{
Item item10 = player[myPlayer].inventory[num94];
item10.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num95 = mouseItem.maxStack - player[myPlayer].inventory[num94].stack;
Item item11 = player[myPlayer].inventory[num94];
item11.stack += num95;
mouseItem.stack -= num95;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].inventory[num94].type > 0)
{
PlaySound(7);
}
Recipe.FindRecipes();
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && (mouseItem.IsTheSameAs(player[myPlayer].inventory[num94]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)player[myPlayer].inventory[num94].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item12 = player[myPlayer].inventory[num94];
item12.stack--;
if (player[myPlayer].inventory[num94].stack <= 0)
{
player[myPlayer].inventory[num94] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
text5 = player[myPlayer].inventory[num94].name;
toolTip = (Item)player[myPlayer].inventory[num94].Clone();
if (player[myPlayer].inventory[num94].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].inventory[num94].stack, ")");
}
}
spriteBatch.Draw(inventoryBackTexture, new Vector2(num92, num93), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color13 = Color.White;
if (player[myPlayer].inventory[num94].type > 0 && player[myPlayer].inventory[num94].stack > 0)
{
float num96 = 1f;
if (itemTexture[player[myPlayer].inventory[num94].type].Width > 32 || itemTexture[player[myPlayer].inventory[num94].type].Height > 32)
{
num96 = ((itemTexture[player[myPlayer].inventory[num94].type].Width <= itemTexture[player[myPlayer].inventory[num94].type].Height) ? (32f / (float)itemTexture[player[myPlayer].inventory[num94].type].Height) : (32f / (float)itemTexture[player[myPlayer].inventory[num94].type].Width));
}
num96 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num94].type], new Vector2((float)num92 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num94].type].Width * 0.5f * num96, (float)num93 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num94].type].Height * 0.5f * num96), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num94].type].Width, itemTexture[player[myPlayer].inventory[num94].type].Height), player[myPlayer].inventory[num94].GetAlpha(color13), 0f, default(Vector2), num96, SpriteEffects.None, 0f);
if (player[myPlayer].inventory[num94].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num94].type], new Vector2((float)num92 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num94].type].Width * 0.5f * num96, (float)num93 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].inventory[num94].type].Height * 0.5f * num96), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num94].type].Width, itemTexture[player[myPlayer].inventory[num94].type].Height), player[myPlayer].inventory[num94].GetColor(color13), 0f, default(Vector2), num96, SpriteEffects.None, 0f);
}
if (player[myPlayer].inventory[num94].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].inventory[num94].stack.ToString(), new Vector2((float)num92 + 10f * inventoryScale, (float)num93 + 26f * inventoryScale), color13, 0f, default(Vector2), num96, SpriteEffects.None, 0f);
}
}
}
spriteBatch.DrawString(fontMouseText, "Ammo", new Vector2(532f, 84f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 0.75f, SpriteEffects.None, 0f);
inventoryScale = 0.6f;
for (int num97 = 0; num97 < 4; num97++)
{
int num98 = 534;
int num99 = (int)(85f + (float)(num97 * 56) * inventoryScale + 20f);
int num100 = num97;
Color color14 = new Color(100, 100, 100, 100);
if (mouseState.X >= num98 && (float)mouseState.X <= (float)num98 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num99 && (float)mouseState.Y <= (float)num99 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if ((player[myPlayer].selectedItem != num100 || player[myPlayer].itemAnimation <= 0) && (mouseItem.type == 0 || mouseItem.ammo > 0))
{
Item item13 = mouseItem;
mouseItem = player[myPlayer].ammo[num100];
player[myPlayer].ammo[num100] = item13;
if (player[myPlayer].ammo[num100].type == 0 || player[myPlayer].ammo[num100].stack < 1)
{
player[myPlayer].ammo[num100] = new Item();
}
if (mouseItem.IsTheSameAs(player[myPlayer].ammo[num100]) && player[myPlayer].ammo[num100].stack != player[myPlayer].ammo[num100].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + player[myPlayer].ammo[num100].stack <= mouseItem.maxStack)
{
Item item14 = player[myPlayer].ammo[num100];
item14.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num101 = mouseItem.maxStack - player[myPlayer].ammo[num100].stack;
Item item15 = player[myPlayer].ammo[num100];
item15.stack += num101;
mouseItem.stack -= num101;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].ammo[num100].type > 0)
{
PlaySound(7);
}
Recipe.FindRecipes();
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && (mouseItem.IsTheSameAs(player[myPlayer].ammo[num100]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)player[myPlayer].ammo[num100].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item16 = player[myPlayer].ammo[num100];
item16.stack--;
if (player[myPlayer].ammo[num100].stack <= 0)
{
player[myPlayer].ammo[num100] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
text5 = player[myPlayer].ammo[num100].name;
toolTip = (Item)player[myPlayer].ammo[num100].Clone();
if (player[myPlayer].ammo[num100].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].ammo[num100].stack, ")");
}
}
spriteBatch.Draw(inventoryBackTexture, new Vector2(num98, num99), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color14 = Color.White;
if (player[myPlayer].ammo[num100].type > 0 && player[myPlayer].ammo[num100].stack > 0)
{
float num102 = 1f;
if (itemTexture[player[myPlayer].ammo[num100].type].Width > 32 || itemTexture[player[myPlayer].ammo[num100].type].Height > 32)
{
num102 = ((itemTexture[player[myPlayer].ammo[num100].type].Width <= itemTexture[player[myPlayer].ammo[num100].type].Height) ? (32f / (float)itemTexture[player[myPlayer].ammo[num100].type].Height) : (32f / (float)itemTexture[player[myPlayer].ammo[num100].type].Width));
}
num102 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].ammo[num100].type], new Vector2((float)num98 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].ammo[num100].type].Width * 0.5f * num102, (float)num99 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].ammo[num100].type].Height * 0.5f * num102), new Rectangle(0, 0, itemTexture[player[myPlayer].ammo[num100].type].Width, itemTexture[player[myPlayer].ammo[num100].type].Height), player[myPlayer].ammo[num100].GetAlpha(color14), 0f, default(Vector2), num102, SpriteEffects.None, 0f);
if (player[myPlayer].ammo[num100].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].ammo[num100].type], new Vector2((float)num98 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].ammo[num100].type].Width * 0.5f * num102, (float)num99 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].ammo[num100].type].Height * 0.5f * num102), new Rectangle(0, 0, itemTexture[player[myPlayer].ammo[num100].type].Width, itemTexture[player[myPlayer].ammo[num100].type].Height), player[myPlayer].ammo[num100].GetColor(color14), 0f, default(Vector2), num102, SpriteEffects.None, 0f);
}
if (player[myPlayer].ammo[num100].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].ammo[num100].stack.ToString(), new Vector2((float)num98 + 10f * inventoryScale, (float)num99 + 26f * inventoryScale), color14, 0f, default(Vector2), num102, SpriteEffects.None, 0f);
}
}
}
if (npcShop > 0 && (!playerInventory || player[myPlayer].talkNPC == -1))
{
npcShop = 0;
}
if (npcShop > 0)
{
spriteBatch.DrawString(fontMouseText, "Shop", new Vector2(284f, 210f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
inventoryScale = 0.75f;
if (mouseState.X > 73 && mouseState.X < (int)(73f + 280f * inventoryScale) && mouseState.Y > 210 && mouseState.Y < (int)(210f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num103 = 0; num103 < 5; num103++)
{
for (int num104 = 0; num104 < 4; num104++)
{
int num105 = (int)(73f + (float)(num103 * 56) * inventoryScale);
int num106 = (int)(210f + (float)(num104 * 56) * inventoryScale);
int num107 = num103 + num104 * 5;
Color color15 = new Color(100, 100, 100, 100);
if (mouseState.X >= num105 && (float)mouseState.X <= (float)num105 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num106 && (float)mouseState.Y <= (float)num106 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (mouseItem.type == 0)
{
if ((player[myPlayer].selectedItem != num107 || player[myPlayer].itemAnimation <= 0) && player[myPlayer].BuyItem(shop[npcShop].item[num107].value))
{
mouseItem.SetDefaults(shop[npcShop].item[num107].name);
if (shop[npcShop].item[num107].buyOnce)
{
Item item17 = shop[npcShop].item[num107];
item17.stack--;
if (shop[npcShop].item[num107].stack <= 0)
{
shop[npcShop].item[num107].SetDefaults(0);
}
}
PlaySound(18);
}
}
else if (shop[npcShop].item[num107].type == 0)
{
if (player[myPlayer].SellItem(mouseItem.value, mouseItem.stack))
{
shop[npcShop].AddShop(mouseItem);
mouseItem.stack = 0;
mouseItem.type = 0;
PlaySound(18);
}
else if (mouseItem.value == 0)
{
shop[npcShop].AddShop(mouseItem);
mouseItem.stack = 0;
mouseItem.type = 0;
PlaySound(7);
}
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && (mouseItem.IsTheSameAs(shop[npcShop].item[num107]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0) && player[myPlayer].BuyItem(shop[npcShop].item[num107].value))
{
PlaySound(18);
if (mouseItem.type == 0)
{
mouseItem.SetDefaults(shop[npcShop].item[num107].name);
mouseItem.stack = 0;
}
mouseItem.stack++;
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
if (shop[npcShop].item[num107].buyOnce)
{
Item item18 = shop[npcShop].item[num107];
item18.stack--;
if (shop[npcShop].item[num107].stack <= 0)
{
shop[npcShop].item[num107].SetDefaults(0);
}
}
}
text5 = shop[npcShop].item[num107].name;
toolTip = (Item)shop[npcShop].item[num107].Clone();
toolTip.buy = true;
if (shop[npcShop].item[num107].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", shop[npcShop].item[num107].stack, ")");
}
}
spriteBatch.Draw(inventoryBack6Texture, new Vector2(num105, num106), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color15 = Color.White;
if (shop[npcShop].item[num107].type > 0 && shop[npcShop].item[num107].stack > 0)
{
float num108 = 1f;
if (itemTexture[shop[npcShop].item[num107].type].Width > 32 || itemTexture[shop[npcShop].item[num107].type].Height > 32)
{
num108 = ((itemTexture[shop[npcShop].item[num107].type].Width <= itemTexture[shop[npcShop].item[num107].type].Height) ? (32f / (float)itemTexture[shop[npcShop].item[num107].type].Height) : (32f / (float)itemTexture[shop[npcShop].item[num107].type].Width));
}
num108 *= inventoryScale;
spriteBatch.Draw(itemTexture[shop[npcShop].item[num107].type], new Vector2((float)num105 + 26f * inventoryScale - (float)itemTexture[shop[npcShop].item[num107].type].Width * 0.5f * num108, (float)num106 + 26f * inventoryScale - (float)itemTexture[shop[npcShop].item[num107].type].Height * 0.5f * num108), new Rectangle(0, 0, itemTexture[shop[npcShop].item[num107].type].Width, itemTexture[shop[npcShop].item[num107].type].Height), shop[npcShop].item[num107].GetAlpha(color15), 0f, default(Vector2), num108, SpriteEffects.None, 0f);
if (shop[npcShop].item[num107].color != default(Color))
{
spriteBatch.Draw(itemTexture[shop[npcShop].item[num107].type], new Vector2((float)num105 + 26f * inventoryScale - (float)itemTexture[shop[npcShop].item[num107].type].Width * 0.5f * num108, (float)num106 + 26f * inventoryScale - (float)itemTexture[shop[npcShop].item[num107].type].Height * 0.5f * num108), new Rectangle(0, 0, itemTexture[shop[npcShop].item[num107].type].Width, itemTexture[shop[npcShop].item[num107].type].Height), shop[npcShop].item[num107].GetColor(color15), 0f, default(Vector2), num108, SpriteEffects.None, 0f);
}
if (shop[npcShop].item[num107].stack > 1)
{
spriteBatch.DrawString(fontItemStack, shop[npcShop].item[num107].stack.ToString(), new Vector2((float)num105 + 10f * inventoryScale, (float)num106 + 26f * inventoryScale), color15, 0f, default(Vector2), num108, SpriteEffects.None, 0f);
}
}
}
}
}
if (player[myPlayer].chest > -1 && tile[player[myPlayer].chestX, player[myPlayer].chestY].type != 21)
{
player[myPlayer].chest = -1;
}
if (player[myPlayer].chest != -1)
{
inventoryScale = 0.75f;
if (mouseState.X > 73 && mouseState.X < (int)(73f + 280f * inventoryScale) && mouseState.Y > 210 && mouseState.Y < (int)(210f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num109 = 0; num109 < 3; num109++)
{
int num110 = 286;
int num111 = 250;
float num112 = chestLootScale;
string text13 = "Loot All";
switch (num109)
{
case 1:
num111 += 26;
num112 = chestDepositScale;
text13 = "Deposit All";
break;
case 2:
num111 += 52;
num112 = chestStackScale;
text13 = "Quick Stack";
break;
}
Vector2 origin = fontMouseText.MeasureString(text13) / 2f;
Color color16 = new Color((byte)((float)(int)mouseTextColor * num112), (byte)((float)(int)mouseTextColor * num112), (byte)((float)(int)mouseTextColor * num112), (byte)((float)(int)mouseTextColor * num112));
num110 += (int)(origin.X * num112);
spriteBatch.DrawString(fontMouseText, text13, new Vector2(num110, num111), color16, 0f, origin, num112, SpriteEffects.None, 0f);
origin *= num112;
if ((float)mouseState.X > (float)num110 - origin.X && (float)mouseState.X < (float)num110 + origin.X && (float)mouseState.Y > (float)num111 - origin.Y && (float)mouseState.Y < (float)num111 + origin.Y)
{
switch (num109)
{
case 0:
if (!chestLootHover)
{
PlaySound(12);
}
chestLootHover = true;
break;
case 1:
if (!chestDepositHover)
{
PlaySound(12);
}
chestDepositHover = true;
break;
default:
if (!chestStackHover)
{
PlaySound(12);
}
chestStackHover = true;
break;
}
player[myPlayer].mouseInterface = true;
num112 += 0.05f;
if (mouseState.LeftButton == ButtonState.Pressed && mouseLeftRelease)
{
switch (num109)
{
case 0:
{
if (player[myPlayer].chest > -1)
{
for (int num122 = 0; num122 < 20; num122++)
{
if (chest[player[myPlayer].chest].item[num122].type > 0)
{
chest[player[myPlayer].chest].item[num122] = player[myPlayer].GetItem(myPlayer, chest[player[myPlayer].chest].item[num122]);
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num122);
}
}
}
break;
}
if (player[myPlayer].chest == -3)
{
for (int num123 = 0; num123 < 20; num123++)
{
if (player[myPlayer].bank2[num123].type > 0)
{
player[myPlayer].bank2[num123] = player[myPlayer].GetItem(myPlayer, player[myPlayer].bank2[num123]);
}
}
break;
}
for (int num124 = 0; num124 < 20; num124++)
{
if (player[myPlayer].bank[num124].type > 0)
{
player[myPlayer].bank[num124] = player[myPlayer].GetItem(myPlayer, player[myPlayer].bank[num124]);
}
}
break;
}
case 1:
{
for (int num125 = 40; num125 >= 10; num125--)
{
if (player[myPlayer].inventory[num125].stack > 0 && player[myPlayer].inventory[num125].type > 0)
{
if (player[myPlayer].inventory[num125].maxStack > 1)
{
for (int num126 = 0; num126 < 20; num126++)
{
if (player[myPlayer].chest > -1)
{
if (chest[player[myPlayer].chest].item[num126].stack >= chest[player[myPlayer].chest].item[num126].maxStack || !player[myPlayer].inventory[num125].IsTheSameAs(chest[player[myPlayer].chest].item[num126]))
{
continue;
}
int num127 = player[myPlayer].inventory[num125].stack;
if (player[myPlayer].inventory[num125].stack + chest[player[myPlayer].chest].item[num126].stack > chest[player[myPlayer].chest].item[num126].maxStack)
{
num127 = chest[player[myPlayer].chest].item[num126].maxStack - chest[player[myPlayer].chest].item[num126].stack;
}
Item item25 = player[myPlayer].inventory[num125];
item25.stack -= num127;
Item item26 = chest[player[myPlayer].chest].item[num126];
item26.stack += num127;
ChestCoins();
PlaySound(7);
if (player[myPlayer].inventory[num125].stack <= 0)
{
player[myPlayer].inventory[num125].SetDefaults(0);
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num126);
}
break;
}
if (chest[player[myPlayer].chest].item[num126].type == 0)
{
chest[player[myPlayer].chest].item[num126] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
}
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num126);
}
}
else if (player[myPlayer].chest == -3)
{
if (player[myPlayer].bank2[num126].stack < player[myPlayer].bank2[num126].maxStack && player[myPlayer].inventory[num125].IsTheSameAs(player[myPlayer].bank2[num126]))
{
int num128 = player[myPlayer].inventory[num125].stack;
if (player[myPlayer].inventory[num125].stack + player[myPlayer].bank2[num126].stack > player[myPlayer].bank2[num126].maxStack)
{
num128 = player[myPlayer].bank2[num126].maxStack - player[myPlayer].bank2[num126].stack;
}
Item item27 = player[myPlayer].inventory[num125];
item27.stack -= num128;
Item item28 = player[myPlayer].bank2[num126];
item28.stack += num128;
PlaySound(7);
BankCoins();
if (player[myPlayer].inventory[num125].stack <= 0)
{
player[myPlayer].inventory[num125].SetDefaults(0);
break;
}
if (player[myPlayer].bank2[num126].type == 0)
{
player[myPlayer].bank2[num126] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
}
}
}
else if (player[myPlayer].bank[num126].stack < player[myPlayer].bank[num126].maxStack && player[myPlayer].inventory[num125].IsTheSameAs(player[myPlayer].bank[num126]))
{
int num129 = player[myPlayer].inventory[num125].stack;
if (player[myPlayer].inventory[num125].stack + player[myPlayer].bank[num126].stack > player[myPlayer].bank[num126].maxStack)
{
num129 = player[myPlayer].bank[num126].maxStack - player[myPlayer].bank[num126].stack;
}
Item item29 = player[myPlayer].inventory[num125];
item29.stack -= num129;
Item item30 = player[myPlayer].bank[num126];
item30.stack += num129;
PlaySound(7);
BankCoins();
if (player[myPlayer].inventory[num125].stack <= 0)
{
player[myPlayer].inventory[num125].SetDefaults(0);
break;
}
if (player[myPlayer].bank[num126].type == 0)
{
player[myPlayer].bank[num126] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
}
}
}
}
if (player[myPlayer].inventory[num125].stack > 0)
{
if (player[myPlayer].chest > -1)
{
for (int num130 = 0; num130 < 20; num130++)
{
if (chest[player[myPlayer].chest].item[num130].stack == 0)
{
PlaySound(7);
chest[player[myPlayer].chest].item[num130] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num130);
}
break;
}
}
}
else if (player[myPlayer].chest == -3)
{
for (int num131 = 0; num131 < 20; num131++)
{
if (player[myPlayer].bank2[num131].stack == 0)
{
PlaySound(7);
player[myPlayer].bank2[num131] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
break;
}
}
}
else
{
for (int num132 = 0; num132 < 20; num132++)
{
if (player[myPlayer].bank[num132].stack == 0)
{
PlaySound(7);
player[myPlayer].bank[num132] = (Item)player[myPlayer].inventory[num125].Clone();
player[myPlayer].inventory[num125].SetDefaults(0);
break;
}
}
}
}
}
}
break;
}
default:
{
if (player[myPlayer].chest > -1)
{
for (int num113 = 0; num113 < 20; num113++)
{
if (chest[player[myPlayer].chest].item[num113].type <= 0 || chest[player[myPlayer].chest].item[num113].stack >= chest[player[myPlayer].chest].item[num113].maxStack)
{
continue;
}
for (int num114 = 0; num114 < 44; num114++)
{
if (chest[player[myPlayer].chest].item[num113].IsTheSameAs(player[myPlayer].inventory[num114]))
{
int num115 = player[myPlayer].inventory[num114].stack;
if (chest[player[myPlayer].chest].item[num113].stack + num115 > chest[player[myPlayer].chest].item[num113].maxStack)
{
num115 = chest[player[myPlayer].chest].item[num113].maxStack - chest[player[myPlayer].chest].item[num113].stack;
}
PlaySound(7);
Item item19 = chest[player[myPlayer].chest].item[num113];
item19.stack += num115;
Item item20 = player[myPlayer].inventory[num114];
item20.stack -= num115;
ChestCoins();
if (player[myPlayer].inventory[num114].stack == 0)
{
player[myPlayer].inventory[num114].SetDefaults(0);
}
else if (chest[player[myPlayer].chest].item[num113].type == 0)
{
chest[player[myPlayer].chest].item[num113] = (Item)player[myPlayer].inventory[num114].Clone();
player[myPlayer].inventory[num114].SetDefaults(0);
}
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num113);
}
}
}
}
break;
}
if (player[myPlayer].chest == -3)
{
for (int num116 = 0; num116 < 20; num116++)
{
if (player[myPlayer].bank2[num116].type <= 0 || player[myPlayer].bank2[num116].stack >= player[myPlayer].bank2[num116].maxStack)
{
continue;
}
for (int num117 = 0; num117 < 44; num117++)
{
if (player[myPlayer].bank2[num116].IsTheSameAs(player[myPlayer].inventory[num117]))
{
int num118 = player[myPlayer].inventory[num117].stack;
if (player[myPlayer].bank2[num116].stack + num118 > player[myPlayer].bank2[num116].maxStack)
{
num118 = player[myPlayer].bank2[num116].maxStack - player[myPlayer].bank2[num116].stack;
}
PlaySound(7);
Item item21 = player[myPlayer].bank2[num116];
item21.stack += num118;
Item item22 = player[myPlayer].inventory[num117];
item22.stack -= num118;
BankCoins();
if (player[myPlayer].inventory[num117].stack == 0)
{
player[myPlayer].inventory[num117].SetDefaults(0);
}
else if (player[myPlayer].bank2[num116].type == 0)
{
player[myPlayer].bank2[num116] = (Item)player[myPlayer].inventory[num117].Clone();
player[myPlayer].inventory[num117].SetDefaults(0);
}
}
}
}
break;
}
for (int num119 = 0; num119 < 20; num119++)
{
if (player[myPlayer].bank[num119].type <= 0 || player[myPlayer].bank[num119].stack >= player[myPlayer].bank[num119].maxStack)
{
continue;
}
for (int num120 = 0; num120 < 44; num120++)
{
if (player[myPlayer].bank[num119].IsTheSameAs(player[myPlayer].inventory[num120]))
{
int num121 = player[myPlayer].inventory[num120].stack;
if (player[myPlayer].bank[num119].stack + num121 > player[myPlayer].bank[num119].maxStack)
{
num121 = player[myPlayer].bank[num119].maxStack - player[myPlayer].bank[num119].stack;
}
PlaySound(7);
Item item23 = player[myPlayer].bank[num119];
item23.stack += num121;
Item item24 = player[myPlayer].inventory[num120];
item24.stack -= num121;
BankCoins();
if (player[myPlayer].inventory[num120].stack == 0)
{
player[myPlayer].inventory[num120].SetDefaults(0);
}
else if (player[myPlayer].bank[num119].type == 0)
{
player[myPlayer].bank[num119] = (Item)player[myPlayer].inventory[num120].Clone();
player[myPlayer].inventory[num120].SetDefaults(0);
}
}
}
}
break;
}
}
Recipe.FindRecipes();
}
}
else
{
num112 -= 0.05f;
switch (num109)
{
case 0:
chestLootHover = false;
break;
case 1:
chestDepositHover = false;
break;
default:
chestStackHover = false;
break;
}
}
if ((double)num112 < 0.75)
{
num112 = 0.75f;
}
if (num112 > 1f)
{
num112 = 1f;
}
switch (num109)
{
case 0:
chestLootScale = num112;
break;
case 1:
chestDepositScale = num112;
break;
default:
chestStackScale = num112;
break;
}
}
}
else
{
chestLootScale = 0.75f;
chestDepositScale = 0.75f;
chestStackScale = 0.75f;
chestLootHover = false;
chestDepositHover = false;
chestStackHover = false;
}
if (player[myPlayer].chest > -1)
{
spriteBatch.DrawString(fontMouseText, chestText, new Vector2(284f, 210f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
inventoryScale = 0.75f;
if (mouseState.X > 73 && mouseState.X < (int)(73f + 280f * inventoryScale) && mouseState.Y > 210 && mouseState.Y < (int)(210f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num133 = 0; num133 < 5; num133++)
{
for (int num134 = 0; num134 < 4; num134++)
{
int num135 = (int)(73f + (float)(num133 * 56) * inventoryScale);
int num136 = (int)(210f + (float)(num134 * 56) * inventoryScale);
int num137 = num133 + num134 * 5;
Color color17 = new Color(100, 100, 100, 100);
if (mouseState.X >= num135 && (float)mouseState.X <= (float)num135 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num136 && (float)mouseState.Y <= (float)num136 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (player[myPlayer].selectedItem != num137 || player[myPlayer].itemAnimation <= 0)
{
Item item31 = mouseItem;
mouseItem = chest[player[myPlayer].chest].item[num137];
chest[player[myPlayer].chest].item[num137] = item31;
if (chest[player[myPlayer].chest].item[num137].type == 0 || chest[player[myPlayer].chest].item[num137].stack < 1)
{
chest[player[myPlayer].chest].item[num137] = new Item();
}
if (mouseItem.IsTheSameAs(chest[player[myPlayer].chest].item[num137]) && chest[player[myPlayer].chest].item[num137].stack != chest[player[myPlayer].chest].item[num137].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + chest[player[myPlayer].chest].item[num137].stack <= mouseItem.maxStack)
{
Item item32 = chest[player[myPlayer].chest].item[num137];
item32.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num138 = mouseItem.maxStack - chest[player[myPlayer].chest].item[num137].stack;
Item item33 = chest[player[myPlayer].chest].item[num137];
item33.stack += num138;
mouseItem.stack -= num138;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || chest[player[myPlayer].chest].item[num137].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num137);
}
}
}
else if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && chest[player[myPlayer].chest].item[num137].maxStack == 1)
{
chest[player[myPlayer].chest].item[num137] = armorSwap(chest[player[myPlayer].chest].item[num137]);
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num137);
}
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && chest[player[myPlayer].chest].item[num137].maxStack > 1 && (mouseItem.IsTheSameAs(chest[player[myPlayer].chest].item[num137]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)chest[player[myPlayer].chest].item[num137].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item34 = chest[player[myPlayer].chest].item[num137];
item34.stack--;
if (chest[player[myPlayer].chest].item[num137].stack <= 0)
{
chest[player[myPlayer].chest].item[num137] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
if (netMode == 1)
{
NetMessage.SendData(32, -1, -1, "", player[myPlayer].chest, num137);
}
}
text5 = chest[player[myPlayer].chest].item[num137].name;
toolTip = (Item)chest[player[myPlayer].chest].item[num137].Clone();
if (chest[player[myPlayer].chest].item[num137].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", chest[player[myPlayer].chest].item[num137].stack, ")");
}
}
spriteBatch.Draw(inventoryBack5Texture, new Vector2(num135, num136), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color17 = Color.White;
if (chest[player[myPlayer].chest].item[num137].type > 0 && chest[player[myPlayer].chest].item[num137].stack > 0)
{
float num139 = 1f;
if (itemTexture[chest[player[myPlayer].chest].item[num137].type].Width > 32 || itemTexture[chest[player[myPlayer].chest].item[num137].type].Height > 32)
{
num139 = ((itemTexture[chest[player[myPlayer].chest].item[num137].type].Width <= itemTexture[chest[player[myPlayer].chest].item[num137].type].Height) ? (32f / (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Height) : (32f / (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Width));
}
num139 *= inventoryScale;
spriteBatch.Draw(itemTexture[chest[player[myPlayer].chest].item[num137].type], new Vector2((float)num135 + 26f * inventoryScale - (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Width * 0.5f * num139, (float)num136 + 26f * inventoryScale - (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Height * 0.5f * num139), new Rectangle(0, 0, itemTexture[chest[player[myPlayer].chest].item[num137].type].Width, itemTexture[chest[player[myPlayer].chest].item[num137].type].Height), chest[player[myPlayer].chest].item[num137].GetAlpha(color17), 0f, default(Vector2), num139, SpriteEffects.None, 0f);
if (chest[player[myPlayer].chest].item[num137].color != default(Color))
{
spriteBatch.Draw(itemTexture[chest[player[myPlayer].chest].item[num137].type], new Vector2((float)num135 + 26f * inventoryScale - (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Width * 0.5f * num139, (float)num136 + 26f * inventoryScale - (float)itemTexture[chest[player[myPlayer].chest].item[num137].type].Height * 0.5f * num139), new Rectangle(0, 0, itemTexture[chest[player[myPlayer].chest].item[num137].type].Width, itemTexture[chest[player[myPlayer].chest].item[num137].type].Height), chest[player[myPlayer].chest].item[num137].GetColor(color17), 0f, default(Vector2), num139, SpriteEffects.None, 0f);
}
if (chest[player[myPlayer].chest].item[num137].stack > 1)
{
spriteBatch.DrawString(fontItemStack, chest[player[myPlayer].chest].item[num137].stack.ToString(), new Vector2((float)num135 + 10f * inventoryScale, (float)num136 + 26f * inventoryScale), color17, 0f, default(Vector2), num139, SpriteEffects.None, 0f);
}
}
}
}
}
if (player[myPlayer].chest == -2)
{
spriteBatch.DrawString(fontMouseText, "Piggy Bank", new Vector2(284f, 210f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
inventoryScale = 0.75f;
if (mouseState.X > 73 && mouseState.X < (int)(73f + 280f * inventoryScale) && mouseState.Y > 210 && mouseState.Y < (int)(210f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num140 = 0; num140 < 5; num140++)
{
for (int num141 = 0; num141 < 4; num141++)
{
int num142 = (int)(73f + (float)(num140 * 56) * inventoryScale);
int num143 = (int)(210f + (float)(num141 * 56) * inventoryScale);
int num144 = num140 + num141 * 5;
Color color18 = new Color(100, 100, 100, 100);
if (mouseState.X >= num142 && (float)mouseState.X <= (float)num142 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num143 && (float)mouseState.Y <= (float)num143 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (player[myPlayer].selectedItem != num144 || player[myPlayer].itemAnimation <= 0)
{
Item item35 = mouseItem;
mouseItem = player[myPlayer].bank[num144];
player[myPlayer].bank[num144] = item35;
if (player[myPlayer].bank[num144].type == 0 || player[myPlayer].bank[num144].stack < 1)
{
player[myPlayer].bank[num144] = new Item();
}
if (mouseItem.IsTheSameAs(player[myPlayer].bank[num144]) && player[myPlayer].bank[num144].stack != player[myPlayer].bank[num144].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + player[myPlayer].bank[num144].stack <= mouseItem.maxStack)
{
Item item36 = player[myPlayer].bank[num144];
item36.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num145 = mouseItem.maxStack - player[myPlayer].bank[num144].stack;
Item item37 = player[myPlayer].bank[num144];
item37.stack += num145;
mouseItem.stack -= num145;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].bank[num144].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
}
else if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && player[myPlayer].bank[num144].maxStack == 1)
{
player[myPlayer].bank[num144] = armorSwap(player[myPlayer].bank[num144]);
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && player[myPlayer].bank[num144].maxStack > 1 && (mouseItem.IsTheSameAs(player[myPlayer].bank[num144]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)player[myPlayer].bank[num144].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item38 = player[myPlayer].bank[num144];
item38.stack--;
if (player[myPlayer].bank[num144].stack <= 0)
{
player[myPlayer].bank[num144] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
text5 = player[myPlayer].bank[num144].name;
toolTip = (Item)player[myPlayer].bank[num144].Clone();
if (player[myPlayer].bank[num144].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].bank[num144].stack, ")");
}
}
spriteBatch.Draw(inventoryBack2Texture, new Vector2(num142, num143), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color18 = Color.White;
if (player[myPlayer].bank[num144].type > 0 && player[myPlayer].bank[num144].stack > 0)
{
float num146 = 1f;
if (itemTexture[player[myPlayer].bank[num144].type].Width > 32 || itemTexture[player[myPlayer].bank[num144].type].Height > 32)
{
num146 = ((itemTexture[player[myPlayer].bank[num144].type].Width <= itemTexture[player[myPlayer].bank[num144].type].Height) ? (32f / (float)itemTexture[player[myPlayer].bank[num144].type].Height) : (32f / (float)itemTexture[player[myPlayer].bank[num144].type].Width));
}
num146 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].bank[num144].type], new Vector2((float)num142 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank[num144].type].Width * 0.5f * num146, (float)num143 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank[num144].type].Height * 0.5f * num146), new Rectangle(0, 0, itemTexture[player[myPlayer].bank[num144].type].Width, itemTexture[player[myPlayer].bank[num144].type].Height), player[myPlayer].bank[num144].GetAlpha(color18), 0f, default(Vector2), num146, SpriteEffects.None, 0f);
if (player[myPlayer].bank[num144].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].bank[num144].type], new Vector2((float)num142 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank[num144].type].Width * 0.5f * num146, (float)num143 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank[num144].type].Height * 0.5f * num146), new Rectangle(0, 0, itemTexture[player[myPlayer].bank[num144].type].Width, itemTexture[player[myPlayer].bank[num144].type].Height), player[myPlayer].bank[num144].GetColor(color18), 0f, default(Vector2), num146, SpriteEffects.None, 0f);
}
if (player[myPlayer].bank[num144].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].bank[num144].stack.ToString(), new Vector2((float)num142 + 10f * inventoryScale, (float)num143 + 26f * inventoryScale), color18, 0f, default(Vector2), num146, SpriteEffects.None, 0f);
}
}
}
}
}
if (player[myPlayer].chest == -3)
{
spriteBatch.DrawString(fontMouseText, "Safe", new Vector2(284f, 210f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
inventoryScale = 0.75f;
if (mouseState.X > 73 && mouseState.X < (int)(73f + 280f * inventoryScale) && mouseState.Y > 210 && mouseState.Y < (int)(210f + 224f * inventoryScale))
{
player[myPlayer].mouseInterface = true;
}
for (int num147 = 0; num147 < 5; num147++)
{
for (int num148 = 0; num148 < 4; num148++)
{
int num149 = (int)(73f + (float)(num147 * 56) * inventoryScale);
int num150 = (int)(210f + (float)(num148 * 56) * inventoryScale);
int num151 = num147 + num148 * 5;
Color color19 = new Color(100, 100, 100, 100);
if (mouseState.X >= num149 && (float)mouseState.X <= (float)num149 + (float)inventoryBackTexture.Width * inventoryScale && mouseState.Y >= num150 && (float)mouseState.Y <= (float)num150 + (float)inventoryBackTexture.Height * inventoryScale)
{
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
if (player[myPlayer].selectedItem != num151 || player[myPlayer].itemAnimation <= 0)
{
Item item39 = mouseItem;
mouseItem = player[myPlayer].bank2[num151];
player[myPlayer].bank2[num151] = item39;
if (player[myPlayer].bank2[num151].type == 0 || player[myPlayer].bank2[num151].stack < 1)
{
player[myPlayer].bank2[num151] = new Item();
}
if (mouseItem.IsTheSameAs(player[myPlayer].bank2[num151]) && player[myPlayer].bank2[num151].stack != player[myPlayer].bank2[num151].maxStack && mouseItem.stack != mouseItem.maxStack)
{
if (mouseItem.stack + player[myPlayer].bank2[num151].stack <= mouseItem.maxStack)
{
Item item40 = player[myPlayer].bank2[num151];
item40.stack += mouseItem.stack;
mouseItem.stack = 0;
}
else
{
int num152 = mouseItem.maxStack - player[myPlayer].bank2[num151].stack;
Item item41 = player[myPlayer].bank2[num151];
item41.stack += num152;
mouseItem.stack -= num152;
}
}
if (mouseItem.type == 0 || mouseItem.stack < 1)
{
mouseItem = new Item();
}
if (mouseItem.type > 0 || player[myPlayer].bank2[num151].type > 0)
{
Recipe.FindRecipes();
PlaySound(7);
}
}
}
else if (mouseState.RightButton == ButtonState.Pressed && mouseRightRelease && player[myPlayer].bank2[num151].maxStack == 1)
{
player[myPlayer].bank2[num151] = armorSwap(player[myPlayer].bank2[num151]);
}
else if (stackSplit <= 1 && mouseState.RightButton == ButtonState.Pressed && player[myPlayer].bank2[num151].maxStack > 1 && (mouseItem.IsTheSameAs(player[myPlayer].bank2[num151]) || mouseItem.type == 0) && (mouseItem.stack < mouseItem.maxStack || mouseItem.type == 0))
{
if (mouseItem.type == 0)
{
mouseItem = (Item)player[myPlayer].bank2[num151].Clone();
mouseItem.stack = 0;
}
mouseItem.stack++;
Item item42 = player[myPlayer].bank2[num151];
item42.stack--;
if (player[myPlayer].bank2[num151].stack <= 0)
{
player[myPlayer].bank2[num151] = new Item();
}
Recipe.FindRecipes();
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
PlaySound(12);
if (stackSplit == 0)
{
stackSplit = 15;
}
else
{
stackSplit = stackDelay;
}
}
text5 = player[myPlayer].bank2[num151].name;
toolTip = (Item)player[myPlayer].bank2[num151].Clone();
if (player[myPlayer].bank2[num151].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].bank2[num151].stack, ")");
}
}
spriteBatch.Draw(inventoryBack2Texture, new Vector2(num149, num150), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), color2, 0f, default(Vector2), inventoryScale, SpriteEffects.None, 0f);
color19 = Color.White;
if (player[myPlayer].bank2[num151].type > 0 && player[myPlayer].bank2[num151].stack > 0)
{
float num153 = 1f;
if (itemTexture[player[myPlayer].bank2[num151].type].Width > 32 || itemTexture[player[myPlayer].bank2[num151].type].Height > 32)
{
num153 = ((itemTexture[player[myPlayer].bank2[num151].type].Width <= itemTexture[player[myPlayer].bank2[num151].type].Height) ? (32f / (float)itemTexture[player[myPlayer].bank2[num151].type].Height) : (32f / (float)itemTexture[player[myPlayer].bank2[num151].type].Width));
}
num153 *= inventoryScale;
spriteBatch.Draw(itemTexture[player[myPlayer].bank2[num151].type], new Vector2((float)num149 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank2[num151].type].Width * 0.5f * num153, (float)num150 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank2[num151].type].Height * 0.5f * num153), new Rectangle(0, 0, itemTexture[player[myPlayer].bank2[num151].type].Width, itemTexture[player[myPlayer].bank2[num151].type].Height), player[myPlayer].bank2[num151].GetAlpha(color19), 0f, default(Vector2), num153, SpriteEffects.None, 0f);
if (player[myPlayer].bank2[num151].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].bank2[num151].type], new Vector2((float)num149 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank2[num151].type].Width * 0.5f * num153, (float)num150 + 26f * inventoryScale - (float)itemTexture[player[myPlayer].bank2[num151].type].Height * 0.5f * num153), new Rectangle(0, 0, itemTexture[player[myPlayer].bank2[num151].type].Width, itemTexture[player[myPlayer].bank2[num151].type].Height), player[myPlayer].bank2[num151].GetColor(color19), 0f, default(Vector2), num153, SpriteEffects.None, 0f);
}
if (player[myPlayer].bank2[num151].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].bank2[num151].stack.ToString(), new Vector2((float)num149 + 10f * inventoryScale, (float)num150 + 26f * inventoryScale), color19, 0f, default(Vector2), num153, SpriteEffects.None, 0f);
}
}
}
}
}
}
if (playerInventory || player[myPlayer].ghost)
{
string text14 = "Save & Exit";
if (netMode != 0)
{
text14 = "Disconnect";
}
Vector2 vector5 = fontDeathText.MeasureString(text14);
int num154 = screenWidth - 110;
int num155 = screenHeight - 20;
if (mouseExit)
{
if (exitScale < 1f)
{
exitScale += 0.02f;
}
}
else if ((double)exitScale > 0.8)
{
exitScale -= 0.02f;
}
for (int num156 = 0; num156 < 5; num156++)
{
int num157 = 0;
int num158 = 0;
Color color20 = Color.Black;
switch (num156)
{
case 0:
num157 = -2;
break;
case 1:
num157 = 2;
break;
case 2:
num158 = -2;
break;
case 3:
num158 = 2;
break;
case 4:
color20 = Color.White;
break;
}
spriteBatch.DrawString(fontDeathText, text14, new Vector2(num154 + num157, num155 + num158), color20, 0f, new Vector2(vector5.X / 2f, vector5.Y / 2f), exitScale - 0.2f, SpriteEffects.None, 0f);
}
if ((float)mouseState.X > (float)num154 - vector5.X / 2f && (float)mouseState.X < (float)num154 + vector5.X / 2f && (float)mouseState.Y > (float)num155 - vector5.Y / 2f && (float)mouseState.Y < (float)num155 + vector5.Y / 2f - 10f)
{
if (!mouseExit)
{
PlaySound(12);
}
mouseExit = true;
player[myPlayer].mouseInterface = true;
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
menuMode = 10;
WorldGen.SaveAndQuit();
}
}
else
{
mouseExit = false;
}
}
if (!playerInventory && !player[myPlayer].ghost)
{
string text15 = "Items";
if (player[myPlayer].inventory[player[myPlayer].selectedItem].name != "" && player[myPlayer].inventory[player[myPlayer].selectedItem].name != null)
{
text15 = player[myPlayer].inventory[player[myPlayer].selectedItem].name;
}
Vector2 vector6 = fontMouseText.MeasureString(text15) / 2f;
spriteBatch.DrawString(fontMouseText, text15, new Vector2(236f - vector6.X, 0f), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
int num159 = 20;
float num160 = 1f;
for (int num161 = 0; num161 < 10; num161++)
{
if (num161 == player[myPlayer].selectedItem)
{
if (hotbarScale[num161] < 1f)
{
hotbarScale[num161] += 0.05f;
}
}
else if ((double)hotbarScale[num161] > 0.75)
{
hotbarScale[num161] -= 0.05f;
}
float num162 = hotbarScale[num161];
int num163 = (int)(20f + 22f * (1f - num162));
int a3 = (int)(75f + 150f * num162);
Color color21 = new Color(255, 255, 255, a3);
spriteBatch.Draw(inventoryBackTexture, new Vector2(num159, num163), new Rectangle(0, 0, inventoryBackTexture.Width, inventoryBackTexture.Height), new Color(100, 100, 100, 100), 0f, default(Vector2), num162, SpriteEffects.None, 0f);
if (mouseState.X >= num159 && (float)mouseState.X <= (float)num159 + (float)inventoryBackTexture.Width * hotbarScale[num161] && mouseState.Y >= num163 && (float)mouseState.Y <= (float)num163 + (float)inventoryBackTexture.Height * hotbarScale[num161] && !player[myPlayer].channel)
{
if (!player[myPlayer].hbLocked)
{
player[myPlayer].mouseInterface = true;
}
if (mouseState.LeftButton == ButtonState.Pressed && !player[myPlayer].hbLocked)
{
player[myPlayer].changeItem = num161;
}
player[myPlayer].showItemIcon = false;
text5 = player[myPlayer].inventory[num161].name;
if (player[myPlayer].inventory[num161].stack > 1)
{
object obj = text5;
text5 = string.Concat(obj, " (", player[myPlayer].inventory[num161].stack, ")");
}
rare = player[myPlayer].inventory[num161].rare;
}
if (player[myPlayer].inventory[num161].type > 0 && player[myPlayer].inventory[num161].stack > 0)
{
num160 = 1f;
if (itemTexture[player[myPlayer].inventory[num161].type].Width > 32 || itemTexture[player[myPlayer].inventory[num161].type].Height > 32)
{
num160 = ((itemTexture[player[myPlayer].inventory[num161].type].Width <= itemTexture[player[myPlayer].inventory[num161].type].Height) ? (32f / (float)itemTexture[player[myPlayer].inventory[num161].type].Height) : (32f / (float)itemTexture[player[myPlayer].inventory[num161].type].Width));
}
num160 *= num162;
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num161].type], new Vector2((float)num159 + 26f * num162 - (float)itemTexture[player[myPlayer].inventory[num161].type].Width * 0.5f * num160, (float)num163 + 26f * num162 - (float)itemTexture[player[myPlayer].inventory[num161].type].Height * 0.5f * num160), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num161].type].Width, itemTexture[player[myPlayer].inventory[num161].type].Height), player[myPlayer].inventory[num161].GetAlpha(color21), 0f, default(Vector2), num160, SpriteEffects.None, 0f);
if (player[myPlayer].inventory[num161].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[num161].type], new Vector2((float)num159 + 26f * num162 - (float)itemTexture[player[myPlayer].inventory[num161].type].Width * 0.5f * num160, (float)num163 + 26f * num162 - (float)itemTexture[player[myPlayer].inventory[num161].type].Height * 0.5f * num160), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[num161].type].Width, itemTexture[player[myPlayer].inventory[num161].type].Height), player[myPlayer].inventory[num161].GetColor(color21), 0f, default(Vector2), num160, SpriteEffects.None, 0f);
}
if (player[myPlayer].inventory[num161].stack > 1)
{
spriteBatch.DrawString(fontItemStack, player[myPlayer].inventory[num161].stack.ToString(), new Vector2((float)num159 + 10f * num162, (float)num163 + 26f * num162), color21, 0f, default(Vector2), num160, SpriteEffects.None, 0f);
}
if (player[myPlayer].inventory[num161].useAmmo > 0)
{
int useAmmo = player[myPlayer].inventory[num161].useAmmo;
int num164 = 0;
for (int num165 = 0; num165 < 40; num165++)
{
if (num165 < 4 && player[myPlayer].ammo[num165].ammo == useAmmo)
{
num164 += player[myPlayer].ammo[num165].stack;
}
if (player[myPlayer].inventory[num165].ammo == useAmmo)
{
num164 += player[myPlayer].inventory[num165].stack;
}
}
spriteBatch.DrawString(fontItemStack, num164.ToString(), new Vector2((float)num159 + 8f * num162, (float)num163 + 30f * num162), color21, 0f, default(Vector2), num162 * 0.8f, SpriteEffects.None, 0f);
}
string text16 = (num161 + 1).ToString();
if (text16 == "10")
{
text16 = "0";
}
spriteBatch.DrawString(fontItemStack, text16, new Vector2((float)num159 + 8f * hotbarScale[num161], (float)num163 + 4f * hotbarScale[num161]), new Color(color21.R / 2, color21.G / 2, color21.B / 2, color21.A / 2), 0f, default(Vector2), num160, SpriteEffects.None, 0f);
if (player[myPlayer].inventory[num161].potion)
{
Color alpha = player[myPlayer].inventory[num161].GetAlpha(color21);
float num166 = (float)player[myPlayer].potionDelay / (float)Item.potionDelay;
float num167 = (float)(int)alpha.R * num166;
float num168 = (float)(int)alpha.G * num166;
float num169 = (float)(int)alpha.B * num166;
float num170 = (float)(int)alpha.A * num166;
alpha = new Color((byte)num167, (byte)num168, (byte)num169, (byte)num170);
spriteBatch.Draw(cdTexture, new Vector2((float)num159 + 26f * hotbarScale[num161] - (float)cdTexture.Width * 0.5f * num160, (float)num163 + 26f * hotbarScale[num161] - (float)cdTexture.Height * 0.5f * num160), new Rectangle(0, 0, cdTexture.Width, cdTexture.Height), alpha, 0f, default(Vector2), num160, SpriteEffects.None, 0f);
}
}
num159 += (int)((float)inventoryBackTexture.Width * hotbarScale[num161]) + 4;
}
}
if (text5 != null && text5 != "" && mouseItem.type == 0)
{
player[myPlayer].showItemIcon = false;
MouseText(text5, rare, 0);
flag2 = true;
}
if (chatMode)
{
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
string text17 = chatText;
if (textBlinkerState == 1)
{
text17 += "|";
}
spriteBatch.Draw(textBackTexture, new Vector2(78f, screenHeight - 36), new Rectangle(0, 0, textBackTexture.Width, textBackTexture.Height), new Color(100, 100, 100, 100), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
for (int num171 = 0; num171 < 5; num171++)
{
int num172 = 0;
int num173 = 0;
Color color22 = Color.Black;
switch (num171)
{
case 0:
num172 = -2;
break;
case 1:
num172 = 2;
break;
case 2:
num173 = -2;
break;
case 3:
num173 = 2;
break;
case 4:
color22 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
break;
}
spriteBatch.DrawString(fontMouseText, text17, new Vector2(88 + num172, screenHeight - 30 + num173), color22, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
for (int num174 = 0; num174 < numChatLines; num174++)
{
if (!chatMode && chatLine[num174].showTime <= 0)
{
continue;
}
float num175 = (float)(int)mouseTextColor / 255f;
for (int num176 = 0; num176 < 5; num176++)
{
int num177 = 0;
int num178 = 0;
Color color23 = Color.Black;
switch (num176)
{
case 0:
num177 = -2;
break;
case 1:
num177 = 2;
break;
case 2:
num178 = -2;
break;
case 3:
num178 = 2;
break;
case 4:
color23 = new Color((byte)((float)(int)chatLine[num174].color.R * num175), (byte)((float)(int)chatLine[num174].color.G * num175), (byte)((float)(int)chatLine[num174].color.B * num175), mouseTextColor);
break;
}
spriteBatch.DrawString(fontMouseText, chatLine[num174].text, new Vector2(88 + num177, screenHeight - 30 + num178 - 28 - num174 * 21), color23, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
if (player[myPlayer].dead)
{
string text18 = "You were slain...";
spriteBatch.DrawString(fontDeathText, text18, new Vector2(screenWidth / 2 - text18.Length * 10, screenHeight / 2 - 20), player[myPlayer].GetDeathAlpha(new Color(0, 0, 0, 0)), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
spriteBatch.Draw(cursorTexture, new Vector2(mouseState.X + 1, mouseState.Y + 1), new Rectangle(0, 0, cursorTexture.Width, cursorTexture.Height), new Color((int)((float)(int)cursorColor.R * 0.2f), (int)((float)(int)cursorColor.G * 0.2f), (int)((float)(int)cursorColor.B * 0.2f), (int)((float)(int)cursorColor.A * 0.5f)), 0f, default(Vector2), cursorScale * 1.1f, SpriteEffects.None, 0f);
spriteBatch.Draw(cursorTexture, new Vector2(mouseState.X, mouseState.Y), new Rectangle(0, 0, cursorTexture.Width, cursorTexture.Height), cursorColor, 0f, default(Vector2), cursorScale, SpriteEffects.None, 0f);
if (mouseItem.type > 0 && mouseItem.stack > 0)
{
player[myPlayer].showItemIcon = false;
player[myPlayer].showItemIcon2 = 0;
flag2 = true;
float num179 = 1f;
if (itemTexture[mouseItem.type].Width > 32 || itemTexture[mouseItem.type].Height > 32)
{
num179 = ((itemTexture[mouseItem.type].Width <= itemTexture[mouseItem.type].Height) ? (32f / (float)itemTexture[mouseItem.type].Height) : (32f / (float)itemTexture[mouseItem.type].Width));
}
float num180 = 1f;
Color white3 = Color.White;
num179 *= num180;
spriteBatch.Draw(itemTexture[mouseItem.type], new Vector2((float)mouseState.X + 26f * num180 - (float)itemTexture[mouseItem.type].Width * 0.5f * num179, (float)mouseState.Y + 26f * num180 - (float)itemTexture[mouseItem.type].Height * 0.5f * num179), new Rectangle(0, 0, itemTexture[mouseItem.type].Width, itemTexture[mouseItem.type].Height), mouseItem.GetAlpha(white3), 0f, default(Vector2), num179, SpriteEffects.None, 0f);
if (mouseItem.color != default(Color))
{
spriteBatch.Draw(itemTexture[mouseItem.type], new Vector2((float)mouseState.X + 26f * num180 - (float)itemTexture[mouseItem.type].Width * 0.5f * num179, (float)mouseState.Y + 26f * num180 - (float)itemTexture[mouseItem.type].Height * 0.5f * num179), new Rectangle(0, 0, itemTexture[mouseItem.type].Width, itemTexture[mouseItem.type].Height), mouseItem.GetColor(white3), 0f, default(Vector2), num179, SpriteEffects.None, 0f);
}
if (mouseItem.stack > 1)
{
spriteBatch.DrawString(fontItemStack, mouseItem.stack.ToString(), new Vector2((float)mouseState.X + 10f * num180, (float)mouseState.Y + 26f * num180), white3, 0f, default(Vector2), num179, SpriteEffects.None, 0f);
}
}
Rectangle rectangle2 = new Rectangle(mouseState.X + (int)screenPosition.X, mouseState.Y + (int)screenPosition.Y, 1, 1);
if (!flag2)
{
int num181 = 26 * player[myPlayer].statLifeMax / num12;
int num182 = 0;
if (player[myPlayer].statLifeMax > 200)
{
num181 = 260;
num182 += 26;
}
if (mouseState.X > 500 + num10 && mouseState.X < 500 + num181 + num10 && mouseState.Y > 32 && mouseState.Y < 32 + heartTexture.Height + num182)
{
player[myPlayer].showItemIcon = false;
string cursorText = player[myPlayer].statLife + "/" + player[myPlayer].statLifeMax;
MouseText(cursorText, 0, 0);
flag2 = true;
}
}
if (!flag2)
{
int num183 = 24;
int num184 = 28 * player[myPlayer].statManaMax2 / num18;
if (mouseState.X > 762 + num10 && mouseState.X < 762 + num183 + num10 && mouseState.Y > 30 && mouseState.Y < 30 + num184)
{
player[myPlayer].showItemIcon = false;
string cursorText2 = player[myPlayer].statMana + "/" + player[myPlayer].statManaMax2;
MouseText(cursorText2, 0, 0);
flag2 = true;
}
}
if (!flag2)
{
for (int num185 = 0; num185 < 200; num185++)
{
if (!Main.item[num185].active)
{
continue;
}
Rectangle value2 = new Rectangle((int)((double)Main.item[num185].position.X + (double)Main.item[num185].width * 0.5 - (double)itemTexture[Main.item[num185].type].Width * 0.5), (int)Main.item[num185].position.Y + Main.item[num185].height - itemTexture[Main.item[num185].type].Height, itemTexture[Main.item[num185].type].Width, itemTexture[Main.item[num185].type].Height);
if (rectangle2.Intersects(value2))
{
player[myPlayer].showItemIcon = false;
string text19 = Main.item[num185].name;
if (Main.item[num185].stack > 1)
{
object obj = text19;
text19 = string.Concat(obj, " (", Main.item[num185].stack, ")");
}
if (Main.item[num185].owner < 255 && showItemOwner)
{
text19 = text19 + " <" + player[Main.item[num185].owner].name + ">";
}
rare = Main.item[num185].rare;
MouseText(text19, rare, 0);
flag2 = true;
break;
}
}
}
for (int num186 = 0; num186 < 255; num186++)
{
if (!player[num186].active || myPlayer == num186 || player[num186].dead)
{
continue;
}
Rectangle value3 = new Rectangle((int)((double)player[num186].position.X + (double)player[num186].width * 0.5 - 16.0), (int)(player[num186].position.Y + (float)player[num186].height - 48f), 32, 48);
if (!flag2 && rectangle2.Intersects(value3))
{
player[myPlayer].showItemIcon = false;
string text20 = player[num186].name + ": " + player[num186].statLife + "/" + player[num186].statLifeMax;
if (player[num186].hostile)
{
text20 += " (PvP)";
}
MouseText(text20, -1, player[num186].difficulty);
}
}
if (!flag2)
{
for (int num187 = 0; num187 < 1000; num187++)
{
if (!npc[num187].active)
{
continue;
}
Rectangle value4 = new Rectangle((int)((double)npc[num187].position.X + (double)npc[num187].width * 0.5 - (double)npcTexture[npc[num187].type].Width * 0.5), (int)npc[num187].position.Y + npc[num187].height - npcTexture[npc[num187].type].Height / npcFrameCount[npc[num187].type], npcTexture[npc[num187].type].Width, npcTexture[npc[num187].type].Height / npcFrameCount[npc[num187].type]);
if (!rectangle2.Intersects(value4))
{
continue;
}
bool flag8 = false;
if (npc[num187].townNPC)
{
Rectangle rectangle3 = new Rectangle((int)player[myPlayer].position.X + player[myPlayer].width / 2 - Player.tileRangeX * 16, (int)player[myPlayer].position.Y + player[myPlayer].height / 2 - Player.tileRangeY * 16, Player.tileRangeX * 16 * 2, Player.tileRangeY * 16 * 2);
Rectangle value5 = new Rectangle((int)npc[num187].position.X, (int)npc[num187].position.Y, npc[num187].width, npc[num187].height);
if (rectangle3.Intersects(value5))
{
flag8 = true;
}
}
if (flag8 && !player[myPlayer].dead)
{
int num188 = -(npc[num187].width / 2 + 8);
SpriteEffects effects2 = SpriteEffects.None;
if (npc[num187].spriteDirection == -1)
{
effects2 = SpriteEffects.FlipHorizontally;
num188 = npc[num187].width / 2 + 8;
}
spriteBatch.Draw(chatTexture, new Vector2(npc[num187].position.X + (float)(npc[num187].width / 2) - screenPosition.X - (float)(chatTexture.Width / 2) - (float)num188, npc[num187].position.Y - (float)chatTexture.Height - screenPosition.Y), new Rectangle(0, 0, chatTexture.Width, chatTexture.Height), new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor), 0f, default(Vector2), 1f, effects2, 0f);
if (mouseState.RightButton == ButtonState.Pressed && npcChatRelease)
{
npcChatRelease = false;
if (player[myPlayer].talkNPC != num187)
{
player[myPlayer].sign = -1;
editSign = false;
player[myPlayer].talkNPC = num187;
playerInventory = false;
player[myPlayer].chest = -1;
npcChatText = npc[num187].GetChat();
PlaySound(24);
}
}
}
player[myPlayer].showItemIcon = false;
string text21 = npc[num187].name;
if (npc[num187].lifeMax > 1 && !npc[num187].dontTakeDamage)
{
object obj = text21;
text21 = string.Concat(obj, ": ", npc[num187].life, "/", npc[num187].lifeMax);
}
MouseText(text21, 0, 0);
break;
}
}
if (mouseState.RightButton == ButtonState.Pressed)
{
npcChatRelease = false;
}
else
{
npcChatRelease = true;
}
if (player[myPlayer].showItemIcon && (player[myPlayer].inventory[player[myPlayer].selectedItem].type > 0 || player[myPlayer].showItemIcon2 > 0))
{
int num189 = player[myPlayer].inventory[player[myPlayer].selectedItem].type;
Color color24 = player[myPlayer].inventory[player[myPlayer].selectedItem].GetAlpha(Color.White);
Color color25 = player[myPlayer].inventory[player[myPlayer].selectedItem].GetColor(Color.White);
if (player[myPlayer].showItemIcon2 > 0)
{
num189 = player[myPlayer].showItemIcon2;
color24 = Color.White;
color25 = default(Color);
}
spriteBatch.Draw(itemTexture[num189], new Vector2(mouseState.X + 10, mouseState.Y + 10), new Rectangle(0, 0, itemTexture[num189].Width, itemTexture[num189].Height), color24, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
if (player[myPlayer].showItemIcon2 == 0 && player[myPlayer].inventory[player[myPlayer].selectedItem].color != default(Color))
{
spriteBatch.Draw(itemTexture[player[myPlayer].inventory[player[myPlayer].selectedItem].type], new Vector2(mouseState.X + 10, mouseState.Y + 10), new Rectangle(0, 0, itemTexture[player[myPlayer].inventory[player[myPlayer].selectedItem].type].Width, itemTexture[player[myPlayer].inventory[player[myPlayer].selectedItem].type].Height), color25, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
player[myPlayer].showItemIcon = false;
player[myPlayer].showItemIcon2 = 0;
}
protected void DrawMenu()
{
Star.UpdateStars();
Cloud.UpdateClouds();
evilTiles = 0;
jungleTiles = 0;
chatMode = false;
for (int i = 0; i < numChatLines; i++)
{
chatLine[i] = new ChatLine();
}
DrawFPS();
screenPosition.Y = (float)(worldSurface * 16.0 - (double)screenHeight);
background = 0;
byte b = (byte)((255 + tileColor.R * 2) / 3);
Color color = new Color(b, b, b, 255);
logoRotation += logoRotationSpeed * 3E-05f;
if ((double)logoRotation > 0.1)
{
logoRotationDirection = -1f;
}
else if ((double)logoRotation < -0.1)
{
logoRotationDirection = 1f;
}
if ((logoRotationSpeed < 20f) & (logoRotationDirection == 1f))
{
logoRotationSpeed += 1f;
}
else if ((logoRotationSpeed > -20f) & (logoRotationDirection == -1f))
{
logoRotationSpeed -= 1f;
}
logoScale += logoScaleSpeed * 1E-05f;
if ((double)logoScale > 1.1)
{
logoScaleDirection = -1f;
}
else if ((double)logoScale < 0.9)
{
logoScaleDirection = 1f;
}
if ((logoScaleSpeed < 50f) & (logoScaleDirection == 1f))
{
logoScaleSpeed += 1f;
}
else if ((logoScaleSpeed > -50f) & (logoScaleDirection == -1f))
{
logoScaleSpeed -= 1f;
}
spriteBatch.Draw(logoTexture, new Vector2(screenWidth / 2, 100f), new Rectangle(0, 0, logoTexture.Width, logoTexture.Height), color, logoRotation, new Vector2(logoTexture.Width / 2, logoTexture.Height / 2), logoScale, SpriteEffects.None, 0f);
int num = 250;
int num2 = screenWidth / 2;
int num3 = 80;
int num4 = 0;
int num5 = menuMode;
int num6 = -1;
int num7 = 0;
int num8 = 0;
bool flag = false;
bool flag2 = false;
bool flag3 = false;
int num9 = 0;
bool[] array = new bool[maxMenuItems];
bool[] array2 = new bool[maxMenuItems];
int[] array3 = new int[maxMenuItems];
int[] array4 = new int[maxMenuItems];
byte[] array5 = new byte[maxMenuItems];
float[] array6 = new float[maxMenuItems];
bool[] array7 = new bool[maxMenuItems];
for (int j = 0; j < maxMenuItems; j++)
{
array[j] = false;
array2[j] = false;
array3[j] = 0;
array4[j] = 0;
array6[j] = 1f;
}
string[] array8 = new string[maxMenuItems];
if (menuMode == -1)
{
menuMode = 0;
}
if (netMode == 2)
{
bool flag4 = true;
for (int k = 0; k < 8; k++)
{
if (k >= 255)
{
continue;
}
try
{
array8[k] = Netplay.serverSock[k].statusText;
if (Netplay.serverSock[k].active && showSpam)
{
IntPtr intPtr = default(IntPtr);
string[] array9 = new string[(int)intPtr + 1];
object obj = array9[(int)intPtr];
(array9 = array8)[(int)(intPtr = (IntPtr)k)] = string.Concat(obj, " (", NetMessage.buffer[k].spamCount, ")");
}
}
catch
{
array8[k] = "";
}
array[k] = true;
if (array8[k] != "" && array8[k] != null)
{
flag4 = false;
}
}
if (flag4)
{
array8[0] = "Start a new instance of Terraria to join!";
array8[1] = "Running on port " + Netplay.serverPort + ".";
}
num4 = 11;
array8[9] = statusText;
array[9] = true;
num = 170;
num3 = 30;
array3[10] = 20;
array3[10] = 40;
array8[10] = "Disconnect";
if (selectedMenu == 10)
{
Netplay.disconnect = true;
PlaySound(11);
}
}
else if (menuMode == 31)
{
string password = Netplay.password;
Netplay.password = GetInputText(Netplay.password);
if (password != Netplay.password)
{
PlaySound(12);
}
array8[0] = "Server Requires Password:";
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = Netplay.password;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[1] = -20;
array3[2] = 20;
array8[2] = "Accept";
array8[3] = "Back";
num4 = 4;
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 0;
Netplay.disconnect = true;
Netplay.password = "";
}
else if (selectedMenu == 2 || inputTextEnter)
{
NetMessage.SendData(38, -1, -1, Netplay.password);
menuMode = 14;
}
}
else if (netMode == 1 || menuMode == 14)
{
num4 = 2;
array8[0] = statusText;
array[0] = true;
num = 300;
array8[1] = "Cancel";
if (selectedMenu == 1)
{
Netplay.disconnect = true;
Netplay.clientSock.tcpClient.Close();
PlaySound(11);
menuMode = 0;
netMode = 0;
try
{
tServer.Kill();
}
catch
{
}
}
}
else if (menuMode == 30)
{
string password2 = Netplay.password;
Netplay.password = GetInputText(Netplay.password);
if (password2 != Netplay.password)
{
PlaySound(12);
}
array8[0] = "Enter Server Password:";
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = Netplay.password;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[1] = -20;
array3[2] = 20;
array8[2] = "Accept";
array8[3] = "Back";
num4 = 4;
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 6;
Netplay.password = "";
}
else if (selectedMenu == 2 || inputTextEnter || autoPass)
{
tServer.StartInfo.FileName = "TerrariaServer.exe";
tServer.StartInfo.Arguments = "-autoshutdown -world \"" + worldPathName + "\" -password \"" + Netplay.password + "\"";
if (libPath != "")
{
ProcessStartInfo startInfo = tServer.StartInfo;
startInfo.Arguments = startInfo.Arguments + " -loadlib " + libPath;
}
tServer.StartInfo.UseShellExecute = false;
tServer.StartInfo.CreateNoWindow = true;
tServer.Start();
Netplay.SetIP("127.0.0.1");
autoPass = true;
statusText = "Starting server...";
Netplay.StartClient();
menuMode = 10;
}
}
else if (menuMode == 15)
{
num4 = 2;
array8[0] = statusText;
array[0] = true;
num = 80;
num3 = 400;
array8[1] = "Back";
if (selectedMenu == 1)
{
Netplay.disconnect = true;
PlaySound(11);
menuMode = 0;
netMode = 0;
}
}
else if (menuMode == 200)
{
num4 = 3;
array8[0] = "Load failed!";
array[0] = true;
num -= 30;
array3[1] = 70;
array3[2] = 50;
array8[1] = "Load Backup";
array8[2] = "Cancel";
if (selectedMenu == 1)
{
if (File.Exists(worldPathName + ".bak"))
{
File.Copy(worldPathName + ".bak", worldPathName, overwrite: true);
File.Delete(worldPathName + ".bak");
PlaySound(10);
WorldGen.playWorld();
menuMode = 10;
}
else
{
PlaySound(11);
menuMode = 0;
netMode = 0;
}
}
if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 0;
netMode = 0;
}
}
else if (menuMode == 201)
{
num4 = 3;
array8[0] = "Load failed!";
array[0] = true;
array[1] = true;
num -= 30;
array3[1] = -30;
array3[2] = 50;
array8[1] = "No backup found";
array8[2] = "Back";
if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 0;
netMode = 0;
}
}
else if (menuMode == 10)
{
num4 = 1;
array8[0] = statusText;
array[0] = true;
num = 300;
}
else if (menuMode == 100)
{
num4 = 1;
array8[0] = statusText;
array[0] = true;
num = 300;
}
else if (menuMode == 0)
{
menuMultiplayer = false;
menuServer = false;
netMode = 0;
array8[0] = "Single Player";
array8[1] = "Multiplayer";
array8[2] = "Settings";
array8[3] = "Exit";
num4 = 4;
if (selectedMenu == 3)
{
QuitGame();
}
if (selectedMenu == 1)
{
PlaySound(10);
menuMode = 12;
}
if (selectedMenu == 2)
{
PlaySound(10);
menuMode = 11;
}
if (selectedMenu == 0)
{
PlaySound(10);
menuMode = 1;
LoadPlayers();
}
}
else if (menuMode == 1)
{
myPlayer = 0;
num = 190;
num3 = 50;
array8[5] = "Create Character";
array8[6] = "Delete";
if (numLoadPlayers == 5)
{
array2[5] = true;
array8[5] = "";
}
else if (numLoadPlayers == 0)
{
array2[6] = true;
array8[6] = "";
}
array8[7] = "Back";
for (int l = 0; l < 5; l++)
{
if (l < numLoadPlayers)
{
array8[l] = loadPlayer[l].name;
array5[l] = loadPlayer[l].difficulty;
}
else
{
array8[l] = null;
}
}
num4 = 8;
if (focusMenu >= 0 && focusMenu < numLoadPlayers)
{
num6 = focusMenu;
Vector2 vector = fontDeathText.MeasureString(array8[num6]);
num7 = (int)((double)(screenWidth / 2) + (double)vector.X * 0.5 + 10.0);
num8 = num + num3 * focusMenu + 4;
}
if (selectedMenu == 7)
{
autoJoin = false;
autoPass = false;
PlaySound(11);
if (menuMultiplayer)
{
menuMode = 12;
menuMultiplayer = false;
menuServer = false;
}
else
{
menuMode = 0;
}
}
else if (selectedMenu == 5)
{
loadPlayer[numLoadPlayers] = new Player();
PlaySound(10);
menuMode = 2;
}
else if (selectedMenu == 6)
{
PlaySound(10);
menuMode = 4;
}
else if (selectedMenu >= 0)
{
if (menuMultiplayer)
{
selectedPlayer = selectedMenu;
Main.player[myPlayer] = (Player)loadPlayer[selectedPlayer].Clone();
playerPathName = loadPlayerPath[selectedPlayer];
PlaySound(10);
if (autoJoin)
{
if (Netplay.SetIP(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
else if (Netplay.SetIP2(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
autoJoin = false;
}
else if (menuServer)
{
LoadWorlds();
menuMode = 6;
}
else
{
menuMode = 13;
}
}
else
{
myPlayer = 0;
selectedPlayer = selectedMenu;
Main.player[myPlayer] = (Player)loadPlayer[selectedPlayer].Clone();
playerPathName = loadPlayerPath[selectedPlayer];
LoadWorlds();
PlaySound(10);
menuMode = 6;
}
}
}
else if (menuMode == 2)
{
if (selectedMenu == 0)
{
menuMode = 17;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].hairColor;
}
if (selectedMenu == 1)
{
menuMode = 18;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].eyeColor;
}
if (selectedMenu == 2)
{
menuMode = 19;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].skinColor;
}
if (selectedMenu == 3)
{
menuMode = 20;
PlaySound(10);
}
array8[0] = "Hair";
array8[1] = "Eyes";
array8[2] = "Skin";
array8[3] = "Clothes";
num = 246;
for (int m = 0; m < 6; m++)
{
array6[m] = 0.8f;
}
num3 = 40;
array3[6] = 16;
array3[7] = 25;
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 200;
if (loadPlayer[num6].male)
{
array8[4] = "Male";
}
else
{
array8[4] = "Female";
}
if (selectedMenu == 4)
{
if (loadPlayer[num6].male)
{
PlaySound(20);
loadPlayer[num6].male = false;
}
else
{
PlaySound(1);
loadPlayer[num6].male = true;
}
}
if (loadPlayer[num6].difficulty == 2)
{
array8[5] = "Hardcore";
array5[5] = loadPlayer[num6].difficulty;
}
else if (loadPlayer[num6].difficulty == 1)
{
array8[5] = "Mediumcore";
array5[5] = loadPlayer[num6].difficulty;
}
else
{
array8[5] = "Softcore";
}
if (selectedMenu == 5)
{
PlaySound(10);
menuMode = 222;
}
array8[6] = "Create";
array8[7] = "Back";
num4 = 8;
if (selectedMenu == 7)
{
PlaySound(11);
menuMode = 1;
}
else if (selectedMenu == 6)
{
PlaySound(10);
loadPlayer[numLoadPlayers].name = "";
menuMode = 3;
}
}
else if (menuMode == 222)
{
if (focusMenu == 3)
{
array8[0] = "Hardcore characters die for good";
}
else if (focusMenu == 2)
{
array8[0] = "Mediumcore characters drop items on death";
}
else if (focusMenu == 1)
{
array8[0] = "Softcore characters drop money on death";
}
else
{
array8[0] = "Select difficulty";
}
num3 = 50;
array3[1] = 25;
array3[2] = 25;
array3[3] = 25;
array[0] = true;
array8[1] = "Softcore";
array8[2] = "Mediumcore";
array5[2] = 1;
array8[3] = "Hardcore";
array5[3] = 2;
num4 = 4;
if (selectedMenu == 1)
{
loadPlayer[numLoadPlayers].difficulty = 0;
menuMode = 2;
}
else if (selectedMenu == 2)
{
menuMode = 2;
loadPlayer[numLoadPlayers].difficulty = 1;
}
else if (selectedMenu == 3)
{
loadPlayer[numLoadPlayers].difficulty = 2;
menuMode = 2;
}
}
else if (menuMode == 20)
{
if (selectedMenu == 0)
{
menuMode = 21;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].shirtColor;
}
if (selectedMenu == 1)
{
menuMode = 22;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].underShirtColor;
}
if (selectedMenu == 2)
{
menuMode = 23;
PlaySound(10);
selColor = loadPlayer[numLoadPlayers].pantsColor;
}
if (selectedMenu == 3)
{
selColor = loadPlayer[numLoadPlayers].shoeColor;
menuMode = 24;
PlaySound(10);
}
array8[0] = "Shirt";
array8[1] = "Undershirt";
array8[2] = "Pants";
array8[3] = "Shoes";
num = 260;
num3 = 50;
array3[5] = 20;
array8[5] = "Back";
num4 = 6;
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
if (selectedMenu == 5)
{
PlaySound(11);
menuMode = 2;
}
}
else if (menuMode == 17)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 390;
num = 260;
num3 = 60;
loadPlayer[num6].hairColor = selColor;
num4 = 3;
array8[0] = "Hair " + (loadPlayer[num6].hair + 1);
array8[1] = "Hair Color";
array[1] = true;
array3[2] = 150;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 0)
{
PlaySound(12);
Player player = loadPlayer[num6];
player.hair++;
if (loadPlayer[num6].hair >= 36)
{
loadPlayer[num6].hair = 0;
}
}
else if (selectedMenu2 == 0)
{
PlaySound(12);
Player player2 = loadPlayer[num6];
player2.hair--;
if (loadPlayer[num6].hair < 0)
{
loadPlayer[num6].hair = 35;
}
}
if (selectedMenu == 2)
{
menuMode = 2;
PlaySound(11);
}
}
else if (menuMode == 18)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].eyeColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Eye Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 2;
PlaySound(11);
}
}
else if (menuMode == 19)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].skinColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Skin Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 2;
PlaySound(11);
}
}
else if (menuMode == 21)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].shirtColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Shirt Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 20;
PlaySound(11);
}
}
else if (menuMode == 22)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].underShirtColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Undershirt Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 20;
PlaySound(11);
}
}
else if (menuMode == 23)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].pantsColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Pants Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 20;
PlaySound(11);
}
}
else if (menuMode == 24)
{
num6 = numLoadPlayers;
num7 = screenWidth / 2 - 16;
num8 = 210;
flag = true;
num9 = 370;
num = 240;
num3 = 60;
loadPlayer[num6].shoeColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Shoe Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 20;
PlaySound(11);
}
}
else if (menuMode == 3)
{
string name = loadPlayer[numLoadPlayers].name;
loadPlayer[numLoadPlayers].name = GetInputText(loadPlayer[numLoadPlayers].name);
if (loadPlayer[numLoadPlayers].name.Length > Player.nameLen)
{
loadPlayer[numLoadPlayers].name = loadPlayer[numLoadPlayers].name.Substring(0, Player.nameLen);
}
if (name != loadPlayer[numLoadPlayers].name)
{
PlaySound(12);
}
array8[0] = "Enter Character Name:";
array2[2] = true;
if (loadPlayer[numLoadPlayers].name != "")
{
if (loadPlayer[numLoadPlayers].name.Substring(0, 1) == " ")
{
loadPlayer[numLoadPlayers].name = "";
}
for (int n = 0; n < loadPlayer[numLoadPlayers].name.Length; n++)
{
if (loadPlayer[numLoadPlayers].name.Substring(n, 1) != " ")
{
array2[2] = false;
}
}
}
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = loadPlayer[numLoadPlayers].name;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[1] = -20;
array3[2] = 20;
array8[2] = "Accept";
array8[3] = "Back";
num4 = 4;
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 2;
}
if (selectedMenu == 2 || (!array2[2] && inputTextEnter))
{
loadPlayer[numLoadPlayers].name.Trim();
loadPlayerPath[numLoadPlayers] = nextLoadPlayer();
Player.SavePlayer(loadPlayer[numLoadPlayers], loadPlayerPath[numLoadPlayers]);
LoadPlayers();
PlaySound(10);
menuMode = 1;
}
}
else if (menuMode == 4)
{
num = 220;
num3 = 60;
array8[5] = "Back";
for (int num10 = 0; num10 < 5; num10++)
{
if (num10 < numLoadPlayers)
{
array8[num10] = loadPlayer[num10].name;
array5[num10] = loadPlayer[num10].difficulty;
}
else
{
array8[num10] = null;
}
}
num4 = 6;
if (focusMenu >= 0 && focusMenu < numLoadPlayers)
{
num6 = focusMenu;
Vector2 vector2 = fontDeathText.MeasureString(array8[num6]);
num7 = (int)((double)(screenWidth / 2) + (double)vector2.X * 0.5 + 10.0);
num8 = num + num3 * focusMenu + 4;
}
if (selectedMenu == 5)
{
PlaySound(11);
menuMode = 1;
}
else if (selectedMenu >= 0)
{
selectedPlayer = selectedMenu;
PlaySound(10);
menuMode = 5;
}
}
else if (menuMode == 5)
{
array8[0] = "Delete " + loadPlayer[selectedPlayer].name + "?";
array[0] = true;
array8[1] = "Yes";
array8[2] = "No";
num4 = 3;
if (selectedMenu == 1)
{
ErasePlayer(selectedPlayer);
PlaySound(10);
menuMode = 1;
}
else if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 1;
}
}
else if (menuMode == 6)
{
num = 190;
num3 = 50;
array8[5] = "Create World";
array8[6] = "Delete";
if (numLoadWorlds == 5)
{
array2[5] = true;
array8[5] = "";
}
else if (numLoadWorlds == 0)
{
array2[6] = true;
array8[6] = "";
}
array8[7] = "Back";
for (int num11 = 0; num11 < 5; num11++)
{
if (num11 < numLoadWorlds)
{
array8[num11] = loadWorld[num11];
}
else
{
array8[num11] = null;
}
}
num4 = 8;
if (selectedMenu == 7)
{
if (menuMultiplayer)
{
menuMode = 12;
}
else
{
menuMode = 1;
}
PlaySound(11);
}
else if (selectedMenu == 5)
{
PlaySound(10);
menuMode = 16;
newWorldName = "World " + (numLoadWorlds + 1);
}
else if (selectedMenu == 6)
{
PlaySound(10);
menuMode = 8;
}
else if (selectedMenu >= 0)
{
if (menuMultiplayer)
{
PlaySound(10);
worldPathName = loadWorldPath[selectedMenu];
menuMode = 30;
}
else
{
PlaySound(10);
worldPathName = loadWorldPath[selectedMenu];
WorldGen.playWorld();
menuMode = 10;
}
}
}
else if (menuMode == 7)
{
string text = newWorldName;
newWorldName = GetInputText(newWorldName);
if (newWorldName.Length > 20)
{
newWorldName = newWorldName.Substring(0, 20);
}
if (text != newWorldName)
{
PlaySound(12);
}
array8[0] = "Enter World Name:";
array2[2] = true;
if (newWorldName != "")
{
if (newWorldName.Substring(0, 1) == " ")
{
newWorldName = "";
}
for (int num12 = 0; num12 < newWorldName.Length; num12++)
{
if (newWorldName != " ")
{
array2[2] = false;
}
}
}
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = newWorldName;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[1] = -20;
array3[2] = 20;
array8[2] = "Accept";
array8[3] = "Back";
num4 = 4;
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 16;
}
if (selectedMenu == 2 || (!array2[2] && inputTextEnter))
{
menuMode = 10;
worldName = newWorldName;
worldPathName = nextLoadWorld();
WorldGen.CreateNewWorld();
}
}
else if (menuMode == 8)
{
num = 220;
num3 = 60;
array8[5] = "Back";
for (int num13 = 0; num13 < 5; num13++)
{
if (num13 < numLoadWorlds)
{
array8[num13] = loadWorld[num13];
}
else
{
array8[num13] = null;
}
}
num4 = 6;
if (selectedMenu == 5)
{
PlaySound(11);
menuMode = 1;
}
else if (selectedMenu >= 0)
{
selectedWorld = selectedMenu;
PlaySound(10);
menuMode = 9;
}
}
else if (menuMode == 9)
{
array8[0] = "Delete " + loadWorld[selectedWorld] + "?";
array[0] = true;
array8[1] = "Yes";
array8[2] = "No";
num4 = 3;
if (selectedMenu == 1)
{
EraseWorld(selectedWorld);
PlaySound(10);
menuMode = 6;
}
else if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 6;
}
}
else if (menuMode == 1111)
{
num3 = 60;
array3[4] = 10;
num4 = 8;
if (graphics.IsFullScreen)
{
array8[0] = "Go Windowed";
}
else
{
array8[0] = "Go Fullscreen";
}
bgScroll = (int)Math.Round((1f - caveParrallax) * 500f);
array8[1] = "Resolution";
array8[2] = "Parallax";
if (fixedTiming)
{
array8[3] = "Frame Skip Off";
}
else
{
array8[3] = "Frame Skip On";
}
array8[4] = "Back";
if (selectedMenu == 4)
{
PlaySound(11);
SaveSettings();
menuMode = 11;
}
if (selectedMenu == 3)
{
PlaySound(12);
if (fixedTiming)
{
fixedTiming = false;
}
else
{
fixedTiming = true;
}
}
if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 28;
}
if (selectedMenu == 1)
{
PlaySound(10);
menuMode = 111;
}
if (selectedMenu == 0)
{
graphics.ToggleFullScreen();
}
}
else if (menuMode == 11)
{
num = 180;
num3 = 48;
array3[7] = 10;
num4 = 8;
array8[0] = "Video";
array8[1] = "Cursor Color";
array8[2] = "Volume";
array8[3] = "Controls";
if (autoSave)
{
array8[4] = "Autosave On";
}
else
{
array8[4] = "Autosave Off";
}
if (autoPause)
{
array8[5] = "Autopause On";
}
else
{
array8[5] = "Autopause Off";
}
if (showItemText)
{
array8[6] = "Pickup Text On";
}
else
{
array8[6] = "Pickup Text Off";
}
array8[7] = "Back";
if (selectedMenu == 7)
{
PlaySound(11);
SaveSettings();
menuMode = 0;
}
if (selectedMenu == 6)
{
PlaySound(12);
if (showItemText)
{
showItemText = false;
}
else
{
showItemText = true;
}
}
if (selectedMenu == 5)
{
PlaySound(12);
if (autoPause)
{
autoPause = false;
}
else
{
autoPause = true;
}
}
if (selectedMenu == 4)
{
PlaySound(12);
if (autoSave)
{
autoSave = false;
}
else
{
autoSave = true;
}
}
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 27;
}
if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 26;
}
if (selectedMenu == 1)
{
PlaySound(10);
selColor = mouseColor;
menuMode = 25;
}
if (selectedMenu == 0)
{
PlaySound(10);
menuMode = 1111;
}
}
else if (menuMode != 111)
{
if (menuMode == 25)
{
flag = true;
num9 = 370;
num = 240;
num3 = 60;
mouseColor = selColor;
num4 = 3;
array8[0] = "";
array8[1] = "Cursor Color";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 11;
PlaySound(11);
}
}
else if (menuMode == 26)
{
flag2 = true;
num = 240;
num3 = 60;
num4 = 3;
array8[0] = "";
array8[1] = "Volume";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 11;
PlaySound(11);
}
}
else if (menuMode == 28)
{
caveParrallax = 1f - (float)bgScroll / 500f;
flag3 = true;
num = 240;
num3 = 60;
num4 = 3;
array8[0] = "";
array8[1] = "Parallax";
array[1] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 2)
{
menuMode = 1111;
PlaySound(11);
}
}
else if (menuMode == 27)
{
num = 176;
num3 = 30;
num4 = 13;
string[] array10 = new string[11]
{
cUp, cDown, cLeft, cRight, cJump, cThrowItem, cInv, cHeal, cMana, cBuff,
cHook
};
if (setKey >= 0)
{
array10[setKey] = "_";
}
array8[0] = "Up " + array10[0];
array8[1] = "Down " + array10[1];
array8[2] = "Left " + array10[2];
array8[3] = "Right " + array10[3];
array8[4] = "Jump " + array10[4];
array8[5] = "Throw " + array10[5];
array8[6] = "Inventory " + array10[6];
array8[7] = "Quick Heal " + array10[7];
array8[8] = "Quick Mana " + array10[8];
array8[9] = "Quick Buff " + array10[9];
array8[10] = "Grapple " + array10[10];
for (int num14 = 0; num14 < 11; num14++)
{
array7[num14] = true;
array6[num14] = 0.55f;
array4[num14] = -80;
}
array6[11] = 0.8f;
array6[12] = 0.8f;
array3[11] = 6;
array8[11] = "Reset to Default";
array3[12] = 16;
array8[12] = "Back";
if (selectedMenu == 12)
{
menuMode = 11;
PlaySound(11);
}
else if (selectedMenu == 11)
{
cUp = "W";
cDown = "S";
cLeft = "A";
cRight = "D";
cJump = "Space";
cThrowItem = "Q";
cInv = "Escape";
cHeal = "H";
cMana = "M";
cBuff = "B";
cHook = "E";
setKey = -1;
PlaySound(11);
}
else if (selectedMenu >= 0)
{
setKey = selectedMenu;
}
if (setKey >= 0)
{
Keys[] pressedKeys = keyState.GetPressedKeys();
if (pressedKeys.Length > 0)
{
string text2 = pressedKeys[0].ToString();
if (setKey == 0)
{
cUp = text2;
}
if (setKey == 1)
{
cDown = text2;
}
if (setKey == 2)
{
cLeft = text2;
}
if (setKey == 3)
{
cRight = text2;
}
if (setKey == 4)
{
cJump = text2;
}
if (setKey == 5)
{
cThrowItem = text2;
}
if (setKey == 6)
{
cInv = text2;
}
if (setKey == 7)
{
cHeal = text2;
}
if (setKey == 8)
{
cMana = text2;
}
if (setKey == 9)
{
cBuff = text2;
}
if (setKey == 10)
{
cHook = text2;
}
setKey = -1;
}
}
}
else if (menuMode == 12)
{
menuServer = false;
array8[0] = "Join";
array8[1] = "Host & Play";
array8[2] = "Back";
if (selectedMenu == 0)
{
LoadPlayers();
menuMultiplayer = true;
PlaySound(10);
menuMode = 1;
}
else if (selectedMenu == 1)
{
LoadPlayers();
PlaySound(10);
menuMode = 1;
menuMultiplayer = true;
menuServer = true;
}
if (selectedMenu == 2)
{
PlaySound(11);
menuMode = 0;
}
num4 = 3;
}
else if (menuMode == 13)
{
string text3 = getIP;
getIP = GetInputText(getIP);
if (text3 != getIP)
{
PlaySound(12);
}
array8[0] = "Enter Server IP Address:";
array2[9] = true;
if (getIP != "")
{
if (getIP.Substring(0, 1) == " ")
{
getIP = "";
}
for (int num15 = 0; num15 < getIP.Length; num15++)
{
if (getIP != " ")
{
array2[9] = false;
}
}
}
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = getIP;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[9] = 44;
array3[10] = 64;
array8[9] = "Accept";
array8[10] = "Back";
num4 = 11;
num = 180;
num3 = 30;
array3[1] = 19;
for (int num16 = 2; num16 < 9; num16++)
{
int num17 = num16 - 2;
if (recentWorld[num17] != null && recentWorld[num17] != "")
{
array8[num16] = recentWorld[num17] + " (" + recentIP[num17] + ":" + recentPort[num17] + ")";
}
else
{
array8[num16] = "";
array[num16] = true;
}
array6[num16] = 0.6f;
array3[num16] = 40;
}
if (selectedMenu >= 2 && selectedMenu < 9)
{
autoPass = false;
int num18 = selectedMenu - 2;
Netplay.serverPort = recentPort[num18];
getIP = recentIP[num18];
if (Netplay.SetIP(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
else if (Netplay.SetIP2(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
}
if (selectedMenu == 10)
{
PlaySound(11);
menuMode = 1;
}
if (selectedMenu == 9 || (!array2[2] && inputTextEnter))
{
PlaySound(12);
menuMode = 131;
}
}
else if (menuMode == 131)
{
int num19 = 7777;
string text4 = getPort;
getPort = GetInputText(getPort);
if (text4 != getPort)
{
PlaySound(12);
}
array8[0] = "Enter Server Port:";
array2[2] = true;
if (getPort != "")
{
bool flag5 = false;
try
{
num19 = Convert.ToInt32(getPort);
if (num19 > 0 && num19 <= 65535)
{
flag5 = true;
}
}
catch
{
}
if (flag5)
{
array2[2] = false;
}
}
textBlinkerCount++;
if (textBlinkerCount >= 20)
{
if (textBlinkerState == 0)
{
textBlinkerState = 1;
}
else
{
textBlinkerState = 0;
}
textBlinkerCount = 0;
}
array8[1] = getPort;
if (textBlinkerState == 1)
{
string[] array9;
(array9 = array8)[1] = array9[1] + "|";
array4[1] = 1;
}
else
{
string[] array9;
(array9 = array8)[1] = array9[1] + " ";
}
array[0] = true;
array[1] = true;
array3[1] = -20;
array3[2] = 20;
array8[2] = "Accept";
array8[3] = "Back";
num4 = 4;
if (selectedMenu == 3)
{
PlaySound(11);
menuMode = 1;
}
if (selectedMenu == 2 || (!array2[2] && inputTextEnter))
{
Netplay.serverPort = num19;
autoPass = false;
if (Netplay.SetIP(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
else if (Netplay.SetIP2(getIP))
{
menuMode = 10;
Netplay.StartClient();
}
}
}
else if (menuMode == 16)
{
num = 200;
num3 = 60;
array3[1] = 30;
array3[2] = 30;
array3[3] = 30;
array3[4] = 70;
array8[0] = "Choose world size:";
array[0] = true;
array8[1] = "Small";
array8[2] = "Medium";
array8[3] = "Large";
array8[4] = "Back";
num4 = 5;
if (selectedMenu == 4)
{
menuMode = 6;
PlaySound(11);
}
else if (selectedMenu > 0)
{
if (selectedMenu == 1)
{
maxTilesX = 4200;
maxTilesY = 1200;
}
else if (selectedMenu == 2)
{
maxTilesX = 6300;
maxTilesY = 1800;
}
else
{
maxTilesX = 8400;
maxTilesY = 2400;
}
menuMode = 7;
PlaySound(10);
WorldGen.setWorldSize();
}
}
}
else
{
num = 240;
num3 = 60;
num4 = 3;
array8[0] = "Fullscreen Resolution";
array8[1] = graphics.PreferredBackBufferWidth + "x" + graphics.PreferredBackBufferHeight;
array[0] = true;
array3[2] = 170;
array3[1] = 10;
array8[2] = "Back";
if (selectedMenu == 1)
{
PlaySound(12);
int num20 = 0;
for (int num21 = 0; num21 < numDisplayModes; num21++)
{
if (displayWidth[num21] == graphics.PreferredBackBufferWidth && displayHeight[num21] == graphics.PreferredBackBufferHeight)
{
num20 = num21;
break;
}
}
num20++;
if (num20 >= numDisplayModes)
{
num20 = 0;
}
graphics.PreferredBackBufferWidth = displayWidth[num20];
graphics.PreferredBackBufferHeight = displayHeight[num20];
}
if (selectedMenu == 2)
{
if (graphics.IsFullScreen)
{
graphics.ApplyChanges();
}
menuMode = 1111;
PlaySound(11);
}
}
if (menuMode != num5)
{
num4 = 0;
for (int num22 = 0; num22 < maxMenuItems; num22++)
{
menuItemScale[num22] = 0.8f;
}
}
int num23 = focusMenu;
selectedMenu = -1;
selectedMenu2 = -1;
focusMenu = -1;
for (int num24 = 0; num24 < num4; num24++)
{
if (array8[num24] == null)
{
continue;
}
if (flag)
{
string text5 = "";
for (int num25 = 0; num25 < 6; num25++)
{
int num26 = num9;
int num27 = 370 + screenWidth / 2 - 400;
switch (num25)
{
case 0:
text5 = "Red:";
break;
case 1:
text5 = "Green:";
num26 += 30;
break;
case 2:
text5 = "Blue:";
num26 += 60;
break;
case 3:
text5 = selColor.R.ToString();
num27 += 90;
break;
case 4:
text5 = selColor.G.ToString();
num27 += 90;
num26 += 30;
break;
case 5:
text5 = selColor.B.ToString();
num27 += 90;
num26 += 60;
break;
}
for (int num28 = 0; num28 < 5; num28++)
{
Color color2 = Color.Black;
if (num28 == 4)
{
color2 = color;
color2.R = (byte)((255 + color2.R) / 2);
color2.G = (byte)((255 + color2.R) / 2);
color2.B = (byte)((255 + color2.R) / 2);
}
int num29 = 255;
int num30 = color2.R - (255 - num29);
if (num30 < 0)
{
num30 = 0;
}
color2 = new Color((byte)num30, (byte)num30, (byte)num30, (byte)num29);
int num31 = 0;
int num32 = 0;
switch (num28)
{
case 0:
num31 = -2;
break;
case 1:
num31 = 2;
break;
case 2:
num32 = -2;
break;
case 3:
num32 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text5, new Vector2(num27 + num31, num26 + num32), color2, 0f, default(Vector2), 0.5f, SpriteEffects.None, 0f);
}
}
bool flag6 = false;
for (int num33 = 0; num33 < 2; num33++)
{
for (int num34 = 0; num34 < 3; num34++)
{
int num35 = num9 + num34 * 30 - 12;
int num36 = 360 + screenWidth / 2 - 400;
float scale = 0.9f;
if (num33 == 0)
{
num36 -= 70;
num35 += 2;
}
else
{
num36 -= 40;
}
text5 = "-";
if (num33 == 1)
{
text5 = "+";
}
Vector2 vector3 = new Vector2(24f, 24f);
int num37 = 142;
if (mouseState.X > num36 && (float)mouseState.X < (float)num36 + vector3.X && mouseState.Y > num35 + 13 && (float)mouseState.Y < (float)(num35 + 13) + vector3.Y)
{
if (focusColor != (num33 + 1) * (num34 + 10))
{
PlaySound(12);
}
focusColor = (num33 + 1) * (num34 + 10);
flag6 = true;
num37 = 255;
if (mouseState.LeftButton == ButtonState.Pressed)
{
if (colorDelay <= 1)
{
if (colorDelay == 0)
{
colorDelay = 40;
}
else
{
colorDelay = 3;
}
int num38 = num33;
if (num33 == 0)
{
num38 = -1;
if (selColor.R + selColor.G + selColor.B < 255)
{
num38 = 0;
}
}
if (num34 == 0 && selColor.R + num38 >= 0 && selColor.R + num38 <= 255)
{
selColor.R = (byte)(selColor.R + num38);
}
if (num34 == 1 && selColor.G + num38 >= 0 && selColor.G + num38 <= 255)
{
selColor.G = (byte)(selColor.G + num38);
}
if (num34 == 2 && selColor.B + num38 >= 0 && selColor.B + num38 <= 255)
{
selColor.B = (byte)(selColor.B + num38);
}
}
colorDelay--;
}
else
{
colorDelay = 0;
}
}
for (int num39 = 0; num39 < 5; num39++)
{
Color color3 = Color.Black;
if (num39 == 4)
{
color3 = color;
color3.R = (byte)((255 + color3.R) / 2);
color3.G = (byte)((255 + color3.R) / 2);
color3.B = (byte)((255 + color3.R) / 2);
}
int num40 = color3.R - (255 - num37);
if (num40 < 0)
{
num40 = 0;
}
color3 = new Color((byte)num40, (byte)num40, (byte)num40, (byte)num37);
int num41 = 0;
int num42 = 0;
switch (num39)
{
case 0:
num41 = -2;
break;
case 1:
num41 = 2;
break;
case 2:
num42 = -2;
break;
case 3:
num42 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text5, new Vector2(num36 + num41, num35 + num42), color3, 0f, default(Vector2), scale, SpriteEffects.None, 0f);
}
}
}
if (!flag6)
{
focusColor = 0;
colorDelay = 0;
}
}
if (flag3)
{
int num43 = 400;
string text6 = "";
for (int num44 = 0; num44 < 4; num44++)
{
int num45 = num43;
int num46 = 370 + screenWidth / 2 - 400;
if (num44 == 0)
{
text6 = "Parallax: " + bgScroll;
}
for (int num47 = 0; num47 < 5; num47++)
{
Color color4 = Color.Black;
if (num47 == 4)
{
color4 = color;
color4.R = (byte)((255 + color4.R) / 2);
color4.G = (byte)((255 + color4.R) / 2);
color4.B = (byte)((255 + color4.R) / 2);
}
int num48 = 255;
int num49 = color4.R - (255 - num48);
if (num49 < 0)
{
num49 = 0;
}
color4 = new Color((byte)num49, (byte)num49, (byte)num49, (byte)num48);
int num50 = 0;
int num51 = 0;
switch (num47)
{
case 0:
num50 = -2;
break;
case 1:
num50 = 2;
break;
case 2:
num51 = -2;
break;
case 3:
num51 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text6, new Vector2(num46 + num50, num45 + num51), color4, 0f, default(Vector2), 0.5f, SpriteEffects.None, 0f);
}
}
bool flag7 = false;
for (int num52 = 0; num52 < 2; num52++)
{
for (int num53 = 0; num53 < 1; num53++)
{
int num54 = num43 + num53 * 30 - 12;
int num55 = 360 + screenWidth / 2 - 400;
float scale2 = 0.9f;
if (num52 == 0)
{
num55 -= 70;
num54 += 2;
}
else
{
num55 -= 40;
}
text6 = "-";
if (num52 == 1)
{
text6 = "+";
}
Vector2 vector4 = new Vector2(24f, 24f);
int num56 = 142;
if (mouseState.X > num55 && (float)mouseState.X < (float)num55 + vector4.X && mouseState.Y > num54 + 13 && (float)mouseState.Y < (float)(num54 + 13) + vector4.Y)
{
if (focusColor != (num52 + 1) * (num53 + 10))
{
PlaySound(12);
}
focusColor = (num52 + 1) * (num53 + 10);
flag7 = true;
num56 = 255;
if (mouseState.LeftButton == ButtonState.Pressed)
{
if (colorDelay <= 1)
{
if (colorDelay == 0)
{
colorDelay = 40;
}
else
{
colorDelay = 3;
}
int num57 = num52;
if (num52 == 0)
{
num57 = -1;
}
if (num53 == 0)
{
bgScroll += num57;
if (bgScroll > 100)
{
bgScroll = 100;
}
if (bgScroll < 0)
{
bgScroll = 0;
}
}
}
colorDelay--;
}
else
{
colorDelay = 0;
}
}
for (int num58 = 0; num58 < 5; num58++)
{
Color color5 = Color.Black;
if (num58 == 4)
{
color5 = color;
color5.R = (byte)((255 + color5.R) / 2);
color5.G = (byte)((255 + color5.R) / 2);
color5.B = (byte)((255 + color5.R) / 2);
}
int num59 = color5.R - (255 - num56);
if (num59 < 0)
{
num59 = 0;
}
color5 = new Color((byte)num59, (byte)num59, (byte)num59, (byte)num56);
int num60 = 0;
int num61 = 0;
switch (num58)
{
case 0:
num60 = -2;
break;
case 1:
num60 = 2;
break;
case 2:
num61 = -2;
break;
case 3:
num61 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text6, new Vector2(num55 + num60, num54 + num61), color5, 0f, default(Vector2), scale2, SpriteEffects.None, 0f);
}
}
}
if (!flag7)
{
focusColor = 0;
colorDelay = 0;
}
}
if (flag2)
{
int num62 = 400;
string text7 = "";
for (int num63 = 0; num63 < 4; num63++)
{
int num64 = num62;
int num65 = 370 + screenWidth / 2 - 400;
switch (num63)
{
case 0:
text7 = "Sound:";
break;
case 1:
text7 = "Music:";
num64 += 30;
break;
case 2:
text7 = Math.Round(soundVolume * 100f) + "%";
num65 += 90;
break;
case 3:
text7 = Math.Round(musicVolume * 100f) + "%";
num65 += 90;
num64 += 30;
break;
}
for (int num66 = 0; num66 < 5; num66++)
{
Color color6 = Color.Black;
if (num66 == 4)
{
color6 = color;
color6.R = (byte)((255 + color6.R) / 2);
color6.G = (byte)((255 + color6.R) / 2);
color6.B = (byte)((255 + color6.R) / 2);
}
int num67 = 255;
int num68 = color6.R - (255 - num67);
if (num68 < 0)
{
num68 = 0;
}
color6 = new Color((byte)num68, (byte)num68, (byte)num68, (byte)num67);
int num69 = 0;
int num70 = 0;
switch (num66)
{
case 0:
num69 = -2;
break;
case 1:
num69 = 2;
break;
case 2:
num70 = -2;
break;
case 3:
num70 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text7, new Vector2(num65 + num69, num64 + num70), color6, 0f, default(Vector2), 0.5f, SpriteEffects.None, 0f);
}
}
bool flag8 = false;
for (int num71 = 0; num71 < 2; num71++)
{
for (int num72 = 0; num72 < 2; num72++)
{
int num73 = num62 + num72 * 30 - 12;
int num74 = 360 + screenWidth / 2 - 400;
float scale3 = 0.9f;
if (num71 == 0)
{
num74 -= 70;
num73 += 2;
}
else
{
num74 -= 40;
}
text7 = "-";
if (num71 == 1)
{
text7 = "+";
}
Vector2 vector5 = new Vector2(24f, 24f);
int num75 = 142;
if (mouseState.X > num74 && !((float)mouseState.X >= (float)num74 + vector5.X) && mouseState.Y > num73 + 13 && !((float)mouseState.Y >= (float)(num73 + 13) + vector5.Y))
{
if (focusColor != (num71 + 1) * (num72 + 10))
{
PlaySound(12);
}
focusColor = (num71 + 1) * (num72 + 10);
flag8 = true;
num75 = 255;
if (mouseState.LeftButton == ButtonState.Pressed)
{
if (colorDelay <= 1)
{
if (colorDelay == 0)
{
colorDelay = 40;
}
else
{
colorDelay = 3;
}
int num76 = num71;
if (num71 == 0)
{
num76 = -1;
}
switch (num72)
{
case 0:
soundVolume += (float)num76 * 0.01f;
if (soundVolume > 1f)
{
soundVolume = 1f;
}
if (soundVolume < 0f)
{
soundVolume = 0f;
}
break;
case 1:
musicVolume += (float)num76 * 0.01f;
if (musicVolume > 1f)
{
musicVolume = 1f;
}
if (musicVolume < 0f)
{
musicVolume = 0f;
}
break;
}
}
colorDelay--;
}
else
{
colorDelay = 0;
}
}
for (int num77 = 0; num77 < 5; num77++)
{
Color color7 = Color.Black;
if (num77 == 4)
{
color7 = color;
color7.R = (byte)((255 + color7.R) / 2);
color7.G = (byte)((255 + color7.R) / 2);
color7.B = (byte)((255 + color7.R) / 2);
}
int num78 = color7.R - (255 - num75);
if (num78 < 0)
{
num78 = 0;
}
color7 = new Color((byte)num78, (byte)num78, (byte)num78, (byte)num75);
int num79 = 0;
int num80 = 0;
switch (num77)
{
case 0:
num79 = -2;
break;
case 1:
num79 = 2;
break;
case 2:
num80 = -2;
break;
case 3:
num80 = 2;
break;
}
spriteBatch.DrawString(fontDeathText, text7, new Vector2(num74 + num79, num73 + num80), color7, 0f, default(Vector2), scale3, SpriteEffects.None, 0f);
}
}
}
if (!flag8)
{
focusColor = 0;
colorDelay = 0;
}
}
for (int num81 = 0; num81 < 5; num81++)
{
Color color8 = Color.Black;
if (num81 == 4)
{
color8 = color;
if (array5[num24] == 2)
{
color8 = hcColor;
}
else if (array5[num24] == 1)
{
color8 = mcColor;
}
color8.R = (byte)((255 + color8.R) / 2);
color8.G = (byte)((255 + color8.G) / 2);
color8.B = (byte)((255 + color8.B) / 2);
}
int num82 = (int)(255f * (menuItemScale[num24] * 2f - 1f));
if (array[num24])
{
num82 = 255;
}
int num83 = color8.R - (255 - num82);
if (num83 < 0)
{
num83 = 0;
}
int num84 = color8.G - (255 - num82);
if (num84 < 0)
{
num84 = 0;
}
int num85 = color8.B - (255 - num82);
if (num85 < 0)
{
num85 = 0;
}
color8 = new Color((byte)num83, (byte)num84, (byte)num85, (byte)num82);
int num86 = 0;
int num87 = 0;
switch (num81)
{
case 0:
num86 = -2;
break;
case 1:
num86 = 2;
break;
case 2:
num87 = -2;
break;
case 3:
num87 = 2;
break;
}
Vector2 origin = fontDeathText.MeasureString(array8[num24]);
origin.X *= 0.5f;
origin.Y *= 0.5f;
float num88 = menuItemScale[num24];
if (menuMode == 15 && num24 == 0)
{
num88 *= 0.35f;
}
else if (netMode == 2)
{
num88 *= 0.5f;
}
num88 *= array6[num24];
if (!array7[num24])
{
spriteBatch.DrawString(fontDeathText, array8[num24], new Vector2(num2 + num86 + array4[num24], (float)(num + num3 * num24 + num87) + origin.Y * array6[num24] + (float)array3[num24]), color8, 0f, origin, num88, SpriteEffects.None, 0f);
}
else
{
spriteBatch.DrawString(fontDeathText, array8[num24], new Vector2(num2 + num86 + array4[num24], (float)(num + num3 * num24 + num87) + origin.Y * array6[num24] + (float)array3[num24]), color8, 0f, new Vector2(0f, origin.Y), num88, SpriteEffects.None, 0f);
}
}
if (!array7[num24])
{
if (!((float)mouseState.X > (float)num2 - (float)(array8[num24].Length * 10) * array6[num24] + (float)array4[num24]) || !((float)mouseState.X < (float)num2 + (float)(array8[num24].Length * 10) * array6[num24] + (float)array4[num24]) || mouseState.Y <= num + num3 * num24 + array3[num24] || !((float)mouseState.Y < (float)(num + num3 * num24 + array3[num24]) + 50f * array6[num24]) || !hasFocus)
{
continue;
}
focusMenu = num24;
if (array[num24] || array2[num24])
{
focusMenu = -1;
continue;
}
if (num23 != focusMenu)
{
PlaySound(12);
}
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
selectedMenu = num24;
}
if (mouseRightRelease && mouseState.RightButton == ButtonState.Pressed)
{
selectedMenu2 = num24;
}
}
else
{
if (mouseState.X <= num2 + array4[num24] || !((float)mouseState.X < (float)num2 + (float)(array8[num24].Length * 20) * array6[num24] + (float)array4[num24]) || mouseState.Y <= num + num3 * num24 + array3[num24] || !((float)mouseState.Y < (float)(num + num3 * num24 + array3[num24]) + 50f * array6[num24]) || !hasFocus)
{
continue;
}
focusMenu = num24;
if (array[num24] || array2[num24])
{
focusMenu = -1;
continue;
}
if (num23 != focusMenu)
{
PlaySound(12);
}
if (mouseLeftRelease && mouseState.LeftButton == ButtonState.Pressed)
{
selectedMenu = num24;
}
if (mouseRightRelease && mouseState.RightButton == ButtonState.Pressed)
{
selectedMenu2 = num24;
}
}
}
for (int num89 = 0; num89 < maxMenuItems; num89++)
{
if (num89 == focusMenu)
{
if (menuItemScale[num89] < 1f)
{
menuItemScale[num89] += 0.02f;
}
if (menuItemScale[num89] > 1f)
{
menuItemScale[num89] = 1f;
}
}
else if ((double)menuItemScale[num89] > 0.8)
{
menuItemScale[num89] -= 0.02f;
}
}
if (num6 >= 0)
{
loadPlayer[num6].PlayerFrame();
loadPlayer[num6].position.X = (float)num7 + screenPosition.X;
loadPlayer[num6].position.Y = (float)num8 + screenPosition.Y;
DrawPlayer(loadPlayer[num6]);
}
for (int num90 = 0; num90 < 5; num90++)
{
Color color9 = Color.Black;
if (num90 == 4)
{
color9 = color;
color9.R = (byte)((255 + color9.R) / 2);
color9.G = (byte)((255 + color9.R) / 2);
color9.B = (byte)((255 + color9.R) / 2);
}
color9.A = (byte)((float)(int)color9.A * 0.3f);
int num91 = 0;
int num92 = 0;
switch (num90)
{
case 0:
num91 = -2;
break;
case 1:
num91 = 2;
break;
case 2:
num92 = -2;
break;
case 3:
num92 = 2;
break;
}
string text8 = "Copyright © 2011 Re-Logic";
Vector2 origin2 = fontMouseText.MeasureString(text8);
origin2.X *= 0.5f;
origin2.Y *= 0.5f;
spriteBatch.DrawString(fontMouseText, text8, new Vector2((float)screenWidth - origin2.X + (float)num91 - 10f, (float)screenHeight - origin2.Y + (float)num92 - 2f), color9, 0f, origin2, 1f, SpriteEffects.None, 0f);
}
for (int num93 = 0; num93 < 5; num93++)
{
Color color10 = Color.Black;
if (num93 == 4)
{
color10 = color;
color10.R = (byte)((255 + color10.R) / 2);
color10.G = (byte)((255 + color10.R) / 2);
color10.B = (byte)((255 + color10.R) / 2);
}
color10.A = (byte)((float)(int)color10.A * 0.3f);
int num94 = 0;
int num95 = 0;
switch (num93)
{
case 0:
num94 = -2;
break;
case 1:
num94 = 2;
break;
case 2:
num95 = -2;
break;
case 3:
num95 = 2;
break;
}
Vector2 origin3 = fontMouseText.MeasureString(versionNumber);
origin3.X *= 0.5f;
origin3.Y *= 0.5f;
spriteBatch.DrawString(fontMouseText, versionNumber, new Vector2(origin3.X + (float)num94 + 10f, (float)screenHeight - origin3.Y + (float)num95 - 2f), color10, 0f, origin3, 1f, SpriteEffects.None, 0f);
}
spriteBatch.Draw(cursorTexture, new Vector2(mouseState.X + 1, mouseState.Y + 1), new Rectangle(0, 0, cursorTexture.Width, cursorTexture.Height), new Color((int)((float)(int)cursorColor.R * 0.2f), (int)((float)(int)cursorColor.G * 0.2f), (int)((float)(int)cursorColor.B * 0.2f), (int)((float)(int)cursorColor.A * 0.5f)), 0f, default(Vector2), cursorScale * 1.1f, SpriteEffects.None, 0f);
spriteBatch.Draw(cursorTexture, new Vector2(mouseState.X, mouseState.Y), new Rectangle(0, 0, cursorTexture.Width, cursorTexture.Height), cursorColor, 0f, default(Vector2), cursorScale, SpriteEffects.None, 0f);
if (fadeCounter > 0)
{
Color white = Color.White;
byte b2 = 0;
fadeCounter--;
float num96 = (float)fadeCounter / 75f * 255f;
b2 = (byte)num96;
white = new Color(b2, b2, b2, b2);
spriteBatch.Draw(fadeTexture, new Rectangle(0, 0, screenWidth, screenHeight), white);
}
spriteBatch.End();
if (mouseState.LeftButton == ButtonState.Pressed)
{
mouseLeftRelease = false;
}
else
{
mouseLeftRelease = true;
}
if (mouseState.RightButton == ButtonState.Pressed)
{
mouseRightRelease = false;
}
else
{
mouseRightRelease = true;
}
}
protected void DrawNPCs(bool behindTiles = false)
{
Rectangle rectangle = new Rectangle((int)screenPosition.X - 300, (int)screenPosition.Y - 300, screenWidth + 600, screenHeight + 600);
for (int num = 999; num >= 0; num--)
{
if (npc[num].active && npc[num].type > 0 && npc[num].behindTiles == behindTiles && rectangle.Intersects(new Rectangle((int)npc[num].position.X, (int)npc[num].position.Y, npc[num].width, npc[num].height)))
{
if (npc[num].aiStyle == 13)
{
Vector2 vector = new Vector2(npc[num].position.X + (float)(npc[num].width / 2), npc[num].position.Y + (float)(npc[num].height / 2));
float num2 = npc[num].ai[0] * 16f + 8f - vector.X;
float num3 = npc[num].ai[1] * 16f + 8f - vector.Y;
float rotation = (float)Math.Atan2(num3, num2) - 1.57f;
bool flag = true;
while (flag)
{
int height = 28;
float num4 = (float)Math.Sqrt(num2 * num2 + num3 * num3);
if (num4 < 40f)
{
height = (int)num4 - 40 + 28;
flag = false;
}
num4 = 28f / num4;
num2 *= num4;
num3 *= num4;
vector.X += num2;
vector.Y += num3;
num2 = npc[num].ai[0] * 16f + 8f - vector.X;
num3 = npc[num].ai[1] * 16f + 8f - vector.Y;
Color color = Lighting.GetColor((int)vector.X / 16, (int)(vector.Y / 16f));
if (npc[num].type == 56)
{
spriteBatch.Draw(chain5Texture, new Vector2(vector.X - screenPosition.X, vector.Y - screenPosition.Y), new Rectangle(0, 0, chain4Texture.Width, height), color, rotation, new Vector2((float)chain4Texture.Width * 0.5f, (float)chain4Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(chain4Texture, new Vector2(vector.X - screenPosition.X, vector.Y - screenPosition.Y), new Rectangle(0, 0, chain4Texture.Width, height), color, rotation, new Vector2((float)chain4Texture.Width * 0.5f, (float)chain4Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
}
if (npc[num].type == 36)
{
Vector2 vector2 = new Vector2(npc[num].position.X + (float)npc[num].width * 0.5f - 5f * npc[num].ai[0], npc[num].position.Y + 20f);
for (int i = 0; i < 2; i++)
{
float num5 = npc[(int)npc[num].ai[1]].position.X + (float)(npc[(int)npc[num].ai[1]].width / 2) - vector2.X;
float num6 = npc[(int)npc[num].ai[1]].position.Y + (float)(npc[(int)npc[num].ai[1]].height / 2) - vector2.Y;
float num7 = 0f;
if (i == 0)
{
num5 -= 200f * npc[num].ai[0];
num6 += 130f;
num7 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
num7 = 92f / num7;
vector2.X += num5 * num7;
vector2.Y += num6 * num7;
}
else
{
num5 -= 50f * npc[num].ai[0];
num6 += 80f;
num7 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
num7 = 60f / num7;
vector2.X += num5 * num7;
vector2.Y += num6 * num7;
}
float rotation2 = (float)Math.Atan2(num6, num5) - 1.57f;
Color color2 = Lighting.GetColor((int)vector2.X / 16, (int)(vector2.Y / 16f));
spriteBatch.Draw(boneArmTexture, new Vector2(vector2.X - screenPosition.X, vector2.Y - screenPosition.Y), new Rectangle(0, 0, boneArmTexture.Width, boneArmTexture.Height), color2, rotation2, new Vector2((float)boneArmTexture.Width * 0.5f, (float)boneArmTexture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
if (i == 0)
{
vector2.X += num5 * num7 / 2f;
vector2.Y += num6 * num7 / 2f;
}
else if (base.IsActive)
{
vector2.X += num5 * num7 - 16f;
vector2.Y += num6 * num7 - 6f;
int num8 = Dust.NewDust(new Vector2(vector2.X, vector2.Y), 30, 10, 5, num5 * 0.02f, num6 * 0.02f, 0, default(Color), 2f);
Main.dust[num8].noGravity = true;
}
}
}
if (npc[num].aiStyle == 20)
{
Vector2 vector3 = new Vector2(npc[num].position.X + (float)(npc[num].width / 2), npc[num].position.Y + (float)(npc[num].height / 2));
float num9 = npc[num].ai[1] - vector3.X;
float num10 = npc[num].ai[2] - vector3.Y;
float num11 = (float)Math.Atan2(num10, num9) - 1.57f;
npc[num].rotation = num11;
bool flag2 = true;
while (flag2)
{
int height2 = 12;
float num12 = (float)Math.Sqrt(num9 * num9 + num10 * num10);
if (num12 < 20f)
{
height2 = (int)num12 - 20 + 12;
flag2 = false;
}
num12 = 12f / num12;
num9 *= num12;
num10 *= num12;
vector3.X += num9;
vector3.Y += num10;
num9 = npc[num].ai[1] - vector3.X;
num10 = npc[num].ai[2] - vector3.Y;
Color color3 = Lighting.GetColor((int)vector3.X / 16, (int)(vector3.Y / 16f));
spriteBatch.Draw(chainTexture, new Vector2(vector3.X - screenPosition.X, vector3.Y - screenPosition.Y), new Rectangle(0, 0, chainTexture.Width, height2), color3, num11, new Vector2((float)chainTexture.Width * 0.5f, (float)chainTexture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
spriteBatch.Draw(spikeBaseTexture, new Vector2(npc[num].ai[1] - screenPosition.X, npc[num].ai[2] - screenPosition.Y), new Rectangle(0, 0, spikeBaseTexture.Width, spikeBaseTexture.Height), Lighting.GetColor((int)npc[num].ai[1] / 16, (int)(npc[num].ai[2] / 16f)), num11 - 0.75f, new Vector2((float)spikeBaseTexture.Width * 0.5f, (float)spikeBaseTexture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
Color color4 = Lighting.GetColor((int)((double)npc[num].position.X + (double)npc[num].width * 0.5) / 16, (int)(((double)npc[num].position.Y + (double)npc[num].height * 0.5) / 16.0));
float num13 = 1f;
float num14 = 1f;
float num15 = 1f;
float num16 = 1f;
if (npc[num].poisoned)
{
if (rand.Next(30) == 0)
{
int num17 = Dust.NewDust(npc[num].position, npc[num].width, npc[num].height, 46, 0f, 0f, 120, default(Color), 0.2f);
Main.dust[num17].noGravity = true;
Main.dust[num17].fadeIn = 1.9f;
}
num13 *= 0.65f;
num15 *= 0.75f;
}
if (npc[num].onFire)
{
if (rand.Next(4) < 3)
{
int num18 = Dust.NewDust(new Vector2(npc[num].position.X - 2f, npc[num].position.Y - 2f), npc[num].width + 4, npc[num].height + 4, 6, npc[num].velocity.X * 0.4f, npc[num].velocity.Y * 0.4f, 100, default(Color), 2.5f);
Main.dust[num18].noGravity = true;
Dust dust = Main.dust[num18];
dust.velocity *= 1.8f;
Main.dust[num18].velocity.Y -= 0.5f;
}
num15 *= 0.6f;
num14 *= 0.7f;
}
if (num13 != 1f || num14 != 1f || num15 != 1f || num16 != 1f)
{
color4 = buffColor(color4, num13, num14, num15, num16);
}
if (player[myPlayer].detectCreature && npc[num].lifeMax > 1)
{
if (color4.R < 150)
{
color4.A = mouseTextColor;
}
if (color4.R < 50)
{
color4.R = 50;
}
if (color4.G < 200)
{
color4.G = 200;
}
if (color4.B < 100)
{
color4.B = 100;
}
if (!gamePaused && base.IsActive && rand.Next(50) == 0)
{
int num19 = Dust.NewDust(new Vector2(npc[num].position.X, npc[num].position.Y), npc[num].width, npc[num].height, 15, 0f, 0f, 150, default(Color), 0.8f);
Dust dust2 = Main.dust[num19];
dust2.velocity *= 0.1f;
Main.dust[num19].noLight = true;
}
}
if (npc[num].type == 50)
{
Vector2 vector4 = default(Vector2);
float num20 = 0f;
vector4.Y -= npc[num].velocity.Y;
vector4.X -= npc[num].velocity.X * 2f;
num20 += npc[num].velocity.X * 0.05f;
if (npc[num].frame.Y == 120)
{
vector4.Y += 2f;
}
if (npc[num].frame.Y == 360)
{
vector4.Y -= 2f;
}
if (npc[num].frame.Y == 480)
{
vector4.Y -= 6f;
}
spriteBatch.Draw(ninjaTexture, new Vector2(npc[num].position.X - screenPosition.X + (float)(npc[num].width / 2) + vector4.X, npc[num].position.Y - screenPosition.Y + (float)(npc[num].height / 2) + vector4.Y), new Rectangle(0, 0, ninjaTexture.Width, ninjaTexture.Height), color4, num20, new Vector2(ninjaTexture.Width / 2, ninjaTexture.Height / 2), 1f, SpriteEffects.None, 0f);
}
if (npc[num].type == 71)
{
Vector2 vector5 = default(Vector2);
float num21 = 0f;
vector5.Y -= npc[num].velocity.Y * 0.3f;
vector5.X -= npc[num].velocity.X * 0.6f;
num21 += npc[num].velocity.X * 0.09f;
if (npc[num].frame.Y == 120)
{
vector5.Y += 2f;
}
if (npc[num].frame.Y == 360)
{
vector5.Y -= 2f;
}
if (npc[num].frame.Y == 480)
{
vector5.Y -= 6f;
}
spriteBatch.Draw(itemTexture[327], new Vector2(npc[num].position.X - screenPosition.X + (float)(npc[num].width / 2) + vector5.X, npc[num].position.Y - screenPosition.Y + (float)(npc[num].height / 2) + vector5.Y), new Rectangle(0, 0, itemTexture[327].Width, itemTexture[327].Height), color4, num21, new Vector2(itemTexture[327].Width / 2, itemTexture[327].Height / 2), 1f, SpriteEffects.None, 0f);
}
if (npc[num].type == 69)
{
spriteBatch.Draw(antLionTexture, new Vector2(npc[num].position.X - screenPosition.X + (float)(npc[num].width / 2), npc[num].position.Y - screenPosition.Y + (float)npc[num].height + 14f), new Rectangle(0, 0, antLionTexture.Width, antLionTexture.Height), color4, (0f - npc[num].rotation) * 0.3f, new Vector2(antLionTexture.Width / 2, antLionTexture.Height / 2), 1f, SpriteEffects.None, 0f);
}
float num22 = 0f;
Vector2 origin = new Vector2(npcTexture[npc[num].type].Width / 2, npcTexture[npc[num].type].Height / npcFrameCount[npc[num].type] / 2);
if (npc[num].type == 4)
{
origin = new Vector2(55f, 107f);
}
else if (npc[num].type == 6)
{
num22 = 26f;
}
else if (npc[num].type == 7 || npc[num].type == 8 || npc[num].type == 9)
{
num22 = 13f;
}
else if (npc[num].type == 10 || npc[num].type == 11 || npc[num].type == 12)
{
num22 = 8f;
}
else if (npc[num].type == 13 || npc[num].type == 14 || npc[num].type == 15)
{
num22 = 26f;
}
else if (npc[num].type == 48)
{
num22 = 32f;
}
else if (npc[num].type == 49 || npc[num].type == 51)
{
num22 = 4f;
}
else if (npc[num].type == 60)
{
num22 = 10f;
}
else if (npc[num].type == 62 || npc[num].type == 66)
{
num22 = 14f;
}
else if (npc[num].type == 63 || npc[num].type == 64)
{
num22 = 4f;
}
else if (npc[num].type == 65)
{
num22 = 14f;
}
else if (npc[num].type == 69)
{
num22 = 4f;
origin.Y += 8f;
}
else if (npc[num].type == 70)
{
num22 = -4f;
}
else if (npc[num].type == 72)
{
num22 = -2f;
}
else if (npc[num].type == 39 || npc[num].type == 40 || npc[num].type == 41)
{
num22 = 26f;
}
num22 *= npc[num].scale;
if (npc[num].aiStyle == 10 || npc[num].type == 72)
{
color4 = Color.White;
}
SpriteEffects effects = SpriteEffects.None;
if (npc[num].spriteDirection == 1)
{
effects = SpriteEffects.FlipHorizontally;
}
spriteBatch.Draw(npcTexture[npc[num].type], new Vector2(npc[num].position.X - screenPosition.X + (float)(npc[num].width / 2) - (float)npcTexture[npc[num].type].Width * npc[num].scale / 2f + origin.X * npc[num].scale, npc[num].position.Y - screenPosition.Y + (float)npc[num].height - (float)npcTexture[npc[num].type].Height * npc[num].scale / (float)npcFrameCount[npc[num].type] + 4f + origin.Y * npc[num].scale + num22), npc[num].frame, npc[num].GetAlpha(color4), npc[num].rotation, origin, npc[num].scale, effects, 0f);
if (npc[num].color != default(Color))
{
spriteBatch.Draw(npcTexture[npc[num].type], new Vector2(npc[num].position.X - screenPosition.X + (float)(npc[num].width / 2) - (float)npcTexture[npc[num].type].Width * npc[num].scale / 2f + origin.X * npc[num].scale, npc[num].position.Y - screenPosition.Y + (float)npc[num].height - (float)npcTexture[npc[num].type].Height * npc[num].scale / (float)npcFrameCount[npc[num].type] + 4f + origin.Y * npc[num].scale + num22), npc[num].frame, npc[num].GetColor(color4), npc[num].rotation, origin, npc[num].scale, effects, 0f);
}
}
}
}
protected void DrawPlayer(Player drawPlayer)
{
SpriteEffects spriteEffects = SpriteEffects.None;
SpriteEffects spriteEffects2 = SpriteEffects.FlipHorizontally;
Color color = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.25) / 16.0), Color.White));
Color color2 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.25) / 16.0), drawPlayer.eyeColor));
Color color3 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.25) / 16.0), drawPlayer.hairColor));
Color color4 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.25) / 16.0), drawPlayer.skinColor));
Color color5 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16.0), drawPlayer.skinColor));
Color color6 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16.0), drawPlayer.shirtColor));
Color color7 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16.0), drawPlayer.underShirtColor));
Color color8 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.75) / 16.0), drawPlayer.pantsColor));
Color color9 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.75) / 16.0), drawPlayer.shoeColor));
Color color10 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.75) / 16, Color.White));
Color color11 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16, Color.White));
Color color12 = drawPlayer.GetImmuneAlpha(Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.25) / 16, Color.White));
float num = 1f;
float num2 = 1f;
float num3 = 1f;
float num4 = 1f;
if (drawPlayer.poisoned)
{
if (rand.Next(50) == 0)
{
int num5 = Dust.NewDust(drawPlayer.position, drawPlayer.width, drawPlayer.height, 46, 0f, 0f, 150, default(Color), 0.2f);
Main.dust[num5].noGravity = true;
Main.dust[num5].fadeIn = 1.9f;
}
num *= 0.65f;
num3 *= 0.75f;
}
if (drawPlayer.onFire)
{
if (rand.Next(4) == 0)
{
int num6 = Dust.NewDust(new Vector2(drawPlayer.position.X - 2f, drawPlayer.position.Y - 2f), drawPlayer.width + 4, drawPlayer.height + 4, 6, drawPlayer.velocity.X * 0.4f, drawPlayer.velocity.Y * 0.4f, 100, default(Color), 2.5f);
Main.dust[num6].noGravity = true;
Dust dust = Main.dust[num6];
dust.velocity *= 1.8f;
Main.dust[num6].velocity.Y -= 0.5f;
}
num3 *= 0.6f;
num2 *= 0.7f;
}
if (drawPlayer.noItems)
{
num2 *= 0.8f;
num *= 0.65f;
}
if (drawPlayer.blind)
{
num2 *= 0.65f;
num *= 0.7f;
}
if (num != 1f || num2 != 1f || num3 != 1f || num4 != 1f)
{
color = buffColor(color, num, num2, num3, num4);
color2 = buffColor(color2, num, num2, num3, num4);
color3 = buffColor(color3, num, num2, num3, num4);
color4 = buffColor(color4, num, num2, num3, num4);
color5 = buffColor(color5, num, num2, num3, num4);
color6 = buffColor(color6, num, num2, num3, num4);
color7 = buffColor(color7, num, num2, num3, num4);
color8 = buffColor(color8, num, num2, num3, num4);
color9 = buffColor(color9, num, num2, num3, num4);
color10 = buffColor(color10, num, num2, num3, num4);
color11 = buffColor(color11, num, num2, num3, num4);
color12 = buffColor(color12, num, num2, num3, num4);
}
if (drawPlayer.gravDir == 1f)
{
if (drawPlayer.direction == 1)
{
spriteEffects = SpriteEffects.None;
spriteEffects2 = SpriteEffects.None;
}
else
{
spriteEffects = SpriteEffects.FlipHorizontally;
spriteEffects2 = SpriteEffects.FlipHorizontally;
}
if (!drawPlayer.dead)
{
drawPlayer.legPosition.Y = 0f;
drawPlayer.headPosition.Y = 0f;
drawPlayer.bodyPosition.Y = 0f;
}
}
else
{
if (drawPlayer.direction == 1)
{
spriteEffects = SpriteEffects.FlipVertically;
spriteEffects2 = SpriteEffects.FlipVertically;
}
else
{
spriteEffects = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
spriteEffects2 = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically;
}
if (!drawPlayer.dead)
{
drawPlayer.legPosition.Y = 6f;
drawPlayer.headPosition.Y = 6f;
drawPlayer.bodyPosition.Y = 6f;
}
}
Vector2 vector = new Vector2((float)drawPlayer.legFrame.Width * 0.5f, (float)drawPlayer.legFrame.Height * 0.75f);
Vector2 origin = new Vector2((float)drawPlayer.legFrame.Width * 0.5f, (float)drawPlayer.legFrame.Height * 0.5f);
Vector2 vector2 = new Vector2((float)drawPlayer.legFrame.Width * 0.5f, (float)drawPlayer.legFrame.Height * 0.25f);
if (drawPlayer.legs > 0 && drawPlayer.legs < 16)
{
spriteBatch.Draw(armorLegTexture[drawPlayer.legs], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.legFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.legFrame.Height + 4f)) + drawPlayer.legPosition + vector, drawPlayer.legFrame, color12, drawPlayer.legRotation, vector, 1f, spriteEffects, 0f);
}
else if (!drawPlayer.invis)
{
spriteBatch.Draw(playerPantsTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.legFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.legFrame.Height + 4f)) + drawPlayer.legPosition + vector, drawPlayer.legFrame, color8, drawPlayer.legRotation, vector, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerShoesTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.legFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.legFrame.Height + 4f)) + drawPlayer.legPosition + vector, drawPlayer.legFrame, color9, drawPlayer.legRotation, vector, 1f, spriteEffects, 0f);
}
if (drawPlayer.body > 0 && drawPlayer.body < 17)
{
spriteBatch.Draw(armorBodyTexture[drawPlayer.body], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color11, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
if ((drawPlayer.body == 10 || drawPlayer.body == 11 || drawPlayer.body == 12 || drawPlayer.body == 13 || drawPlayer.body == 14 || drawPlayer.body == 15 || drawPlayer.body == 16) && !drawPlayer.invis)
{
spriteBatch.Draw(playerHandsTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color5, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
}
}
else if (!drawPlayer.invis)
{
spriteBatch.Draw(playerUnderShirtTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color7, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerShirtTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color6, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerHandsTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color5, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
}
if (!drawPlayer.invis)
{
spriteBatch.Draw(playerHeadTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color4, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerEyeWhitesTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerEyesTexture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color2, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
if (drawPlayer.head == 10 || drawPlayer.head == 12 || drawPlayer.head == 28)
{
spriteBatch.Draw(armorHeadTexture[drawPlayer.head], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color10, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
if (!drawPlayer.invis)
{
Rectangle bodyFrame = drawPlayer.bodyFrame;
bodyFrame.Y -= 336;
if (bodyFrame.Y < 0)
{
bodyFrame.Y = 0;
}
spriteBatch.Draw(playerHairTexture[drawPlayer.hair], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, bodyFrame, color3, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
}
if (drawPlayer.head == 23)
{
Rectangle bodyFrame2 = drawPlayer.bodyFrame;
bodyFrame2.Y -= 336;
if (bodyFrame2.Y < 0)
{
bodyFrame2.Y = 0;
}
if (!drawPlayer.invis)
{
spriteBatch.Draw(playerHairTexture[drawPlayer.hair], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, bodyFrame2, color3, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
spriteBatch.Draw(armorHeadTexture[drawPlayer.head], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color10, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
else if (drawPlayer.head == 14)
{
Rectangle bodyFrame3 = drawPlayer.bodyFrame;
int num7 = 0;
if (bodyFrame3.Y == bodyFrame3.Height * 6)
{
bodyFrame3.Height -= 2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 7)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 8)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 9)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 10)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 13)
{
bodyFrame3.Height -= 2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 14)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 15)
{
num7 = -2;
}
else if (bodyFrame3.Y == bodyFrame3.Height * 16)
{
num7 = -2;
}
bodyFrame3.Y += num7;
spriteBatch.Draw(armorHeadTexture[drawPlayer.head], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f) + num7) + drawPlayer.headPosition + vector2, bodyFrame3, color10, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
else if (drawPlayer.head > 0 && drawPlayer.head < 29 && drawPlayer.head != 28)
{
spriteBatch.Draw(armorHeadTexture[drawPlayer.head], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, drawPlayer.bodyFrame, color10, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
else if (!drawPlayer.invis)
{
Rectangle bodyFrame4 = drawPlayer.bodyFrame;
bodyFrame4.Y -= 336;
if (bodyFrame4.Y < 0)
{
bodyFrame4.Y = 0;
}
spriteBatch.Draw(playerHairTexture[drawPlayer.hair], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.headPosition + vector2, bodyFrame4, color3, drawPlayer.headRotation, vector2, 1f, spriteEffects, 0f);
}
if (drawPlayer.heldProj >= 0)
{
DrawProj(drawPlayer.heldProj);
}
Color color13 = Lighting.GetColor((int)((double)drawPlayer.position.X + (double)drawPlayer.width * 0.5) / 16, (int)(((double)drawPlayer.position.Y + (double)drawPlayer.height * 0.5) / 16.0));
if ((drawPlayer.itemAnimation > 0 || drawPlayer.inventory[drawPlayer.selectedItem].holdStyle > 0) && drawPlayer.inventory[drawPlayer.selectedItem].type > 0 && !drawPlayer.dead && !drawPlayer.inventory[drawPlayer.selectedItem].noUseGraphic && (!drawPlayer.wet || !drawPlayer.inventory[drawPlayer.selectedItem].noWet))
{
if (drawPlayer.inventory[drawPlayer.selectedItem].useStyle == 5)
{
int num8 = 10;
Vector2 vector3 = new Vector2(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width / 2, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height / 2);
if (drawPlayer.inventory[drawPlayer.selectedItem].type == 95)
{
num8 = 10;
vector3.Y += 2f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 96)
{
num8 = -5;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 98)
{
num8 = -5;
vector3.Y -= 2f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 197)
{
num8 = -5;
vector3.Y += 4f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 126)
{
num8 = 4;
vector3.Y += 4f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 127)
{
num8 = 4;
vector3.Y += 2f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 157)
{
num8 = 6;
vector3.Y += 2f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 160)
{
num8 = -8;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 164 || drawPlayer.inventory[drawPlayer.selectedItem].type == 219)
{
num8 = 2;
vector3.Y += 4f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 165 || drawPlayer.inventory[drawPlayer.selectedItem].type == 272)
{
num8 = 4;
vector3.Y += 4f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 266)
{
num8 = 0;
vector3.Y += 2f * drawPlayer.gravDir;
}
else if (drawPlayer.inventory[drawPlayer.selectedItem].type == 281)
{
num8 = 6;
vector3.Y -= 6f * drawPlayer.gravDir;
}
Vector2 origin2 = new Vector2(-num8, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height / 2);
if (drawPlayer.direction == -1)
{
origin2 = new Vector2(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width + num8, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height / 2);
}
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X + vector3.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y + vector3.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetAlpha(color13), drawPlayer.itemRotation, origin2, drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
if (drawPlayer.inventory[drawPlayer.selectedItem].color != default(Color))
{
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X + vector3.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y + vector3.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetColor(color13), drawPlayer.itemRotation, origin2, drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
}
}
else if (drawPlayer.gravDir == -1f)
{
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetAlpha(color13), drawPlayer.itemRotation, new Vector2((float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f - (float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f * (float)drawPlayer.direction, 0f), drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
if (drawPlayer.inventory[drawPlayer.selectedItem].color != default(Color))
{
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetColor(color13), drawPlayer.itemRotation, new Vector2((float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f - (float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f * (float)drawPlayer.direction, 0f), drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
}
}
else
{
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetAlpha(color13), drawPlayer.itemRotation, new Vector2((float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f - (float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f * (float)drawPlayer.direction, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
if (drawPlayer.inventory[drawPlayer.selectedItem].color != default(Color))
{
spriteBatch.Draw(itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type], new Vector2((int)(drawPlayer.itemLocation.X - screenPosition.X), (int)(drawPlayer.itemLocation.Y - screenPosition.Y)), new Rectangle(0, 0, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].GetColor(color13), drawPlayer.itemRotation, new Vector2((float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f - (float)itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Width * 0.5f * (float)drawPlayer.direction, itemTexture[drawPlayer.inventory[drawPlayer.selectedItem].type].Height), drawPlayer.inventory[drawPlayer.selectedItem].scale, spriteEffects2, 0f);
}
}
}
if (drawPlayer.body > 0 && drawPlayer.body < 17)
{
spriteBatch.Draw(armorArmTexture[drawPlayer.body], new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color11, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
if ((drawPlayer.body == 10 || drawPlayer.body == 11 || drawPlayer.body == 12 || drawPlayer.body == 13 || drawPlayer.body == 14 || drawPlayer.body == 15 || drawPlayer.body == 16) && !drawPlayer.invis)
{
spriteBatch.Draw(playerHands2Texture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color5, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
}
}
else if (!drawPlayer.invis)
{
spriteBatch.Draw(playerUnderShirt2Texture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color7, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
spriteBatch.Draw(playerHands2Texture, new Vector2((int)(drawPlayer.position.X - screenPosition.X) - drawPlayer.bodyFrame.Width / 2 + drawPlayer.width / 2, (int)(drawPlayer.position.Y - screenPosition.Y + (float)drawPlayer.height - (float)drawPlayer.bodyFrame.Height + 4f)) + drawPlayer.bodyPosition + new Vector2(drawPlayer.bodyFrame.Width / 2, drawPlayer.bodyFrame.Height / 2), drawPlayer.bodyFrame, color5, drawPlayer.bodyRotation, origin, 1f, spriteEffects, 0f);
}
}
protected void DrawProj(int i)
{
if (projectile[i].type == 32)
{
Vector2 vector = new Vector2(projectile[i].position.X + (float)projectile[i].width * 0.5f, projectile[i].position.Y + (float)projectile[i].height * 0.5f);
float num = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector.X;
float num2 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector.Y;
float rotation = (float)Math.Atan2(num2, num) - 1.57f;
bool flag = true;
if (num == 0f && num2 == 0f)
{
flag = false;
}
else
{
float num3 = (float)Math.Sqrt(num * num + num2 * num2);
num3 = 8f / num3;
num *= num3;
num2 *= num3;
vector.X -= num;
vector.Y -= num2;
num = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector.X;
num2 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector.Y;
}
while (flag)
{
float num4 = (float)Math.Sqrt(num * num + num2 * num2);
if (num4 < 28f)
{
flag = false;
continue;
}
num4 = 28f / num4;
num *= num4;
num2 *= num4;
vector.X += num;
vector.Y += num2;
num = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector.X;
num2 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector.Y;
Color color = Lighting.GetColor((int)vector.X / 16, (int)(vector.Y / 16f));
spriteBatch.Draw(chain5Texture, new Vector2(vector.X - screenPosition.X, vector.Y - screenPosition.Y), new Rectangle(0, 0, chain5Texture.Width, chain5Texture.Height), color, rotation, new Vector2((float)chain5Texture.Width * 0.5f, (float)chain5Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
else if (projectile[i].aiStyle == 7)
{
Vector2 vector2 = new Vector2(projectile[i].position.X + (float)projectile[i].width * 0.5f, projectile[i].position.Y + (float)projectile[i].height * 0.5f);
float num5 = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector2.X;
float num6 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector2.Y;
float rotation2 = (float)Math.Atan2(num6, num5) - 1.57f;
bool flag2 = true;
while (flag2)
{
float num7 = (float)Math.Sqrt(num5 * num5 + num6 * num6);
if (num7 < 25f)
{
flag2 = false;
continue;
}
num7 = 12f / num7;
num5 *= num7;
num6 *= num7;
vector2.X += num5;
vector2.Y += num6;
num5 = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector2.X;
num6 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector2.Y;
Color color2 = Lighting.GetColor((int)vector2.X / 16, (int)(vector2.Y / 16f));
spriteBatch.Draw(chainTexture, new Vector2(vector2.X - screenPosition.X, vector2.Y - screenPosition.Y), new Rectangle(0, 0, chainTexture.Width, chainTexture.Height), color2, rotation2, new Vector2((float)chainTexture.Width * 0.5f, (float)chainTexture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
else if (projectile[i].aiStyle == 13)
{
float num8 = projectile[i].position.X + 8f;
float num9 = projectile[i].position.Y + 2f;
float x = projectile[i].velocity.X;
float y = projectile[i].velocity.Y;
float num10 = (float)Math.Sqrt(x * x + y * y);
num10 = 20f / num10;
if (projectile[i].ai[0] == 0f)
{
num8 -= projectile[i].velocity.X * num10;
num9 -= projectile[i].velocity.Y * num10;
}
else
{
num8 += projectile[i].velocity.X * num10;
num9 += projectile[i].velocity.Y * num10;
}
Vector2 vector3 = new Vector2(num8, num9);
x = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector3.X;
y = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector3.Y;
float rotation3 = (float)Math.Atan2(y, x) - 1.57f;
if (projectile[i].alpha == 0)
{
int num11 = -1;
if (projectile[i].position.X + (float)(projectile[i].width / 2) < player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2))
{
num11 = 1;
}
if (player[projectile[i].owner].direction == 1)
{
player[projectile[i].owner].itemRotation = (float)Math.Atan2(y * (float)num11, x * (float)num11);
}
else
{
player[projectile[i].owner].itemRotation = (float)Math.Atan2(y * (float)num11, x * (float)num11);
}
}
bool flag3 = true;
while (flag3)
{
float num12 = (float)Math.Sqrt(x * x + y * y);
if (num12 < 25f)
{
flag3 = false;
continue;
}
num12 = 12f / num12;
x *= num12;
y *= num12;
vector3.X += x;
vector3.Y += y;
x = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector3.X;
y = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector3.Y;
Color color3 = Lighting.GetColor((int)vector3.X / 16, (int)(vector3.Y / 16f));
spriteBatch.Draw(chainTexture, new Vector2(vector3.X - screenPosition.X, vector3.Y - screenPosition.Y), new Rectangle(0, 0, chainTexture.Width, chainTexture.Height), color3, rotation3, new Vector2((float)chainTexture.Width * 0.5f, (float)chainTexture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
else if (projectile[i].aiStyle == 15)
{
Vector2 vector4 = new Vector2(projectile[i].position.X + (float)projectile[i].width * 0.5f, projectile[i].position.Y + (float)projectile[i].height * 0.5f);
float num13 = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector4.X;
float num14 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector4.Y;
float rotation4 = (float)Math.Atan2(num14, num13) - 1.57f;
if (projectile[i].alpha == 0)
{
int num15 = -1;
if (projectile[i].position.X + (float)(projectile[i].width / 2) < player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2))
{
num15 = 1;
}
if (player[projectile[i].owner].direction == 1)
{
player[projectile[i].owner].itemRotation = (float)Math.Atan2(num14 * (float)num15, num13 * (float)num15);
}
else
{
player[projectile[i].owner].itemRotation = (float)Math.Atan2(num14 * (float)num15, num13 * (float)num15);
}
}
bool flag4 = true;
while (flag4)
{
float num16 = (float)Math.Sqrt(num13 * num13 + num14 * num14);
if (num16 < 25f)
{
flag4 = false;
continue;
}
num16 = 12f / num16;
num13 *= num16;
num14 *= num16;
vector4.X += num13;
vector4.Y += num14;
num13 = player[projectile[i].owner].position.X + (float)(player[projectile[i].owner].width / 2) - vector4.X;
num14 = player[projectile[i].owner].position.Y + (float)(player[projectile[i].owner].height / 2) - vector4.Y;
Color color4 = Lighting.GetColor((int)vector4.X / 16, (int)(vector4.Y / 16f));
if (projectile[i].type == 25)
{
spriteBatch.Draw(chain2Texture, new Vector2(vector4.X - screenPosition.X, vector4.Y - screenPosition.Y), new Rectangle(0, 0, chain2Texture.Width, chain2Texture.Height), color4, rotation4, new Vector2((float)chain2Texture.Width * 0.5f, (float)chain2Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
else if (projectile[i].type == 35)
{
spriteBatch.Draw(chain6Texture, new Vector2(vector4.X - screenPosition.X, vector4.Y - screenPosition.Y), new Rectangle(0, 0, chain6Texture.Width, chain6Texture.Height), color4, rotation4, new Vector2((float)chain6Texture.Width * 0.5f, (float)chain6Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(chain3Texture, new Vector2(vector4.X - screenPosition.X, vector4.Y - screenPosition.Y), new Rectangle(0, 0, chain3Texture.Width, chain3Texture.Height), color4, rotation4, new Vector2((float)chain3Texture.Width * 0.5f, (float)chain3Texture.Height * 0.5f), 1f, SpriteEffects.None, 0f);
}
}
}
Color newColor = Lighting.GetColor((int)((double)projectile[i].position.X + (double)projectile[i].width * 0.5) / 16, (int)(((double)projectile[i].position.Y + (double)projectile[i].height * 0.5) / 16.0));
if (projectile[i].hide)
{
newColor = Lighting.GetColor((int)((double)player[projectile[i].owner].position.X + (double)player[projectile[i].owner].width * 0.5) / 16, (int)(((double)player[projectile[i].owner].position.Y + (double)player[projectile[i].owner].height * 0.5) / 16.0));
}
if (projectile[i].type == 14)
{
newColor = Color.White;
}
int num17 = 0;
int num18 = 0;
if (projectile[i].type == 16)
{
num17 = 6;
}
if (projectile[i].type == 17 || projectile[i].type == 31)
{
num17 = 2;
}
if (projectile[i].type == 25 || projectile[i].type == 26 || projectile[i].type == 35)
{
num17 = 6;
num18 -= 6;
}
if (projectile[i].type == 28 || projectile[i].type == 37)
{
num17 = 8;
}
if (projectile[i].type == 29)
{
num17 = 11;
}
if (projectile[i].type == 43)
{
num17 = 4;
}
float num19 = (float)(projectileTexture[projectile[i].type].Width - projectile[i].width) * 0.5f + (float)projectile[i].width * 0.5f;
if (projectile[i].type == 50 || projectile[i].type == 53)
{
num18 = -8;
}
if (projectile[i].aiStyle == 19)
{
spriteBatch.Draw(projectileTexture[projectile[i].type], new Vector2(projectile[i].position.X - screenPosition.X + (float)(projectile[i].width / 2), projectile[i].position.Y - screenPosition.Y + (float)(projectile[i].height / 2)), new Rectangle(0, 0, projectileTexture[projectile[i].type].Width, projectileTexture[projectile[i].type].Height), projectile[i].GetAlpha(newColor), projectile[i].rotation, default(Vector2), projectile[i].scale, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(projectileTexture[projectile[i].type], new Vector2(projectile[i].position.X - screenPosition.X + num19 + (float)num18, projectile[i].position.Y - screenPosition.Y + (float)(projectile[i].height / 2)), new Rectangle(0, 0, projectileTexture[projectile[i].type].Width, projectileTexture[projectile[i].type].Height), projectile[i].GetAlpha(newColor), projectile[i].rotation, new Vector2(num19, projectile[i].height / 2 + num17), projectile[i].scale, SpriteEffects.None, 0f);
}
}
protected void DrawSplash(GameTime gameTime)
{
base.GraphicsDevice.Clear(Color.Black);
base.Draw(gameTime);
spriteBatch.Begin();
splashCounter++;
Color white = Color.White;
byte b = 0;
if (splashCounter <= 75)
{
float num = (float)splashCounter / 75f * 255f;
b = (byte)num;
}
else if (splashCounter <= 200)
{
b = byte.MaxValue;
}
else if (splashCounter <= 275)
{
int num2 = 275 - splashCounter;
float num3 = (float)num2 / 75f * 255f;
b = (byte)num3;
}
else
{
showSplash = false;
fadeCounter = 75;
}
white = new Color(b, b, b, b);
spriteBatch.Draw(splashTexture, new Rectangle(0, 0, screenWidth, screenHeight), white);
spriteBatch.End();
}
protected void DrawTiles(bool solidOnly = true)
{
int num = (int)(screenPosition.X / 16f - 1f);
int num2 = (int)((screenPosition.X + (float)screenWidth) / 16f) + 2;
int num3 = (int)(screenPosition.Y / 16f - 1f);
int num4 = (int)((screenPosition.Y + (float)screenHeight) / 16f) + 2;
if (num < 0)
{
num = 0;
}
if (num2 > maxTilesX)
{
num2 = maxTilesX;
}
if (num3 < 0)
{
num3 = 0;
}
if (num4 > maxTilesY)
{
num4 = maxTilesY;
}
int num5 = 16;
int num6 = 16;
for (int i = num3; i < num4 + 4; i++)
{
for (int j = num - 2; j < num2 + 2; j++)
{
if (!tile[j, i].active || tileSolid[tile[j, i].type] != solidOnly)
{
continue;
}
Color color = Lighting.GetColor(j, i);
int num7 = 0;
if (tile[j, i].type == 78 || tile[j, i].type == 85)
{
num7 = 2;
}
if (tile[j, i].type == 33 || tile[j, i].type == 49)
{
num7 = -4;
}
num5 = ((tile[j, i].type != 3 && tile[j, i].type != 4 && tile[j, i].type != 5 && tile[j, i].type != 24 && tile[j, i].type != 33 && tile[j, i].type != 49 && tile[j, i].type != 61 && tile[j, i].type != 71) ? ((tile[j, i].type != 15 && tile[j, i].type != 14 && tile[j, i].type != 16 && tile[j, i].type != 17 && tile[j, i].type != 18 && tile[j, i].type != 20 && tile[j, i].type != 21 && tile[j, i].type != 26 && tile[j, i].type != 27 && tile[j, i].type != 32 && tile[j, i].type != 69 && tile[j, i].type != 72 && tile[j, i].type != 77 && tile[j, i].type != 80) ? 16 : 18) : 20);
num6 = ((tile[j, i].type != 4 && tile[j, i].type != 5) ? 16 : 20);
if (tile[j, i].type == 73 || tile[j, i].type == 74)
{
num7 -= 12;
num5 = 32;
}
if (tile[j, i].type == 81)
{
num7 -= 8;
num5 = 26;
num6 = 24;
}
if (player[myPlayer].findTreasure && (tile[j, i].type == 6 || tile[j, i].type == 7 || tile[j, i].type == 8 || tile[j, i].type == 9 || tile[j, i].type == 12 || tile[j, i].type == 21 || tile[j, i].type == 22 || tile[j, i].type == 28 || (tile[j, i].type >= 63 && tile[j, i].type <= 68) || tileAlch[tile[j, i].type]))
{
if (color.R < mouseTextColor / 2)
{
color.R = (byte)(mouseTextColor / 2);
}
if (color.G < 70)
{
color.G = 70;
}
if (color.B < 210)
{
color.B = 210;
}
color.A = mouseTextColor;
if (!gamePaused && base.IsActive && rand.Next(150) == 0)
{
int num8 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 15, 0f, 0f, 150, default(Color), 0.8f);
Dust dust = Main.dust[num8];
dust.velocity *= 0.1f;
Main.dust[num8].noLight = true;
}
}
if (!gamePaused && base.IsActive)
{
if (tile[j, i].type == 4 && rand.Next(40) == 0)
{
if (tile[j, i].frameX == 22)
{
Dust.NewDust(new Vector2(j * 16 + 6, i * 16), 4, 4, 6, 0f, 0f, 100);
}
if (tile[j, i].frameX == 44)
{
Dust.NewDust(new Vector2(j * 16 + 2, i * 16), 4, 4, 6, 0f, 0f, 100);
}
else
{
Dust.NewDust(new Vector2(j * 16 + 4, i * 16), 4, 4, 6, 0f, 0f, 100);
}
}
if (tile[j, i].type == 33 && rand.Next(40) == 0)
{
Dust.NewDust(new Vector2(j * 16 + 4, i * 16 - 4), 4, 4, 6, 0f, 0f, 100);
}
if (tile[j, i].type == 93 && rand.Next(40) == 0 && tile[j, i].frameY == 0)
{
Dust.NewDust(new Vector2(j * 16 + 4, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
if (tile[j, i].type == 100 && rand.Next(40) == 0 && tile[j, i].frameY == 0)
{
if (tile[j, i].frameX == 0)
{
if (rand.Next(3) == 0)
{
Dust.NewDust(new Vector2(j * 16 + 4, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
else
{
Dust.NewDust(new Vector2(j * 16 + 14, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
}
else if (rand.Next(3) == 0)
{
Dust.NewDust(new Vector2(j * 16 + 6, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
else
{
Dust.NewDust(new Vector2(j * 16, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
}
if (tile[j, i].type == 98 && rand.Next(40) == 0 && tile[j, i].frameY == 0 && tile[j, i].frameX == 0)
{
Dust.NewDust(new Vector2(j * 16 + 12, i * 16 + 2), 4, 4, 6, 0f, 0f, 100);
}
if (tile[j, i].type == 49 && rand.Next(20) == 0)
{
Dust.NewDust(new Vector2(j * 16 + 4, i * 16 - 4), 4, 4, 29, 0f, 0f, 100);
}
if ((tile[j, i].type == 34 || tile[j, i].type == 35 || tile[j, i].type == 36) && rand.Next(40) == 0 && tile[j, i].frameY == 18 && (tile[j, i].frameX == 0 || tile[j, i].frameX == 36))
{
Dust.NewDust(new Vector2(j * 16, i * 16 + 2), 14, 6, 6, 0f, 0f, 100);
}
if (tile[j, i].type == 22 && rand.Next(400) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14);
}
else if ((tile[j, i].type == 23 || tile[j, i].type == 24 || tile[j, i].type == 32) && rand.Next(500) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14);
}
else if (tile[j, i].type == 25 && rand.Next(700) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14);
}
else if (tile[j, i].type == 31 && rand.Next(20) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14, 0f, 0f, 100);
}
else if (tile[j, i].type == 26 && rand.Next(20) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14, 0f, 0f, 100);
}
else if ((tile[j, i].type == 71 || tile[j, i].type == 72) && rand.Next(500) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 41, 0f, 0f, 250, default(Color), 0.8f);
}
else if ((tile[j, i].type == 17 || tile[j, i].type == 77) && rand.Next(40) == 0)
{
if ((tile[j, i].frameX == 18) & (tile[j, i].frameY == 18))
{
Dust.NewDust(new Vector2(j * 16 + 2, i * 16), 8, 6, 6, 0f, 0f, 100);
}
}
else if (tile[j, i].type == 37 && rand.Next(250) == 0)
{
int num9 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 6, 0f, 0f, 0, default(Color), rand.Next(3));
if (Main.dust[num9].scale > 1f)
{
Main.dust[num9].noGravity = true;
}
}
else if ((tile[j, i].type == 58 || tile[j, i].type == 76) && rand.Next(250) == 0)
{
int num10 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 6, 0f, 0f, 0, default(Color), rand.Next(3));
if (Main.dust[num10].scale > 1f)
{
Main.dust[num10].noGravity = true;
}
Main.dust[num10].noLight = true;
}
else if (tile[j, i].type == 61)
{
if (tile[j, i].frameX == 144)
{
if (rand.Next(60) == 0)
{
int num11 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 44, 0f, 0f, 250, default(Color), 0.4f);
Main.dust[num11].fadeIn = 0.7f;
}
color.A = (byte)(245f - (float)(int)mouseTextColor * 1.5f);
color.R = (byte)(245f - (float)(int)mouseTextColor * 1.5f);
color.B = (byte)(245f - (float)(int)mouseTextColor * 1.5f);
color.G = (byte)(245f - (float)(int)mouseTextColor * 1.5f);
}
}
else if (tileShine[tile[j, i].type] > 0 && color.R > 60 && rand.Next(tileShine[tile[j, i].type]) < color.R / 50 && (tile[j, i].type != 21 || (tile[j, i].frameX >= 36 && tile[j, i].frameX < 180)))
{
int num12 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 43, 0f, 0f, 254, default(Color), 0.5f);
Dust dust2 = Main.dust[num12];
dust2.velocity *= 0f;
}
}
if (tile[j, i].type == 5 && tile[j, i].frameY >= 198 && tile[j, i].frameX >= 22)
{
int num13 = 0;
if (tile[j, i].frameX == 22)
{
if (tile[j, i].frameY == 220)
{
num13 = 1;
}
else if (tile[j, i].frameY == 242)
{
num13 = 2;
}
int num14 = 0;
int num15 = 80;
int num16 = 80;
int num17 = 32;
for (int k = i; k < i + 100; k++)
{
if (tile[j, k].type == 2)
{
num14 = 0;
break;
}
if (tile[j, k].type == 23)
{
num14 = 1;
break;
}
if (tile[j, k].type == 60)
{
num14 = 2;
num15 = 114;
num16 = 96;
num17 = 48;
break;
}
}
spriteBatch.Draw(treeTopTexture[num14], new Vector2(j * 16 - (int)screenPosition.X - num17, i * 16 - (int)screenPosition.Y - num16 + 16), new Rectangle(num13 * (num15 + 2), 0, num15, num16), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
else if (tile[j, i].frameX == 44)
{
if (tile[j, i].frameY == 220)
{
num13 = 1;
}
else if (tile[j, i].frameY == 242)
{
num13 = 2;
}
int num18 = 0;
for (int l = i; l < i + 100; l++)
{
if (tile[j + 1, l].type == 2)
{
num18 = 0;
break;
}
if (tile[j + 1, l].type == 23)
{
num18 = 1;
break;
}
if (tile[j + 1, l].type == 60)
{
num18 = 2;
break;
}
}
spriteBatch.Draw(treeBranchTexture[num18], new Vector2(j * 16 - (int)screenPosition.X - 24, i * 16 - (int)screenPosition.Y - 12), new Rectangle(0, num13 * 42, 40, 40), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
else if (tile[j, i].frameX == 66)
{
if (tile[j, i].frameY == 220)
{
num13 = 1;
}
else if (tile[j, i].frameY == 242)
{
num13 = 2;
}
int num19 = 0;
for (int m = i; m < i + 100; m++)
{
if (tile[j - 1, m].type == 2)
{
num19 = 0;
break;
}
if (tile[j - 1, m].type == 23)
{
num19 = 1;
break;
}
if (tile[j - 1, m].type == 60)
{
num19 = 2;
break;
}
}
spriteBatch.Draw(treeBranchTexture[num19], new Vector2(j * 16 - (int)screenPosition.X, i * 16 - (int)screenPosition.Y - 12), new Rectangle(42, num13 * 42, 40, 40), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
if (tile[j, i].type == 72 && tile[j, i].frameX >= 36)
{
int num20 = 0;
if (tile[j, i].frameY == 18)
{
num20 = 1;
}
else if (tile[j, i].frameY == 36)
{
num20 = 2;
}
spriteBatch.Draw(shroomCapTexture, new Vector2(j * 16 - (int)screenPosition.X - 22, i * 16 - (int)screenPosition.Y - 26), new Rectangle(num20 * 62, 0, 60, 42), Lighting.GetColor(j, i), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
if (color.R <= 0)
{
continue;
}
if (solidOnly && tileSolid[tile[j, i].type] && !tileSolidTop[tile[j, i].type] && (tile[j - 1, i].liquid > 0 || tile[j + 1, i].liquid > 0 || tile[j, i - 1].liquid > 0 || tile[j, i + 1].liquid > 0))
{
Color color2 = Lighting.GetColor(j, i);
int num21 = 0;
bool flag = false;
bool flag2 = false;
bool flag3 = false;
bool flag4 = false;
int num22 = 0;
bool flag5 = false;
if (tile[j - 1, i].liquid > num21)
{
num21 = tile[j - 1, i].liquid;
flag = true;
}
else if (tile[j - 1, i].liquid > 0)
{
flag = true;
}
if (tile[j + 1, i].liquid > num21)
{
num21 = tile[j + 1, i].liquid;
flag2 = true;
}
else if (tile[j + 1, i].liquid > 0)
{
num21 = tile[j + 1, i].liquid;
flag2 = true;
}
if (tile[j, i - 1].liquid > 0)
{
flag3 = true;
}
if (tile[j, i + 1].liquid > 240)
{
flag4 = true;
}
if (tile[j - 1, i].liquid > 0)
{
if (tile[j - 1, i].lava)
{
num22 = 1;
}
else
{
flag5 = true;
}
}
if (tile[j + 1, i].liquid > 0)
{
if (tile[j + 1, i].lava)
{
num22 = 1;
}
else
{
flag5 = true;
}
}
if (tile[j, i - 1].liquid > 0)
{
if (tile[j, i - 1].lava)
{
num22 = 1;
}
else
{
flag5 = true;
}
}
if (tile[j, i + 1].liquid > 0)
{
if (tile[j, i + 1].lava)
{
num22 = 1;
}
else
{
flag5 = true;
}
}
if (!flag5 || num22 != 1)
{
float num23 = 0f;
Vector2 vector = new Vector2(j * 16, i * 16);
Rectangle value = new Rectangle(0, 4, 16, 16);
if (flag4 && (flag || flag2))
{
flag = true;
flag2 = true;
}
if ((!flag3 || (!flag && !flag2)) && (!flag4 || !flag3))
{
if (flag3)
{
value = new Rectangle(0, 4, 16, 4);
}
else if (flag4 && !flag && !flag2)
{
vector = new Vector2(j * 16, i * 16 + 12);
value = new Rectangle(0, 4, 16, 4);
}
else
{
num23 = 256 - num21;
num23 /= 32f;
if (flag && flag2)
{
vector = new Vector2(j * 16, i * 16 + (int)num23 * 2);
value = new Rectangle(0, 4, 16, 16 - (int)num23 * 2);
}
else if (flag)
{
vector = new Vector2(j * 16, i * 16 + (int)num23 * 2);
value = new Rectangle(0, 4, 4, 16 - (int)num23 * 2);
}
else
{
vector = new Vector2(j * 16 + 12, i * 16 + (int)num23 * 2);
value = new Rectangle(0, 4, 4, 16 - (int)num23 * 2);
}
}
}
float num24 = 0.5f;
if (num22 == 1)
{
num24 *= 1.6f;
}
if ((double)i < worldSurface || num24 > 1f)
{
num24 = 1f;
}
float num25 = (float)(int)color2.R * num24;
float num26 = (float)(int)color2.G * num24;
float num27 = (float)(int)color2.B * num24;
float num28 = (float)(int)color2.A * num24;
color2 = new Color((byte)num25, (byte)num26, (byte)num27, (byte)num28);
spriteBatch.Draw(liquidTexture[num22], vector - screenPosition, value, color2, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
if (tile[j, i].type == 51)
{
Color color3 = Lighting.GetColor(j, i);
float num29 = 0.5f;
float num30 = (float)(int)color3.R * num29;
float num31 = (float)(int)color3.G * num29;
float num32 = (float)(int)color3.B * num29;
float num33 = (float)(int)color3.A * num29;
color3 = new Color((byte)num30, (byte)num31, (byte)num32, (byte)num33);
spriteBatch.Draw(tileTexture[tile[j, i].type], new Vector2((float)(j * 16 - (int)screenPosition.X) - ((float)num6 - 16f) / 2f, i * 16 - (int)screenPosition.Y + num7), new Rectangle(tile[j, i].frameX, tile[j, i].frameY, num6, num5), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
else if (tileAlch[tile[j, i].type])
{
num5 = 20;
num7 = -1;
int num34 = tile[j, i].type;
int num35 = tile[j, i].frameX / 18;
if (num34 > 82)
{
if (num35 == 0 && dayTime)
{
num34 = 84;
}
if (num35 == 1 && !dayTime)
{
num34 = 84;
}
if (num35 == 3 && bloodMoon)
{
num34 = 84;
}
}
if (num34 == 84)
{
if (num35 == 0 && rand.Next(100) == 0)
{
int num36 = Dust.NewDust(new Vector2(j * 16, i * 16 - 4), 16, 16, 19, 0f, 0f, 160, default(Color), 0.1f);
Main.dust[num36].velocity.X /= 2f;
Main.dust[num36].velocity.Y /= 2f;
Main.dust[num36].noGravity = true;
Main.dust[num36].fadeIn = 1f;
}
if (num35 == 1 && rand.Next(100) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 41, 0f, 0f, 250, default(Color), 0.8f);
}
if (num35 == 3)
{
if (rand.Next(200) == 0)
{
int num37 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 14, 0f, 0f, 100, default(Color), 0.2f);
Main.dust[num37].fadeIn = 1.2f;
}
if (rand.Next(75) == 0)
{
int num38 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 27, 0f, 0f, 100);
Main.dust[num38].velocity.X /= 2f;
Main.dust[num38].velocity.Y /= 2f;
}
}
if (num35 == 4 && rand.Next(150) == 0)
{
int num39 = Dust.NewDust(new Vector2(j * 16, i * 16), 16, 8, 16);
Main.dust[num39].velocity.X /= 3f;
Main.dust[num39].velocity.Y /= 3f;
Main.dust[num39].velocity.Y -= 0.7f;
Main.dust[num39].alpha = 50;
Dust dust3 = Main.dust[num39];
dust3.scale *= 0.1f;
Main.dust[num39].fadeIn = 0.9f;
Main.dust[num39].noGravity = true;
}
if (num35 == 5)
{
if (rand.Next(40) == 0)
{
int num40 = Dust.NewDust(new Vector2(j * 16, i * 16 - 6), 16, 16, 6, 0f, 0f, 0, default(Color), 1.5f);
Main.dust[num40].velocity.Y -= 2f;
Main.dust[num40].noGravity = true;
}
color.A = (byte)(mouseTextColor / 2);
color.G = mouseTextColor;
color.B = mouseTextColor;
}
}
spriteBatch.Draw(tileTexture[num34], new Vector2((float)(j * 16 - (int)screenPosition.X) - ((float)num6 - 16f) / 2f, i * 16 - (int)screenPosition.Y + num7), new Rectangle(tile[j, i].frameX, tile[j, i].frameY, num6, num5), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
else
{
spriteBatch.Draw(tileTexture[tile[j, i].type], new Vector2((float)(j * 16 - (int)screenPosition.X) - ((float)num6 - 16f) / 2f, i * 16 - (int)screenPosition.Y + num7), new Rectangle(tile[j, i].frameX, tile[j, i].frameY, num6, num5), color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
}
protected void DrawWater(bool bg = false)
{
int num = (int)(screenPosition.X / 16f - 1f);
int num2 = (int)((screenPosition.X + (float)screenWidth) / 16f) + 2;
int num3 = (int)(screenPosition.Y / 16f - 1f);
int num4 = (int)((screenPosition.Y + (float)screenHeight) / 16f) + 2;
if (num < 0)
{
num = 0;
}
if (num2 > maxTilesX)
{
num2 = maxTilesX;
}
if (num3 < 0)
{
num3 = 0;
}
if (num4 > maxTilesY)
{
num4 = maxTilesY;
}
for (int i = num3; i < num4 + 4; i++)
{
for (int j = num - 2; j < num2 + 2; j++)
{
if (tile[j, i].liquid <= 0 || Lighting.Brightness(j, i) <= 0f)
{
continue;
}
Color color = Lighting.GetColor(j, i);
float num5 = 256 - tile[j, i].liquid;
num5 /= 32f;
int num6 = 0;
if (tile[j, i].lava)
{
num6 = 1;
}
float num7 = 0.5f;
if (bg)
{
num7 = 1f;
}
Vector2 vector = new Vector2(j * 16, i * 16 + (int)num5 * 2);
Rectangle value = new Rectangle(0, 0, 16, 16 - (int)num5 * 2);
if (tile[j, i + 1].liquid < 245 && (!tile[j, i + 1].active || !tileSolid[tile[j, i + 1].type] || tileSolidTop[tile[j, i + 1].type]))
{
float num8 = 256 - tile[j, i + 1].liquid;
num8 /= 32f;
num7 = 0.5f * (8f - num5) / 4f;
if ((double)num7 > 0.55)
{
num7 = 0.55f;
}
if ((double)num7 < 0.35)
{
num7 = 0.35f;
}
float num9 = num5 / 2f;
if (tile[j, i + 1].liquid < 200)
{
if (bg)
{
continue;
}
if (tile[j, i - 1].liquid > 0 && tile[j, i - 1].liquid > 0)
{
value = new Rectangle(0, 4, 16, 16);
num7 = 0.5f;
}
else if (tile[j, i - 1].liquid > 0)
{
vector = new Vector2(j * 16, i * 16 + 4);
value = new Rectangle(0, 4, 16, 12);
num7 = 0.5f;
}
else if (tile[j, i + 1].liquid > 0)
{
vector = new Vector2(j * 16, i * 16 + (int)num5 * 2 + (int)num8 * 2);
value = new Rectangle(0, 4, 16, 16 - (int)num5 * 2);
}
else
{
vector = new Vector2(j * 16 + (int)num9, i * 16 + (int)num9 * 2 + (int)num8 * 2);
value = new Rectangle(0, 4, 16 - (int)num9 * 2, 16 - (int)num9 * 2);
}
}
else
{
num7 = 0.5f;
value = new Rectangle(0, 4, 16, 16 - (int)num5 * 2 + (int)num8 * 2);
}
}
else if (tile[j, i - 1].liquid > 32)
{
value = new Rectangle(0, 4, value.Width, value.Height);
}
else if (num5 < 1f && tile[j, i - 1].active && tileSolid[tile[j, i - 1].type] && !tileSolidTop[tile[j, i - 1].type])
{
vector = new Vector2(j * 16, i * 16);
value = new Rectangle(0, 4, 16, 16);
}
else
{
bool flag = true;
for (int k = i + 1; k < i + 6 && (!tile[j, k].active || !tileSolid[tile[j, k].type] || tileSolidTop[tile[j, k].type]); k++)
{
if (tile[j, k].liquid < 200)
{
flag = false;
break;
}
}
if (!flag)
{
num7 = 0.5f;
value = new Rectangle(0, 4, 16, 16);
}
else if (tile[j, i - 1].liquid > 0)
{
value = new Rectangle(0, 2, value.Width, value.Height);
}
}
if (tile[j, i].lava)
{
num7 *= 1.8f;
if (num7 > 1f)
{
num7 = 1f;
}
if (base.IsActive && !gamePaused && Dust.lavaBubbles < 200)
{
if (tile[j, i].liquid > 200 && rand.Next(700) == 0)
{
Dust.NewDust(new Vector2(j * 16, i * 16), 16, 16, 35);
}
if (value.Y == 0 && rand.Next(350) == 0)
{
int num10 = Dust.NewDust(new Vector2(j * 16, (float)(i * 16) + num5 * 2f - 8f), 16, 8, 35, 0f, 0f, 50, default(Color), 1.5f);
Dust dust = Main.dust[num10];
dust.velocity *= 0.8f;
Main.dust[num10].velocity.X *= 2f;
Main.dust[num10].velocity.Y -= (float)rand.Next(1, 7) * 0.1f;
if (rand.Next(10) == 0)
{
Main.dust[num10].velocity.Y *= rand.Next(2, 5);
}
Main.dust[num10].noGravity = true;
}
}
}
float num11 = (float)(int)color.R * num7;
float num12 = (float)(int)color.G * num7;
float num13 = (float)(int)color.B * num7;
float num14 = (float)(int)color.A * num7;
color = new Color((byte)num11, (byte)num12, (byte)num13, (byte)num14);
spriteBatch.Draw(liquidTexture[num6], vector - screenPosition, value, color, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
}
private static void ErasePlayer(int i)
{
try
{
File.Delete(loadPlayerPath[i]);
File.Delete(loadPlayerPath[i] + ".bak");
LoadPlayers();
}
catch
{
}
}
private static void EraseWorld(int i)
{
try
{
File.Delete(loadWorldPath[i]);
File.Delete(loadWorldPath[i] + ".bak");
LoadWorlds();
}
catch
{
}
}
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static string GetInputText(string oldString)
{
if (!hasFocus)
{
return oldString;
}
inputTextEnter = false;
string text = oldString;
if (text == null)
{
text = "";
}
oldInputText = inputText;
inputText = Keyboard.GetState();
bool flag = ((ushort)GetKeyState(20) & 0xFFFF) != 0;
bool flag2 = false;
if (inputText.IsKeyDown(Keys.LeftShift) || inputText.IsKeyDown(Keys.RightShift))
{
flag2 = true;
}
Keys[] pressedKeys = inputText.GetPressedKeys();
Keys[] pressedKeys2 = oldInputText.GetPressedKeys();
bool flag3 = false;
if (inputText.IsKeyDown(Keys.Back) && oldInputText.IsKeyDown(Keys.Back))
{
if (backSpaceCount == 0)
{
backSpaceCount = 7;
flag3 = true;
}
backSpaceCount--;
}
else
{
backSpaceCount = 15;
}
for (int i = 0; i < pressedKeys.Length; i++)
{
bool flag4 = true;
for (int j = 0; j < pressedKeys2.Length; j++)
{
if (pressedKeys[i] == pressedKeys2[j])
{
flag4 = false;
}
}
string text2 = pressedKeys[i].ToString();
if (text2 == "Back" && (flag4 || flag3))
{
if (text.Length > 0)
{
text = text.Substring(0, text.Length - 1);
}
}
else
{
if (!flag4)
{
continue;
}
if (text2 == "Space")
{
text2 = " ";
}
else if (text2.Length == 1)
{
int num = Convert.ToInt32(Convert.ToChar(text2));
if (num >= 65 && num <= 90 && ((!flag2 && !flag) || (flag2 && flag)))
{
num += 32;
text2 = Convert.ToChar(num).ToString();
}
}
else if (text2.Length == 2 && text2.Substring(0, 1) == "D")
{
text2 = text2.Substring(1, 1);
if (flag2)
{
switch (text2)
{
case "1":
text2 = "!";
break;
case "2":
text2 = "@";
break;
case "3":
text2 = "#";
break;
case "4":
text2 = "$";
break;
case "5":
text2 = "%";
break;
case "6":
text2 = "^";
break;
case "7":
text2 = "&";
break;
case "8":
text2 = "*";
break;
case "9":
text2 = "(";
break;
case "0":
text2 = ")";
break;
}
}
}
else if (text2.Length == 7 && text2.Substring(0, 6) == "NumPad")
{
text2 = text2.Substring(6, 1);
}
else
{
switch (text2)
{
case "Divide":
text2 = "/";
break;
case "Multiply":
text2 = "*";
break;
case "Subtract":
text2 = "-";
break;
case "Add":
text2 = "+";
break;
case "Decimal":
text2 = ".";
break;
case "OemSemicolon":
text2 = ";";
goto default;
case "OemPlus":
text2 = "=";
goto default;
case "OemComma":
text2 = ",";
goto default;
case "OemMinus":
text2 = "-";
goto default;
case "OemPeriod":
text2 = ".";
goto default;
case "OemQuestion":
text2 = "/";
goto default;
case "OemTilde":
text2 = "`";
goto default;
case "OemOpenBrackets":
text2 = "[";
goto default;
case "OemPipe":
text2 = "\\";
goto default;
case "OemCloseBrackets":
text2 = "]";
goto default;
case "OemQuotes":
text2 = "'";
goto default;
case "OemBackslash":
text2 = "\\";
goto default;
default:
if (flag2)
{
switch (text2)
{
case ";":
text2 = ":";
break;
case "=":
text2 = "+";
break;
case ",":
text2 = "<";
break;
case "-":
text2 = "_";
break;
case ".":
text2 = ">";
break;
case "/":
text2 = "?";
break;
case "`":
text2 = "~";
break;
case "[":
text2 = "{";
break;
case "\\":
text2 = "|";
break;
case "]":
text2 = "}";
break;
case "'":
text2 = "\"";
break;
}
}
break;
}
}
if (text2 == "Enter")
{
inputTextEnter = true;
}
if (text2.Length == 1)
{
text += text2;
}
}
}
return text;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern short GetKeyState(int keyCode);
[DllImport("User32")]
private static extern int GetMenuItemCount(IntPtr hWnd);
[DllImport("User32")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
private static void HelpText()
{
bool flag = false;
if (player[myPlayer].statLifeMax > 100)
{
flag = true;
}
bool flag2 = false;
if (player[myPlayer].statManaMax > 0)
{
flag2 = true;
}
bool flag3 = true;
bool flag4 = false;
bool flag5 = false;
bool flag6 = false;
bool flag7 = false;
bool flag8 = false;
bool flag9 = false;
bool flag10 = false;
for (int i = 0; i < 44; i++)
{
if (player[myPlayer].inventory[i].pick > 0 && player[myPlayer].inventory[i].name != "Copper Pickaxe")
{
flag3 = false;
}
if (player[myPlayer].inventory[i].axe > 0 && player[myPlayer].inventory[i].name != "Copper Axe")
{
flag3 = false;
}
if (player[myPlayer].inventory[i].hammer > 0)
{
flag3 = false;
}
if (player[myPlayer].inventory[i].type == 11 || player[myPlayer].inventory[i].type == 12 || player[myPlayer].inventory[i].type == 13 || player[myPlayer].inventory[i].type == 14)
{
flag4 = true;
}
if (player[myPlayer].inventory[i].type == 19 || player[myPlayer].inventory[i].type == 20 || player[myPlayer].inventory[i].type == 21 || player[myPlayer].inventory[i].type == 22)
{
flag5 = true;
}
if (player[myPlayer].inventory[i].type == 75)
{
flag6 = true;
}
if (player[myPlayer].inventory[i].type == 75)
{
flag8 = true;
}
if (player[myPlayer].inventory[i].type == 68 || player[myPlayer].inventory[i].type == 70)
{
flag9 = true;
}
if (player[myPlayer].inventory[i].type == 84)
{
flag10 = true;
}
if (player[myPlayer].inventory[i].type == 117)
{
flag7 = true;
}
}
bool flag11 = false;
bool flag12 = false;
bool flag13 = false;
bool flag14 = false;
for (int j = 0; j < 1000; j++)
{
if (npc[j].active)
{
if (npc[j].type == 17)
{
flag11 = true;
}
if (npc[j].type == 18)
{
flag12 = true;
}
if (npc[j].type == 19)
{
flag14 = true;
}
if (npc[j].type == 20)
{
flag13 = true;
}
}
}
while (true)
{
helpText++;
if (flag3)
{
if (helpText == 1)
{
npcChatText = "You can use your pickaxe to dig through dirt, and your axe to chop down trees. Just place your cursor over the tile and click!";
return;
}
if (helpText == 2)
{
npcChatText = "If you want to survive, you will need to create weapons and shelter. Start by chopping down trees and gathering wood.";
return;
}
if (helpText == 3)
{
npcChatText = "Press ESC to access your crafting menu. When you have enough wood, create a workbench. This will allow you to create more complicated things, as long as you are standing close to it.";
return;
}
if (helpText == 4)
{
npcChatText = "You can build a shelter by placing wood or other blocks in the world. Don't forget to create and place walls.";
return;
}
if (helpText == 5)
{
npcChatText = "Once you have a wooden sword, you might try to gather some gel from the slimes. Combine wood and gel to make a torch!";
return;
}
if (helpText == 6)
{
npcChatText = "To interact with backgrounds and placed objects, use a hammer!";
return;
}
}
if (flag3 && !flag4 && !flag5 && helpText == 11)
{
npcChatText = "You should do some mining to find metal ore. You can craft very useful things with it.";
return;
}
if (flag3 && flag4 && !flag5)
{
if (helpText == 21)
{
npcChatText = "Now that you have some ore, you will need to turn it into a bar in order to make items with it. This requires a furnace!";
return;
}
if (helpText == 22)
{
npcChatText = "You can create a furnace out of torches, wood, and stone. Make sure you are standing near a work bench.";
return;
}
}
if (flag3 && flag5)
{
if (helpText == 31)
{
npcChatText = "You will need an anvil to make most things out of metal bars.";
return;
}
if (helpText == 32)
{
npcChatText = "Anvils can be crafted out of iron, or purchased from a merchant.";
return;
}
}
if (!flag && helpText == 41)
{
npcChatText = "Underground are crystal hearts that can be used to increase your max life. You will need a hammer to obtain them.";
return;
}
if (!flag2 && helpText == 42)
{
npcChatText = "If you gather 10 fallen stars, they can be combined to create an item that will increase your magic capacity.";
return;
}
if (!flag2 && !flag6 && helpText == 43)
{
npcChatText = "Stars fall all over the world at night. They can be used for all sorts of usefull things. If you see one, be sure to grab it because they disappear after sunrise.";
return;
}
if (!flag11 && !flag12)
{
if (helpText == 51)
{
npcChatText = "There are many different ways you can attract people to move in to our town. They will of course need a home to live in.";
return;
}
if (helpText == 52)
{
npcChatText = "In order for a room to be considered a home, it needs to have a door, chair, table, and a light source. Make sure the house has walls as well.";
return;
}
if (helpText == 53)
{
npcChatText = "Two people will not live in the same home. Also, if their home is destroyed, they will look for a new place to live.";
return;
}
}
if (!flag11 && helpText == 61)
{
npcChatText = "If you want a merchant to move in, you will need to gather plenty of money. 50 silver coins should do the trick!";
return;
}
if (!flag12 && helpText == 62)
{
npcChatText = "For a nurse to move in, you might want to increase your maximum life.";
return;
}
if (!flag14 && helpText == 63)
{
npcChatText = "If you had a gun, I bet an arms dealer might show up to sell you some ammo!";
return;
}
if (!flag13 && helpText == 64)
{
npcChatText = "You should prove yourself by defeating a strong monster. That will get the attention of a dryad.";
return;
}
if (flag8 && helpText == 71)
{
npcChatText = "If you combine lenses at a demon altar, you might be able to find a way to summon a powerful monster. You will want to wait until night before using it, though.";
return;
}
if (flag9 && helpText == 72)
{
npcChatText = "You can create worm bait with rotten chunks and vile powder. Make sure you are in a corrupt area before using it.";
return;
}
if ((flag8 || flag9) && helpText == 80)
{
npcChatText = "Demonic altars can usually be found in the corruption. You will need to be near them to craft some items.";
return;
}
if (!flag10 && helpText == 201)
{
npcChatText = "You can make a grappling hook from a hook and 3 chains. Skeletons found deep underground usually carry hooks, and chains can be made from iron bars.";
return;
}
if (flag7 && helpText == 202)
{
npcChatText = "You can craft a space gun using a flintlock pistol, 10 fallen stars, and 30 meteorite bars.";
return;
}
if (helpText == 1000)
{
npcChatText = "If you see a pot, be sure to smash it open. They contain all sorts of useful supplies.";
return;
}
if (helpText == 1001)
{
npcChatText = "There is treasure hidden all over the world. Some amazing things can be found deep underground!";
return;
}
if (helpText == 1002)
{
break;
}
if (helpText > 1100)
{
helpText = 0;
}
}
npcChatText = "Smashing a shadow orb will cause a meteor to fall out of the sky. Shadow orbs can usually be found in the chasms around corrupt areas.";
}
protected override void Initialize()
{
debuff[20] = true;
debuff[21] = true;
debuff[22] = true;
debuff[23] = true;
debuff[24] = true;
debuff[25] = true;
buffName[1] = "Obsidian Skin";
buffTip[1] = "Immune to lava";
buffName[2] = "Regeneration";
buffTip[2] = "Provides life regeneration";
buffName[3] = "Swiftness";
buffTip[3] = "%25 increased movement speed";
buffName[4] = "Gills";
buffTip[4] = "Breathe water instead of air";
buffName[5] = "Ironskin";
buffTip[5] = "Increase defense by 8";
buffName[6] = "Mana Regeneration";
buffTip[6] = "Increased mana regeneration";
buffName[7] = "Magic Power";
buffTip[7] = "20% increased magic damage";
buffName[8] = "Featherfall";
buffTip[8] = "Press UP or DOWN to control speed of descent";
buffName[9] = "Spelunker";
buffTip[9] = "Shows the location of treasure and ore";
buffName[10] = "Invisibility";
buffTip[10] = "Grants invisibility";
buffName[11] = "Shine";
buffTip[11] = "Emitting light";
buffName[12] = "Night Owl";
buffTip[12] = "Increased night vision";
buffName[13] = "Battle";
buffTip[13] = "Increased enemy spawn rate";
buffName[14] = "Thorns";
buffTip[14] = "Attackers also take damage";
buffName[15] = "Water Walking";
buffTip[15] = "Press DOWN to enter water";
buffName[16] = "Archery";
buffTip[16] = "20% increased arrow damage and speed";
buffName[17] = "Hunter";
buffTip[17] = "Shows the location of enemies";
buffName[18] = "Gravitation";
buffTip[18] = "Press UP or DOWN to reverse gravity";
buffName[19] = "Orb of Light";
buffTip[19] = "A magical orb that provides light";
buffName[20] = "Poisoned";
buffTip[20] = "Slowly losing life";
buffName[21] = "Potion Sickness";
buffTip[21] = "Cannot consume anymore healing items";
buffName[22] = "Darkness";
buffTip[22] = "Decreased light vision";
buffName[23] = "Cursed";
buffTip[23] = "Cannot use any items";
buffName[24] = "On Fire!";
buffTip[24] = "Slowly losing life";
buffName[25] = "Tipsy";
buffTip[25] = "Increased melee abilities, lowered defense";
buffName[26] = "Well Fed";
buffTip[26] = "Minor improvements to all stats";
for (int i = 0; i < 10; i++)
{
recentWorld[i] = "";
recentIP[i] = "";
recentPort[i] = 0;
}
if (rand == null)
{
rand = new Random((int)DateTime.Now.Ticks);
}
if (WorldGen.genRand == null)
{
WorldGen.genRand = new Random((int)DateTime.Now.Ticks);
}
switch (rand.Next(15))
{
case 0:
base.Window.Title = "Terraria: Dig Peon, Dig!";
break;
case 1:
base.Window.Title = "Terraria: Epic Dirt";
break;
case 2:
base.Window.Title = "Terraria: Hey Guys!";
break;
case 3:
base.Window.Title = "Terraria: Sand is Overpowered";
break;
case 4:
base.Window.Title = "Terraria Part 3: The Return of the Guide";
break;
case 5:
base.Window.Title = "Terraria: A Bunnies Tale";
break;
case 6:
base.Window.Title = "Terraria: Dr. Bones and The Temple of Blood Moon";
break;
case 7:
base.Window.Title = "Terraria: Slimeassic Park";
break;
case 8:
base.Window.Title = "Terraria: The Grass is Greener on This Side";
break;
case 9:
base.Window.Title = "Terraria: Small Blocks, Not for Children Under the Age of 5";
break;
case 10:
base.Window.Title = "Terraria: Digger T' Blocks";
break;
case 11:
base.Window.Title = "Terraria: There is No Cow Layer";
break;
case 12:
base.Window.Title = "Terraria: Suspicous Looking Eyeballs";
break;
case 13:
base.Window.Title = "Terraria: Purple Grass!";
break;
case 14:
base.Window.Title = "Terraria: Noone Dug Behind!";
break;
default:
base.Window.Title = "Terraria: Shut Up and Dig Gaiden!";
break;
}
tileShine[22] = 1150;
tileShine[6] = 1150;
tileShine[7] = 1100;
tileShine[8] = 1000;
tileShine[9] = 1050;
tileShine[12] = 1000;
tileShine[21] = 1000;
tileShine[63] = 900;
tileShine[64] = 900;
tileShine[65] = 900;
tileShine[66] = 900;
tileShine[67] = 900;
tileShine[68] = 900;
tileShine[45] = 1900;
tileShine[46] = 2000;
tileShine[47] = 2100;
tileMergeDirt[1] = true;
tileMergeDirt[6] = true;
tileMergeDirt[7] = true;
tileMergeDirt[8] = true;
tileMergeDirt[9] = true;
tileMergeDirt[22] = true;
tileMergeDirt[25] = true;
tileMergeDirt[37] = true;
tileMergeDirt[40] = true;
tileMergeDirt[53] = true;
tileMergeDirt[56] = true;
tileMergeDirt[59] = true;
tileCut[3] = true;
tileCut[24] = true;
tileCut[28] = true;
tileCut[32] = true;
tileCut[51] = true;
tileCut[52] = true;
tileCut[61] = true;
tileCut[62] = true;
tileCut[69] = true;
tileCut[71] = true;
tileCut[73] = true;
tileCut[74] = true;
tileCut[82] = true;
tileCut[83] = true;
tileCut[84] = true;
tileAlch[82] = true;
tileAlch[83] = true;
tileAlch[84] = true;
tileFrameImportant[82] = true;
tileFrameImportant[83] = true;
tileFrameImportant[84] = true;
tileFrameImportant[85] = true;
tileFrameImportant[100] = true;
tileFrameImportant[104] = true;
tileFrameImportant[105] = true;
tileLavaDeath[104] = true;
tileLavaDeath[105] = true;
tileSolid[0] = true;
tileBlockLight[0] = true;
tileSolid[1] = true;
tileBlockLight[1] = true;
tileSolid[2] = true;
tileBlockLight[2] = true;
tileSolid[3] = false;
tileNoAttach[3] = true;
tileNoFail[3] = true;
tileSolid[4] = false;
tileNoAttach[4] = true;
tileNoFail[4] = true;
tileNoFail[24] = true;
tileSolid[5] = false;
tileSolid[6] = true;
tileBlockLight[6] = true;
tileSolid[7] = true;
tileBlockLight[7] = true;
tileSolid[8] = true;
tileBlockLight[8] = true;
tileSolid[9] = true;
tileBlockLight[9] = true;
tileBlockLight[10] = true;
tileSolid[10] = true;
tileNoAttach[10] = true;
tileBlockLight[10] = true;
tileSolid[11] = false;
tileSolidTop[19] = true;
tileSolid[19] = true;
tileSolid[22] = true;
tileSolid[23] = true;
tileSolid[25] = true;
tileSolid[30] = true;
tileNoFail[32] = true;
tileBlockLight[32] = true;
tileSolid[37] = true;
tileBlockLight[37] = true;
tileSolid[38] = true;
tileBlockLight[38] = true;
tileSolid[39] = true;
tileBlockLight[39] = true;
tileSolid[40] = true;
tileBlockLight[40] = true;
tileSolid[41] = true;
tileBlockLight[41] = true;
tileSolid[43] = true;
tileBlockLight[43] = true;
tileSolid[44] = true;
tileBlockLight[44] = true;
tileSolid[45] = true;
tileBlockLight[45] = true;
tileSolid[46] = true;
tileBlockLight[46] = true;
tileSolid[47] = true;
tileBlockLight[47] = true;
tileSolid[48] = true;
tileBlockLight[48] = true;
tileSolid[53] = true;
tileBlockLight[53] = true;
tileSolid[54] = true;
tileBlockLight[52] = true;
tileSolid[56] = true;
tileBlockLight[56] = true;
tileSolid[57] = true;
tileBlockLight[57] = true;
tileSolid[58] = true;
tileBlockLight[58] = true;
tileSolid[59] = true;
tileBlockLight[59] = true;
tileSolid[60] = true;
tileBlockLight[60] = true;
tileSolid[63] = true;
tileBlockLight[63] = true;
tileStone[63] = true;
tileSolid[64] = true;
tileBlockLight[64] = true;
tileStone[64] = true;
tileSolid[65] = true;
tileBlockLight[65] = true;
tileStone[65] = true;
tileSolid[66] = true;
tileBlockLight[66] = true;
tileStone[66] = true;
tileSolid[67] = true;
tileBlockLight[67] = true;
tileStone[67] = true;
tileSolid[68] = true;
tileBlockLight[68] = true;
tileStone[68] = true;
tileSolid[75] = true;
tileBlockLight[75] = true;
tileSolid[76] = true;
tileBlockLight[76] = true;
tileSolid[70] = true;
tileBlockLight[70] = true;
tileBlockLight[51] = true;
tileNoFail[50] = true;
tileNoAttach[50] = true;
tileDungeon[41] = true;
tileDungeon[43] = true;
tileDungeon[44] = true;
tileBlockLight[30] = true;
tileBlockLight[25] = true;
tileBlockLight[23] = true;
tileBlockLight[22] = true;
tileBlockLight[62] = true;
tileSolidTop[18] = true;
tileSolidTop[14] = true;
tileSolidTop[16] = true;
tileNoAttach[20] = true;
tileNoAttach[19] = true;
tileNoAttach[13] = true;
tileNoAttach[14] = true;
tileNoAttach[15] = true;
tileNoAttach[16] = true;
tileNoAttach[17] = true;
tileNoAttach[18] = true;
tileNoAttach[19] = true;
tileNoAttach[21] = true;
tileNoAttach[27] = true;
tileFrameImportant[3] = true;
tileFrameImportant[5] = true;
tileFrameImportant[10] = true;
tileFrameImportant[11] = true;
tileFrameImportant[12] = true;
tileFrameImportant[13] = true;
tileFrameImportant[14] = true;
tileFrameImportant[15] = true;
tileFrameImportant[16] = true;
tileFrameImportant[17] = true;
tileFrameImportant[18] = true;
tileFrameImportant[20] = true;
tileFrameImportant[21] = true;
tileFrameImportant[24] = true;
tileFrameImportant[26] = true;
tileFrameImportant[27] = true;
tileFrameImportant[28] = true;
tileFrameImportant[29] = true;
tileFrameImportant[31] = true;
tileFrameImportant[33] = true;
tileFrameImportant[34] = true;
tileFrameImportant[35] = true;
tileFrameImportant[36] = true;
tileFrameImportant[42] = true;
tileFrameImportant[50] = true;
tileFrameImportant[55] = true;
tileFrameImportant[61] = true;
tileFrameImportant[71] = true;
tileFrameImportant[72] = true;
tileFrameImportant[73] = true;
tileFrameImportant[74] = true;
tileFrameImportant[77] = true;
tileFrameImportant[78] = true;
tileFrameImportant[79] = true;
tileFrameImportant[81] = true;
tileFrameImportant[103] = true;
tileTable[14] = true;
tileTable[18] = true;
tileTable[19] = true;
tileNoAttach[86] = true;
tileNoAttach[87] = true;
tileNoAttach[88] = true;
tileNoAttach[89] = true;
tileNoAttach[90] = true;
tileFrameImportant[86] = true;
tileFrameImportant[87] = true;
tileFrameImportant[88] = true;
tileFrameImportant[89] = true;
tileFrameImportant[90] = true;
tileLavaDeath[86] = true;
tileLavaDeath[87] = true;
tileLavaDeath[88] = true;
tileLavaDeath[89] = true;
tileFrameImportant[101] = true;
tileLavaDeath[101] = true;
tileTable[101] = true;
tileNoAttach[101] = true;
tileFrameImportant[102] = true;
tileLavaDeath[102] = true;
tileNoAttach[102] = true;
tileNoAttach[94] = true;
tileNoAttach[95] = true;
tileNoAttach[96] = true;
tileNoAttach[97] = true;
tileNoAttach[98] = true;
tileNoAttach[99] = true;
tileFrameImportant[94] = true;
tileFrameImportant[95] = true;
tileFrameImportant[96] = true;
tileFrameImportant[97] = true;
tileFrameImportant[98] = true;
tileFrameImportant[99] = true;
tileFrameImportant[106] = true;
tileLavaDeath[94] = true;
tileLavaDeath[95] = true;
tileLavaDeath[96] = true;
tileLavaDeath[97] = true;
tileLavaDeath[98] = true;
tileLavaDeath[99] = true;
tileLavaDeath[100] = true;
tileLavaDeath[103] = true;
tileTable[87] = true;
tileTable[88] = true;
tileSolidTop[87] = true;
tileSolidTop[88] = true;
tileSolidTop[101] = true;
tileNoAttach[91] = true;
tileFrameImportant[91] = true;
tileLavaDeath[91] = true;
tileNoAttach[92] = true;
tileFrameImportant[92] = true;
tileLavaDeath[92] = true;
tileNoAttach[93] = true;
tileFrameImportant[93] = true;
tileLavaDeath[93] = true;
tileWaterDeath[4] = true;
tileWaterDeath[51] = true;
tileWaterDeath[93] = true;
tileWaterDeath[98] = true;
tileLavaDeath[3] = true;
tileLavaDeath[5] = true;
tileLavaDeath[10] = true;
tileLavaDeath[11] = true;
tileLavaDeath[12] = true;
tileLavaDeath[13] = true;
tileLavaDeath[14] = true;
tileLavaDeath[15] = true;
tileLavaDeath[16] = true;
tileLavaDeath[17] = true;
tileLavaDeath[18] = true;
tileLavaDeath[19] = true;
tileLavaDeath[20] = true;
tileLavaDeath[27] = true;
tileLavaDeath[28] = true;
tileLavaDeath[29] = true;
tileLavaDeath[32] = true;
tileLavaDeath[33] = true;
tileLavaDeath[34] = true;
tileLavaDeath[35] = true;
tileLavaDeath[36] = true;
tileLavaDeath[42] = true;
tileLavaDeath[49] = true;
tileLavaDeath[50] = true;
tileLavaDeath[52] = true;
tileLavaDeath[55] = true;
tileLavaDeath[61] = true;
tileLavaDeath[62] = true;
tileLavaDeath[69] = true;
tileLavaDeath[71] = true;
tileLavaDeath[72] = true;
tileLavaDeath[73] = true;
tileLavaDeath[74] = true;
tileLavaDeath[79] = true;
tileLavaDeath[80] = true;
tileLavaDeath[81] = true;
tileLavaDeath[106] = true;
wallHouse[1] = true;
wallHouse[4] = true;
wallHouse[5] = true;
wallHouse[6] = true;
wallHouse[10] = true;
wallHouse[11] = true;
wallHouse[12] = true;
wallHouse[16] = true;
wallHouse[17] = true;
wallHouse[18] = true;
wallHouse[19] = true;
wallHouse[20] = true;
tileNoFail[32] = true;
tileNoFail[61] = true;
tileNoFail[69] = true;
tileNoFail[73] = true;
tileNoFail[74] = true;
tileNoFail[82] = true;
tileNoFail[83] = true;
tileNoFail[84] = true;
for (int j = 0; j < 107; j++)
{
tileName[j] = "";
}
tileName[13] = "Bottle";
tileName[14] = "Table";
tileName[15] = "Chair";
tileName[16] = "Anvil";
tileName[17] = "Furnace";
tileName[18] = "Workbench";
tileName[26] = "Demon Altar";
tileName[77] = "Hellforge";
tileName[86] = "Loom";
tileName[94] = "Keg";
tileName[96] = "Cooking Pot";
tileName[106] = "Sawmill";
for (int k = 0; k < maxMenuItems; k++)
{
menuItemScale[k] = 0.8f;
}
for (int l = 0; l < 1001; l++)
{
dust[l] = new Dust();
}
for (int m = 0; m < 201; m++)
{
Main.item[m] = new Item();
}
for (int n = 0; n < 1001; n++)
{
npc[n] = new NPC();
npc[n].whoAmI = n;
}
for (int num = 0; num < 256; num++)
{
player[num] = new Player();
}
for (int num2 = 0; num2 < 1001; num2++)
{
projectile[num2] = new Projectile();
}
for (int num3 = 0; num3 < 201; num3++)
{
gore[num3] = new Gore();
}
for (int num4 = 0; num4 < 100; num4++)
{
cloud[num4] = new Cloud();
}
for (int num5 = 0; num5 < 100; num5++)
{
combatText[num5] = new CombatText();
}
for (int num6 = 0; num6 < 100; num6++)
{
itemText[num6] = new ItemText();
}
for (int num7 = 0; num7 < 364; num7++)
{
Item item = new Item();
item.SetDefaults(num7);
itemName[num7] = item.name;
}
for (int num8 = 0; num8 < Recipe.maxRecipes; num8++)
{
recipe[num8] = new Recipe();
availableRecipeY[num8] = 65 * num8;
}
Recipe.SetupRecipes();
for (int num9 = 0; num9 < numChatLines; num9++)
{
chatLine[num9] = new ChatLine();
}
for (int num10 = 0; num10 < Liquid.resLiquid; num10++)
{
liquid[num10] = new Liquid();
}
for (int num11 = 0; num11 < 10000; num11++)
{
liquidBuffer[num11] = new LiquidBuffer();
}
shop[0] = new Chest();
shop[1] = new Chest();
shop[1].SetupShop(1);
shop[2] = new Chest();
shop[2].SetupShop(2);
shop[3] = new Chest();
shop[3].SetupShop(3);
shop[4] = new Chest();
shop[4].SetupShop(4);
shop[5] = new Chest();
shop[5].SetupShop(5);
ref Color reference = ref teamColor[0];
reference = Color.White;
ref Color reference2 = ref teamColor[1];
reference2 = new Color(230, 40, 20);
ref Color reference3 = ref teamColor[2];
reference3 = new Color(20, 200, 30);
ref Color reference4 = ref teamColor[3];
reference4 = new Color(75, 90, 255);
ref Color reference5 = ref teamColor[4];
reference5 = new Color(200, 180, 0);
if (menuMode == 1)
{
LoadPlayers();
}
Netplay.Init();
if (skipMenu)
{
WorldGen.clearWorld();
gameMenu = false;
LoadPlayers();
player[myPlayer] = (Player)loadPlayer[0].Clone();
PlayerPath = loadPlayerPath[0];
LoadWorlds();
WorldGen.generateWorld();
WorldGen.EveryTileFrame();
player[myPlayer].Spawn();
}
else
{
IntPtr systemMenu = GetSystemMenu(base.Window.Handle, bRevert: false);
int menuItemCount = GetMenuItemCount(systemMenu);
RemoveMenu(systemMenu, menuItemCount - 1, 1024);
}
if (!dedServ)
{
graphics.PreferredBackBufferWidth = screenWidth;
graphics.PreferredBackBufferHeight = screenHeight;
graphics.ApplyChanges();
base.Initialize();
base.Window.AllowUserResizing = true;
OpenSettings();
OpenRecent();
Star.SpawnStars();
foreach (DisplayMode supportedDisplayMode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
{
if (supportedDisplayMode.Width < minScreenW || supportedDisplayMode.Height < minScreenH || supportedDisplayMode.Width > maxScreenW || supportedDisplayMode.Height > maxScreenH)
{
continue;
}
bool flag = true;
for (int num12 = 0; num12 < numDisplayModes; num12++)
{
if (supportedDisplayMode.Width == displayWidth[num12] && supportedDisplayMode.Height == displayHeight[num12])
{
flag = false;
break;
}
}
if (flag)
{
displayHeight[numDisplayModes] = supportedDisplayMode.Height;
displayWidth[numDisplayModes] = supportedDisplayMode.Width;
numDisplayModes++;
}
}
if (autoJoin)
{
LoadPlayers();
menuMode = 1;
menuMultiplayer = true;
}
}
ThreadPool.QueueUserWorkItem(ModClass.startNonDedInputCallBack, 1);
try
{
StreamReader streamReader = File.OpenText("default.txt");
string text = null;
while ((text = streamReader.ReadLine()) != null)
{
ModClass.onChat(text, fromConsole: true);
NewText(text, 175, 75);
}
streamReader.Close();
Console.Clear();
}
catch (Exception ex)
{
//Console.WriteLine("failed to load default.txt please check if the file exist and is not in use by another process", ex.ToString());
}
}
private static void InvasionWarning()
{
if (invasionType != 0)
{
string text = "";
text = ((invasionSize <= 0) ? "The goblin army has been defeated!" : ((invasionX < (double)spawnTileX) ? "A goblin army is approaching from the west!" : ((!(invasionX > (double)spawnTileX)) ? "The goblin army has arrived!" : "A goblin army is approaching from the east!")));
if (netMode == 0)
{
NewText(text, 175, 75);
}
else if (netMode == 2)
{
NetMessage.SendData(25, -1, -1, text, 255, 175f, 75f, 255f);
}
}
}
protected override void LoadContent()
{
try
{
engine = new AudioEngine("Content\\TerrariaMusic.xgs");
soundBank = new SoundBank(engine, "Content\\Sound Bank.xsb");
waveBank = new WaveBank(engine, "Content\\Wave Bank.xwb");
for (int i = 1; i < 9; i++)
{
music[i] = soundBank.GetCue("Music_" + i);
}
soundGrab = base.Content.Load<SoundEffect>("Sounds\\Grab");
soundInstanceGrab = soundGrab.CreateInstance();
soundDig[0] = base.Content.Load<SoundEffect>("Sounds\\Dig_0");
soundInstanceDig[0] = soundDig[0].CreateInstance();
soundDig[1] = base.Content.Load<SoundEffect>("Sounds\\Dig_1");
soundInstanceDig[1] = soundDig[1].CreateInstance();
soundDig[2] = base.Content.Load<SoundEffect>("Sounds\\Dig_2");
soundInstanceDig[2] = soundDig[2].CreateInstance();
soundTink[0] = base.Content.Load<SoundEffect>("Sounds\\Tink_0");
soundInstanceTink[0] = soundTink[0].CreateInstance();
soundTink[1] = base.Content.Load<SoundEffect>("Sounds\\Tink_1");
soundInstanceTink[1] = soundTink[1].CreateInstance();
soundTink[2] = base.Content.Load<SoundEffect>("Sounds\\Tink_2");
soundInstanceTink[2] = soundTink[2].CreateInstance();
soundPlayerHit[0] = base.Content.Load<SoundEffect>("Sounds\\Player_Hit_0");
soundInstancePlayerHit[0] = soundPlayerHit[0].CreateInstance();
soundPlayerHit[1] = base.Content.Load<SoundEffect>("Sounds\\Player_Hit_1");
soundInstancePlayerHit[1] = soundPlayerHit[1].CreateInstance();
soundPlayerHit[2] = base.Content.Load<SoundEffect>("Sounds\\Player_Hit_2");
soundInstancePlayerHit[2] = soundPlayerHit[2].CreateInstance();
soundFemaleHit[0] = base.Content.Load<SoundEffect>("Sounds\\Female_Hit_0");
soundInstanceFemaleHit[0] = soundFemaleHit[0].CreateInstance();
soundFemaleHit[1] = base.Content.Load<SoundEffect>("Sounds\\Female_Hit_1");
soundInstanceFemaleHit[1] = soundFemaleHit[1].CreateInstance();
soundFemaleHit[2] = base.Content.Load<SoundEffect>("Sounds\\Female_Hit_2");
soundInstanceFemaleHit[2] = soundFemaleHit[2].CreateInstance();
soundPlayerKilled = base.Content.Load<SoundEffect>("Sounds\\Player_Killed");
soundInstancePlayerKilled = soundPlayerKilled.CreateInstance();
soundChat = base.Content.Load<SoundEffect>("Sounds\\Chat");
soundInstanceChat = soundChat.CreateInstance();
soundGrass = base.Content.Load<SoundEffect>("Sounds\\Grass");
soundInstanceGrass = soundGrass.CreateInstance();
soundDoorOpen = base.Content.Load<SoundEffect>("Sounds\\Door_Opened");
soundInstanceDoorOpen = soundDoorOpen.CreateInstance();
soundDoorClosed = base.Content.Load<SoundEffect>("Sounds\\Door_Closed");
soundInstanceDoorClosed = soundDoorClosed.CreateInstance();
soundMenuTick = base.Content.Load<SoundEffect>("Sounds\\Menu_Tick");
soundInstanceMenuTick = soundMenuTick.CreateInstance();
soundMenuOpen = base.Content.Load<SoundEffect>("Sounds\\Menu_Open");
soundInstanceMenuOpen = soundMenuOpen.CreateInstance();
soundMenuClose = base.Content.Load<SoundEffect>("Sounds\\Menu_Close");
soundInstanceMenuClose = soundMenuClose.CreateInstance();
soundShatter = base.Content.Load<SoundEffect>("Sounds\\Shatter");
soundInstanceShatter = soundShatter.CreateInstance();
soundZombie[0] = base.Content.Load<SoundEffect>("Sounds\\Zombie_0");
soundInstanceZombie[0] = soundZombie[0].CreateInstance();
soundZombie[1] = base.Content.Load<SoundEffect>("Sounds\\Zombie_1");
soundInstanceZombie[1] = soundZombie[1].CreateInstance();
soundZombie[2] = base.Content.Load<SoundEffect>("Sounds\\Zombie_2");
soundInstanceZombie[2] = soundZombie[2].CreateInstance();
soundRoar[0] = base.Content.Load<SoundEffect>("Sounds\\Roar_0");
soundInstanceRoar[0] = soundRoar[0].CreateInstance();
soundRoar[1] = base.Content.Load<SoundEffect>("Sounds\\Roar_1");
soundInstanceRoar[1] = soundRoar[1].CreateInstance();
soundSplash[0] = base.Content.Load<SoundEffect>("Sounds\\Splash_0");
soundInstanceSplash[0] = soundRoar[0].CreateInstance();
soundSplash[1] = base.Content.Load<SoundEffect>("Sounds\\Splash_1");
soundInstanceSplash[1] = soundSplash[1].CreateInstance();
soundDoubleJump = base.Content.Load<SoundEffect>("Sounds\\Double_Jump");
soundInstanceDoubleJump = soundRoar[0].CreateInstance();
soundRun = base.Content.Load<SoundEffect>("Sounds\\Run");
soundInstanceRun = soundRun.CreateInstance();
soundCoins = base.Content.Load<SoundEffect>("Sounds\\Coins");
soundInstanceCoins = soundCoins.CreateInstance();
soundUnlock = base.Content.Load<SoundEffect>("Sounds\\Unlock");
soundInstanceUnlock = soundUnlock.CreateInstance();
soundMaxMana = base.Content.Load<SoundEffect>("Sounds\\MaxMana");
soundInstanceMaxMana = soundMaxMana.CreateInstance();
soundDrown = base.Content.Load<SoundEffect>("Sounds\\Drown");
soundInstanceDrown = soundDrown.CreateInstance();
for (int j = 1; j < 22; j++)
{
soundItem[j] = base.Content.Load<SoundEffect>("Sounds\\Item_" + j);
soundInstanceItem[j] = soundItem[j].CreateInstance();
}
for (int k = 1; k < 4; k++)
{
soundNPCHit[k] = base.Content.Load<SoundEffect>("Sounds\\NPC_Hit_" + k);
soundInstanceNPCHit[k] = soundNPCHit[k].CreateInstance();
}
for (int l = 1; l < 6; l++)
{
soundNPCKilled[l] = base.Content.Load<SoundEffect>("Sounds\\NPC_Killed_" + l);
soundInstanceNPCKilled[l] = soundNPCKilled[l].CreateInstance();
}
}
catch
{
musicVolume = 0f;
soundVolume = 0f;
}
raTexture = base.Content.Load<Texture2D>("Images\\ra-logo");
reTexture = base.Content.Load<Texture2D>("Images\\re-logo");
splashTexture = base.Content.Load<Texture2D>("Images\\splash");
fadeTexture = base.Content.Load<Texture2D>("Images\\fade-out");
ghostTexture = base.Content.Load<Texture2D>("Images\\Ghost");
spriteBatch = new SpriteBatch(base.GraphicsDevice);
for (int m = 0; m < 107; m++)
{
tileTexture[m] = base.Content.Load<Texture2D>("Images\\Tiles_" + m);
}
for (int n = 1; n < 21; n++)
{
wallTexture[n] = base.Content.Load<Texture2D>("Images\\Wall_" + n);
}
for (int num = 1; num < 27; num++)
{
buffTexture[num] = base.Content.Load<Texture2D>("Images\\Buff_" + num);
}
for (int num2 = 0; num2 < 7; num2++)
{
backgroundTexture[num2] = base.Content.Load<Texture2D>("Images\\Background_" + num2);
backgroundWidth[num2] = backgroundTexture[num2].Width;
backgroundHeight[num2] = backgroundTexture[num2].Height;
}
for (int num3 = 0; num3 < 364; num3++)
{
itemTexture[num3] = base.Content.Load<Texture2D>("Images\\Item_" + num3);
}
for (int num4 = 0; num4 < 74; num4++)
{
npcTexture[num4] = base.Content.Load<Texture2D>("Images\\NPC_" + num4);
}
for (int num5 = 0; num5 < 56; num5++)
{
projectileTexture[num5] = base.Content.Load<Texture2D>("Images\\Projectile_" + num5);
}
for (int num6 = 1; num6 < 99; num6++)
{
goreTexture[num6] = base.Content.Load<Texture2D>("Images\\Gore_" + num6);
}
for (int num7 = 0; num7 < 4; num7++)
{
cloudTexture[num7] = base.Content.Load<Texture2D>("Images\\Cloud_" + num7);
}
for (int num8 = 0; num8 < 5; num8++)
{
starTexture[num8] = base.Content.Load<Texture2D>("Images\\Star_" + num8);
}
for (int num9 = 0; num9 < 2; num9++)
{
liquidTexture[num9] = base.Content.Load<Texture2D>("Images\\Liquid_" + num9);
}
HBLockTexture[0] = base.Content.Load<Texture2D>("Images\\Lock_0");
HBLockTexture[1] = base.Content.Load<Texture2D>("Images\\Lock_1");
trashTexture = base.Content.Load<Texture2D>("Images\\Trash");
cdTexture = base.Content.Load<Texture2D>("Images\\CoolDown");
logoTexture = base.Content.Load<Texture2D>("Images\\Logo");
dustTexture = base.Content.Load<Texture2D>("Images\\Dust");
sunTexture = base.Content.Load<Texture2D>("Images\\Sun");
sun2Texture = base.Content.Load<Texture2D>("Images\\Sun2");
moonTexture = base.Content.Load<Texture2D>("Images\\Moon");
blackTileTexture = base.Content.Load<Texture2D>("Images\\Black_Tile");
heartTexture = base.Content.Load<Texture2D>("Images\\Heart");
bubbleTexture = base.Content.Load<Texture2D>("Images\\Bubble");
manaTexture = base.Content.Load<Texture2D>("Images\\Mana");
cursorTexture = base.Content.Load<Texture2D>("Images\\Cursor");
ninjaTexture = base.Content.Load<Texture2D>("Images\\Ninja");
antLionTexture = base.Content.Load<Texture2D>("Images\\AntlionBody");
spikeBaseTexture = base.Content.Load<Texture2D>("Images\\Spike_Base");
treeTopTexture[0] = base.Content.Load<Texture2D>("Images\\Tree_Tops_0");
treeBranchTexture[0] = base.Content.Load<Texture2D>("Images\\Tree_Branches_0");
treeTopTexture[1] = base.Content.Load<Texture2D>("Images\\Tree_Tops_1");
treeBranchTexture[1] = base.Content.Load<Texture2D>("Images\\Tree_Branches_1");
treeTopTexture[2] = base.Content.Load<Texture2D>("Images\\Tree_Tops_2");
treeBranchTexture[2] = base.Content.Load<Texture2D>("Images\\Tree_Branches_2");
shroomCapTexture = base.Content.Load<Texture2D>("Images\\Shroom_Tops");
inventoryBackTexture = base.Content.Load<Texture2D>("Images\\Inventory_Back");
inventoryBack2Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back2");
inventoryBack3Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back3");
inventoryBack4Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back4");
inventoryBack5Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back5");
inventoryBack6Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back6");
inventoryBack7Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back7");
inventoryBack8Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back8");
inventoryBack9Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back9");
inventoryBack10Texture = base.Content.Load<Texture2D>("Images\\Inventory_Back10");
textBackTexture = base.Content.Load<Texture2D>("Images\\Text_Back");
chatTexture = base.Content.Load<Texture2D>("Images\\Chat");
chat2Texture = base.Content.Load<Texture2D>("Images\\Chat2");
chatBackTexture = base.Content.Load<Texture2D>("Images\\Chat_Back");
teamTexture = base.Content.Load<Texture2D>("Images\\Team");
for (int num10 = 1; num10 < 17; num10++)
{
armorBodyTexture[num10] = base.Content.Load<Texture2D>("Images\\Armor_Body_" + num10);
armorArmTexture[num10] = base.Content.Load<Texture2D>("Images\\Armor_Arm_" + num10);
}
for (int num11 = 1; num11 < 29; num11++)
{
armorHeadTexture[num11] = base.Content.Load<Texture2D>("Images\\Armor_Head_" + num11);
}
for (int num12 = 1; num12 < 16; num12++)
{
armorLegTexture[num12] = base.Content.Load<Texture2D>("Images\\Armor_Legs_" + num12);
}
for (int num13 = 0; num13 < 36; num13++)
{
playerHairTexture[num13] = base.Content.Load<Texture2D>("Images\\Player_Hair_" + (num13 + 1));
}
playerEyeWhitesTexture = base.Content.Load<Texture2D>("Images\\Player_Eye_Whites");
playerEyesTexture = base.Content.Load<Texture2D>("Images\\Player_Eyes");
playerHandsTexture = base.Content.Load<Texture2D>("Images\\Player_Hands");
playerHands2Texture = base.Content.Load<Texture2D>("Images\\Player_Hands2");
playerHeadTexture = base.Content.Load<Texture2D>("Images\\Player_Head");
playerPantsTexture = base.Content.Load<Texture2D>("Images\\Player_Pants");
playerShirtTexture = base.Content.Load<Texture2D>("Images\\Player_Shirt");
playerShoesTexture = base.Content.Load<Texture2D>("Images\\Player_Shoes");
playerUnderShirtTexture = base.Content.Load<Texture2D>("Images\\Player_Undershirt");
playerUnderShirt2Texture = base.Content.Load<Texture2D>("Images\\Player_Undershirt2");
chainTexture = base.Content.Load<Texture2D>("Images\\Chain");
chain2Texture = base.Content.Load<Texture2D>("Images\\Chain2");
chain3Texture = base.Content.Load<Texture2D>("Images\\Chain3");
chain4Texture = base.Content.Load<Texture2D>("Images\\Chain4");
chain5Texture = base.Content.Load<Texture2D>("Images\\Chain5");
chain6Texture = base.Content.Load<Texture2D>("Images\\Chain6");
boneArmTexture = base.Content.Load<Texture2D>("Images\\Arm_Bone");
fontItemStack = base.Content.Load<SpriteFont>("Fonts\\Item_Stack");
fontMouseText = base.Content.Load<SpriteFont>("Fonts\\Mouse_Text");
fontDeathText = base.Content.Load<SpriteFont>("Fonts\\Death_Text");
fontCombatText[0] = base.Content.Load<SpriteFont>("Fonts\\Combat_Text");
fontCombatText[1] = base.Content.Load<SpriteFont>("Fonts\\Combat_Crit");
}
public void LoadDedConfig(string configPath)
{
if (!File.Exists(configPath))
{
return;
}
using StreamReader streamReader = new StreamReader(configPath);
string text;
while ((text = streamReader.ReadLine()) != null)
{
try
{
if (text.Length > 6 && text.Substring(0, 6).ToLower() == "world=")
{
worldPathName = text.Substring(6);
}
if (text.Length > 5 && text.Substring(0, 5).ToLower() == "port=")
{
string value = text.Substring(5);
try
{
Netplay.serverPort = Convert.ToInt32(value);
}
catch
{
}
}
if (text.Length > 11 && text.Substring(0, 11).ToLower() == "maxplayers=")
{
string value2 = text.Substring(11);
try
{
maxNetPlayers = Convert.ToInt32(value2);
}
catch
{
}
}
if (text.Length > 9 && text.Substring(0, 9).ToLower() == "password=")
{
Netplay.password = text.Substring(9);
}
if (text.Length > 5 && text.Substring(0, 5).ToLower() == "motd=")
{
motd = text.Substring(5);
}
if (text.Length >= 10 && text.Substring(0, 10).ToLower() == "worldpath=")
{
WorldPath = text.Substring(10);
}
if (text.Length >= 10 && text.Substring(0, 10).ToLower() == "worldname=")
{
worldName = text.Substring(10);
}
if (text.Length > 8 && text.Substring(0, 8).ToLower() == "banlist=")
{
Netplay.banFile = text.Substring(8);
}
if (text.Length > 11 && text.Substring(0, 11).ToLower() == "autocreate=")
{
switch (text.Substring(11))
{
case "0":
autoGen = false;
break;
case "1":
maxTilesX = 4200;
maxTilesY = 1200;
autoGen = true;
break;
case "2":
maxTilesX = 6300;
maxTilesY = 1800;
autoGen = true;
break;
case "3":
maxTilesX = 8400;
maxTilesY = 2400;
autoGen = true;
break;
}
}
if (text.Length > 7 && text.Substring(0, 7).ToLower() == "secure=" && text.Substring(7) == "1")
{
Netplay.spamCheck = true;
}
}
catch
{
}
}
}
public void loadLib(string path)
{
libPath = path;
LoadLibrary(libPath);
}
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
private static void LoadPlayers()
{
Directory.CreateDirectory(PlayerPath);
string[] files = Directory.GetFiles(PlayerPath, "*.plr");
int num = files.Length;
if (num > 5)
{
num = 5;
}
for (int i = 0; i < 5; i++)
{
loadPlayer[i] = new Player();
if (i < num)
{
loadPlayerPath[i] = files[i];
loadPlayer[i] = Player.LoadPlayer(loadPlayerPath[i]);
}
}
numLoadPlayers = num;
}
public static void LoadWorlds()
{
Directory.CreateDirectory(WorldPath);
string[] files = Directory.GetFiles(WorldPath, "*.wld");
int num = files.Length;
if (!dedServ && num > 5)
{
num = 5;
}
for (int i = 0; i < num; i++)
{
loadWorldPath[i] = files[i];
try
{
using FileStream input = new FileStream(loadWorldPath[i], FileMode.Open);
using BinaryReader binaryReader = new BinaryReader(input);
binaryReader.ReadInt32();
loadWorld[i] = binaryReader.ReadString();
binaryReader.Close();
}
catch
{
loadWorld[i] = loadWorldPath[i];
}
}
numLoadWorlds = num;
}
protected void MouseText(string cursorText, int rare = 0, byte diff = 0)
{
if (cursorText == null)
{
return;
}
int num = mouseState.X + 10;
int num2 = mouseState.Y + 10;
Color color = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
float num10;
if (toolTip.type > 0)
{
rare = toolTip.rare;
int num3 = 20;
int num4 = 1;
string[] array = new string[num3];
array[0] = toolTip.name;
if (toolTip.stack > 1)
{
string[] array2 = new string[1];
object obj = array2[0];
array[0] = array[0] + " (" + toolTip.stack + ")";
}
if (toolTip.social)
{
array[num4] = "Equipped in social slot";
num4++;
array[num4] = "No stats will be gained";
num4++;
}
else
{
if (toolTip.damage > 0)
{
int damage = toolTip.damage;
if (toolTip.melee)
{
array[num4] = (player[myPlayer].meleeDamage * (float)damage).ToString();
string[] array3;
IntPtr intPtr;
(array3 = array)[(int)(intPtr = (IntPtr)num4)] = array3[(int)intPtr] + " melee";
}
else if (toolTip.ranged)
{
array[num4] = (player[myPlayer].rangedDamage * (float)damage).ToString();
string[] array4;
IntPtr intPtr2;
(array4 = array)[(int)(intPtr2 = (IntPtr)num4)] = array4[(int)intPtr2] + " ranged";
}
else if (toolTip.magic)
{
array[num4] = (player[myPlayer].magicDamage * (float)damage).ToString();
string[] array5;
IntPtr intPtr3;
(array5 = array)[(int)(intPtr3 = (IntPtr)num4)] = array5[(int)intPtr3] + " magic";
}
else
{
array[num4] = damage.ToString();
}
string[] array6;
IntPtr intPtr4;
(array6 = array)[(int)(intPtr4 = (IntPtr)num4)] = array6[(int)intPtr4] + " damage";
num4++;
if (toolTip.useStyle > 0)
{
if (toolTip.useAnimation <= 8)
{
array[num4] = "Insanely fast";
}
else if (toolTip.useAnimation <= 20)
{
array[num4] = "Very fast";
}
else if (toolTip.useAnimation <= 25)
{
array[num4] = "Fast";
}
else if (toolTip.useAnimation <= 30)
{
array[num4] = "Average";
}
else if (toolTip.useAnimation <= 35)
{
array[num4] = "Slow";
}
else if (toolTip.useAnimation <= 45)
{
array[num4] = "Very slow";
}
else if (toolTip.useAnimation <= 55)
{
array[num4] = "Extremely slow";
}
else
{
array[num4] = "Snail";
}
string[] array7;
IntPtr intPtr5;
(array7 = array)[(int)(intPtr5 = (IntPtr)num4)] = array7[(int)intPtr5] + " speed";
num4++;
}
}
if (toolTip.headSlot > 0 || toolTip.bodySlot > 0 || toolTip.legSlot > 0 || toolTip.accessory)
{
array[num4] = "Equipable";
num4++;
}
if (toolTip.vanity)
{
array[num4] = "Vanity Item";
num4++;
}
if (toolTip.defense > 0)
{
array[num4] = toolTip.defense + " defense";
num4++;
}
if (toolTip.pick > 0)
{
array[num4] = toolTip.pick + "% pickaxe power";
num4++;
}
if (toolTip.axe > 0)
{
array[num4] = toolTip.axe * 5 + "% axe power";
num4++;
}
if (toolTip.hammer > 0)
{
array[num4] = toolTip.hammer + "% hammer power";
num4++;
}
if (toolTip.healLife > 0)
{
array[num4] = "Restores " + toolTip.healLife + " life";
num4++;
}
if (toolTip.healMana > 0)
{
array[num4] = "Restores " + toolTip.healMana + " mana";
num4++;
}
if (toolTip.mana > 0 && (toolTip.type != 127 || !player[myPlayer].spaceGun))
{
array[num4] = "Uses " + (int)((float)toolTip.mana * player[myPlayer].manaCost) + " mana";
num4++;
}
if (toolTip.createWall > 0 || toolTip.createTile > -1)
{
if (toolTip.type != 213)
{
array[num4] = "Can be placed";
num4++;
}
}
else if (toolTip.ammo > 0)
{
array[num4] = "Ammo";
num4++;
}
else if (toolTip.consumable)
{
array[num4] = "Consumable";
num4++;
}
if (toolTip.material)
{
array[num4] = "Material";
num4++;
}
if (toolTip.toolTip != null)
{
array[num4] = toolTip.toolTip;
num4++;
}
if (toolTip.toolTip2 != null)
{
array[num4] = toolTip.toolTip2;
num4++;
}
if (toolTip.buffTime > 0)
{
string text = "0 s";
text = ((toolTip.buffTime / 60 < 60) ? (Math.Round((double)toolTip.buffTime / 60.0) + " second duration") : (Math.Round((double)(toolTip.buffTime / 60) / 60.0) + " minute duration"));
array[num4] = text;
num4++;
}
if (toolTip.wornArmor && player[myPlayer].setBonus != "")
{
array[num4] = "Set bonus: " + player[myPlayer].setBonus;
num4++;
}
}
if (npcShop > 0)
{
if (toolTip.value > 0)
{
string text2 = "";
int num5 = 0;
int num6 = 0;
int num7 = 0;
int num8 = 0;
int num9 = toolTip.value * toolTip.stack;
if (!toolTip.buy)
{
num9 = toolTip.value / 5 * toolTip.stack;
}
if (num9 < 1)
{
num9 = 1;
}
if (num9 >= 1000000)
{
num5 = num9 / 1000000;
num9 -= num5 * 1000000;
}
if (num9 >= 10000)
{
num6 = num9 / 10000;
num9 -= num6 * 10000;
}
if (num9 >= 100)
{
num7 = num9 / 100;
num9 -= num7 * 100;
}
if (num9 >= 1)
{
num8 = num9;
}
if (num5 > 0)
{
text2 = text2 + num5 + " platinum ";
}
if (num6 > 0)
{
text2 = text2 + num6 + " gold ";
}
if (num7 > 0)
{
text2 = text2 + num7 + " silver ";
}
if (num8 > 0)
{
text2 = text2 + num8 + " copper ";
}
if (!toolTip.buy)
{
array[num4] = "Sell price: " + text2;
}
else
{
array[num4] = "Buy price: " + text2;
}
num4++;
num10 = (float)(int)mouseTextColor / 255f;
if (num5 > 0)
{
color = new Color((byte)(220f * num10), (byte)(220f * num10), (byte)(198f * num10), mouseTextColor);
}
else if (num6 > 0)
{
color = new Color((byte)(224f * num10), (byte)(201f * num10), (byte)(92f * num10), mouseTextColor);
}
else if (num7 > 0)
{
color = new Color((byte)(181f * num10), (byte)(192f * num10), (byte)(193f * num10), mouseTextColor);
}
else if (num8 > 0)
{
color = new Color((byte)(246f * num10), (byte)(138f * num10), (byte)(96f * num10), mouseTextColor);
}
}
else
{
num10 = (float)(int)mouseTextColor / 255f;
array[num4] = "No value";
num4++;
color = new Color((byte)(120f * num10), (byte)(120f * num10), (byte)(120f * num10), mouseTextColor);
}
}
Vector2 vector = default(Vector2);
int num11 = 0;
for (int i = 0; i < num4; i++)
{
Vector2 vector2 = fontMouseText.MeasureString(array[i]);
if (vector2.X > vector.X)
{
vector.X = vector2.X;
}
vector.Y += vector2.Y + (float)num11;
}
if ((float)num + vector.X + 4f > (float)screenWidth)
{
num = (int)((float)screenWidth - vector.X - 4f);
}
if ((float)num2 + vector.Y + 4f > (float)screenHeight)
{
num2 = (int)((float)screenHeight - vector.Y - 4f);
}
int num12 = 0;
num10 = (float)(int)mouseTextColor / 255f;
for (int j = 0; j < num4; j++)
{
for (int k = 0; k < 5; k++)
{
int num13 = num;
int num14 = num2 + num12;
Color color2 = Color.Black;
switch (k)
{
case 0:
num13 -= 2;
break;
case 1:
num13 += 2;
break;
case 2:
num14 -= 2;
break;
case 3:
num14 += 2;
break;
default:
color2 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
if (j == 0)
{
if (rare == 1)
{
color2 = new Color((byte)(150f * num10), (byte)(150f * num10), (byte)(255f * num10), mouseTextColor);
}
if (rare == 2)
{
color2 = new Color((byte)(150f * num10), (byte)(255f * num10), (byte)(150f * num10), mouseTextColor);
}
if (rare == 3)
{
color2 = new Color((byte)(255f * num10), (byte)(200f * num10), (byte)(150f * num10), mouseTextColor);
}
if (rare == 4)
{
color2 = new Color((byte)(255f * num10), (byte)(150f * num10), (byte)(150f * num10), mouseTextColor);
}
if (diff == 1)
{
color2 = new Color((byte)((float)(int)mcColor.R * num10), (byte)((float)(int)mcColor.G * num10), (byte)((float)(int)mcColor.B * num10), mouseTextColor);
}
if (diff == 2)
{
color2 = new Color((byte)((float)(int)hcColor.R * num10), (byte)((float)(int)hcColor.G * num10), (byte)((float)(int)hcColor.B * num10), mouseTextColor);
}
}
else if (j == num4 - 1)
{
color2 = color;
}
break;
}
spriteBatch.DrawString(fontMouseText, array[j], new Vector2(num13, num14), color2, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
num12 += (int)fontMouseText.MeasureString(array[j]).Y + num11;
}
return;
}
if (buffString != "" && buffString != null)
{
for (int l = 0; l < 5; l++)
{
int num15 = num;
int num16 = num2 + (int)fontMouseText.MeasureString(buffString).Y;
Color color3 = Color.Black;
switch (l)
{
case 0:
num15 -= 2;
break;
case 1:
num15 += 2;
break;
case 2:
num16 -= 2;
break;
case 3:
num16 += 2;
break;
default:
color3 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
break;
}
spriteBatch.DrawString(fontMouseText, buffString, new Vector2(num15, num16), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
}
Vector2 vector3 = fontMouseText.MeasureString(cursorText);
if ((float)num + vector3.X + 4f > (float)screenWidth)
{
num = (int)((float)screenWidth - vector3.X - 4f);
}
if ((float)num2 + vector3.Y + 4f > (float)screenHeight)
{
num2 = (int)((float)screenHeight - vector3.Y - 4f);
}
spriteBatch.DrawString(fontMouseText, cursorText, new Vector2(num, num2 - 2), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, cursorText, new Vector2(num, num2 + 2), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, cursorText, new Vector2(num - 2, num2), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
spriteBatch.DrawString(fontMouseText, cursorText, new Vector2(num + 2, num2), Color.Black, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
num10 = (float)(int)mouseTextColor / 255f;
Color color4 = new Color(mouseTextColor, mouseTextColor, mouseTextColor, mouseTextColor);
if (rare == 1)
{
color4 = new Color((byte)(150f * num10), (byte)(150f * num10), (byte)(255f * num10), mouseTextColor);
}
if (rare == 2)
{
color4 = new Color((byte)(150f * num10), (byte)(255f * num10), (byte)(150f * num10), mouseTextColor);
}
if (rare == 3)
{
color4 = new Color((byte)(255f * num10), (byte)(200f * num10), (byte)(150f * num10), mouseTextColor);
}
if (rare == 4)
{
color4 = new Color((byte)(255f * num10), (byte)(150f * num10), (byte)(150f * num10), mouseTextColor);
}
if (diff == 1)
{
color4 = new Color((byte)((float)(int)mcColor.R * num10), (byte)((float)(int)mcColor.G * num10), (byte)((float)(int)mcColor.B * num10), mouseTextColor);
}
if (diff == 2)
{
color4 = new Color((byte)((float)(int)hcColor.R * num10), (byte)((float)(int)hcColor.G * num10), (byte)((float)(int)hcColor.B * num10), mouseTextColor);
}
spriteBatch.DrawString(fontMouseText, cursorText, new Vector2(num, num2), color4, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
}
public void NewMOTD(string newMOTD)
{
motd = newMOTD;
}
public static void NewText(string newText, byte R = byte.MaxValue, byte G = byte.MaxValue, byte B = byte.MaxValue)
{
for (int num = numChatLines - 1; num > 0; num--)
{
chatLine[num].text = chatLine[num - 1].text;
chatLine[num].showTime = chatLine[num - 1].showTime;
chatLine[num].color = chatLine[num - 1].color;
}
if (R == 0 && G == 0 && B == 0)
{
chatLine[0].color = Color.White;
}
else
{
chatLine[0].color = new Color(R, G, B);
}
chatLine[0].text = newText;
chatLine[0].showTime = chatLength;
PlaySound(12);
}
private static string nextLoadPlayer()
{
int num = 1;
while (File.Exists(PlayerPath + "\\player" + num + ".plr"))
{
num++;
}
return PlayerPath + "\\player" + num + ".plr";
}
private static string nextLoadWorld()
{
int num = 1;
while (File.Exists(WorldPath + "\\world" + num + ".wld"))
{
num++;
}
return WorldPath + "\\world" + num + ".wld";
}
protected void OpenRecent()
{
try
{
if (!File.Exists(SavePath + "\\servers.dat"))
{
return;
}
using FileStream input = new FileStream(SavePath + "\\servers.dat", FileMode.Open);
using BinaryReader binaryReader = new BinaryReader(input);
binaryReader.ReadInt32();
for (int i = 0; i < 10; i++)
{
recentWorld[i] = binaryReader.ReadString();
recentIP[i] = binaryReader.ReadString();
recentPort[i] = binaryReader.ReadInt32();
}
}
catch
{
}
}
protected void OpenSettings()
{
try
{
if (!File.Exists(SavePath + "\\config.dat"))
{
return;
}
using FileStream input = new FileStream(SavePath + "\\config.dat", FileMode.Open);
using BinaryReader binaryReader = new BinaryReader(input);
int num = binaryReader.ReadInt32();
bool flag = binaryReader.ReadBoolean();
mouseColor.R = binaryReader.ReadByte();
mouseColor.G = binaryReader.ReadByte();
mouseColor.B = binaryReader.ReadByte();
soundVolume = binaryReader.ReadSingle();
musicVolume = binaryReader.ReadSingle();
cUp = binaryReader.ReadString();
cDown = binaryReader.ReadString();
cLeft = binaryReader.ReadString();
cRight = binaryReader.ReadString();
cJump = binaryReader.ReadString();
cThrowItem = binaryReader.ReadString();
if (num >= 1)
{
cInv = binaryReader.ReadString();
}
if (num >= 12)
{
cHeal = binaryReader.ReadString();
cMana = binaryReader.ReadString();
cBuff = binaryReader.ReadString();
}
if (num >= 13)
{
cHook = binaryReader.ReadString();
}
caveParrallax = binaryReader.ReadSingle();
if (num >= 2)
{
fixedTiming = binaryReader.ReadBoolean();
}
if (num >= 4)
{
graphics.PreferredBackBufferWidth = binaryReader.ReadInt32();
graphics.PreferredBackBufferHeight = binaryReader.ReadInt32();
}
if (num >= 8)
{
autoSave = binaryReader.ReadBoolean();
}
if (num >= 9)
{
autoPause = binaryReader.ReadBoolean();
}
if (num >= 19)
{
showItemText = binaryReader.ReadBoolean();
}
binaryReader.Close();
if (flag && !graphics.IsFullScreen)
{
graphics.ToggleFullScreen();
}
}
catch
{
}
}
public static void PlaySound(int type, int x = -1, int y = -1, int Style = 1)
{
int num = Style;
try
{
if (dedServ || soundVolume == 0f)
{
return;
}
bool flag = false;
float num2 = 1f;
float num3 = 0f;
if (x == -1 || y == -1)
{
flag = true;
}
else
{
if (WorldGen.gen || netMode == 2)
{
return;
}
Rectangle value = new Rectangle((int)screenPosition.X - screenWidth * 2, (int)screenPosition.Y - screenHeight * 2, screenWidth * 5, screenHeight * 5);
Rectangle rectangle = new Rectangle(x, y, 1, 1);
Vector2 vector = new Vector2(screenPosition.X + (float)screenWidth * 0.5f, screenPosition.Y + (float)screenHeight * 0.5f);
if (rectangle.Intersects(value))
{
flag = true;
}
if (flag)
{
num3 = ((float)x - vector.X) / ((float)screenWidth * 0.5f);
float num4 = Math.Abs((float)x - vector.X);
float num5 = Math.Abs((float)y - vector.Y);
float num6 = (float)Math.Sqrt(num4 * num4 + num5 * num5);
num2 = 1f - num6 / ((float)screenWidth * 1.5f);
}
}
if (num3 < -1f)
{
num3 = -1f;
}
if (num3 > 1f)
{
num3 = 1f;
}
if (num2 > 1f)
{
num2 = 1f;
}
if (num2 <= 0f || !flag)
{
return;
}
num2 *= soundVolume;
switch (type)
{
case 0:
{
int num9 = rand.Next(3);
soundInstanceDig[num9].Stop();
soundInstanceDig[num9] = soundDig[num9].CreateInstance();
soundInstanceDig[num9].Volume = num2;
soundInstanceDig[num9].Pan = num3;
soundInstanceDig[num9].Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceDig[num9].Play();
break;
}
case 1:
{
int num10 = rand.Next(3);
soundInstancePlayerHit[num10].Stop();
soundInstancePlayerHit[num10] = soundPlayerHit[num10].CreateInstance();
soundInstancePlayerHit[num10].Volume = num2;
soundInstancePlayerHit[num10].Pan = num3;
soundInstancePlayerHit[num10].Play();
break;
}
case 2:
if (num == 1)
{
switch (rand.Next(3))
{
case 1:
num = 18;
break;
case 2:
num = 19;
break;
}
}
if (num != 9 && num != 10)
{
soundInstanceItem[num].Stop();
}
soundInstanceItem[num] = soundItem[num].CreateInstance();
soundInstanceItem[num].Volume = num2;
soundInstanceItem[num].Pan = num3;
soundInstanceItem[num].Pitch = (float)rand.Next(-6, 7) * 0.01f;
soundInstanceItem[num].Play();
break;
case 3:
soundInstanceNPCHit[num].Stop();
soundInstanceNPCHit[num] = soundNPCHit[num].CreateInstance();
soundInstanceNPCHit[num].Volume = num2;
soundInstanceNPCHit[num].Pan = num3;
soundInstanceNPCHit[num].Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceNPCHit[num].Play();
break;
case 4:
soundInstanceNPCKilled[num] = soundNPCKilled[num].CreateInstance();
soundInstanceNPCKilled[num].Volume = num2;
soundInstanceNPCKilled[num].Pan = num3;
soundInstanceNPCKilled[num].Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceNPCKilled[num].Play();
break;
case 5:
soundInstancePlayerKilled.Stop();
soundInstancePlayerKilled = soundPlayerKilled.CreateInstance();
soundInstancePlayerKilled.Volume = num2;
soundInstancePlayerKilled.Pan = num3;
soundInstancePlayerKilled.Play();
break;
case 6:
soundInstanceGrass.Stop();
soundInstanceGrass = soundGrass.CreateInstance();
soundInstanceGrass.Volume = num2;
soundInstanceGrass.Pan = num3;
soundInstanceGrass.Pitch = (float)rand.Next(-30, 31) * 0.01f;
soundInstanceGrass.Play();
break;
case 7:
soundInstanceGrab.Stop();
soundInstanceGrab = soundGrab.CreateInstance();
soundInstanceGrab.Volume = num2;
soundInstanceGrab.Pan = num3;
soundInstanceGrab.Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceGrab.Play();
break;
case 8:
soundInstanceDoorOpen.Stop();
soundInstanceDoorOpen = soundDoorOpen.CreateInstance();
soundInstanceDoorOpen.Volume = num2;
soundInstanceDoorOpen.Pan = num3;
soundInstanceDoorOpen.Pitch = (float)rand.Next(-20, 21) * 0.01f;
soundInstanceDoorOpen.Play();
break;
case 9:
soundInstanceDoorClosed.Stop();
soundInstanceDoorClosed = soundDoorClosed.CreateInstance();
soundInstanceDoorClosed.Volume = num2;
soundInstanceDoorClosed.Pan = num3;
soundInstanceDoorOpen.Pitch = (float)rand.Next(-20, 21) * 0.01f;
soundInstanceDoorClosed.Play();
break;
case 10:
soundInstanceMenuOpen.Stop();
soundInstanceMenuOpen = soundMenuOpen.CreateInstance();
soundInstanceMenuOpen.Volume = num2;
soundInstanceMenuOpen.Pan = num3;
soundInstanceMenuOpen.Play();
break;
case 11:
soundInstanceMenuClose.Stop();
soundInstanceMenuClose = soundMenuClose.CreateInstance();
soundInstanceMenuClose.Volume = num2;
soundInstanceMenuClose.Pan = num3;
soundInstanceMenuClose.Play();
break;
case 12:
soundInstanceMenuTick.Stop();
soundInstanceMenuTick = soundMenuTick.CreateInstance();
soundInstanceMenuTick.Volume = num2;
soundInstanceMenuTick.Pan = num3;
soundInstanceMenuTick.Play();
break;
case 13:
soundInstanceShatter.Stop();
soundInstanceShatter = soundShatter.CreateInstance();
soundInstanceShatter.Volume = num2;
soundInstanceShatter.Pan = num3;
soundInstanceShatter.Play();
break;
case 14:
{
int num11 = rand.Next(3);
soundInstanceZombie[num11] = soundZombie[num11].CreateInstance();
soundInstanceZombie[num11].Volume = num2 * 0.4f;
soundInstanceZombie[num11].Pan = num3;
soundInstanceZombie[num11].Play();
break;
}
case 15:
if (soundInstanceRoar[num].State == SoundState.Stopped)
{
soundInstanceRoar[num] = soundRoar[num].CreateInstance();
soundInstanceRoar[num].Volume = num2;
soundInstanceRoar[num].Pan = num3;
soundInstanceRoar[num].Play();
}
break;
case 16:
soundInstanceDoubleJump.Stop();
soundInstanceDoubleJump = soundDoubleJump.CreateInstance();
soundInstanceDoubleJump.Volume = num2;
soundInstanceDoubleJump.Pan = num3;
soundInstanceDoubleJump.Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceDoubleJump.Play();
break;
case 17:
soundInstanceRun.Stop();
soundInstanceRun = soundRun.CreateInstance();
soundInstanceRun.Volume = num2;
soundInstanceRun.Pan = num3;
soundInstanceRun.Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceRun.Play();
break;
case 18:
soundInstanceCoins = soundCoins.CreateInstance();
soundInstanceCoins.Volume = num2;
soundInstanceCoins.Pan = num3;
soundInstanceCoins.Play();
break;
case 19:
if (soundInstanceSplash[num].State == SoundState.Stopped)
{
soundInstanceSplash[num] = soundSplash[num].CreateInstance();
soundInstanceSplash[num].Volume = num2;
soundInstanceSplash[num].Pan = num3;
soundInstanceSplash[num].Pitch = (float)rand.Next(-10, 11) * 0.01f;
soundInstanceSplash[num].Play();
}
break;
case 20:
{
int num8 = rand.Next(3);
soundInstanceFemaleHit[num8].Stop();
soundInstanceFemaleHit[num8] = soundFemaleHit[num8].CreateInstance();
soundInstanceFemaleHit[num8].Volume = num2;
soundInstanceFemaleHit[num8].Pan = num3;
soundInstanceFemaleHit[num8].Play();
break;
}
case 21:
{
int num7 = rand.Next(3);
soundInstanceTink[num7].Stop();
soundInstanceTink[num7] = soundTink[num7].CreateInstance();
soundInstanceTink[num7].Volume = num2;
soundInstanceTink[num7].Pan = num3;
soundInstanceTink[num7].Play();
break;
}
case 22:
soundInstanceUnlock.Stop();
soundInstanceUnlock = soundUnlock.CreateInstance();
soundInstanceUnlock.Volume = num2;
soundInstanceUnlock.Pan = num3;
soundInstanceUnlock.Play();
break;
case 23:
soundInstanceDrown.Stop();
soundInstanceDrown = soundDrown.CreateInstance();
soundInstanceDrown.Volume = num2;
soundInstanceDrown.Pan = num3;
soundInstanceDrown.Play();
break;
case 24:
soundInstanceChat = soundChat.CreateInstance();
soundInstanceChat.Volume = num2;
soundInstanceChat.Pan = num3;
soundInstanceChat.Play();
break;
case 25:
soundInstanceMaxMana = soundMaxMana.CreateInstance();
soundInstanceMaxMana.Volume = num2;
soundInstanceMaxMana.Pan = num3;
soundInstanceMaxMana.Play();
break;
}
}
catch
{
}
}
protected void QuitGame()
{
Exit();
}
[DllImport("User32")]
private static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlags);
public static void SaveRecent()
{
Directory.CreateDirectory(SavePath);
try
{
File.SetAttributes(SavePath + "\\servers.dat", FileAttributes.Normal);
}
catch
{
}
try
{
using FileStream output = new FileStream(SavePath + "\\servers.dat", FileMode.Create);
using BinaryWriter binaryWriter = new BinaryWriter(output);
binaryWriter.Write(curRelease);
for (int i = 0; i < 10; i++)
{
binaryWriter.Write(recentWorld[i]);
binaryWriter.Write(recentIP[i]);
binaryWriter.Write(recentPort[i]);
}
}
catch
{
}
}
protected void SaveSettings()
{
Directory.CreateDirectory(SavePath);
try
{
File.SetAttributes(SavePath + "\\config.dat", FileAttributes.Normal);
}
catch
{
}
try
{
using FileStream output = new FileStream(SavePath + "\\config.dat", FileMode.Create);
using BinaryWriter binaryWriter = new BinaryWriter(output);
binaryWriter.Write(curRelease);
binaryWriter.Write(graphics.IsFullScreen);
binaryWriter.Write(mouseColor.R);
binaryWriter.Write(mouseColor.G);
binaryWriter.Write(mouseColor.B);
binaryWriter.Write(soundVolume);
binaryWriter.Write(musicVolume);
binaryWriter.Write(cUp);
binaryWriter.Write(cDown);
binaryWriter.Write(cLeft);
binaryWriter.Write(cRight);
binaryWriter.Write(cJump);
binaryWriter.Write(cThrowItem);
binaryWriter.Write(cInv);
binaryWriter.Write(cHeal);
binaryWriter.Write(cMana);
binaryWriter.Write(cBuff);
binaryWriter.Write(cHook);
binaryWriter.Write(caveParrallax);
binaryWriter.Write(fixedTiming);
binaryWriter.Write(graphics.PreferredBackBufferWidth);
binaryWriter.Write(graphics.PreferredBackBufferHeight);
binaryWriter.Write(autoSave);
binaryWriter.Write(autoPause);
binaryWriter.Write(showItemText);
binaryWriter.Close();
}
catch
{
}
}
public void SetNetPlayers(int mPlayers)
{
maxNetPlayers = mPlayers;
}
public void SetWorld(string wrold)
{
worldPathName = wrold;
}
public void SetWorldName(string wrold)
{
worldName = wrold;
}
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public static void startDedInput()
{
ThreadPool.QueueUserWorkItem(startDedInputCallBack, 1);
}
public static void startDedInputCallBack(object threadContext)
{
while (!Netplay.disconnect)
{
Console.Write(": ");
string text = Console.ReadLine();
string text2 = text;
text = text.ToLower();
try
{
switch (text)
{
case "help":
Console.WriteLine("Available commands:");
Console.WriteLine("");
Console.WriteLine("help " + '\t' + '\t' + " Displays a list of commands.");
Console.WriteLine("playing " + '\t' + " Shows the list of players");
Console.WriteLine("clear " + '\t' + '\t' + " Clear the console window.");
Console.WriteLine("exit " + '\t' + '\t' + " Shutdown the server and save.");
Console.WriteLine("exit-nosave " + '\t' + " Shutdown the server without saving.");
Console.WriteLine("save " + '\t' + '\t' + " Save the game world.");
Console.WriteLine("kick <player> " + '\t' + " Kicks a player from the server.");
Console.WriteLine("ban <player> " + '\t' + " Bans a player from the server.");
Console.WriteLine("password" + '\t' + " Show password.");
Console.WriteLine("password <pass>" + '\t' + " Change password.");
Console.WriteLine("version" + '\t' + '\t' + " Print version number.");
Console.WriteLine("time" + '\t' + '\t' + " Display game time.");
Console.WriteLine("port" + '\t' + '\t' + " Print the listening port.");
Console.WriteLine("maxplayers" + '\t' + " Print the max number of players.");
Console.WriteLine("say <words>" + '\t' + " Send a message.");
Console.WriteLine("motd" + '\t' + '\t' + " Print MOTD.");
Console.WriteLine("motd <words>" + '\t' + " Change MOTD.");
Console.WriteLine("dawn" + '\t' + '\t' + " Change time to dawn.");
Console.WriteLine("noon" + '\t' + '\t' + " Change time to noon.");
Console.WriteLine("dusk" + '\t' + '\t' + " Change time to dusk.");
Console.WriteLine("midnight" + '\t' + " Change time to midnight.");
Console.WriteLine("settle" + '\t' + '\t' + " Settle all water.");
continue;
case "settle":
if (!Liquid.panicMode)
{
Liquid.StartPanic();
}
else
{
Console.WriteLine("Water is already settling");
}
continue;
case "dawn":
dayTime = true;
time = 0.0;
NetMessage.SendData(7);
continue;
case "dusk":
dayTime = false;
time = 0.0;
NetMessage.SendData(7);
continue;
case "noon":
dayTime = true;
time = 27000.0;
NetMessage.SendData(7);
continue;
case "midnight":
dayTime = false;
time = 16200.0;
NetMessage.SendData(7);
continue;
case "exit-nosave":
Netplay.disconnect = true;
continue;
case "exit":
WorldGen.saveWorld();
Netplay.disconnect = true;
continue;
case "save":
WorldGen.saveWorld();
continue;
case "time":
{
string text3 = "AM";
double num = time;
if (!dayTime)
{
num += 54000.0;
}
num = num / 86400.0 * 24.0;
double num2 = 7.5;
num = num - num2 - 12.0;
if (num < 0.0)
{
num += 24.0;
}
if (num >= 12.0)
{
text3 = "PM";
}
int num3 = (int)num;
double num4 = num - (double)num3;
num4 = (int)(num4 * 60.0);
string text4 = num4.ToString();
if (num4 < 10.0)
{
text4 = "0" + text4;
}
if (num3 > 12)
{
num3 -= 12;
}
if (num3 == 0)
{
num3 = 12;
}
Console.WriteLine("Time: " + num3 + ":" + text4 + " " + text3);
continue;
}
case "maxplayers":
Console.WriteLine("Player limit: " + maxNetPlayers);
continue;
case "port":
Console.WriteLine("Port: " + Netplay.serverPort);
continue;
case "version":
Console.WriteLine("Terraria Server " + versionNumber);
continue;
case "clear":
try
{
Console.Clear();
}
catch
{
}
continue;
case "playing":
{
int num5 = 0;
for (int i = 0; i < 255; i++)
{
if (player[i].active)
{
num5++;
Console.WriteLine(string.Concat(player[i].name, " (", Netplay.serverSock[i].tcpClient.Client.RemoteEndPoint, ")"));
}
}
switch (num5)
{
case 0:
Console.WriteLine("No players connected.");
break;
case 1:
Console.WriteLine("1 player connected.");
break;
default:
Console.WriteLine(num5 + " players connected.");
break;
}
continue;
}
case "":
continue;
case "motd":
if (motd == "")
{
Console.WriteLine("Welcome to " + worldName + "!");
}
else
{
Console.WriteLine("MOTD: " + motd);
}
continue;
}
if (text.Length >= 5 && text.Substring(0, 5) == "motd ")
{
motd = text2.Substring(5);
}
else if (text.Length == 8 && text.Substring(0, 8) == "password")
{
if (Netplay.password == "")
{
Console.WriteLine("No password set.");
}
else
{
Console.WriteLine("Password: " + Netplay.password);
}
}
else if (text.Length >= 9 && text.Substring(0, 9) == "password ")
{
string text5 = text2.Substring(9);
if (text5 == "")
{
Netplay.password = "";
Console.WriteLine("Password disabled.");
}
else
{
Netplay.password = text5;
Console.WriteLine("Password: " + Netplay.password);
}
}
else if (text == "say")
{
Console.WriteLine("Usage: say <words>");
}
else if (text.Length >= 4 && text.Substring(0, 4) == "say ")
{
string text6 = text2.Substring(4);
if (text6 == "")
{
Console.WriteLine("Usage: say <words>");
continue;
}
Console.WriteLine("<Server> " + text6);
NetMessage.SendData(25, -1, -1, "<Server> " + text6, 255, 255f, 240f, 20f);
}
else if (text.Length == 4 && text.Substring(0, 4) == "kick")
{
Console.WriteLine("Usage: kick <player>");
}
else if (text.Length >= 5 && text.Substring(0, 5) == "kick ")
{
string text7 = text.Substring(5).ToLower();
if (text7 == "")
{
Console.WriteLine("Usage: kick <player>");
continue;
}
for (int j = 0; j < 255; j++)
{
if (player[j].active && player[j].name.ToLower() == text7)
{
NetMessage.SendData(2, j, -1, "Kicked from server.");
}
}
}
else if (text.Length == 3 && text.Substring(0, 3) == "ban")
{
Console.WriteLine("Usage: ban <player>");
}
else if (text.Length >= 4 && text.Substring(0, 4) == "ban ")
{
string text8 = text.Substring(4).ToLower();
if (text8 == "")
{
Console.WriteLine("Usage: ban <player>");
continue;
}
for (int k = 0; k < 255; k++)
{
if (player[k].active && player[k].name.ToLower() == text8)
{
Netplay.AddBan(k);
NetMessage.SendData(2, k, -1, "Banned from server.");
}
}
}
else
{
Console.WriteLine("Invalid command.");
}
}
catch
{
Console.WriteLine("Invalid command.");
}
}
}
public static void StartInvasion()
{
if (invasionType != 0 || invasionDelay != 0)
{
return;
}
int num = 0;
for (int i = 0; i < 255; i++)
{
if (player[i].active && player[i].statLifeMax >= 200)
{
num++;
}
}
if (num > 0)
{
invasionType = 1;
invasionSize = 100 + 50 * num;
invasionWarn = 0;
if (rand.Next(2) == 0)
{
invasionX = 0.0;
}
else
{
invasionX = maxTilesX;
}
}
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (!dedServ)
{
if (fixedTiming)
{
if (base.IsActive)
{
base.IsFixedTimeStep = false;
graphics.SynchronizeWithVerticalRetrace = true;
}
else
{
base.IsFixedTimeStep = true;
}
}
else
{
base.IsFixedTimeStep = true;
}
UpdateMusic();
if (showSplash)
{
return;
}
if (!gameMenu && netMode == 1)
{
if (!saveTime.IsRunning)
{
saveTime.Start();
}
if (saveTime.ElapsedMilliseconds > 300000)
{
saveTime.Reset();
WorldGen.saveToonWhilePlaying();
}
}
else if (!gameMenu && autoSave)
{
if (!saveTime.IsRunning)
{
saveTime.Start();
}
if (saveTime.ElapsedMilliseconds > 600000)
{
saveTime.Reset();
WorldGen.saveToonWhilePlaying();
WorldGen.saveAndPlay();
}
}
else if (saveTime.IsRunning)
{
saveTime.Stop();
}
if (teamCooldown > 0)
{
teamCooldown--;
}
updateTime++;
if (updateTime >= 60)
{
frameRate = drawTime;
updateTime = 0;
drawTime = 0;
if (frameRate == 60)
{
Lighting.lightPasses = 2;
Lighting.lightSkip = 2;
cloudLimit = 100;
Gore.goreTime = 1200;
numDust = 1000;
}
else if (frameRate >= 58)
{
Lighting.lightPasses = 2;
Lighting.lightSkip = 2;
cloudLimit = 100;
Gore.goreTime = 600;
numDust = 1000;
}
else if (frameRate >= 43)
{
Lighting.lightPasses = 2;
Lighting.lightSkip = 3;
cloudLimit = 75;
Gore.goreTime = 300;
numDust = 700;
}
else if (frameRate >= 28)
{
if (!gameMenu)
{
Liquid.maxLiquid = 3000;
Liquid.cycles = 6;
}
Lighting.lightPasses = 2;
Lighting.lightSkip = 4;
cloudLimit = 50;
Gore.goreTime = 180;
numDust = 500;
}
else
{
Lighting.lightPasses = 2;
Lighting.lightSkip = 5;
cloudLimit = 0;
Gore.goreTime = 0;
numDust = 200;
}
if (Liquid.quickSettle)
{
Liquid.maxLiquid = Liquid.resLiquid;
Liquid.cycles = 1;
}
else if (frameRate == 60)
{
Liquid.maxLiquid = 5000;
Liquid.cycles = 7;
}
else if (frameRate >= 58)
{
Liquid.maxLiquid = 5000;
Liquid.cycles = 12;
}
else if (frameRate >= 43)
{
Liquid.maxLiquid = 4000;
Liquid.cycles = 13;
}
else if (frameRate >= 28)
{
Liquid.maxLiquid = 3500;
Liquid.cycles = 15;
}
else
{
Liquid.maxLiquid = 3000;
Liquid.cycles = 17;
}
if (netMode == 2)
{
cloudLimit = 0;
}
}
if (!base.IsActive)
{
hasFocus = false;
}
else
{
hasFocus = true;
}
if (!base.IsActive && netMode == 0)
{
base.IsMouseVisible = true;
if (netMode != 2 && myPlayer >= 0)
{
player[myPlayer].delayUseItem = true;
}
mouseLeftRelease = false;
mouseRightRelease = false;
if (gameMenu)
{
UpdateMenu();
}
gamePaused = true;
return;
}
base.IsMouseVisible = false;
if (keyState.IsKeyDown(Keys.F10) && !chatMode && !editSign)
{
if (frameRelease)
{
PlaySound(12);
if (showFrameRate)
{
showFrameRate = false;
}
else
{
showFrameRate = true;
}
}
frameRelease = false;
}
else
{
frameRelease = true;
}
if (keyState.IsKeyDown(Keys.F11))
{
if (releaseUI)
{
if (hideUI)
{
hideUI = false;
}
else
{
hideUI = true;
}
}
releaseUI = false;
}
else
{
releaseUI = true;
}
if ((keyState.IsKeyDown(Keys.LeftAlt) || keyState.IsKeyDown(Keys.RightAlt)) && keyState.IsKeyDown(Keys.Enter))
{
if (toggleFullscreen)
{
graphics.ToggleFullScreen();
chatRelease = false;
}
toggleFullscreen = false;
}
else
{
toggleFullscreen = true;
}
oldMouseState = mouseState;
mouseState = Mouse.GetState();
keyState = Keyboard.GetState();
if (editSign)
{
chatMode = false;
}
if (chatMode)
{
if (keyState.IsKeyDown(Keys.Escape))
{
chatMode = false;
}
string text = chatText;
chatText = GetInputText(chatText);
while (fontMouseText.MeasureString(chatText).X > 470f)
{
chatText = chatText.Substring(0, chatText.Length - 1);
}
if (text != chatText)
{
PlaySound(12);
}
if (inputTextEnter && chatRelease)
{
if (chatText != "" && ModClass.onChat(chatText, fromConsole: false))
{
NetMessage.SendData(25, -1, -1, chatText, myPlayer);
}
chatText = "";
chatMode = false;
chatRelease = false;
player[myPlayer].releaseHook = false;
player[myPlayer].releaseThrow = false;
PlaySound(11);
}
}
if (keyState.IsKeyDown(Keys.Enter) && !keyState.IsKeyDown(Keys.LeftAlt) && !keyState.IsKeyDown(Keys.RightAlt))
{
if (chatRelease && !chatMode && !editSign && !keyState.IsKeyDown(Keys.Escape))
{
PlaySound(10);
chatMode = true;
chatText = "";
}
chatRelease = false;
}
else
{
chatRelease = true;
}
if (gameMenu)
{
UpdateMenu();
if (netMode != 2)
{
return;
}
gamePaused = false;
}
}
if (netMode == 1)
{
for (int i = 0; i < 44; i++)
{
if (player[myPlayer].inventory[i].IsNotTheSameAs(clientPlayer.inventory[i]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].inventory[i].name, myPlayer, i);
}
}
if (player[myPlayer].armor[0].IsNotTheSameAs(clientPlayer.armor[0]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[0].name, myPlayer, 44f);
}
if (player[myPlayer].armor[1].IsNotTheSameAs(clientPlayer.armor[1]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[1].name, myPlayer, 45f);
}
if (player[myPlayer].armor[2].IsNotTheSameAs(clientPlayer.armor[2]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[2].name, myPlayer, 46f);
}
if (player[myPlayer].armor[3].IsNotTheSameAs(clientPlayer.armor[3]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[3].name, myPlayer, 47f);
}
if (player[myPlayer].armor[4].IsNotTheSameAs(clientPlayer.armor[4]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[4].name, myPlayer, 48f);
}
if (player[myPlayer].armor[5].IsNotTheSameAs(clientPlayer.armor[5]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[5].name, myPlayer, 49f);
}
if (player[myPlayer].armor[6].IsNotTheSameAs(clientPlayer.armor[6]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[6].name, myPlayer, 50f);
}
if (player[myPlayer].armor[7].IsNotTheSameAs(clientPlayer.armor[7]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[7].name, myPlayer, 51f);
}
if (player[myPlayer].armor[8].IsNotTheSameAs(clientPlayer.armor[8]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[8].name, myPlayer, 52f);
}
if (player[myPlayer].armor[9].IsNotTheSameAs(clientPlayer.armor[9]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[9].name, myPlayer, 53f);
}
if (player[myPlayer].armor[10].IsNotTheSameAs(clientPlayer.armor[10]))
{
NetMessage.SendData(5, -1, -1, player[myPlayer].armor[10].name, myPlayer, 54f);
}
if (player[myPlayer].chest != clientPlayer.chest)
{
NetMessage.SendData(33, -1, -1, "", player[myPlayer].chest);
}
if (player[myPlayer].talkNPC != clientPlayer.talkNPC)
{
NetMessage.SendData(40, -1, -1, "", myPlayer);
}
if (player[myPlayer].zoneEvil != clientPlayer.zoneEvil)
{
NetMessage.SendData(36, -1, -1, "", myPlayer);
}
if (player[myPlayer].zoneMeteor != clientPlayer.zoneMeteor)
{
NetMessage.SendData(36, -1, -1, "", myPlayer);
}
if (player[myPlayer].zoneDungeon != clientPlayer.zoneDungeon)
{
NetMessage.SendData(36, -1, -1, "", myPlayer);
}
if (player[myPlayer].zoneJungle != clientPlayer.zoneJungle)
{
NetMessage.SendData(36, -1, -1, "", myPlayer);
}
bool flag = false;
for (int j = 0; j < 10; j++)
{
if (player[myPlayer].buffType[j] != clientPlayer.buffType[j])
{
flag = true;
}
}
if (flag)
{
NetMessage.SendData(50, -1, -1, "", myPlayer);
NetMessage.SendData(13, -1, -1, "", myPlayer);
}
}
if (netMode == 1)
{
clientPlayer = (Player)player[myPlayer].clientClone();
}
if (netMode == 0 && (playerInventory || npcChatText != "" || player[myPlayer].sign >= 0) && autoPause)
{
Keys[] pressedKeys = keyState.GetPressedKeys();
player[myPlayer].controlInv = false;
for (int k = 0; k < pressedKeys.Length; k++)
{
if (pressedKeys[k].ToString() == cInv)
{
player[myPlayer].controlInv = true;
}
}
if (player[myPlayer].controlInv)
{
if (player[myPlayer].releaseInventory)
{
player[myPlayer].toggleInv();
}
player[myPlayer].releaseInventory = false;
}
else
{
player[myPlayer].releaseInventory = true;
}
if (playerInventory)
{
int num = (mouseState.ScrollWheelValue - oldMouseState.ScrollWheelValue) / 120;
focusRecipe += num;
if (focusRecipe > numAvailableRecipes - 1)
{
focusRecipe = numAvailableRecipes - 1;
}
if (focusRecipe < 0)
{
focusRecipe = 0;
}
player[myPlayer].dropItemCheck();
}
player[myPlayer].head = player[myPlayer].armor[0].headSlot;
player[myPlayer].body = player[myPlayer].armor[1].bodySlot;
player[myPlayer].legs = player[myPlayer].armor[2].legSlot;
if (!player[myPlayer].hostile)
{
if (player[myPlayer].armor[8].headSlot >= 0)
{
player[myPlayer].head = player[myPlayer].armor[8].headSlot;
}
if (player[myPlayer].armor[9].bodySlot >= 0)
{
player[myPlayer].body = player[myPlayer].armor[9].bodySlot;
}
if (player[myPlayer].armor[10].legSlot >= 0)
{
player[myPlayer].legs = player[myPlayer].armor[10].legSlot;
}
}
if (editSign)
{
if (player[myPlayer].sign == -1)
{
editSign = false;
}
else
{
npcChatText = GetInputText(npcChatText);
if (inputTextEnter)
{
byte[] bytes = new byte[1] { 10 };
npcChatText += Encoding.ASCII.GetString(bytes);
}
}
}
gamePaused = true;
return;
}
gamePaused = false;
if (!dedServ && (double)screenPosition.Y < worldSurface * 16.0 + 16.0 && 255 - tileColor.R - 100 > 0 && netMode != 2)
{
Star.UpdateStars();
Cloud.UpdateClouds();
}
for (int l = 0; l < 255; l++)
{
if (ignoreErrors)
{
try
{
player[l].UpdatePlayer(l);
}
catch
{
}
}
else
{
player[l].UpdatePlayer(l);
}
}
if (netMode != 1)
{
NPC.SpawnNPC();
}
for (int m = 0; m < 255; m++)
{
player[m].activeNPCs = 0f;
player[m].townNPCs = 0f;
}
for (int n = 0; n < 1000; n++)
{
if (ignoreErrors)
{
try
{
npc[n].UpdateNPC(n);
}
catch (Exception)
{
npc[n] = new NPC();
}
}
else
{
npc[n].UpdateNPC(n);
}
}
for (int num2 = 0; num2 < 200; num2++)
{
if (ignoreErrors)
{
try
{
gore[num2].Update();
}
catch
{
gore[num2] = new Gore();
}
}
else
{
gore[num2].Update();
}
}
for (int num3 = 0; num3 < 1000; num3++)
{
if (ignoreErrors)
{
try
{
projectile[num3].Update(num3);
}
catch
{
projectile[num3] = new Projectile();
}
}
else
{
projectile[num3].Update(num3);
}
}
for (int num4 = 0; num4 < 200; num4++)
{
if (ignoreErrors)
{
try
{
item[num4].UpdateItem(num4);
}
catch
{
item[num4] = new Item();
}
}
else
{
item[num4].UpdateItem(num4);
}
}
if (ignoreErrors)
{
try
{
Dust.UpdateDust();
}
catch
{
for (int num5 = 0; num5 < 1000; num5++)
{
dust[num5] = new Dust();
}
}
}
else
{
Dust.UpdateDust();
}
if (netMode != 2)
{
CombatText.UpdateCombatText();
ItemText.UpdateItemText();
}
if (ignoreErrors)
{
try
{
UpdateTime();
}
catch
{
checkForSpawns = 0;
}
}
else
{
UpdateTime();
}
if (netMode != 1)
{
if (ignoreErrors)
{
try
{
WorldGen.UpdateWorld();
UpdateInvasion();
}
catch
{
}
}
else
{
WorldGen.UpdateWorld();
UpdateInvasion();
}
}
if (ignoreErrors)
{
try
{
if (netMode == 2)
{
UpdateServer();
}
if (netMode == 1)
{
UpdateClient();
}
}
catch
{
int num6 = netMode;
}
}
else
{
if (netMode == 2)
{
UpdateServer();
}
if (netMode == 1)
{
UpdateClient();
}
}
if (ignoreErrors)
{
try
{
for (int num7 = 0; num7 < numChatLines; num7++)
{
if (Main.chatLine[num7].showTime > 0)
{
ChatLine chatLine = Main.chatLine[num7];
chatLine.showTime--;
}
}
}
catch
{
for (int num8 = 0; num8 < numChatLines; num8++)
{
Main.chatLine[num8] = new ChatLine();
}
}
}
else
{
for (int num9 = 0; num9 < numChatLines; num9++)
{
if (Main.chatLine[num9].showTime > 0)
{
ChatLine chatLine2 = Main.chatLine[num9];
chatLine2.showTime--;
}
}
}
ModClass.main();
base.Update(gameTime);
}
private static void UpdateClient()
{
if (myPlayer == 255)
{
Netplay.disconnect = true;
}
netPlayCounter++;
if (netPlayCounter > 3600)
{
netPlayCounter = 0;
}
if (Math.IEEERemainder(netPlayCounter, 300.0) == 0.0)
{
NetMessage.SendData(13, -1, -1, "", myPlayer);
NetMessage.SendData(36, -1, -1, "", myPlayer);
}
if (Math.IEEERemainder(netPlayCounter, 600.0) == 0.0)
{
NetMessage.SendData(16, -1, -1, "", myPlayer);
NetMessage.SendData(40, -1, -1, "", myPlayer);
}
if (Netplay.clientSock.active)
{
Netplay.clientSock.timeOut++;
if (!stopTimeOuts && Netplay.clientSock.timeOut > 60 * timeOut)
{
statusText = "Connection timed out";
Netplay.disconnect = true;
}
}
for (int i = 0; i < 200; i++)
{
if (item[i].active && item[i].owner == myPlayer)
{
item[i].FindOwner(i);
}
}
}
private static void UpdateInvasion()
{
if (invasionType <= 0)
{
return;
}
if (invasionSize <= 0)
{
InvasionWarning();
invasionType = 0;
invasionDelay = 7;
}
if (invasionX == (double)spawnTileX)
{
return;
}
float num = 0.2f;
if (invasionX > (double)spawnTileX)
{
invasionX -= num;
if (invasionX <= (double)spawnTileX)
{
invasionX = spawnTileX;
InvasionWarning();
}
else
{
invasionWarn--;
}
}
else if (invasionX < (double)spawnTileX)
{
invasionX += num;
if (invasionX >= (double)spawnTileX)
{
invasionX = spawnTileX;
InvasionWarning();
}
else
{
invasionWarn--;
}
}
if (invasionWarn <= 0)
{
invasionWarn = 3600;
InvasionWarning();
}
}
private static void UpdateMenu()
{
playerInventory = false;
exitScale = 0.8f;
if (netMode == 0)
{
if (grabSky)
{
return;
}
time += 86.4;
if (dayTime)
{
if (time > 54000.0)
{
time = 0.0;
dayTime = false;
}
}
else if (time > 32400.0)
{
bloodMoon = false;
time = 0.0;
dayTime = true;
moonPhase++;
if (moonPhase >= 8)
{
moonPhase = 0;
}
}
}
else if (netMode == 1)
{
UpdateTime();
}
}
protected void UpdateMusic()
{
try
{
if (dedServ)
{
return;
}
if (curMusic > 0)
{
if (!base.IsActive)
{
if (!music[curMusic].IsPaused && music[curMusic].IsPlaying)
{
try
{
music[curMusic].Pause();
return;
}
catch
{
return;
}
}
return;
}
if (music[curMusic].IsPaused)
{
music[curMusic].Resume();
}
}
bool flag = false;
Rectangle rectangle = new Rectangle((int)screenPosition.X, (int)screenPosition.Y, screenWidth, screenHeight);
int num = 5000;
for (int i = 0; i < 1000; i++)
{
if (npc[i].active && (npc[i].boss || npc[i].type == 13 || npc[i].type == 14 || npc[i].type == 15 || npc[i].type == 26 || npc[i].type == 27 || npc[i].type == 28 || npc[i].type == 29))
{
Rectangle value = new Rectangle((int)npc[i].position.X + npc[i].width / 2 - num, (int)npc[i].position.Y + npc[i].height / 2 - num, num * 2, num * 2);
if (rectangle.Intersects(value))
{
flag = true;
break;
}
}
}
if (musicVolume == 0f)
{
newMusic = 0;
}
else if (gameMenu)
{
if (netMode != 2)
{
newMusic = 6;
}
else
{
newMusic = 0;
}
}
else if (flag)
{
newMusic = 5;
}
else if (player[myPlayer].position.Y > (float)((maxTilesY - 200) * 16))
{
newMusic = 2;
}
else if (player[myPlayer].zoneEvil)
{
newMusic = 8;
}
else if (player[myPlayer].zoneMeteor || player[myPlayer].zoneDungeon)
{
newMusic = 2;
}
else if (player[myPlayer].zoneJungle)
{
newMusic = 7;
}
else if ((double)player[myPlayer].position.Y > worldSurface * 16.0 + (double)screenHeight)
{
newMusic = 4;
}
else if (dayTime)
{
newMusic = 1;
}
else if (!dayTime)
{
if (bloodMoon)
{
newMusic = 2;
}
else
{
newMusic = 3;
}
}
curMusic = newMusic;
for (int j = 1; j < 9; j++)
{
if (j == curMusic)
{
if (!music[j].IsPlaying)
{
music[j] = soundBank.GetCue("Music_" + j);
music[j].Play();
music[j].SetVariable("Volume", musicFade[j] * musicVolume);
continue;
}
musicFade[j] += 0.005f;
if (musicFade[j] > 1f)
{
musicFade[j] = 1f;
}
music[j].SetVariable("Volume", musicFade[j] * musicVolume);
}
else if (music[j].IsPlaying)
{
if (musicFade[curMusic] > 0.25f)
{
musicFade[j] -= 0.005f;
}
else if (curMusic == 0)
{
musicFade[j] = 0f;
}
if (musicFade[j] <= 0f)
{
musicFade[j] -= 0f;
music[j].Stop(AudioStopOptions.Immediate);
}
else
{
music[j].SetVariable("Volume", musicFade[j] * musicVolume);
}
}
else
{
musicFade[j] = 0f;
}
}
}
catch
{
musicVolume = 0f;
}
}
private static void UpdateServer()
{
netPlayCounter++;
if (netPlayCounter > 3600)
{
NetMessage.SendData(7);
NetMessage.syncPlayers();
netPlayCounter = 0;
}
for (int i = 0; i < maxNetPlayers; i++)
{
if (player[i].active && Netplay.serverSock[i].active)
{
Netplay.serverSock[i].SpamUpdate();
}
}
Math.IEEERemainder(netPlayCounter, 60.0);
if (Math.IEEERemainder(netPlayCounter, 360.0) == 0.0)
{
bool flag = true;
int num = lastItemUpdate;
int num2 = 0;
while (flag)
{
num++;
if (num >= 200)
{
num = 0;
}
num2++;
if (!item[num].active || item[num].owner == 255)
{
NetMessage.SendData(21, -1, -1, "", num);
}
if (num2 >= maxItemUpdates || num == lastItemUpdate)
{
flag = false;
}
}
lastItemUpdate = num;
}
for (int j = 0; j < 200; j++)
{
if (item[j].active && (item[j].owner == 255 || !player[item[j].owner].active))
{
item[j].FindOwner(j);
}
}
for (int k = 0; k < 255; k++)
{
if (Netplay.serverSock[k].active)
{
ServerSock serverSock = Netplay.serverSock[k];
serverSock.timeOut++;
if (!stopTimeOuts && Netplay.serverSock[k].timeOut > 60 * timeOut)
{
Netplay.serverSock[k].kill = true;
}
}
if (!player[k].active)
{
continue;
}
int sectionX = Netplay.GetSectionX((int)(player[k].position.X / 16f));
int sectionY = Netplay.GetSectionY((int)(player[k].position.Y / 16f));
int num3 = 0;
for (int l = sectionX - 1; l < sectionX + 2; l++)
{
for (int m = sectionY - 1; m < sectionY + 2; m++)
{
if (l >= 0 && l < maxSectionsX && m >= 0 && m < maxSectionsY && !Netplay.serverSock[k].tileSection[l, m])
{
num3++;
}
}
}
if (num3 <= 0)
{
continue;
}
int num4 = num3 * 150;
NetMessage.SendData(9, k, -1, "Receiving tile data", num4);
Netplay.serverSock[k].statusText2 = "is receiving tile data";
ServerSock serverSock2 = Netplay.serverSock[k];
serverSock2.statusMax += num4;
for (int n = sectionX - 1; n < sectionX + 2; n++)
{
for (int num5 = sectionY - 1; num5 < sectionY + 2; num5++)
{
if (n >= 0 && n < maxSectionsX && num5 >= 0 && num5 < maxSectionsY && !Netplay.serverSock[k].tileSection[n, num5])
{
NetMessage.SendSection(k, n, num5);
NetMessage.SendData(11, k, -1, "", n, num5, n, num5);
}
}
}
}
}
private static void UpdateTime()
{
time += 1.0;
if (dayTime)
{
bloodMoon = false;
if (!(time <= 54000.0))
{
WorldGen.spawnNPC = 0;
checkForSpawns = 0;
if (rand.Next(50) == 0 && netMode != 1 && WorldGen.shadowOrbSmashed)
{
WorldGen.spawnMeteor = true;
}
if (!NPC.downedBoss1 && netMode != 1)
{
bool flag = false;
for (int i = 0; i < 255; i++)
{
if (player[i].active && player[i].statLifeMax >= 200 && player[i].statDefense > 10)
{
flag = true;
break;
}
}
if (flag && rand.Next(3) == 0)
{
int num = 0;
for (int j = 0; j < 1000; j++)
{
if (npc[j].active && npc[j].townNPC)
{
num++;
}
}
if (num >= 4)
{
WorldGen.spawnEye = true;
if (netMode == 0)
{
NewText("You feel an evil presence watching you...", 50, byte.MaxValue, 130);
}
else if (netMode == 2)
{
NetMessage.SendData(25, -1, -1, "You feel an evil presence watching you...", 255, 50f, 255f, 130f);
}
}
}
}
if (!WorldGen.spawnEye && moonPhase != 4 && rand.Next(7) == 0 && netMode != 1)
{
for (int k = 0; k < 255; k++)
{
if (player[k].active && player[k].statLifeMax > 120)
{
bloodMoon = true;
break;
}
}
if (bloodMoon)
{
if (netMode == 0)
{
NewText("The Blood Moon is rising...", 50, byte.MaxValue, 130);
}
else if (netMode == 2)
{
NetMessage.SendData(25, -1, -1, "The Blood Moon is rising...", 255, 50f, 255f, 130f);
}
}
}
time = 0.0;
dayTime = false;
if (netMode == 2)
{
NetMessage.SendData(7);
}
}
if (netMode == 1)
{
return;
}
checkForSpawns++;
if (checkForSpawns < 7200)
{
return;
}
int num2 = 0;
for (int l = 0; l < 255; l++)
{
if (player[l].active)
{
num2++;
}
}
checkForSpawns = 0;
WorldGen.spawnNPC = 0;
int num3 = 0;
int num4 = 0;
int num5 = 0;
int num6 = 0;
int num7 = 0;
int num8 = 0;
int num9 = 0;
int num10 = 0;
int num11 = 0;
for (int m = 0; m < 1000; m++)
{
if (npc[m].active && npc[m].townNPC)
{
if (npc[m].type != 37 && !npc[m].homeless)
{
WorldGen.QuickFindHome(m);
}
if (npc[m].type == 37)
{
num8++;
}
if (npc[m].type == 17)
{
num3++;
}
if (npc[m].type == 18)
{
num4++;
}
if (npc[m].type == 19)
{
num6++;
}
if (npc[m].type == 20)
{
num5++;
}
if (npc[m].type == 22)
{
num7++;
}
if (npc[m].type == 38)
{
num9++;
}
if (npc[m].type == 54)
{
num10++;
}
num11++;
}
}
if (WorldGen.spawnNPC != 0)
{
return;
}
int num12 = 0;
bool flag2 = false;
int num13 = 0;
bool flag3 = false;
bool flag4 = false;
for (int n = 0; n < 255; n++)
{
if (!player[n].active)
{
continue;
}
for (int num14 = 0; num14 < 44; num14++)
{
if ((player[n].inventory[num14] != null) & (player[n].inventory[num14].stack > 0))
{
if (player[n].inventory[num14].type == 71)
{
num12 += player[n].inventory[num14].stack;
}
if (player[n].inventory[num14].type == 72)
{
num12 += player[n].inventory[num14].stack * 100;
}
if (player[n].inventory[num14].type == 73)
{
num12 += player[n].inventory[num14].stack * 10000;
}
if (player[n].inventory[num14].type == 74)
{
num12 += player[n].inventory[num14].stack * 1000000;
}
if (player[n].inventory[num14].ammo == 14 || player[n].inventory[num14].useAmmo == 14)
{
flag3 = true;
}
if (player[n].inventory[num14].type == 166 || player[n].inventory[num14].type == 167 || player[n].inventory[num14].type == 168 || player[n].inventory[num14].type == 235)
{
flag4 = true;
}
}
}
int num15 = player[n].statLifeMax / 20;
if (num15 > 5)
{
flag2 = true;
}
num13 += num15;
}
if (!NPC.downedBoss3 && num8 == 0)
{
int num16 = NPC.NewNPC(dungeonX * 16 + 8, dungeonY * 16, 37);
npc[num16].homeless = false;
npc[num16].homeTileX = dungeonX;
npc[num16].homeTileY = dungeonY;
}
if (WorldGen.spawnNPC == 0 && num7 < 1)
{
WorldGen.spawnNPC = 22;
}
if (WorldGen.spawnNPC == 0 && (double)num12 > 5000.0 && num3 < 1)
{
WorldGen.spawnNPC = 17;
}
if (WorldGen.spawnNPC == 0 && flag2 && num4 < 1)
{
WorldGen.spawnNPC = 18;
}
if (WorldGen.spawnNPC == 0 && flag3 && num6 < 1)
{
WorldGen.spawnNPC = 19;
}
if (WorldGen.spawnNPC == 0 && (NPC.downedBoss1 || NPC.downedBoss2 || NPC.downedBoss3) && num5 < 1)
{
WorldGen.spawnNPC = 20;
}
if (WorldGen.spawnNPC == 0 && flag4 && num3 > 0 && num9 < 1)
{
WorldGen.spawnNPC = 38;
}
if (WorldGen.spawnNPC == 0 && NPC.downedBoss3 && num10 < 1)
{
WorldGen.spawnNPC = 54;
}
if (WorldGen.spawnNPC == 0 && num12 > 100000 && num3 < 2 && num2 > 2)
{
WorldGen.spawnNPC = 17;
}
if (WorldGen.spawnNPC == 0 && num13 >= 20 && num4 < 2 && num2 > 2)
{
WorldGen.spawnNPC = 18;
}
if (WorldGen.spawnNPC == 0 && num12 > 5000000 && num3 < 3 && num2 > 4)
{
WorldGen.spawnNPC = 17;
}
return;
}
if (WorldGen.spawnEye && netMode != 1 && time > 4860.0)
{
for (int num17 = 0; num17 < 255; num17++)
{
if (player[num17].active && !player[num17].dead && (double)player[num17].position.Y < worldSurface * 16.0)
{
NPC.SpawnOnPlayer(num17, 4);
WorldGen.spawnEye = false;
break;
}
}
}
if (time > 32400.0)
{
if (invasionDelay > 0)
{
invasionDelay--;
}
WorldGen.spawnNPC = 0;
checkForSpawns = 0;
time = 0.0;
bloodMoon = false;
dayTime = true;
moonPhase++;
if (moonPhase >= 8)
{
moonPhase = 0;
}
if (netMode == 2)
{
NetMessage.SendData(7);
WorldGen.saveAndPlay();
}
if (netMode != 1 && WorldGen.shadowOrbSmashed && rand.Next(15) == 0)
{
StartInvasion();
}
}
if (time > 16200.0 && WorldGen.spawnMeteor)
{
WorldGen.spawnMeteor = false;
WorldGen.dropMeteor();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment