コード例 #1
0
ファイル: PlayerFileData.cs プロジェクト: EmuDevs/EDTerraria
 public static PlayerFileData CreateAndSave(Player player)
 {
     PlayerFileData playerFile = new PlayerFileData();
     playerFile.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
     playerFile.Player = player;
     playerFile._path = Main.GetPlayerPathFromName(player.name, false);
     Player.SavePlayer(playerFile, true);
     return playerFile;
 }
コード例 #2
0
 public UICharacterListItem(PlayerFileData data)
 {
     BorderColor = new Color(89, 116, 213) * 0.7f;
     _dividerTexture = TextureManager.Load("Images/UI/Divider");
     _innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
     _buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
     _buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
     _buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
     _buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
     _buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
     _buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
     Height.Set(96f, 0.0f);
     Width.Set(0.0f, 1f);
     SetPadding(6f);
     playerFileData = data;
     _playerPanel = new UICharacter(data.Player);
     _playerPanel.Left.Set(4f, 0.0f);
     _playerPanel.OnDoubleClick += new UIElement.MouseEvent(PlayGame);
     OnDoubleClick += new UIElement.MouseEvent(PlayGame);
     Append(_playerPanel);
     UIImageButton uiImageButton1 = new UIImageButton(_buttonPlayTexture);
     uiImageButton1.VAlign = 1f;
     uiImageButton1.Left.Set(4f, 0.0f);
     uiImageButton1.OnClick += new UIElement.MouseEvent(PlayGame);
     uiImageButton1.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver);
     uiImageButton1.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
     Append(uiImageButton1);
     UIImageButton uiImageButton2 = new UIImageButton(playerFileData.IsFavorite ? _buttonFavoriteActiveTexture : _buttonFavoriteInactiveTexture);
     uiImageButton2.VAlign = 1f;
     uiImageButton2.Left.Set(28f, 0.0f);
     uiImageButton2.OnClick += new UIElement.MouseEvent(FavoriteButtonClick);
     uiImageButton2.OnMouseOver += new UIElement.MouseEvent(FavoriteMouseOver);
     uiImageButton2.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
     uiImageButton2.SetVisibility(1f, playerFileData.IsFavorite ? 0.8f : 0.4f);
     Append(uiImageButton2);
     UIImageButton uiImageButton4 = new UIImageButton(_buttonDeleteTexture);
     uiImageButton4.VAlign = 1f;
     uiImageButton4.HAlign = 1f;
     uiImageButton4.OnClick += new UIElement.MouseEvent(DeleteButtonClick);
     uiImageButton4.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver);
     uiImageButton4.OnMouseOut += new UIElement.MouseEvent(DeleteMouseOut);
     _deleteButton = uiImageButton4;
     if (!playerFileData.IsFavorite)
         Append(uiImageButton4);
     _buttonLabel = new UIText("", 1f, false);
     _buttonLabel.VAlign = 1f;
     _buttonLabel.Left.Set(80f, 0.0f);
     _buttonLabel.Top.Set(-3f, 0.0f);
     Append(_buttonLabel);
     _deleteButtonLabel = new UIText("", 1f, false);
     _deleteButtonLabel.VAlign = 1f;
     _deleteButtonLabel.HAlign = 1f;
     _deleteButtonLabel.Left.Set(-30f, 0.0f);
     _deleteButtonLabel.Top.Set(-3f, 0.0f);
     Append(_deleteButtonLabel);
 }
コード例 #3
0
 public static PlayerFileData CreateAndSave(Terraria.Player player)
 {
     PlayerFileData playerFileDatum = new PlayerFileData()
     {
         Metadata = FileMetadata.FromCurrentSettings(FileType.Player),
         Player = player,
     };
     playerFileDatum._path = Main.GetPlayerPathFromName(player.name);
     Terraria.Player.SavePlayer(playerFileDatum, true);
     return playerFileDatum;
 }
コード例 #4
0
		public static PlayerFileData CreateAndSave(Player player)
		{
			PlayerFileData playerFileData = new PlayerFileData();
			playerFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
			playerFileData.Player = player;
			playerFileData._isCloudSave = (SocialAPI.Cloud != null && SocialAPI.Cloud.EnabledByDefault);
			playerFileData._path = Main.GetPlayerPathFromName(player.name, playerFileData.IsCloudSave);
			(playerFileData.IsCloudSave ? Main.CloudFavoritesData : Main.LocalFavoriteData).ClearEntry(playerFileData);
			Player.SavePlayer(playerFileData, true);
			return playerFileData;
		}
コード例 #5
0
 public static PlayerFileData CreateAndSave(Terraria.Player player)
 {
     PlayerFileData playerFileDatum = new PlayerFileData()
     {
         Metadata = FileMetadata.FromCurrentSettings(FileType.Player),
         Player = player,
         _isCloudSave = (SocialAPI.Cloud == null ? false : SocialAPI.Cloud.EnabledByDefault),
     };
     playerFileDatum._path = Main.GetPlayerPathFromName(player.name, playerFileDatum.IsCloudSave);
     ((playerFileDatum.IsCloudSave ? Main.CloudFavoritesData : Main.LocalFavoriteData)).ClearEntry(playerFileDatum);
     Terraria.Player.SavePlayer(playerFileDatum, true);
     return playerFileDatum;
 }
