Пример #1
0
 public virtual void Clear()
 {
     Vertices.Clear();
     Normals.Clear();
     Colors.Clear();
     Lighting.Clear();
     Indexes.Clear();
 }
Пример #2
0
        /// <summary>
        /// Carbon copy of the vanilla Player.Teleport, without effects. Only handles basic code and effects, no netcode
        /// </summary>
        /// <param name="player">The player</param>
        /// <param name="newPos">The teleport position</param>
        public static void ClickerTeleport(this Player player, Vector2 newPos)
        {
            player.RemoveAllGrapplingHooks();

            float distance = Vector2.Distance(player.Center, newPos);

            PressurePlateHelper.UpdatePlayerPosition(player);
            player.Center    = newPos;
            player.fallStart = (int)(player.position.Y / 16f);
            if (player.whoAmI == Main.myPlayer)
            {
                bool offScreen = true;
                if (distance < new Vector2(Main.screenWidth, Main.screenHeight).Length() / 2f + 100f)
                {
                    Main.SetCameraLerp(0.1f, 0);
                    offScreen = false;
                }
                else
                {
                    Main.BlackFadeIn = 255;
                    Lighting.Clear();
                    Main.screenLastPosition         = Main.screenPosition;
                    Main.screenPosition             = player.Center - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2);
                    Main.instantBGTransitionCounter = 10;
                }
                if (offScreen)
                {
                    if (Main.mapTime < 5)
                    {
                        Main.mapTime = 5;
                    }

                    Main.maxQ      = true;
                    Main.renderNow = true;
                }
            }

            PressurePlateHelper.UpdatePlayerPosition(player);
            for (int j = 0; j < 3; j++)
            {
                player.UpdateSocialShadow();
            }

            player.oldPosition = player.position + player.BlehOldPositionFixer;
        }
Пример #3
0
        public void Load()
        {
            Lighting.Clear();
            bool isCloudSave = Main.ActivePlayerFileData.IsCloudSave;

            if ((isCloudSave && SocialAPI.Cloud == null) || !Main.mapEnabled)
            {
                return;
            }
            string text = Main.playerPathName.Substring(0, Main.playerPathName.Length - 4) + Path.DirectorySeparatorChar.ToString();

            if (Main.ActiveWorldFileData.UseGuidAsMapName)
            {
                string arg = text;
                text = text + Main.ActiveWorldFileData.UniqueId + ".map";
                if (!FileUtilities.Exists(text, isCloudSave))
                {
                    text = arg + Main.worldID + ".map";
                }
            }
            else
            {
                text = text + Main.worldID + ".map";
            }
            if (!FileUtilities.Exists(text, isCloudSave))
            {
                Main.MapFileMetadata = FileMetadata.FromCurrentSettings(FileType.Map);
            }
            else
            {
                using (MemoryStream input = new MemoryStream(FileUtilities.ReadAllBytes(text, isCloudSave)))
                {
                    using (BinaryReader binaryReader = new BinaryReader(input))
                    {
                        try
                        {
                            int num = binaryReader.ReadInt32();
                            if (num <= 227)
                            {
                                if (num <= 91)
                                {
                                    MapHelper.LoadMapVersion1(binaryReader, num);
                                }
                                else
                                {
                                    MapHelper.LoadMapVersion2(binaryReader, num);
                                }
                                ClearEdges();
                                Main.clearMap    = true;
                                Main.loadMap     = true;
                                Main.loadMapLock = true;
                                Main.refreshMap  = false;
                            }
                        }
                        catch (Exception value)
                        {
                            using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", append: true))
                            {
                                streamWriter.WriteLine(DateTime.Now);
                                streamWriter.WriteLine(value);
                                streamWriter.WriteLine("");
                            }
                            if (!isCloudSave)
                            {
                                File.Copy(text, text + ".bad", overwrite: true);
                            }
                            Clear();
                        }
                    }
                }
            }
        }
Пример #4
0
        public void Load()
        {
            Lighting.Clear();
            bool isCloudSave = Main.ActivePlayerFileData.IsCloudSave;

            if (isCloudSave && SocialAPI.Cloud == null || !Main.mapEnabled)
            {
                return;
            }
            string str1 = Main.playerPathName.Substring(0, Main.playerPathName.Length - 4) + Path.DirectorySeparatorChar.ToString();
            string str2;

            if (Main.ActiveWorldFileData.UseGuidAsMapName)
            {
                string str3 = str1;
                str2 = str1 + (object)Main.ActiveWorldFileData.UniqueId + ".map";
                if (!FileUtilities.Exists(str2, isCloudSave))
                {
                    str2 = str3 + (object)Main.worldID + ".map";
                }
            }
            else
            {
                str2 = str1 + (object)Main.worldID + ".map";
            }
            if (!FileUtilities.Exists(str2, isCloudSave))
            {
                Main.MapFileMetadata = FileMetadata.FromCurrentSettings(FileType.Map);
            }
            else
            {
                using (MemoryStream memoryStream = new MemoryStream(FileUtilities.ReadAllBytes(str2, isCloudSave)))
                {
                    using (BinaryReader fileIO = new BinaryReader((Stream)memoryStream))
                    {
                        try
                        {
                            int release = fileIO.ReadInt32();
                            if (release > 230)
                            {
                                return;
                            }
                            if (release <= 91)
                            {
                                MapHelper.LoadMapVersion1(fileIO, release);
                            }
                            else
                            {
                                MapHelper.LoadMapVersion2(fileIO, release);
                            }
                            this.ClearEdges();
                            Main.clearMap    = true;
                            Main.loadMap     = true;
                            Main.loadMapLock = true;
                            Main.refreshMap  = false;
                        }
                        catch (Exception ex)
                        {
                            using (StreamWriter streamWriter = new StreamWriter("client-crashlog.txt", true))
                            {
                                streamWriter.WriteLine((object)DateTime.Now);
                                streamWriter.WriteLine((object)ex);
                                streamWriter.WriteLine("");
                            }
                            if (!isCloudSave)
                            {
                                File.Copy(str2, str2 + ".bad", true);
                            }
                            this.Clear();
                        }
                    }
                }
            }
        }