コード例 #6
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 static Main()
 {
     Main.curRelease = 156;
     Main.versionNumber = "v1.3.0.8";
     Main.versionNumber2 = "v1.3.0.8";
     Main.destroyerHB = new Vector2(0f, 0f);
     Main.drawBackGore = false;
     Main.expertLife = 2f;
     Main.expertDamage = 2f;
     Main.expertDebuffTime = 2f;
     Main.expertKnockBack = 0.9f;
     Main.expertNPCDamage = 1.5f;
     Main.knockBackMultiplier = 1f;
     Main.damageMultiplier = 1f;
     Main.ServerSideCharacter = false;
     Main.ContentLoaded = false;
     Main.maxMsg = 106;
     Main.GlobalTime = 0f;
     Main.GlobalTimerPaused = false;
     Main._tileFrameSeed = (ulong)Guid.NewGuid().GetHashCode();
     Main.npcStreamSpeed = 60;
     Main.musicError = 0;
     Main.dedServFPS = false;
     Main.dedServCount1 = 0;
     Main.dedServCount2 = 0;
     Main.superFast = false;
     Main.hairLoaded = new bool[134];
     Main.wingsLoaded = new bool[37];
     Main.goreLoaded = new bool[907];
     Main.projectileLoaded = new bool[Main.maxProjectileTypes];
     Main.itemFlameLoaded = new bool[Main.maxItemTypes];
     Main.backgroundLoaded = new bool[207];
     Main.tileSetsLoaded = new bool[Main.maxTileSets];
     Main.wallLoaded = new bool[Main.maxWallTypes];
     Main.NPCLoaded = new bool[Main.maxNPCTypes];
     Main.armorHeadLoaded = new bool[194];
     Main.armorBodyLoaded = new bool[195];
     Main.armorLegsLoaded = new bool[135];
     Main.accHandsOnLoaded = new bool[19];
     Main.accHandsOffLoaded = new bool[12];
     Main.accBackLoaded = new bool[10];
     Main.accFrontLoaded = new bool[5];
     Main.accShoesLoaded = new bool[18];
     Main.accWaistLoaded = new bool[12];
     Main.accShieldLoaded = new bool[6];
     Main.accNeckLoaded = new bool[9];
     Main.accFaceLoaded = new bool[9];
     Main.accballoonLoaded = new bool[16];
     Vector2[] vector2 = new Vector2[] { new Vector2(14f, 34f), new Vector2(14f, 32f), new Vector2(14f, 26f), new Vector2(14f, 22f), new Vector2(14f, 18f) };
     Main.OffsetsNPCOffhand = vector2;
     Vector2[] vector2Array = new Vector2[] { new Vector2(14f, 20f), new Vector2(14f, 20f), new Vector2(14f, 20f), new Vector2(14f, 18f), new Vector2(14f, 20f), new Vector2(16f, 4f), new Vector2(16f, 16f), new Vector2(18f, 14f), new Vector2(18f, 14f), new Vector2(18f, 14f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f), new Vector2(14f, 14f), new Vector2(14f, 14f), new Vector2(12f, 14f), new Vector2(14f, 16f), new Vector2(16f, 16f), new Vector2(16f, 16f) };
     Main.OffsetsPlayerOffhand = vector2Array;
     Vector2[] vector21 = new Vector2[] { new Vector2(6f, 19f), new Vector2(5f, 10f), new Vector2(12f, 10f), new Vector2(13f, 17f), new Vector2(12f, 19f), new Vector2(5f, 10f), new Vector2(7f, 17f), new Vector2(6f, 16f), new Vector2(6f, 16f), new Vector2(6f, 16f), new Vector2(6f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f), new Vector2(8f, 17f), new Vector2(9f, 16f), new Vector2(9f, 12f), new Vector2(8f, 17f), new Vector2(7f, 17f), new Vector2(7f, 17f) };
     Main.OffsetsPlayerOnhand = vector21;
     Vector2[] vector2Array1 = new Vector2[] { new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(0f, 2f), new Vector2(0f, 2f), new Vector2(0f, 2f) };
     Main.OffsetsPlayerHeadgear = vector2Array1;
     Main.BlackFadeIn = 0;
     Main.noWindowBorder = false;
     Main.ugBack = 0;
     Main.oldUgBack = 0;
     Main.bgFrame = new int[1];
     Main.bgFrameCounter = new int[1];
     Main.skipMenu = false;
     Main.verboseNetplay = false;
     Main.stopTimeOuts = false;
     Main.showSpam = false;
     Main.showItemOwner = false;
     Main.nextNPC = new bool[Main.maxNPCTypes];
     Main.musicBox = -1;
     Main.musicBox2 = -1;
     Main.hbPosition = 1;
     Main.cEd = false;
     Main.wFrCounter = 0f;
     Main.wFrame = 0f;
     Main.drawDiag = false;
     Main.drawRelease = false;
     Main.drawBetterDebug = false;
     Main.betterDebugRelease = false;
     Main.renderNow = false;
     Main.drawToScreen = false;
     Main.targetSet = false;
     Main.essScale = 1f;
     Main.essDir = -1;
     Main.cloudBGX = new float[2];
     Main.cloudBG = new int[] { 112, 113 };
     Main.treeMntBG = new int[2];
     Main.treeBG = new int[3];
     Main.corruptBG = new int[3];
     Main.jungleBG = new int[3];
     Main.snowMntBG = new int[2];
     Main.snowBG = new int[3];
     Main.hallowBG = new int[3];
     Main.crimsonBG = new int[3];
     Main.desertBG = new int[2];
     Main.treeX = new int[4];
     Main.treeStyle = new int[4];
     Main.caveBackX = new int[4];
     Main.caveBackStyle = new int[4];
     Main.debugWords = "";
     Main.gamePad = false;
     Main.xMas = false;
     Main.halloween = false;
     Main.snowDust = 0;
     Main.chTitle = false;
     Main.hairWindow = false;
     Main.clothesWindow = false;
     Main.ingameOptionsWindow = false;
     Main.achievementsWindow = false;
     Main.keyCount = 0;
     Main.keyString = new string[10];
     Main.keyInt = new int[10];
     Main.gFade = 0;
     Main.gFader = 0f;
     Main.gFadeDir = 1;
     Main.netDiag = false;
     Main.txData = 0;
     Main.rxData = 0;
     Main.txMsg = 0;
     Main.rxMsg = 0;
     Main.uCarry = 0f;
     Main.drawSkip = false;
     Main.fpsCount = 0;
     Main.fpsTimer = new Stopwatch();
     Main.updateTimer = new Stopwatch();
     Main.fountainColor = -1;
     Main.monolithType = -1;
     Main.showSplash = true;
     Main.ignoreErrors = true;
     Main.defaultIP = "";
     Main.dayRate = 1;
     Main.maxScreenW = 1920;
     Main.minScreenW = 800;
     Main.maxScreenH = 1200;
     Main.minScreenH = 600;
     Main.iS = 1f;
     Main.render = false;
     Main.qaStyle = 0;
     Main.zoneX = 99;
     Main.zoneY = 87;
     Main.harpNote = 0f;
     Main.projHostile = new bool[Main.maxProjectileTypes];
     Main.projHook = new bool[Main.maxProjectileTypes];
     Main.pvpBuff = new bool[Main.maxBuffTypes];
     Main.persistentBuff = new bool[Main.maxBuffTypes];
     Main.vanityPet = new bool[191];
     Main.lightPet = new bool[191];
     Main.meleeBuff = new bool[Main.maxBuffTypes];
     Main.debuff = new bool[Main.maxBuffTypes];
     Main.buffName = new string[Main.maxBuffTypes];
     Main.buffTip = new string[Main.maxBuffTypes];
     Main.buffNoSave = new bool[Main.maxBuffTypes];
     Main.buffNoTimeDisplay = new bool[Main.maxBuffTypes];
     Main.buffDoubleApply = new bool[Main.maxBuffTypes];
     Main.maxMP = 10;
     Main.recentWorld = new string[Main.maxMP];
     Main.recentIP = new string[Main.maxMP];
     Main.recentPort = new int[Main.maxMP];
     Main.shortRender = true;
     Main.owBack = true;
     Main.quickBG = 2;
     Main.bgDelay = 0;
     Main.bgStyle = 0;
     Main.bgAlpha = new float[10];
     Main.bgAlpha2 = new float[10];
     Main.EquipPage = 0;
     Main.EquipPageSelected = 0;
     Main.wof = -1;
     Main.wofF = 0;
     Main.offScreenRange = 200;
     Main.maxMapUpdates = 250000;
     Main.refreshMap = false;
     Main.loadMapLastX = 0;
     Main.loadMapLock = false;
     Main.loadMap = false;
     Main.mapReady = false;
     Main.textureMaxWidth = 2000;
     Main.textureMaxHeight = 1800;
     Main.updateMap = false;
     Main.mapMinX = 0;
     Main.mapMaxX = 0;
     Main.mapMinY = 0;
     Main.mapMaxY = 0;
     Main.mapTimeMax = 30;
     Main.mapTime = Main.mapTimeMax;
     Main.mapTargetX = 5;
     Main.mapTargetY = 2;
     Main.initMap = new bool[Main.mapTargetX, Main.mapTargetY];
     Main.mapWasContentLost = new bool[Main.mapTargetX, Main.mapTargetY];
     Main.OurFavoriteColor = new Color(255, 231, 69);
     Main.mapInit = false;
     Main.mapEnabled = true;
     Main.mapStyle = 1;
     Main.grabMapX = 0f;
     Main.grabMapY = 0f;
     Main.miniMapX = 0;
     Main.miniMapY = 0;
     Main.miniMapWidth = 0;
     Main.miniMapHeight = 0;
     Main.mapMinimapScale = 1.25f;
     Main.mapMinimapAlpha = 1f;
     Main.mapOverlayScale = 2.5f;
     Main.mapOverlayAlpha = 0.35f;
     Main.mapFullscreen = false;
     Main.resetMapFull = false;
     Main.mapFullscreenScale = 4f;
     Main.mapFullscreenPos = new Vector2(-1f, -1f);
     Main.renderCount = 99;
     Main.saveTime = new Stopwatch();
     Main.mcColor = new Color(125, 125, 255);
     Main.hcColor = new Color(200, 125, 255);
     Main.highVersionColor = new Color(255, 255, 0);
     Main.errorColor = new Color(255, 0, 0);
     Main.mouseHC = false;
     Main.craftingHide = false;
     Main.armorHide = false;
     Main.craftingAlpha = 1f;
     Main.armorAlpha = 1f;
     Main.buffAlpha = new float[Main.maxBuffTypes];
     Main.trashItem = new Item();
     Main.hardMode = false;
     Main.sceneWaterPos = Vector2.Zero;
     Main.sceneTilePos = Vector2.Zero;
     Main.sceneTile2Pos = Vector2.Zero;
     Main.sceneWallPos = Vector2.Zero;
     Main.sceneBackgroundPos = Vector2.Zero;
     Main.maxQ = true;
     Main.gfxQuality = 1f;
     Main.gfxRate = 0.01f;
     Main.DiscoR = 255;
     Main.DiscoB = 0;
     Main.DiscoG = 0;
     Main.teamCooldown = 0;
     Main.teamCooldownLen = 300;
     Main.gamePaused = false;
     Main.gameInactive = false;
     Main.updateTime = 0;
     Main.drawTime = 0;
     Main.uCount = 0;
     Main.updateRate = 0;
     Main.frameRate = 0;
     Main.RGBRelease = false;
     Main.qRelease = false;
     Main.netRelease = false;
     Main.frameRelease = false;
     Main.showFrameRate = false;
     Main.magmaBGFrame = 0;
     Main.magmaBGFrameCounter = 0;
     Main.saveTimer = 0;
     Main.autoJoin = false;
     Main.serverStarting = false;
     Main.leftWorld = 0f;
     Main.rightWorld = 134400f;
     Main.topWorld = 0f;
     Main.bottomWorld = 38400f;
     Main.maxTilesX = (int)Main.rightWorld / 16 + 1;
     Main.maxTilesY = (int)Main.bottomWorld / 16 + 1;
     Main.maxSectionsX = Main.maxTilesX / 200;
     Main.maxSectionsY = Main.maxTilesY / 150;
     Main.numDust = 6000;
     Main.numPlayers = 0;
     Main.maxNetPlayers = 255;
     Main.maxRain = 750;
     Main.slimeWarningTime = 0;
     Main.slimeWarningDelay = 420;
     Main.slimeRainNPCSlots = 0.65f;
     Main.slimeRainNPC = new bool[Main.maxNPCTypes];
     Main.slimeRainTime = 0;
     Main.slimeRain = false;
     Main.slimeRainKillCount = 0;
     Main.cameraX = 0f;
     Main.drewLava = false;
     Main.liquidAlpha = new float[12];
     Main.waterStyle = 0;
     Main.worldRate = 1;
     Main.caveParallax = 0.88f;
     Main.liquid = new Liquid[Liquid.resLiquid];
     Main.liquidBuffer = new LiquidBuffer[10000];
     Main.dedServ = false;
     Main.spamCount = 0;
     Main.curMusic = 0;
     Main.dayMusic = 0;
     Main.ugMusic = 0;
     Main.showItemText = true;
     Main.autoSave = true;
     Main.validateSaves = true;
     Main.bannerMouseOver = false;
     Main.buffString = "";
     Main.libPath = "";
     Main.lo = 0;
     Main.LogoA = 255;
     Main.LogoB = 0;
     Main.LogoT = false;
     Main.statusText = "";
     Main.worldName = "";
     Main.background = 0;
     Main.caveBackground = 0;
     Main.ugBackTransition = 0f;
     Main.teamColor = new Color[6];
     Main.dayTime = true;
     Main.time = 13500;
     Main.moonPhase = 0;
     Main.sunModY = 0;
     Main.moonModY = 0;
     Main.grabSky = false;
     Main.bloodMoon = false;
     Main.pumpkinMoon = false;
     Main.snowMoon = false;
     Main.cloudAlpha = 0f;
     Main.maxRaining = 0f;
     Main.oldMaxRaining = 0f;
     Main.rainTime = 0;
     Main.raining = false;
     Main.eclipse = false;
     Main.eclipseLight = 0f;
     Main.checkForSpawns = 0;
     Main.helpText = 0;
     Main.autoGen = false;
     Main.autoPause = false;
     Main.projFrames = new int[Main.maxProjectileTypes];
     Main.projPet = new bool[Main.maxProjectileTypes];
     Main.demonTorch = 1f;
     Main.demonTorchDir = 1;
     Main.martianLight = 1f;
     Main.martianLightDir = 1;
     Main.placementPreview = true;
     Main.weatherCounter = 0;
     Main.cloudLimit = 200;
     Main.numClouds = Main.cloudLimit;
     Main.numCloudsTemp = Main.numClouds;
     Main.windSpeedTemp = 0f;
     Main.windSpeed = 0f;
     Main.windSpeedSet = 0f;
     Main.windSpeedSpeed = 0f;
     Main.cloud = new Cloud[200];
     Main.resetClouds = true;
     Main.fadeCounter = 0;
     Main.invAlpha = 1f;
     Main.invDir = 1f;
     Main.maxMoons = 3;
     Main.moonType = 0;
     Main.numTileColors = 31;
     Main.tileAltTextureInit = new bool[Main.maxTileSets, Main.numTileColors];
     Main.tileAltTextureDrawn = new bool[Main.maxTileSets, Main.numTileColors];
     Main.numTreeStyles = 19;
     Main.treeAltTextureInit = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.treeAltTextureDrawn = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.checkTreeAlt = new bool[Main.numTreeStyles, Main.numTileColors];
     Main.wallAltTextureInit = new bool[Main.maxWallTypes, Main.numTileColors];
     Main.wallAltTextureDrawn = new bool[Main.maxWallTypes, Main.numTileColors];
     Main.musicFade = new float[40];
     Main.musicVolume = 0.75f;
     Main.ambientVolume = 0.75f;
     Main.soundVolume = 1f;
     Main.MenuServerMode = ServerSocialMode.None;
     Main.tileLighted = new bool[Main.maxTileSets];
     Main.tileMergeDirt = new bool[Main.maxTileSets];
     Main.tileCut = new bool[Main.maxTileSets];
     Main.tileAlch = new bool[Main.maxTileSets];
     Main.tileShine = new int[Main.maxTileSets];
     Main.tileShine2 = new bool[Main.maxTileSets];
     Main.wallHouse = new bool[Main.maxWallTypes];
     Main.wallDungeon = new bool[Main.maxWallTypes];
     Main.wallLight = new bool[Main.maxWallTypes];
     Main.wallBlend = new int[Main.maxWallTypes];
     Main.tileStone = new bool[Main.maxTileSets];
     Main.tileAxe = new bool[Main.maxTileSets];
     Main.tileHammer = new bool[Main.maxTileSets];
     Main.tileWaterDeath = new bool[Main.maxTileSets];
     Main.tileLavaDeath = new bool[Main.maxTileSets];
     Main.tileTable = new bool[Main.maxTileSets];
     Main.tileBlockLight = new bool[Main.maxTileSets];
     Main.tileNoSunLight = new bool[Main.maxTileSets];
     Main.tileDungeon = new bool[Main.maxTileSets];
     Main.tileSpelunker = new bool[Main.maxTileSets];
     Main.tileSolidTop = new bool[Main.maxTileSets];
     Main.tileSolid = new bool[Main.maxTileSets];
     Main.tileBouncy = new bool[Main.maxTileSets];
     Main.tileValue = new short[Main.maxTileSets];
     Main.tileLargeFrames = new byte[Main.maxTileSets];
     Main.wallLargeFrames = new byte[Main.maxWallTypes];
     Main.tileRope = new bool[Main.maxTileSets];
     Main.tileBrick = new bool[Main.maxTileSets];
     Main.tileMoss = new bool[Main.maxTileSets];
     Main.tileNoAttach = new bool[Main.maxTileSets];
     Main.tileNoFail = new bool[Main.maxTileSets];
     Main.tileObsidianKill = new bool[Main.maxTileSets];
     Main.tileFrameImportant = new bool[Main.maxTileSets];
     Main.tilePile = new bool[Main.maxTileSets];
     Main.tileBlendAll = new bool[Main.maxTileSets];
     Main.tileGlowMask = new short[Main.maxTileSets];
     Main.tileContainer = new bool[Main.maxTileSets];
     Main.tileSign = new bool[Main.maxTileSets];
     Main.tileMerge = new bool[Main.maxTileSets][];
     Main.cageFrames = 25;
     Main.critterCage = false;
     Main.bunnyCageFrame = new int[Main.cageFrames];
     Main.bunnyCageFrameCounter = new int[Main.cageFrames];
     Main.squirrelCageFrame = new int[Main.cageFrames];
     Main.squirrelCageFrameCounter = new int[Main.cageFrames];
     Main.squirrelCageFrameOrange = new int[Main.cageFrames];
     Main.squirrelCageFrameCounterOrange = new int[Main.cageFrames];
     Main.mallardCageFrame = new int[Main.cageFrames];
     Main.mallardCageFrameCounter = new int[Main.cageFrames];
     Main.duckCageFrame = new int[Main.cageFrames];
     Main.duckCageFrameCounter = new int[Main.cageFrames];
     Main.birdCageFrame = new int[Main.cageFrames];
     Main.birdCageFrameCounter = new int[Main.cageFrames];
     Main.redBirdCageFrame = new int[Main.cageFrames];
     Main.redBirdCageFrameCounter = new int[Main.cageFrames];
     Main.blueBirdCageFrame = new int[Main.cageFrames];
     Main.blueBirdCageFrameCounter = new int[Main.cageFrames];
     Main.butterflyCageMode = new byte[9, Main.cageFrames];
     Main.butterflyCageFrame = new int[9, Main.cageFrames];
     Main.butterflyCageFrameCounter = new int[9, Main.cageFrames];
     Main.scorpionCageFrame = new int[2, Main.cageFrames];
     Main.scorpionCageFrameCounter = new int[2, Main.cageFrames];
     Main.snailCageFrame = new int[Main.cageFrames];
     Main.snailCageFrameCounter = new int[Main.cageFrames];
     Main.snail2CageFrame = new int[Main.cageFrames];
     Main.snail2CageFrameCounter = new int[Main.cageFrames];
     Main.fishBowlFrameMode = new byte[Main.cageFrames];
     Main.fishBowlFrame = new int[Main.cageFrames];
     Main.fishBowlFrameCounter = new int[Main.cageFrames];
     Main.frogCageFrame = new int[Main.cageFrames];
     Main.frogCageFrameCounter = new int[Main.cageFrames];
     Main.mouseCageFrame = new int[Main.cageFrames];
     Main.mouseCageFrameCounter = new int[Main.cageFrames];
     Main.jellyfishCageMode = new byte[3, Main.cageFrames];
     Main.jellyfishCageFrame = new int[3, Main.cageFrames];
     Main.jellyfishCageFrameCounter = new int[3, Main.cageFrames];
     Main.wormCageFrame = new int[Main.cageFrames];
     Main.wormCageFrameCounter = new int[Main.cageFrames];
     Main.penguinCageFrame = new int[Main.cageFrames];
     Main.penguinCageFrameCounter = new int[Main.cageFrames];
     Main.slugCageFrame = new int[3, Main.cageFrames];
     Main.slugCageFrameCounter = new int[3, Main.cageFrames];
     Main.grasshopperCageFrame = new int[Main.cageFrames];
     Main.grasshopperCageFrameCounter = new int[Main.cageFrames];
     Main.tileSand = new bool[Main.maxTileSets];
     Main.tileFlame = new bool[Main.maxTileSets];
     Main.npcCatchable = new bool[Main.maxNPCTypes];
     Main.tileFrame = new int[Main.maxTileSets];
     Main.tileFrameCounter = new int[Main.maxTileSets];
     Main.wallFrame = new byte[Main.maxWallTypes];
     Main.wallFrameCounter = new byte[Main.maxWallTypes];
     Main.backgroundWidth = new int[207];
     Main.backgroundHeight = new int[207];
     Main.tilesLoaded = false;
     //Main.Map = new WorldMap(Main.maxTilesX, Main.maxTilesY);
     //Main.tile = new Tile[Main.maxTilesX, Main.maxTilesY];
     Main.tile = new TileProvider();
     Main.star = new Star[130];
     Main.item = new Item[401];
     Main.itemLockoutTime = new int[401];
     Main.npc = new NPC[201];
     Main.projectile = new Projectile[1001];
     Main.projectileIdentity = new int[256, 1001];
     Main.combatText = new CombatText[100];
     Main.itemText = new ItemText[20];
     Main.chest = new Chest[1000];
     Main.sign = new Sign[1000];
     Main.itemFrame = new int[401];
     Main.itemFrameCounter = new int[401];
     Main.itemAnimations = new DrawAnimation[Main.maxItemTypes];
     Main.itemAnimationsRegistered = new List<int>();
     Main.screenWidth = 1152;
     Main.screenHeight = 864;
     Main.screenMaximized = false;
     Main.chatLength = 600;
     Main.chatMode = false;
     Main.chatRelease = false;
     Main.showCount = 10;
     Main.numChatLines = 500;
     Main.startChatLine = 0;
     Main.chatText = "";
     Main.inputTextEnter = false;
     Main.inputTextEscape = false;
     Main.hotbarScale = new float[] { 1f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f };
     Main.mouseTextColor = 0;
     Main.mouseTextColorChange = 1;
     Main.mouseLeftRelease = false;
     Main.mouseRightRelease = false;
     Main.playerInventory = false;
     Main.stackCounter = 0;
     Main.stackDelay = 7;
     Main.superFastStack = 0;
     Main.mouseItem = new Item();
     Main.guideItem = new Item();
     Main.reforgeItem = new Item();
     Main.inventoryScale = 0.75f;
     Main.hasFocus = true;
     Main.recFastScroll = false;
     Main.recBigList = false;
     Main.recStart = 0;
     Main.recipe = new Recipe[Recipe.maxRecipes];
     Main.availableRecipe = new int[Recipe.maxRecipes];
     Main.availableRecipeY = new float[Recipe.maxRecipes];
     Main.myPlayer = 0;
     Main.player = new Player[256];
     Main.playerDrawDust = new List<int>();
     Main.playerDrawGore = new List<int>();
     Main.npcChatRelease = false;
     Main.editSign = false;
     Main.editChest = false;
     Main.blockInput = false;
     Main.defaultChestName = string.Empty;
     Main.npcChatText = "";
     Main.npcChatFocus1 = false;
     Main.npcChatFocus2 = false;
     Main.npcChatFocus3 = false;
     Main.npcShop = 0;
     Main.numShops = 21;
     Main.npcChatCornerItem = 0;
     Main.travelShop = new int[40];
     Main.anglerWhoFinishedToday = new List<string>();
     Main.anglerQuest = 0;
     Main.anglerQuestItemNetIDs = new int[] { 2450, 2451, 2452, 2453, 2454, 2455, 2456, 2457, 2458, 2459, 2460, 2461, 2462, 2463, 2464, 2465, 2466, 2467, 2468, 2469, 2470, 2471, 2472, 2473, 2474, 2475, 2476, 2477, 2478, 2479, 2480, 2481, 2482, 2483, 2484, 2485, 2486, 2487, 2488 };
     Main.craftGuide = false;
     Main.reforge = false;
     Main.toolTip = new Item();
     Main.motd = "";
     Main.numDisplayModes = 0;
     Main.displayWidth = new int[99];
     Main.displayHeight = new int[99];
     Main.gameMenu = true;
     Main.maxLoadPlayer = 1000;
     Main.maxLoadWorld = 1000;
     Main.PlayerList = new List<PlayerFileData>();
     Main.ActivePlayerFileData = new PlayerFileData();
     Main.PendingPlayer = null;
     Main.WorldList = new List<WorldFileData>();
     Main.ActiveWorldFileData = new WorldFileData();
     object[] objArray = new object[] { Environment.GetFolderPath(Environment.SpecialFolder.Personal), Path.DirectorySeparatorChar, "My Games", Path.DirectorySeparatorChar, "Terraria" };
     Main.SavePath = string.Concat(objArray);
     Main.WorldPath = string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "Worlds");
     Main.CloudWorldPath = "worlds";
     Main.PlayerPath = string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "Players");
     Main.CloudPlayerPath = "players";
     Main.Configuration = new Preferences(string.Concat(Main.SavePath, Path.DirectorySeparatorChar, "config.json"), false, false);
     Main.itemName = new string[Main.maxItemTypes];
     Main.npcName = new string[Main.maxNPCTypes];
     Main.PendingResolutionWidth = 800;
     Main.PendingResolutionHeight = 600;
     Main.invasionType = 0;
     Main.invasionX = 0;
     Main.invasionSize = 0;
     Main.invasionDelay = 0;
     Main.invasionWarn = 0;
     Main.invasionSizeStart = 0;
     Main.invasionProgressNearInvasion = false;
     Main.invasionProgressMode = 2;
     Main.invasionProgressIcon = 0;
     Main.invasionProgress = 0;
     Main.invasionProgressMax = 0;
     Main.invasionProgressWave = 0;
     Main.invasionProgressDisplayLeft = 0;
     Main.invasionProgressAlpha = 0f;
     Main.npcFrameCount = new int[] { 1, 2, 2, 3, 6, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 25, 23, 25, 21, 15, 26, 2, 10, 1, 16, 16, 16, 3, 1, 15, 3, 1, 3, 1, 1, 21, 25, 1, 1, 1, 3, 3, 15, 3, 7, 7, 4, 5, 6, 5, 3, 3, 23, 6, 3, 6, 6, 2, 5, 3, 2, 7, 7, 4, 2, 8, 1, 5, 1, 2, 4, 16, 5, 4, 4, 15, 15, 15, 15, 2, 4, 6, 6, 24, 16, 1, 1, 1, 1, 1, 1, 4, 3, 1, 1, 1, 1, 1, 1, 5, 6, 7, 16, 1, 1, 25, 23, 12, 20, 21, 1, 2, 2, 3, 6, 1, 1, 1, 15, 4, 11, 1, 23, 6, 6, 3, 1, 2, 2, 1, 3, 4, 1, 2, 1, 4, 2, 1, 15, 3, 25, 4, 5, 7, 3, 2, 12, 12, 4, 4, 4, 8, 8, 9, 5, 6, 4, 15, 23, 3, 3, 8, 5, 4, 13, 15, 12, 4, 14, 14, 3, 2, 5, 3, 2, 3, 23, 5, 14, 16, 5, 2, 2, 12, 3, 3, 3, 3, 2, 2, 2, 2, 2, 7, 14, 15, 16, 8, 3, 15, 15, 15, 2, 3, 20, 25, 23, 26, 4, 4, 16, 16, 20, 20, 20, 2, 2, 2, 2, 8, 12, 3, 4, 2, 4, 25, 26, 26, 6, 3, 3, 3, 3, 3, 3, 4, 4, 5, 4, 6, 7, 15, 4, 7, 6, 1, 1, 2, 4, 3, 5, 3, 3, 3, 4, 5, 6, 4, 2, 1, 8, 4, 4, 1, 8, 1, 4, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 3, 3, 3, 3, 3, 3, 15, 3, 6, 12, 20, 20, 20, 15, 15, 15, 5, 5, 6, 6, 5, 2, 7, 2, 6, 6, 6, 6, 6, 15, 15, 15, 15, 15, 11, 4, 2, 2, 3, 3, 3, 15, 15, 15, 10, 14, 12, 1, 10, 8, 3, 3, 2, 2, 2, 2, 7, 15, 15, 15, 6, 3, 10, 10, 6, 9, 8, 9, 8, 20, 10, 6, 23, 1, 4, 24, 2, 4, 6, 6, 10, 15, 15, 15, 15, 4, 4, 26, 23, 8, 2, 4, 4, 4, 4, 2, 2, 4, 12, 12, 9, 9, 9, 1, 9, 11, 2, 2, 9, 5, 6, 4, 18, 8, 11, 1, 4, 5, 8, 4, 1, 1, 1, 1, 4, 2, 5, 4, 11, 5, 11, 1, 1, 1, 10, 10, 15, 8, 17, 6, 6, 1, 12, 12, 13, 15, 9, 5, 10, 7, 7, 7, 7, 7, 7, 7, 4, 4, 16, 16, 25, 5, 7, 3, 10, 2, 6, 2, 19, 19, 19, 19, 26, 3, 1, 1, 1, 1, 1, 16, 21, 9, 16, 7, 6, 18, 13, 20, 12, 12, 20, 6, 14, 14, 14, 14, 6, 1, 3, 25, 19, 20, 22, 2, 4, 4, 4, 11, 9, 8, 1, 9, 1, 8, 8, 12, 12, 11, 11, 11, 11, 11, 11, 11, 11, 11, 1, 6, 9, 1, 1, 1, 1, 1, 1, 4, 1, 10, 1, 8, 4, 1, 5, 8, 8, 8, 8, 9, 9, 5, 4, 8, 16, 8, 2, 3, 3, 6, 6 };
     Main.npcLifeBytes = new Dictionary<int, byte>();
     Main.clientPlayer = new Player();
     Main.getIP = Main.defaultIP;
     Main.getPort = Convert.ToString(Netplay.ListenPort);
     Main.menuMultiplayer = false;
     Main.menuServer = false;
     Main.netMode = 0;
     Main._targetNetMode = 0;
     Main._hasPendingNetmodeChange = false;
     Main.maxNPCUpdates = 5;
     Main.maxItemUpdates = 5;
     Main.cUp = "W";
     Main.cLeft = "A";
     Main.cDown = "S";
     Main.cRight = "D";
     Main.cJump = "Space";
     Main.cThrowItem = "T";
     Main.cHeal = "H";
     Main.cMana = "J";
     Main.cBuff = "B";
     Main.cHook = "E";
     Main.cTorch = "LeftShift";
     Main.cInv = "Escape";
     Main.cSmart = "LeftControl";
     Main.cMount = "R";
     Main.cSmartToggle = true;
     Main.smartDigEnabled = false;
     Main.smartDigShowing = false;
     Main.cursorOverride = -1;
     Main.signHover = -1;
     Main.cMapZoomIn = "Add";
     Main.cMapZoomOut = "Subtract";
     Main.cMapAlphaUp = "PageUp";
     Main.cMapAlphaDown = "PageDown";
     Main.cMapFull = "M";
     Main.cMapStyle = "Tab";
     Main.mouseColor = new Color(255, 50, 95);
     Main.cursorColor = Color.White;
     Main.cursorColorDirection = 1;
     Main.cursorAlpha = 0f;
     Main.cursorScale = 0f;
     Main.signBubble = false;
     Main.signX = 0;
     Main.signY = 0;
     Main.hideUI = false;
     Main.releaseUI = false;
     Main.fixedTiming = true;
     Main.oldStatusText = "";
     Main.autoShutdown = false;
     Main.serverGenLock = false;
     Main.sundialCooldown = 0;
     Main.fastForwardTime = false;
     Main.ambientWaterfallX = -1f;
     Main.ambientWaterfallY = -1f;
     Main.ambientWaterfallStrength = 0f;
     Main.ambientLavafallX = -1f;
     Main.ambientLavafallY = -1f;
     Main.ambientLavafallStrength = 0f;
     Main.ambientLavaX = -1f;
     Main.ambientLavaY = -1f;
     Main.ambientLavaStrength = 0f;
     Main.ambientCounter = 0;
     Main.ProjectileUpdateLoopIndex = -1;
     Main.maxMenuItems = 16;
     Main.selectedPlayer = 0;
     Main.selectedWorld = 0;
     Main.menuMode = 0;
     Main.menuSkip = 0;
     Main.cpItem = new Item();
     Main.newWorldName = "";
     Main.hoverItemName = "";
     Main.inventoryBack = new Color(220, 220, 220, 220);
     Main.mouseText = false;
     Main.sX = Main.screenWidth - 800;
     Main.oldClothesColor = new Color[4];
     Main.selColor = Color.White;
     Main.focusColor = 0;
     Main.colorDelay = 0;
     Main.setKey = -1;
     Main.bgScroll = 0;
     Main.autoPass = false;
     Main.menuFocus = 0;
     Main.blockMouse = false;
     string[] strArrays = new string[] { "MonolithVortex", "MonolithNebula", "MonolithStardust", "MonolithSolar" };
     Main.MonolithFilterNames = strArrays;
     string[] strArrays1 = new string[] { "MonolithVortex", "MonolithNebula", "MonolithStardust", "MonolithSolar" };
     Main.MonolithSkyNames = strArrays1;
     Main.bgScale = 1f;
     Main.bgW = (int)(1024f * Main.bgScale);
     Main.backColor = Color.White;
     Main.trueBackColor = Main.backColor;
 }
コード例 #7
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 public static void SelectPlayer(PlayerFileData data)
 {
     if (Main._pendingCharacterSelect != null)
     {
         Main._pendingCharacterSelect(data);
         Main._pendingCharacterSelect = null;
         return;
     }
     if (!Main.menuMultiplayer)
     {
         Main.ServerSideCharacter = false;
         Main.myPlayer = 0;
         data.SetAsActive();
         Main.player[Main.myPlayer].position = Vector2.Zero;
         Main.LoadWorlds();
         Main.menuMode = 6;
         return;
     }
     Main.ServerSideCharacter = false;
     data.SetAsActive();
     if (Main.autoJoin)
     {
         if (Netplay.SetRemoteIP(Main.getIP))
         {
             Main.menuMode = 10;
             Netplay.StartTcpClient();
         }
         Main.autoJoin = false;
         return;
     }
     if (Main.menuServer)
     {
         Main.LoadWorlds();
         Main.menuMode = 6;
         return;
     }
     Main.menuMode = 13;
     Main.ClearInput();
 }
コード例 #8
0
ファイル: Main.cs プロジェクト: hastinbe/TerrariaAPI-Server
 private static int PlayerListSortMethod(PlayerFileData data1, PlayerFileData data2)
 {
     return data1.Name.CompareTo(data2.Name);
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: hastinbe/TerrariaAPI-Server
        public static void SavePlayer(PlayerFileData playerFile, bool skipMapSave = false)
        {
            Stream memoryStream;
            Main.Achievements.Save();
            string path = playerFile.Path;
            Player player = playerFile.Player;
            if (!skipMapSave)
            {
                try
                {
                    Directory.CreateDirectory(Main.PlayerPath);
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Console.WriteLine(ex);
                    System.Diagnostics.Debugger.Break();

            #endif
                }
            }
            if (Main.ServerSideCharacter)
            {
                return;
            }
            if (path == null || path == "")
            {
                return;
            }
            if (FileUtilities.Exists(path))
            {
                FileUtilities.Copy(path, string.Concat(path, ".bak"), false, true);
            }
            RijndaelManaged rijndaelManaged = new RijndaelManaged();
            memoryStream = new FileStream(path, FileMode.Create);
            using (Stream stream = memoryStream)
            {
                using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write))
                {
                    using (BinaryWriter binaryWriter = new BinaryWriter(cryptoStream))
                    {
                        binaryWriter.Write(Main.curRelease);
                        playerFile.Metadata.Write(binaryWriter);
                        binaryWriter.Write(player.name);
                        binaryWriter.Write(player.difficulty);
                        binaryWriter.Write(playerFile.GetPlayTime().Ticks);
                        binaryWriter.Write(player.hair);
                        binaryWriter.Write(player.hairDye);
                        BitsByte bitsByte = 0;
                        for (int i = 0; i < 8; i++)
                        {
                            bitsByte[i] = player.hideVisual[i];
                        }
                        binaryWriter.Write(bitsByte);
                        bitsByte = 0;
                        for (int j = 0; j < 2; j++)
                        {
                            bitsByte[j] = player.hideVisual[j + 8];
                        }
                        binaryWriter.Write(bitsByte);
                        binaryWriter.Write(player.hideMisc);
                        binaryWriter.Write((byte)player.skinVariant);
                        binaryWriter.Write(player.statLife);
                        binaryWriter.Write(player.statLifeMax);
                        binaryWriter.Write(player.statMana);
                        binaryWriter.Write(player.statManaMax);
                        binaryWriter.Write(player.extraAccessory);
                        binaryWriter.Write(player.taxMoney);
                        binaryWriter.Write(player.hairColor.R);
                        binaryWriter.Write(player.hairColor.G);
                        binaryWriter.Write(player.hairColor.B);
                        binaryWriter.Write(player.skinColor.R);
                        binaryWriter.Write(player.skinColor.G);
                        binaryWriter.Write(player.skinColor.B);
                        binaryWriter.Write(player.eyeColor.R);
                        binaryWriter.Write(player.eyeColor.G);
                        binaryWriter.Write(player.eyeColor.B);
                        binaryWriter.Write(player.shirtColor.R);
                        binaryWriter.Write(player.shirtColor.G);
                        binaryWriter.Write(player.shirtColor.B);
                        binaryWriter.Write(player.underShirtColor.R);
                        binaryWriter.Write(player.underShirtColor.G);
                        binaryWriter.Write(player.underShirtColor.B);
                        binaryWriter.Write(player.pantsColor.R);
                        binaryWriter.Write(player.pantsColor.G);
                        binaryWriter.Write(player.pantsColor.B);
                        binaryWriter.Write(player.shoeColor.R);
                        binaryWriter.Write(player.shoeColor.G);
                        binaryWriter.Write(player.shoeColor.B);
                        for (int k = 0; k < (int)player.armor.Length; k++)
                        {
                            if (player.armor[k].name == null)
                            {
                                player.armor[k].name = "";
                            }
                            binaryWriter.Write(player.armor[k].netID);
                            binaryWriter.Write(player.armor[k].prefix);
                        }
                        for (int l = 0; l < (int)player.dye.Length; l++)
                        {
                            binaryWriter.Write(player.dye[l].netID);
                            binaryWriter.Write(player.dye[l].prefix);
                        }
                        for (int m = 0; m < 58; m++)
                        {
                            if (player.inventory[m].name == null)
                            {
                                player.inventory[m].name = "";
                            }
                            binaryWriter.Write(player.inventory[m].netID);
                            binaryWriter.Write(player.inventory[m].stack);
                            binaryWriter.Write(player.inventory[m].prefix);
                            binaryWriter.Write(player.inventory[m].favorited);
                        }
                        for (int n = 0; n < (int)player.miscEquips.Length; n++)
                        {
                            binaryWriter.Write(player.miscEquips[n].netID);
                            binaryWriter.Write(player.miscEquips[n].prefix);
                            binaryWriter.Write(player.miscDyes[n].netID);
                            binaryWriter.Write(player.miscDyes[n].prefix);
                        }
                        for (int o = 0; o < 40; o++)
                        {
                            if (player.bank.item[o].name == null)
                            {
                                player.bank.item[o].name = "";
                            }
                            binaryWriter.Write(player.bank.item[o].netID);
                            binaryWriter.Write(player.bank.item[o].stack);
                            binaryWriter.Write(player.bank.item[o].prefix);
                        }
                        for (int p = 0; p < 40; p++)
                        {
                            if (player.bank2.item[p].name == null)
                            {
                                player.bank2.item[p].name = "";
                            }
                            binaryWriter.Write(player.bank2.item[p].netID);
                            binaryWriter.Write(player.bank2.item[p].stack);
                            binaryWriter.Write(player.bank2.item[p].prefix);
                        }
                        for (int q = 0; q < 22; q++)
                        {
                            if (!Main.buffNoSave[player.buffType[q]])
                            {
                                binaryWriter.Write(player.buffType[q]);
                                binaryWriter.Write(player.buffTime[q]);
                            }
                            else
                            {
                                binaryWriter.Write(0);
                                binaryWriter.Write(0);
                            }
                        }
                        int num = 0;
                        while (num < 200)
                        {
                            if (player.spN[num] != null)
                            {
                                binaryWriter.Write(player.spX[num]);
                                binaryWriter.Write(player.spY[num]);
                                binaryWriter.Write(player.spI[num]);
                                binaryWriter.Write(player.spN[num]);
                                num++;
                            }
                            else
                            {
                                binaryWriter.Write(-1);
                                break;
                            }
                        }
                        binaryWriter.Write(player.hbLocked);
                        for (int r = 0; r < (int)player.hideInfo.Length; r++)
                        {
                            binaryWriter.Write(player.hideInfo[r]);
                        }
                        binaryWriter.Write(player.anglerQuestsFinished);
                        binaryWriter.Flush();
                        cryptoStream.FlushFinalBlock();
                        stream.Flush();
                    }
                }
            }
        }
コード例 #10
0
ファイル: Player.cs プロジェクト: hastinbe/TerrariaAPI-Server
 public static PlayerFileData LoadPlayer(string playerPath)
 {
     PlayerFileData playerFileDatum;
     PlayerFileData playerFileDatum1 = new PlayerFileData(playerPath);
     if (Main.rand == null)
     {
         Main.rand = new Random((int)DateTime.Now.Ticks);
     }
     Player player = new Player();
     try
     {
         RijndaelManaged rijndaelManaged = new RijndaelManaged()
         {
             Padding = PaddingMode.None
         };
         using (MemoryStream memoryStream = new MemoryStream(FileUtilities.ReadAllBytes(playerPath)))
         {
             using (CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Read))
             {
                 using (BinaryReader binaryReader = new BinaryReader(cryptoStream))
                 {
                     int num = binaryReader.ReadInt32();
                     if (num < 135)
                     {
                         playerFileDatum1.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
                     }
                     else
                     {
                         playerFileDatum1.Metadata = FileMetadata.Read(binaryReader, FileType.Player);
                     }
                     if (num <= Main.curRelease)
                     {
                         player.name = binaryReader.ReadString();
                         if (num >= 10)
                         {
                             if (num >= 17)
                             {
                                 player.difficulty = binaryReader.ReadByte();
                             }
                             else if (binaryReader.ReadBoolean())
                             {
                                 player.difficulty = 2;
                             }
                         }
                         if (num < 138)
                         {
                             playerFileDatum1.SetPlayTime(TimeSpan.Zero);
                         }
                         else
                         {
                             playerFileDatum1.SetPlayTime(new TimeSpan(binaryReader.ReadInt64()));
                         }
                         player.hair = binaryReader.ReadInt32();
                         if (num >= 82)
                         {
                             player.hairDye = binaryReader.ReadByte();
                         }
                         if (num >= 124)
                         {
                             BitsByte bitsByte = binaryReader.ReadByte();
                             for (int i = 0; i < 8; i++)
                             {
                                 player.hideVisual[i] = bitsByte[i];
                             }
                             bitsByte = binaryReader.ReadByte();
                             for (int j = 0; j < 2; j++)
                             {
                                 player.hideVisual[j + 8] = bitsByte[j];
                             }
                         }
                         else if (num >= 83)
                         {
                             BitsByte bitsByte1 = binaryReader.ReadByte();
                             for (int k = 0; k < 8; k++)
                             {
                                 player.hideVisual[k] = bitsByte1[k];
                             }
                         }
                         if (num >= 119)
                         {
                             player.hideMisc = binaryReader.ReadByte();
                         }
                         if (num <= 17)
                         {
                             if (player.hair == 5 || player.hair == 6 || player.hair == 9 || player.hair == 11)
                             {
                                 player.Male = false;
                             }
                             else
                             {
                                 player.Male = true;
                             }
                         }
                         else if (num >= 107)
                         {
                             player.skinVariant = binaryReader.ReadByte();
                         }
                         else
                         {
                             player.Male = binaryReader.ReadBoolean();
                         }
                         player.statLife = binaryReader.ReadInt32();
                         player.statLifeMax = binaryReader.ReadInt32();
                         if (player.statLifeMax > 500)
                         {
                             player.statLifeMax = 500;
                         }
                         player.statMana = binaryReader.ReadInt32();
                         player.statManaMax = binaryReader.ReadInt32();
                         if (player.statManaMax > 200)
                         {
                             player.statManaMax = 200;
                         }
                         if (player.statMana > 400)
                         {
                             player.statMana = 400;
                         }
                         if (num >= 125)
                         {
                             player.extraAccessory = binaryReader.ReadBoolean();
                         }
                         if (num >= 128)
                         {
                             player.taxMoney = binaryReader.ReadInt32();
                         }
                         player.hairColor = binaryReader.ReadRGB();
                         player.skinColor = binaryReader.ReadRGB();
                         player.eyeColor = binaryReader.ReadRGB();
                         player.shirtColor = binaryReader.ReadRGB();
                         player.underShirtColor = binaryReader.ReadRGB();
                         player.pantsColor = binaryReader.ReadRGB();
                         player.shoeColor = binaryReader.ReadRGB();
                         Main.player[Main.myPlayer].shirtColor = player.shirtColor;
                         Main.player[Main.myPlayer].pantsColor = player.pantsColor;
                         Main.player[Main.myPlayer].hairColor = player.hairColor;
                         if (num < 38)
                         {
                             for (int l = 0; l < 8; l++)
                             {
                                 player.armor[l].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 if (num >= 36)
                                 {
                                     player.armor[l].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             if (num >= 6)
                             {
                                 for (int m = 8; m < 11; m++)
                                 {
                                     player.armor[m].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                     if (num >= 36)
                                     {
                                         player.armor[m].Prefix((int)binaryReader.ReadByte());
                                     }
                                 }
                             }
                             for (int n = 0; n < 44; n++)
                             {
                                 player.inventory[n].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 player.inventory[n].stack = binaryReader.ReadInt32();
                                 if (num >= 36)
                                 {
                                     player.inventory[n].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             if (num >= 15)
                             {
                                 for (int o = 44; o < 48; o++)
                                 {
                                     player.inventory[o].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                     player.inventory[o].stack = binaryReader.ReadInt32();
                                     if (num >= 36)
                                     {
                                         player.inventory[o].Prefix((int)binaryReader.ReadByte());
                                     }
                                 }
                             }
                             for (int p = 0; p < 20; p++)
                             {
                                 player.bank.item[p].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 player.bank.item[p].stack = binaryReader.ReadInt32();
                                 if (num >= 36)
                                 {
                                     player.bank.item[p].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             if (num >= 20)
                             {
                                 for (int q = 0; q < 20; q++)
                                 {
                                     player.bank2.item[q].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                     player.bank2.item[q].stack = binaryReader.ReadInt32();
                                     if (num >= 36)
                                     {
                                         player.bank2.item[q].Prefix((int)binaryReader.ReadByte());
                                     }
                                 }
                             }
                         }
                         else
                         {
                             if (num >= 124)
                             {
                                 int num1 = 20;
                                 for (int r = 0; r < num1; r++)
                                 {
                                     player.armor[r].netDefaults(binaryReader.ReadInt32());
                                     player.armor[r].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             else
                             {
                                 int num2 = 11;
                                 if (num >= 81)
                                 {
                                     num2 = 16;
                                 }
                                 for (int s = 0; s < num2; s++)
                                 {
                                     int num3 = s;
                                     if (num3 >= 8)
                                     {
                                         num3 = num3 + 2;
                                     }
                                     player.armor[num3].netDefaults(binaryReader.ReadInt32());
                                     player.armor[num3].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             if (num >= 47)
                             {
                                 int num4 = 3;
                                 if (num >= 81)
                                 {
                                     num4 = 8;
                                 }
                                 if (num >= 124)
                                 {
                                     num4 = 10;
                                 }
                                 for (int t = 0; t < num4; t++)
                                 {
                                     int num5 = t;
                                     player.dye[num5].netDefaults(binaryReader.ReadInt32());
                                     player.dye[num5].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             if (num < 58)
                             {
                                 for (int u = 0; u < 48; u++)
                                 {
                                     int num6 = binaryReader.ReadInt32();
                                     if (num6 < Main.maxItemTypes)
                                     {
                                         player.inventory[u].netDefaults(num6);
                                         player.inventory[u].stack = binaryReader.ReadInt32();
                                         player.inventory[u].Prefix((int)binaryReader.ReadByte());
                                     }
                                     else
                                     {
                                         player.inventory[u].netDefaults(0);
                                     }
                                 }
                             }
                             else
                             {
                                 for (int v = 0; v < 58; v++)
                                 {
                                     int num7 = binaryReader.ReadInt32();
                                     if (num7 < Main.maxItemTypes)
                                     {
                                         player.inventory[v].netDefaults(num7);
                                         player.inventory[v].stack = binaryReader.ReadInt32();
                                         player.inventory[v].Prefix((int)binaryReader.ReadByte());
                                         if (num >= 114)
                                         {
                                             player.inventory[v].favorited = binaryReader.ReadBoolean();
                                         }
                                     }
                                     else
                                     {
                                         player.inventory[v].netDefaults(0);
                                     }
                                 }
                             }
                             if (num >= 117)
                             {
                                 if (num >= 136)
                                 {
                                     for (int w = 0; w < 5; w++)
                                     {
                                         int num8 = binaryReader.ReadInt32();
                                         if (num8 < Main.maxItemTypes)
                                         {
                                             player.miscEquips[w].netDefaults(num8);
                                             player.miscEquips[w].Prefix((int)binaryReader.ReadByte());
                                         }
                                         else
                                         {
                                             player.miscEquips[w].netDefaults(0);
                                         }
                                         num8 = binaryReader.ReadInt32();
                                         if (num8 < Main.maxItemTypes)
                                         {
                                             player.miscDyes[w].netDefaults(num8);
                                             player.miscDyes[w].Prefix((int)binaryReader.ReadByte());
                                         }
                                         else
                                         {
                                             player.miscDyes[w].netDefaults(0);
                                         }
                                     }
                                 }
                                 else
                                 {
                                     for (int x = 0; x < 5; x++)
                                     {
                                         if (x != 1)
                                         {
                                             int num9 = binaryReader.ReadInt32();
                                             if (num9 < Main.maxItemTypes)
                                             {
                                                 player.miscEquips[x].netDefaults(num9);
                                                 player.miscEquips[x].Prefix((int)binaryReader.ReadByte());
                                             }
                                             else
                                             {
                                                 player.miscEquips[x].netDefaults(0);
                                             }
                                             num9 = binaryReader.ReadInt32();
                                             if (num9 < Main.maxItemTypes)
                                             {
                                                 player.miscDyes[x].netDefaults(num9);
                                                 player.miscDyes[x].Prefix((int)binaryReader.ReadByte());
                                             }
                                             else
                                             {
                                                 player.miscDyes[x].netDefaults(0);
                                             }
                                         }
                                     }
                                 }
                             }
                             if (num < 58)
                             {
                                 for (int y = 0; y < 20; y++)
                                 {
                                     player.bank.item[y].netDefaults(binaryReader.ReadInt32());
                                     player.bank.item[y].stack = binaryReader.ReadInt32();
                                     player.bank.item[y].Prefix((int)binaryReader.ReadByte());
                                 }
                                 for (int a = 0; a < 20; a++)
                                 {
                                     player.bank2.item[a].netDefaults(binaryReader.ReadInt32());
                                     player.bank2.item[a].stack = binaryReader.ReadInt32();
                                     player.bank2.item[a].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                             else
                             {
                                 for (int b = 0; b < 40; b++)
                                 {
                                     player.bank.item[b].netDefaults(binaryReader.ReadInt32());
                                     player.bank.item[b].stack = binaryReader.ReadInt32();
                                     player.bank.item[b].Prefix((int)binaryReader.ReadByte());
                                 }
                                 for (int c = 0; c < 40; c++)
                                 {
                                     player.bank2.item[c].netDefaults(binaryReader.ReadInt32());
                                     player.bank2.item[c].stack = binaryReader.ReadInt32();
                                     player.bank2.item[c].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                         if (num < 58)
                         {
                             for (int d = 40; d < 48; d++)
                             {
                                 player.inventory[d + 10] = player.inventory[d].Clone();
                                 player.inventory[d].SetDefaults(0, false);
                             }
                         }
                         if (num >= 11)
                         {
                             int num10 = 22;
                             if (num < 74)
                             {
                                 num10 = 10;
                             }
                             for (int e = 0; e < num10; e++)
                             {
                                 player.buffType[e] = binaryReader.ReadInt32();
                                 player.buffTime[e] = binaryReader.ReadInt32();
                                 if (player.buffType[e] == 0)
                                 {
                                     e--;
                                     num10--;
                                 }
                             }
                         }
                         for (int f = 0; f < 200; f++)
                         {
                             int num11 = binaryReader.ReadInt32();
                             if (num11 == -1)
                             {
                                 break;
                             }
                             player.spX[f] = num11;
                             player.spY[f] = binaryReader.ReadInt32();
                             player.spI[f] = binaryReader.ReadInt32();
                             player.spN[f] = binaryReader.ReadString();
                         }
                         if (num >= 16)
                         {
                             player.hbLocked = binaryReader.ReadBoolean();
                         }
                         if (num >= 115)
                         {
                             int num12 = 13;
                             for (int g = 0; g < num12; g++)
                             {
                                 player.hideInfo[g] = binaryReader.ReadBoolean();
                             }
                         }
                         if (num >= 98)
                         {
                             player.anglerQuestsFinished = binaryReader.ReadInt32();
                         }
                         player.skinVariant = (int)MathHelper.Clamp((float)player.skinVariant, 0f, 7f);
                         for (int h = 3; h < 8 + player.extraAccessorySlots; h++)
                         {
                             int num13 = player.armor[h].type;
                             if (num13 == 908)
                             {
                                 Player player1 = player;
                                 player1.lavaMax = player1.lavaMax + 420;
                             }
                             if (num13 == 906)
                             {
                                 Player player2 = player;
                                 player2.lavaMax = player2.lavaMax + 420;
                             }
                             if (player.wingsLogic == 0 && player.armor[h].wingSlot >= 0)
                             {
                                 player.wingsLogic = player.armor[h].wingSlot;
                             }
                             if (num13 == 158 || num13 == 396 || num13 == 1250 || num13 == 1251 || num13 == 1252)
                             {
                                 player.noFallDmg = true;
                             }
                             player.lavaTime = player.lavaMax;
                         }
                     }
                     else
                     {
                         player.loadStatus = 1;
                         player.name = binaryReader.ReadString();
                         playerFileDatum1.Player = player;
                         playerFileDatum = playerFileDatum1;
                         return playerFileDatum;
                     }
                 }
             }
         }
         player.PlayerFrame();
         player.loadStatus = 0;
         playerFileDatum1.Player = player;
         playerFileDatum = playerFileDatum1;
     }
     catch
     {
         Player player3 = new Player()
         {
             loadStatus = 2
         };
         if (player.name == "")
         {
             char[] directorySeparatorChar = new char[] { Path.DirectorySeparatorChar };
             string[] strArrays = playerPath.Split(directorySeparatorChar);
             string str = strArrays[(int)strArrays.Length - 1];
             char[] chrArray = new char[] { '.' };
             player.name = str.Split(chrArray)[0];
         }
         else
         {
             player3.name = player.name;
         }
         playerFileDatum1.Player = player3;
         return playerFileDatum1;
     }
     return playerFileDatum;
 }
コード例 #11
0
        /// <summary>
        /// Save mod data to a .plr.prism file
        /// </summary>
        /// <param name="playerFile">The player being saved</param>
        internal static void SavePlayer(PlayerFileData playerFile)
        {
            string path = playerFile.Path;
            Player player = playerFile.Player;

            if (Main.ServerSideCharacter || String.IsNullOrEmpty(path))
                return;

            path += ".prism";

            if (File.Exists(path))
                File.Copy(path, playerFile.Path + ".bak.prism", true);

            using (FileStream fileStream = new FileStream(path, FileMode.Create))
            {
                fileStream.WriteByte(PLAYER_VERSION); // write this before doing the crypto stuff, so we can change it between versions

                // can't we just get rid of this?
                using (CryptoStream cryptoStream = new CryptoStream(fileStream, new RijndaelManaged() /*{ Padding = PaddingMode.None }*/.CreateEncryptor(GenerateKey(player.name), ENCRYPTION_KEY), CryptoStreamMode.Write))
                using (BinBuffer bb = new BinBuffer(cryptoStream))
                {
                    #region Player Data
                    if (player.P_BHandler != null)
                    {
                        var bh = (PlayerBHandler)player.P_BHandler;

                        bh.Save(bb);
                    }
                    else
                        bb.Write(0);
                    #endregion Player Data

                    #region Item Data
                    SaveItemSlots(bb, player.armor, player.armor.Length, false, false);
                    SaveItemSlots(bb, player.dye, player.dye.Length, false, false);
                    SaveItemSlots(bb, player.inventory, Main.maxInventory, true, true);
                    SaveItemSlots(bb, player.miscEquips, player.miscEquips.Length, false, false);
                    SaveItemSlots(bb, player.bank.item, Chest.maxItems, true, false);
                    SaveItemSlots(bb, player.bank2.item, Chest.maxItems, true, false);
                    #endregion Item Data

                    #region Buff Data
                    for (int i = 0; i < Player.maxBuffs; i++)
                    {
                        if (Main.buffNoSave[player.buffType[i]] || player.buffType[i] < BuffID.Count || player.buffTime[i] <= 0)
                            bb.Write(String.Empty);
                        else
                        {
                            var buff = Handler.BuffDef.DefsByType[player.buffType[i]];

                            bb.Write(buff.Mod.InternalName);
                            bb.Write(buff.InternalName);
                            bb.Write(player.buffTime[i]);
                        }

                        if (player.P_BuffBHandler[i] != null)
                        {
                            var bh = (BuffBHandler)player.P_BuffBHandler[i];

                            bh.Save(bb);
                        }
                        else
                            bb.Write(0);
                    }
                    #endregion Buff Data
                }
            }
        }
コード例 #12
0
ファイル: Player.cs プロジェクト: EmuDevs/EDTerraria
 public static void SavePlayer(PlayerFileData playerFile, bool skipMapSave = false)
 {
     Main.Achievements.Save();
     string path = playerFile.Path;
     Player player = playerFile.Player;
     if (!skipMapSave)
     {
         try
         {
             if (Main.mapEnabled)
                 Main.Map.Save();
             Directory.CreateDirectory(Main.PlayerPath);
         }
         catch
         {
         }
     }
     if (Main.ServerSideCharacter || path == null || path == "")
         return;
     if (FileUtilities.Exists(path))
         FileUtilities.Copy(path, path + ".bak");
     RijndaelManaged rijndaelManaged = new RijndaelManaged();
     using (Stream stream = new FileStream(path, FileMode.Create))
     {
         using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write))
         {
             using (BinaryWriter writer = new BinaryWriter(cryptoStream))
             {
                 writer.Write(Main.curRelease);
                 playerFile.Metadata.Write(writer);
                 writer.Write(player.name);
                 writer.Write(player.difficulty);
                 writer.Write(playerFile.GetPlayTime().Ticks);
                 writer.Write(player.hair);
                 writer.Write(player.hairDye);
                 BitsByte bitsByte1 = (BitsByte)(byte)0;
                 for (int index = 0; index < 8; ++index)
                     bitsByte1[index] = player.hideVisual[index];
                 writer.Write((byte)bitsByte1);
                 BitsByte bitsByte2 = (BitsByte)(byte)0;
                 for (int index = 0; index < 2; ++index)
                     bitsByte2[index] = player.hideVisual[index + 8];
                 writer.Write((byte)bitsByte2);
                 writer.Write((byte)player.hideMisc);
                 writer.Write((byte)player.skinVariant);
                 writer.Write(player.statLife);
                 writer.Write(player.statLifeMax);
                 writer.Write(player.statMana);
                 writer.Write(player.statManaMax);
                 writer.Write(player.extraAccessory);
                 writer.Write(player.taxMoney);
                 writer.Write(player.hairColor.R);
                 writer.Write(player.hairColor.G);
                 writer.Write(player.hairColor.B);
                 writer.Write(player.skinColor.R);
                 writer.Write(player.skinColor.G);
                 writer.Write(player.skinColor.B);
                 writer.Write(player.eyeColor.R);
                 writer.Write(player.eyeColor.G);
                 writer.Write(player.eyeColor.B);
                 writer.Write(player.shirtColor.R);
                 writer.Write(player.shirtColor.G);
                 writer.Write(player.shirtColor.B);
                 writer.Write(player.underShirtColor.R);
                 writer.Write(player.underShirtColor.G);
                 writer.Write(player.underShirtColor.B);
                 writer.Write(player.pantsColor.R);
                 writer.Write(player.pantsColor.G);
                 writer.Write(player.pantsColor.B);
                 writer.Write(player.shoeColor.R);
                 writer.Write(player.shoeColor.G);
                 writer.Write(player.shoeColor.B);
                 for (int index = 0; index < player.armor.Length; ++index)
                 {
                     if (player.armor[index].name == null)
                         player.armor[index].name = "";
                     writer.Write(player.armor[index].netID);
                     writer.Write(player.armor[index].prefix);
                 }
                 for (int index = 0; index < player.dye.Length; ++index)
                 {
                     writer.Write(player.dye[index].netID);
                     writer.Write(player.dye[index].prefix);
                 }
                 for (int index = 0; index < 58; ++index)
                 {
                     if (player.inventory[index].name == null)
                         player.inventory[index].name = "";
                     writer.Write(player.inventory[index].netID);
                     writer.Write(player.inventory[index].stack);
                     writer.Write(player.inventory[index].prefix);
                     writer.Write(player.inventory[index].favorited);
                 }
                 for (int index = 0; index < player.miscEquips.Length; ++index)
                 {
                     writer.Write(player.miscEquips[index].netID);
                     writer.Write(player.miscEquips[index].prefix);
                     writer.Write(player.miscDyes[index].netID);
                     writer.Write(player.miscDyes[index].prefix);
                 }
                 for (int index = 0; index < 40; ++index)
                 {
                     if (player.bank.item[index].name == null)
                         player.bank.item[index].name = "";
                     writer.Write(player.bank.item[index].netID);
                     writer.Write(player.bank.item[index].stack);
                     writer.Write(player.bank.item[index].prefix);
                 }
                 for (int index = 0; index < 40; ++index)
                 {
                     if (player.bank2.item[index].name == null)
                         player.bank2.item[index].name = "";
                     writer.Write(player.bank2.item[index].netID);
                     writer.Write(player.bank2.item[index].stack);
                     writer.Write(player.bank2.item[index].prefix);
                 }
                 for (int index = 0; index < 22; ++index)
                 {
                     if (Main.buffNoSave[player.buffType[index]])
                     {
                         writer.Write(0);
                         writer.Write(0);
                     }
                     else
                     {
                         writer.Write(player.buffType[index]);
                         writer.Write(player.buffTime[index]);
                     }
                 }
                 for (int index = 0; index < 200; ++index)
                 {
                     if (player.spN[index] == null)
                     {
                         writer.Write(-1);
                         break;
                     }
                     writer.Write(player.spX[index]);
                     writer.Write(player.spY[index]);
                     writer.Write(player.spI[index]);
                     writer.Write(player.spN[index]);
                 }
                 writer.Write(player.hbLocked);
                 for (int index = 0; index < player.hideInfo.Length; ++index)
                     writer.Write(player.hideInfo[index]);
                 writer.Write(player.anglerQuestsFinished);
                 writer.Flush();
                 cryptoStream.FlushFinalBlock();
                 stream.Flush();
             }
         }
     }
 }
コード例 #13
0
ファイル: Player.cs プロジェクト: EmuDevs/EDTerraria
 public static PlayerFileData LoadPlayer(string playerPath, bool cloudSave)
 {
     PlayerFileData playerFileData = new PlayerFileData(playerPath);
     if (Main.rand == null)
         Main.rand = new Random((int)DateTime.Now.Ticks);
     Player player1 = new Player();
     try
     {
         RijndaelManaged rijndaelManaged = new RijndaelManaged();
         rijndaelManaged.Padding = PaddingMode.None;
         using (MemoryStream memoryStream = new MemoryStream(FileUtilities.ReadAllBytes(playerPath)))
         {
             using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, rijndaelManaged.CreateDecryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Read))
             {
                 using (BinaryReader binaryReader = new BinaryReader((Stream)cryptoStream))
                 {
                     int release = binaryReader.ReadInt32();
                     if (release >= 135)
                         playerFileData.Metadata = FileMetadata.Read(binaryReader, FileType.Player);
                     else
                         playerFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
                     if (release > Main.curRelease)
                     {
                         player1.loadStatus = 1;
                         player1.name = binaryReader.ReadString();
                         playerFileData.Player = player1;
                         return playerFileData;
                     }
                     player1.name = binaryReader.ReadString();
                     if (release >= 10)
                     {
                         if (release >= 17)
                             player1.difficulty = binaryReader.ReadByte();
                         else if (binaryReader.ReadBoolean())
                             player1.difficulty = (byte)2;
                     }
                     if (release >= 138)
                         playerFileData.SetPlayTime(new TimeSpan(binaryReader.ReadInt64()));
                     else
                         playerFileData.SetPlayTime(TimeSpan.Zero);
                     player1.hair = binaryReader.ReadInt32();
                     if (release >= 82)
                         player1.hairDye = binaryReader.ReadByte();
                     if (release >= 124)
                     {
                         BitsByte bitsByte = (BitsByte)binaryReader.ReadByte();
                         for (int index = 0; index < 8; ++index)
                             player1.hideVisual[index] = bitsByte[index];
                         bitsByte = (BitsByte)binaryReader.ReadByte();
                         for (int index = 0; index < 2; ++index)
                             player1.hideVisual[index + 8] = bitsByte[index];
                     }
                     else if (release >= 83)
                     {
                         BitsByte bitsByte = (BitsByte)binaryReader.ReadByte();
                         for (int index = 0; index < 8; ++index)
                             player1.hideVisual[index] = bitsByte[index];
                     }
                     if (release >= 119)
                         player1.hideMisc = (BitsByte)binaryReader.ReadByte();
                     if (release <= 17)
                         player1.Male = player1.hair != 5 && player1.hair != 6 && (player1.hair != 9 && player1.hair != 11);
                     else if (release < 107)
                         player1.Male = binaryReader.ReadBoolean();
                     else
                         player1.skinVariant = (int)binaryReader.ReadByte();
                     player1.statLife = binaryReader.ReadInt32();
                     player1.statLifeMax = binaryReader.ReadInt32();
                     if (player1.statLifeMax > 500)
                         player1.statLifeMax = 500;
                     player1.statMana = binaryReader.ReadInt32();
                     player1.statManaMax = binaryReader.ReadInt32();
                     if (player1.statManaMax > 200)
                         player1.statManaMax = 200;
                     if (player1.statMana > 400)
                         player1.statMana = 400;
                     if (release >= 125)
                         player1.extraAccessory = binaryReader.ReadBoolean();
                     if (release >= 128)
                         player1.taxMoney = binaryReader.ReadInt32();
                     player1.hairColor = Utils.ReadRGB(binaryReader);
                     player1.skinColor = Utils.ReadRGB(binaryReader);
                     player1.eyeColor = Utils.ReadRGB(binaryReader);
                     player1.shirtColor = Utils.ReadRGB(binaryReader);
                     player1.underShirtColor = Utils.ReadRGB(binaryReader);
                     player1.pantsColor = Utils.ReadRGB(binaryReader);
                     player1.shoeColor = Utils.ReadRGB(binaryReader);
                     Main.player[Main.myPlayer].shirtColor = player1.shirtColor;
                     Main.player[Main.myPlayer].pantsColor = player1.pantsColor;
                     Main.player[Main.myPlayer].hairColor = player1.hairColor;
                     if (release >= 38)
                     {
                         if (release < 124)
                         {
                             int num = 11;
                             if (release >= 81)
                                 num = 16;
                             for (int index1 = 0; index1 < num; ++index1)
                             {
                                 int index2 = index1;
                                 if (index2 >= 8)
                                     index2 += 2;
                                 player1.armor[index2].netDefaults(binaryReader.ReadInt32());
                                 player1.armor[index2].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         else
                         {
                             int num = 20;
                             for (int index = 0; index < num; ++index)
                             {
                                 player1.armor[index].netDefaults(binaryReader.ReadInt32());
                                 player1.armor[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (release >= 47)
                         {
                             int num = 3;
                             if (release >= 81)
                                 num = 8;
                             if (release >= 124)
                                 num = 10;
                             for (int index1 = 0; index1 < num; ++index1)
                             {
                                 int index2 = index1;
                                 player1.dye[index2].netDefaults(binaryReader.ReadInt32());
                                 player1.dye[index2].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (release >= 58)
                         {
                             for (int index = 0; index < 58; ++index)
                             {
                                 int type = binaryReader.ReadInt32();
                                 if (type >= 3601)
                                 {
                                     player1.inventory[index].netDefaults(0);
                                 }
                                 else
                                 {
                                     player1.inventory[index].netDefaults(type);
                                     player1.inventory[index].stack = binaryReader.ReadInt32();
                                     player1.inventory[index].Prefix((int)binaryReader.ReadByte());
                                     if (release >= 114)
                                         player1.inventory[index].favorited = binaryReader.ReadBoolean();
                                 }
                             }
                         }
                         else
                         {
                             for (int index = 0; index < 48; ++index)
                             {
                                 int type = binaryReader.ReadInt32();
                                 if (type >= 3601)
                                 {
                                     player1.inventory[index].netDefaults(0);
                                 }
                                 else
                                 {
                                     player1.inventory[index].netDefaults(type);
                                     player1.inventory[index].stack = binaryReader.ReadInt32();
                                     player1.inventory[index].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                         if (release >= 117)
                         {
                             if (release < 136)
                             {
                                 for (int index = 0; index < 5; ++index)
                                 {
                                     if (index != 1)
                                     {
                                         int type1 = binaryReader.ReadInt32();
                                         if (type1 >= 3601)
                                         {
                                             player1.miscEquips[index].netDefaults(0);
                                         }
                                         else
                                         {
                                             player1.miscEquips[index].netDefaults(type1);
                                             player1.miscEquips[index].Prefix((int)binaryReader.ReadByte());
                                         }
                                         int type2 = binaryReader.ReadInt32();
                                         if (type2 >= 3601)
                                         {
                                             player1.miscDyes[index].netDefaults(0);
                                         }
                                         else
                                         {
                                             player1.miscDyes[index].netDefaults(type2);
                                             player1.miscDyes[index].Prefix((int)binaryReader.ReadByte());
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 for (int index = 0; index < 5; ++index)
                                 {
                                     int type1 = binaryReader.ReadInt32();
                                     if (type1 >= 3601)
                                     {
                                         player1.miscEquips[index].netDefaults(0);
                                     }
                                     else
                                     {
                                         player1.miscEquips[index].netDefaults(type1);
                                         player1.miscEquips[index].Prefix((int)binaryReader.ReadByte());
                                     }
                                     int type2 = binaryReader.ReadInt32();
                                     if (type2 >= 3601)
                                     {
                                         player1.miscDyes[index].netDefaults(0);
                                     }
                                     else
                                     {
                                         player1.miscDyes[index].netDefaults(type2);
                                         player1.miscDyes[index].Prefix((int)binaryReader.ReadByte());
                                     }
                                 }
                             }
                         }
                         if (release >= 58)
                         {
                             for (int index = 0; index < 40; ++index)
                             {
                                 player1.bank.item[index].netDefaults(binaryReader.ReadInt32());
                                 player1.bank.item[index].stack = binaryReader.ReadInt32();
                                 player1.bank.item[index].Prefix((int)binaryReader.ReadByte());
                             }
                             for (int index = 0; index < 40; ++index)
                             {
                                 player1.bank2.item[index].netDefaults(binaryReader.ReadInt32());
                                 player1.bank2.item[index].stack = binaryReader.ReadInt32();
                                 player1.bank2.item[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         else
                         {
                             for (int index = 0; index < 20; ++index)
                             {
                                 player1.bank.item[index].netDefaults(binaryReader.ReadInt32());
                                 player1.bank.item[index].stack = binaryReader.ReadInt32();
                                 player1.bank.item[index].Prefix((int)binaryReader.ReadByte());
                             }
                             for (int index = 0; index < 20; ++index)
                             {
                                 player1.bank2.item[index].netDefaults(binaryReader.ReadInt32());
                                 player1.bank2.item[index].stack = binaryReader.ReadInt32();
                                 player1.bank2.item[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     else
                     {
                         for (int index = 0; index < 8; ++index)
                         {
                             player1.armor[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                             if (release >= 36)
                                 player1.armor[index].Prefix((int)binaryReader.ReadByte());
                         }
                         if (release >= 6)
                         {
                             for (int index = 8; index < 11; ++index)
                             {
                                 player1.armor[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                                 if (release >= 36)
                                     player1.armor[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         for (int index = 0; index < 44; ++index)
                         {
                             player1.inventory[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                             player1.inventory[index].stack = binaryReader.ReadInt32();
                             if (release >= 36)
                                 player1.inventory[index].Prefix((int)binaryReader.ReadByte());
                         }
                         if (release >= 15)
                         {
                             for (int index = 44; index < 48; ++index)
                             {
                                 player1.inventory[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                                 player1.inventory[index].stack = binaryReader.ReadInt32();
                                 if (release >= 36)
                                     player1.inventory[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         for (int index = 0; index < 20; ++index)
                         {
                             player1.bank.item[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                             player1.bank.item[index].stack = binaryReader.ReadInt32();
                             if (release >= 36)
                                 player1.bank.item[index].Prefix((int)binaryReader.ReadByte());
                         }
                         if (release >= 20)
                         {
                             for (int index = 0; index < 20; ++index)
                             {
                                 player1.bank2.item[index].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                                 player1.bank2.item[index].stack = binaryReader.ReadInt32();
                                 if (release >= 36)
                                     player1.bank2.item[index].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     if (release < 58)
                     {
                         for (int index = 40; index < 48; ++index)
                         {
                             player1.inventory[index + 10] = player1.inventory[index].Clone();
                             player1.inventory[index].SetDefaults(0, false);
                         }
                     }
                     if (release >= 11)
                     {
                         int num = 22;
                         if (release < 74)
                             num = 10;
                         for (int index = 0; index < num; ++index)
                         {
                             player1.buffType[index] = binaryReader.ReadInt32();
                             player1.buffTime[index] = binaryReader.ReadInt32();
                             if (player1.buffType[index] == 0)
                             {
                                 --index;
                                 --num;
                             }
                         }
                     }
                     for (int index = 0; index < 200; ++index)
                     {
                         int num = binaryReader.ReadInt32();
                         if (num != -1)
                         {
                             player1.spX[index] = num;
                             player1.spY[index] = binaryReader.ReadInt32();
                             player1.spI[index] = binaryReader.ReadInt32();
                             player1.spN[index] = binaryReader.ReadString();
                         }
                         else
                             break;
                     }
                     if (release >= 16)
                         player1.hbLocked = binaryReader.ReadBoolean();
                     if (release >= 115)
                     {
                         int num = 13;
                         for (int index = 0; index < num; ++index)
                             player1.hideInfo[index] = binaryReader.ReadBoolean();
                     }
                     if (release >= 98)
                         player1.anglerQuestsFinished = binaryReader.ReadInt32();
                     player1.skinVariant = (int)MathHelper.Clamp((float)player1.skinVariant, 0.0f, 7f);
                     for (int index = 3; index < 8 + player1.extraAccessorySlots; ++index)
                     {
                         int num = player1.armor[index].itemId;
                         if (num == 908)
                             player1.lavaMax += 420;
                         if (num == 906)
                             player1.lavaMax += 420;
                         if (player1.wingsLogic == 0 && (int)player1.armor[index].wingSlot >= 0)
                             player1.wingsLogic = (int)player1.armor[index].wingSlot;
                         if (num == 158 || num == 396 || (num == 1250 || num == 1251) || num == 1252)
                             player1.noFallDmg = true;
                         player1.lavaTime = player1.lavaMax;
                     }
                 }
             }
         }
         player1.PlayerFrame();
         player1.loadStatus = 0;
         playerFileData.Player = player1;
         return playerFileData;
     }
     catch
     {
     }
     Player player2 = new Player();
     player2.loadStatus = 2;
     if (player1.name != "")
     {
         player2.name = player1.name;
     }
     else
     {
         string[] strArray = playerPath.Split(Path.DirectorySeparatorChar);
         player1.name = strArray[strArray.Length - 1].Split('.')[0];
     }
     playerFileData.Player = player2;
     return playerFileData;
 }
コード例 #14
0
ファイル: Player.cs プロジェクト: itamargreen/ModLoader
 public static void SavePlayer(PlayerFileData playerFile, bool skipMapSave = false)
 {
     Main.Achievements.Save();
     string path = playerFile.Path;
     Player player = playerFile.Player;
     bool isCloudSave = playerFile.IsCloudSave;
     if (!skipMapSave)
     {
         try
         {
             if (Main.mapEnabled)
             {
                 Main.Map.Save();
             }
         }
         catch
         {
         }
         try
         {
             if (!isCloudSave)
             {
                 Directory.CreateDirectory(Main.PlayerPath);
             }
         }
         catch
         {
         }
     }
     if (Main.ServerSideCharacter)
     {
         return;
     }
     if (path == null || path == "")
     {
         return;
     }
     if (FileUtilities.Exists(path, isCloudSave))
     {
         FileUtilities.Copy(path, path + ".bak", isCloudSave, true);
     }
     RijndaelManaged rijndaelManaged = new RijndaelManaged();
     using (Stream stream = isCloudSave ? (Stream)new MemoryStream(2000) : (Stream)new FileStream(path, FileMode.Create))
     {
         using (CryptoStream cryptoStream = new CryptoStream(stream, rijndaelManaged.CreateEncryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Write))
         {
             using (BinaryWriter binaryWriter = new BinaryWriter(cryptoStream))
             {
                 binaryWriter.Write(Main.curRelease);
                 playerFile.Metadata.Write(binaryWriter);
                 binaryWriter.Write(player.name);
                 binaryWriter.Write(player.difficulty);
                 binaryWriter.Write(playerFile.GetPlayTime().Ticks);
                 binaryWriter.Write(player.hair);
                 binaryWriter.Write(player.hairDye);
                 BitsByte bb = 0;
                 for (int i = 0; i < 8; i++)
                 {
                     bb[i] = player.hideVisual[i];
                 }
                 binaryWriter.Write(bb);
                 bb = 0;
                 for (int j = 0; j < 2; j++)
                 {
                     bb[j] = player.hideVisual[j + 8];
                 }
                 binaryWriter.Write(bb);
                 binaryWriter.Write(player.hideMisc);
                 binaryWriter.Write((byte)player.skinVariant);
                 binaryWriter.Write(player.statLife);
                 binaryWriter.Write(player.statLifeMax);
                 binaryWriter.Write(player.statMana);
                 binaryWriter.Write(player.statManaMax);
                 binaryWriter.Write(player.extraAccessory);
                 binaryWriter.Write(player.taxMoney);
                 binaryWriter.Write(player.hairColor.R);
                 binaryWriter.Write(player.hairColor.G);
                 binaryWriter.Write(player.hairColor.B);
                 binaryWriter.Write(player.skinColor.R);
                 binaryWriter.Write(player.skinColor.G);
                 binaryWriter.Write(player.skinColor.B);
                 binaryWriter.Write(player.eyeColor.R);
                 binaryWriter.Write(player.eyeColor.G);
                 binaryWriter.Write(player.eyeColor.B);
                 binaryWriter.Write(player.shirtColor.R);
                 binaryWriter.Write(player.shirtColor.G);
                 binaryWriter.Write(player.shirtColor.B);
                 binaryWriter.Write(player.underShirtColor.R);
                 binaryWriter.Write(player.underShirtColor.G);
                 binaryWriter.Write(player.underShirtColor.B);
                 binaryWriter.Write(player.pantsColor.R);
                 binaryWriter.Write(player.pantsColor.G);
                 binaryWriter.Write(player.pantsColor.B);
                 binaryWriter.Write(player.shoeColor.R);
                 binaryWriter.Write(player.shoeColor.G);
                 binaryWriter.Write(player.shoeColor.B);
                 for (int k = 0; k < player.armor.Length; k++)
                 {
                     if (player.armor[k].name == null)
                     {
                         player.armor[k].name = "";
                     }
                     binaryWriter.Write(player.armor[k].netID);
                     binaryWriter.Write(player.armor[k].prefix);
                 }
                 for (int l = 0; l < player.dye.Length; l++)
                 {
                     binaryWriter.Write(player.dye[l].netID);
                     binaryWriter.Write(player.dye[l].prefix);
                 }
                 for (int m = 0; m < 58; m++)
                 {
                     if (player.inventory[m].name == null)
                     {
                         player.inventory[m].name = "";
                     }
                     binaryWriter.Write(player.inventory[m].netID);
                     binaryWriter.Write(player.inventory[m].stack);
                     binaryWriter.Write(player.inventory[m].prefix);
                     binaryWriter.Write(player.inventory[m].favorited);
                 }
                 for (int n = 0; n < player.miscEquips.Length; n++)
                 {
                     binaryWriter.Write(player.miscEquips[n].netID);
                     binaryWriter.Write(player.miscEquips[n].prefix);
                     binaryWriter.Write(player.miscDyes[n].netID);
                     binaryWriter.Write(player.miscDyes[n].prefix);
                 }
                 for (int num = 0; num < 40; num++)
                 {
                     if (player.bank.item[num].name == null)
                     {
                         player.bank.item[num].name = "";
                     }
                     binaryWriter.Write(player.bank.item[num].netID);
                     binaryWriter.Write(player.bank.item[num].stack);
                     binaryWriter.Write(player.bank.item[num].prefix);
                 }
                 for (int num2 = 0; num2 < 40; num2++)
                 {
                     if (player.bank2.item[num2].name == null)
                     {
                         player.bank2.item[num2].name = "";
                     }
                     binaryWriter.Write(player.bank2.item[num2].netID);
                     binaryWriter.Write(player.bank2.item[num2].stack);
                     binaryWriter.Write(player.bank2.item[num2].prefix);
                 }
                 for (int num3 = 0; num3 < 22; num3++)
                 {
                     if (Main.buffNoSave[player.buffType[num3]])
                     {
                         binaryWriter.Write(0);
                         binaryWriter.Write(0);
                     }
                     else
                     {
                         binaryWriter.Write(player.buffType[num3]);
                         binaryWriter.Write(player.buffTime[num3]);
                     }
                 }
                 for (int num4 = 0; num4 < 200; num4++)
                 {
                     if (player.spN[num4] == null)
                     {
                         binaryWriter.Write(-1);
                         break;
                     }
                     binaryWriter.Write(player.spX[num4]);
                     binaryWriter.Write(player.spY[num4]);
                     binaryWriter.Write(player.spI[num4]);
                     binaryWriter.Write(player.spN[num4]);
                 }
                 binaryWriter.Write(player.hbLocked);
                 for (int num5 = 0; num5 < player.hideInfo.Length; num5++)
                 {
                     binaryWriter.Write(player.hideInfo[num5]);
                 }
                 binaryWriter.Write(player.anglerQuestsFinished);
                 binaryWriter.Flush();
                 cryptoStream.FlushFinalBlock();
                 stream.Flush();
                 if (isCloudSave && SocialAPI.Cloud != null)
                 {
                     SocialAPI.Cloud.Write(playerFile.Path, ((MemoryStream)stream).ToArray());
                 }
             }
         }
     }
 }
コード例 #15
0
		public UICharacterListItem(PlayerFileData data)
		{
			this.BorderColor = new Color(89, 116, 213) * 0.7f;
			this._dividerTexture = TextureManager.Load("Images/UI/Divider");
			this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
			this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
			this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
			this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
			this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
			this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
			this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
			this.Height.Set(96f, 0f);
			this.Width.Set(0f, 1f);
			base.SetPadding(6f);
			this._data = data;
			this._playerPanel = new UICharacter(data.Player);
			this._playerPanel.Left.Set(4f, 0f);
			this._playerPanel.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
			base.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
			base.Append(this._playerPanel);
			UIImageButton uIImageButton = new UIImageButton(this._buttonPlayTexture);
			uIImageButton.VAlign = 1f;
			uIImageButton.Left.Set(4f, 0f);
			uIImageButton.OnClick += new UIElement.MouseEvent(this.PlayGame);
			uIImageButton.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
			uIImageButton.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
			base.Append(uIImageButton);
			UIImageButton uIImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
			uIImageButton2.VAlign = 1f;
			uIImageButton2.Left.Set(28f, 0f);
			uIImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
			uIImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
			uIImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
			uIImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
			base.Append(uIImageButton2);
			if (SocialAPI.Cloud != null)
			{
				UIImageButton uIImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
				uIImageButton3.VAlign = 1f;
				uIImageButton3.Left.Set(52f, 0f);
				uIImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
				uIImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
				uIImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
				base.Append(uIImageButton3);
			}
			UIImageButton uIImageButton4 = new UIImageButton(this._buttonDeleteTexture);
			uIImageButton4.VAlign = 1f;
			uIImageButton4.HAlign = 1f;
			uIImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
			uIImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
			uIImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
			this._deleteButton = uIImageButton4;
			if (!this._data.IsFavorite)
			{
				base.Append(uIImageButton4);
			}
			this._buttonLabel = new UIText("", 1f, false);
			this._buttonLabel.VAlign = 1f;
			this._buttonLabel.Left.Set(80f, 0f);
			this._buttonLabel.Top.Set(-3f, 0f);
			base.Append(this._buttonLabel);
			this._deleteButtonLabel = new UIText("", 1f, false);
			this._deleteButtonLabel.VAlign = 1f;
			this._deleteButtonLabel.HAlign = 1f;
			this._deleteButtonLabel.Left.Set(-30f, 0f);
			this._deleteButtonLabel.Top.Set(-3f, 0f);
			base.Append(this._deleteButtonLabel);
		}
コード例 #16
0
ファイル: Player.cs プロジェクト: itamargreen/ModLoader
 public static PlayerFileData LoadPlayer(string playerPath, bool cloudSave)
 {
     PlayerFileData playerFileData = new PlayerFileData(playerPath, cloudSave);
     if (cloudSave && SocialAPI.Cloud == null)
     {
         return playerFileData;
     }
     if (Main.rand == null)
     {
         Main.rand = new Random((int)DateTime.Now.Ticks);
     }
     Player player = new Player();
     try
     {
         RijndaelManaged rijndaelManaged = new RijndaelManaged();
         rijndaelManaged.Padding = PaddingMode.None;
         byte[] buffer = FileUtilities.ReadAllBytes(playerPath, cloudSave);
         PlayerFileData result;
         using (MemoryStream memoryStream = new MemoryStream(buffer))
         {
             using (CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(Player.ENCRYPTION_KEY, Player.ENCRYPTION_KEY), CryptoStreamMode.Read))
             {
                 using (BinaryReader binaryReader = new BinaryReader(cryptoStream))
                 {
                     int num = binaryReader.ReadInt32();
                     if (num >= 135)
                     {
                         playerFileData.Metadata = FileMetadata.Read(binaryReader, FileType.Player);
                     }
                     else
                     {
                         playerFileData.Metadata = FileMetadata.FromCurrentSettings(FileType.Player);
                     }
                     if (num > Main.curRelease)
                     {
                         player.loadStatus = 1;
                         player.name = binaryReader.ReadString();
                         playerFileData.Player = player;
                         result = playerFileData;
                         return result;
                     }
                     player.name = binaryReader.ReadString();
                     if (num >= 10)
                     {
                         if (num >= 17)
                         {
                             player.difficulty = binaryReader.ReadByte();
                         }
                         else
                         {
                             bool flag = binaryReader.ReadBoolean();
                             if (flag)
                             {
                                 player.difficulty = 2;
                             }
                         }
                     }
                     if (num >= 138)
                     {
                         playerFileData.SetPlayTime(new TimeSpan(binaryReader.ReadInt64()));
                     }
                     else
                     {
                         playerFileData.SetPlayTime(TimeSpan.Zero);
                     }
                     player.hair = binaryReader.ReadInt32();
                     if (num >= 82)
                     {
                         player.hairDye = binaryReader.ReadByte();
                     }
                     if (num >= 124)
                     {
                         BitsByte bitsByte = binaryReader.ReadByte();
                         for (int i = 0; i < 8; i++)
                         {
                             player.hideVisual[i] = bitsByte[i];
                         }
                         bitsByte = binaryReader.ReadByte();
                         for (int j = 0; j < 2; j++)
                         {
                             player.hideVisual[j + 8] = bitsByte[j];
                         }
                     }
                     else if (num >= 83)
                     {
                         BitsByte bitsByte2 = binaryReader.ReadByte();
                         for (int k = 0; k < 8; k++)
                         {
                             player.hideVisual[k] = bitsByte2[k];
                         }
                     }
                     if (num >= 119)
                     {
                         player.hideMisc = binaryReader.ReadByte();
                     }
                     if (num <= 17)
                     {
                         if (player.hair == 5 || player.hair == 6 || player.hair == 9 || player.hair == 11)
                         {
                             player.Male = false;
                         }
                         else
                         {
                             player.Male = true;
                         }
                     }
                     else if (num < 107)
                     {
                         player.Male = binaryReader.ReadBoolean();
                     }
                     else
                     {
                         player.skinVariant = (int)binaryReader.ReadByte();
                     }
                     player.statLife = binaryReader.ReadInt32();
                     player.statLifeMax = binaryReader.ReadInt32();
                     if (player.statLifeMax > 500)
                     {
                         player.statLifeMax = 500;
                     }
                     player.statMana = binaryReader.ReadInt32();
                     player.statManaMax = binaryReader.ReadInt32();
                     if (player.statManaMax > 200)
                     {
                         player.statManaMax = 200;
                     }
                     if (player.statMana > 400)
                     {
                         player.statMana = 400;
                     }
                     if (num >= 125)
                     {
                         player.extraAccessory = binaryReader.ReadBoolean();
                     }
                     if (num >= 128)
                     {
                         player.taxMoney = binaryReader.ReadInt32();
                     }
                     player.hairColor = binaryReader.ReadRGB();
                     player.skinColor = binaryReader.ReadRGB();
                     player.eyeColor = binaryReader.ReadRGB();
                     player.shirtColor = binaryReader.ReadRGB();
                     player.underShirtColor = binaryReader.ReadRGB();
                     player.pantsColor = binaryReader.ReadRGB();
                     player.shoeColor = binaryReader.ReadRGB();
                     Main.player[Main.myPlayer].shirtColor = player.shirtColor;
                     Main.player[Main.myPlayer].pantsColor = player.pantsColor;
                     Main.player[Main.myPlayer].hairColor = player.hairColor;
                     if (num >= 38)
                     {
                         if (num < 124)
                         {
                             int num2 = 11;
                             if (num >= 81)
                             {
                                 num2 = 16;
                             }
                             for (int l = 0; l < num2; l++)
                             {
                                 int num3 = l;
                                 if (num3 >= 8)
                                 {
                                     num3 += 2;
                                 }
                                 player.armor[num3].netDefaults(binaryReader.ReadInt32());
                                 player.armor[num3].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         else
                         {
                             int num4 = 20;
                             for (int m = 0; m < num4; m++)
                             {
                                 player.armor[m].netDefaults(binaryReader.ReadInt32());
                                 player.armor[m].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (num >= 47)
                         {
                             int num5 = 3;
                             if (num >= 81)
                             {
                                 num5 = 8;
                             }
                             if (num >= 124)
                             {
                                 num5 = 10;
                             }
                             for (int n = 0; n < num5; n++)
                             {
                                 int num6 = n;
                                 player.dye[num6].netDefaults(binaryReader.ReadInt32());
                                 player.dye[num6].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (num >= 58)
                         {
                             for (int num7 = 0; num7 < 58; num7++)
                             {
                                 int num8 = binaryReader.ReadInt32();
                                 if (num8 >= 3602)
                                 {
                                     player.inventory[num7].netDefaults(0);
                                 }
                                 else
                                 {
                                     player.inventory[num7].netDefaults(num8);
                                     player.inventory[num7].stack = binaryReader.ReadInt32();
                                     player.inventory[num7].Prefix((int)binaryReader.ReadByte());
                                     if (num >= 114)
                                     {
                                         player.inventory[num7].favorited = binaryReader.ReadBoolean();
                                     }
                                 }
                             }
                         }
                         else
                         {
                             for (int num9 = 0; num9 < 48; num9++)
                             {
                                 int num10 = binaryReader.ReadInt32();
                                 if (num10 >= 3602)
                                 {
                                     player.inventory[num9].netDefaults(0);
                                 }
                                 else
                                 {
                                     player.inventory[num9].netDefaults(num10);
                                     player.inventory[num9].stack = binaryReader.ReadInt32();
                                     player.inventory[num9].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                         if (num >= 117)
                         {
                             if (num < 136)
                             {
                                 for (int num11 = 0; num11 < 5; num11++)
                                 {
                                     if (num11 != 1)
                                     {
                                         int num12 = binaryReader.ReadInt32();
                                         if (num12 >= 3602)
                                         {
                                             player.miscEquips[num11].netDefaults(0);
                                         }
                                         else
                                         {
                                             player.miscEquips[num11].netDefaults(num12);
                                             player.miscEquips[num11].Prefix((int)binaryReader.ReadByte());
                                         }
                                         num12 = binaryReader.ReadInt32();
                                         if (num12 >= 3602)
                                         {
                                             player.miscDyes[num11].netDefaults(0);
                                         }
                                         else
                                         {
                                             player.miscDyes[num11].netDefaults(num12);
                                             player.miscDyes[num11].Prefix((int)binaryReader.ReadByte());
                                         }
                                     }
                                 }
                             }
                             else
                             {
                                 for (int num13 = 0; num13 < 5; num13++)
                                 {
                                     int num14 = binaryReader.ReadInt32();
                                     if (num14 >= 3602)
                                     {
                                         player.miscEquips[num13].netDefaults(0);
                                     }
                                     else
                                     {
                                         player.miscEquips[num13].netDefaults(num14);
                                         player.miscEquips[num13].Prefix((int)binaryReader.ReadByte());
                                     }
                                     num14 = binaryReader.ReadInt32();
                                     if (num14 >= 3602)
                                     {
                                         player.miscDyes[num13].netDefaults(0);
                                     }
                                     else
                                     {
                                         player.miscDyes[num13].netDefaults(num14);
                                         player.miscDyes[num13].Prefix((int)binaryReader.ReadByte());
                                     }
                                 }
                             }
                         }
                         if (num >= 58)
                         {
                             for (int num15 = 0; num15 < 40; num15++)
                             {
                                 player.bank.item[num15].netDefaults(binaryReader.ReadInt32());
                                 player.bank.item[num15].stack = binaryReader.ReadInt32();
                                 player.bank.item[num15].Prefix((int)binaryReader.ReadByte());
                             }
                             for (int num16 = 0; num16 < 40; num16++)
                             {
                                 player.bank2.item[num16].netDefaults(binaryReader.ReadInt32());
                                 player.bank2.item[num16].stack = binaryReader.ReadInt32();
                                 player.bank2.item[num16].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         else
                         {
                             for (int num17 = 0; num17 < 20; num17++)
                             {
                                 player.bank.item[num17].netDefaults(binaryReader.ReadInt32());
                                 player.bank.item[num17].stack = binaryReader.ReadInt32();
                                 player.bank.item[num17].Prefix((int)binaryReader.ReadByte());
                             }
                             for (int num18 = 0; num18 < 20; num18++)
                             {
                                 player.bank2.item[num18].netDefaults(binaryReader.ReadInt32());
                                 player.bank2.item[num18].stack = binaryReader.ReadInt32();
                                 player.bank2.item[num18].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                     }
                     else
                     {
                         for (int num19 = 0; num19 < 8; num19++)
                         {
                             player.armor[num19].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             if (num >= 36)
                             {
                                 player.armor[num19].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (num >= 6)
                         {
                             for (int num20 = 8; num20 < 11; num20++)
                             {
                                 player.armor[num20].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 if (num >= 36)
                                 {
                                     player.armor[num20].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                         for (int num21 = 0; num21 < 44; num21++)
                         {
                             player.inventory[num21].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             player.inventory[num21].stack = binaryReader.ReadInt32();
                             if (num >= 36)
                             {
                                 player.inventory[num21].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (num >= 15)
                         {
                             for (int num22 = 44; num22 < 48; num22++)
                             {
                                 player.inventory[num22].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 player.inventory[num22].stack = binaryReader.ReadInt32();
                                 if (num >= 36)
                                 {
                                     player.inventory[num22].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                         for (int num23 = 0; num23 < 20; num23++)
                         {
                             player.bank.item[num23].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                             player.bank.item[num23].stack = binaryReader.ReadInt32();
                             if (num >= 36)
                             {
                                 player.bank.item[num23].Prefix((int)binaryReader.ReadByte());
                             }
                         }
                         if (num >= 20)
                         {
                             for (int num24 = 0; num24 < 20; num24++)
                             {
                                 player.bank2.item[num24].SetDefaults(Item.VersionName(binaryReader.ReadString(), num));
                                 player.bank2.item[num24].stack = binaryReader.ReadInt32();
                                 if (num >= 36)
                                 {
                                     player.bank2.item[num24].Prefix((int)binaryReader.ReadByte());
                                 }
                             }
                         }
                     }
                     if (num < 58)
                     {
                         for (int num25 = 40; num25 < 48; num25++)
                         {
                             player.inventory[num25 + 10] = player.inventory[num25].Clone();
                             player.inventory[num25].SetDefaults(0, false);
                         }
                     }
                     if (num >= 11)
                     {
                         int num26 = 22;
                         if (num < 74)
                         {
                             num26 = 10;
                         }
                         for (int num27 = 0; num27 < num26; num27++)
                         {
                             player.buffType[num27] = binaryReader.ReadInt32();
                             player.buffTime[num27] = binaryReader.ReadInt32();
                             if (player.buffType[num27] == 0)
                             {
                                 num27--;
                                 num26--;
                             }
                         }
                     }
                     for (int num28 = 0; num28 < 200; num28++)
                     {
                         int num29 = binaryReader.ReadInt32();
                         if (num29 == -1)
                         {
                             break;
                         }
                         player.spX[num28] = num29;
                         player.spY[num28] = binaryReader.ReadInt32();
                         player.spI[num28] = binaryReader.ReadInt32();
                         player.spN[num28] = binaryReader.ReadString();
                     }
                     if (num >= 16)
                     {
                         player.hbLocked = binaryReader.ReadBoolean();
                     }
                     if (num >= 115)
                     {
                         int num30 = 13;
                         for (int num31 = 0; num31 < num30; num31++)
                         {
                             player.hideInfo[num31] = binaryReader.ReadBoolean();
                         }
                     }
                     if (num >= 98)
                     {
                         player.anglerQuestsFinished = binaryReader.ReadInt32();
                     }
                     player.skinVariant = (int)MathHelper.Clamp((float)player.skinVariant, 0f, 7f);
                     for (int num32 = 3; num32 < 8 + player.extraAccessorySlots; num32++)
                     {
                         int type = player.armor[num32].type;
                         if (type == 908)
                         {
                             player.lavaMax += 420;
                         }
                         if (type == 906)
                         {
                             player.lavaMax += 420;
                         }
                         if (player.wingsLogic == 0 && player.armor[num32].wingSlot >= 0)
                         {
                             player.wingsLogic = (int)player.armor[num32].wingSlot;
                         }
                         if (type == 158 || type == 396 || type == 1250 || type == 1251 || type == 1252)
                         {
                             player.noFallDmg = true;
                         }
                         player.lavaTime = player.lavaMax;
                     }
                 }
             }
         }
         player.PlayerFrame();
         player.loadStatus = 0;
         playerFileData.Player = player;
         result = playerFileData;
         return result;
     }
     catch
     {
     }
     Player player2 = new Player();
     player2.loadStatus = 2;
     if (player.name != "")
     {
         player2.name = player.name;
     }
     else
     {
         string[] array = playerPath.Split(new char[]
             {
                 Path.DirectorySeparatorChar
             });
         player.name = array[array.Length - 1].Split(new char[]
             {
                 '.'
             })[0];
     }
     playerFileData.Player = player2;
     return playerFileData;
 }
コード例 #17
0
ファイル: Loader.cs プロジェクト: Reuged/TerrariaPatcher
 public static void OnPlayerSave(PlayerFileData playerFileData, BinaryWriter binaryWriter)
 {
     foreach (var plugin in loadedPlugins.OfType<IPluginPlayerSave>())
         plugin.OnPlayerSave(playerFileData, binaryWriter);
 }
コード例 #18
0
ファイル: Loader.cs プロジェクト: Reuged/TerrariaPatcher
 public static void OnPlayerLoad(PlayerFileData playerFileData, Player player, BinaryReader binaryReader)
 {
     foreach (var plugin in loadedPlugins.OfType<IPluginPlayerLoad>())
         plugin.OnPlayerLoad(playerFileData, player, binaryReader);
 }
コード例 #19
0
 public void OnPlayerSave(PlayerFileData playerFileData, BinaryWriter binaryWriter)
 {
     IniAPI.WriteIni("SavePosition", Main.worldID + "," + Main.player[Main.myPlayer].name, playerFileData.Player.position.ToString());
 }
コード例 #20
0
 public void OnPlayerLoad(PlayerFileData playerFileData, Player player, BinaryReader binaryReader)
 {
     justLoadedIn = true;
 }