예제 #1
0
        public override void Unload()
        {
            Main.logoTexture              = storedLogo;
            Main.logo2Texture             = storedLogo2;
            Main.soundMenuTick            = tick;
            Main.soundMenuClose           = close;
            Main.soundMenuOpen            = open;
            Main.logoTexture              = storedLogo;
            IL.Terraria.Main.UpdateAudio -= new ILContext.Manipulator(ChangeMenuMusic);
            customTitleMusicSlot          = 6;
            ManualResetEvent evt = titleMusicStopped;

            if (evt != null)
            {
                evt.Set();
            }
            titleMusicStopped = null;
            // Wtf...
            Main.versionNumber = $"v1.3.5.3";
            SpookyTerrariaUtils.ReturnTexturesToDefaults();
            lock (blackPixel)
            {
                blackPixel = null;
            }
            lock (slenderLogo)
            {
                slenderLogo = null;
            }
            lock (chad)
            {
                chad = null;
            }
            Sprint = null;
        }
        public override void Close()
        {
            for (var texIteration = 0; texIteration < _texturesDisposable.Length - 1; texIteration++)
            {
                if (_texturesDisposable[texIteration] != null)
                {
                    lock (_texturesDisposable[texIteration])
                        _texturesDisposable[texIteration] = null;
                }
            }

            var soundSlot2 = GetSoundSlot(SoundType.Music, "Sounds/Music/MainMenu/Slender_MainMenu");

            if (Main.music.IndexInRange(soundSlot2))
            {
                var musicIndex = Main.music[soundSlot2];
                if (musicIndex != null && musicIndex.IsPlaying)
                {
                    Main.music[soundSlot2].Stop(AudioStopOptions.Immediate);
                }
            }

            SpookyTerrariaUtils.ReturnTexturesToDefaults();
            base.Close();
        }
        public override void Unload()
        {
            DiscordRPCInfo.Terminate();
            Main.logoTexture              = storedLogo;
            Main.logo2Texture             = storedLogo2;
            Main.soundMenuTick            = tick;
            Main.soundMenuClose           = close;
            Main.soundMenuOpen            = open;
            Main.logoTexture              = storedLogo;
            IL.Terraria.Main.UpdateAudio -= ChangeMenuMusic;
            customTitleMusicSlot          = 6;
            var evt = titleMusicStopped;

            if (evt != null)
            {
                evt.Set();
            }

            titleMusicStopped = null;
            // Wtf...
            Main.versionNumber = "v1.3.5.3";
            SpookyTerrariaUtils.ReturnTexturesToDefaults();

            /*for (int texIteration = 0; texIteration < _texturesDisposable.Length - 1; texIteration++)
             * {
             *  if (_texturesDisposable[texIteration] != null)
             *  {
             *      lock (_texturesDisposable[texIteration])
             *      {
             *          _texturesDisposable[texIteration] = null;
             *      }
             *  }
             * }*/
            Sprint = null;
        }
        public override void PostSetupContent()
        {
            if (Main.soundVolume == 0f)
            {
                volRaisedNotifTimer = 90;
                Main.soundVolume    = 0.5f;
            }

            if (Main.musicVolume == 0f)
            {
                volRaisedNotifTimer = 90;
                Main.musicVolume    = 0.25f;
            }

            if (ModLoader.GetMod("TerrariaOverhaul") == null)
            {
                MenuMusicSet_Slender();
            }

            var recievedInstance = ModContent.GetInstance <SpookyConfigClient>();

            if (recievedInstance.betterUI)
            {
                SpookyTerrariaUtils.ModifyUITextures();
            }
        }
예제 #5
0
        public override void OnEnterWorld(Player player)
        {
            int batteryCount = player.CountItem(ModContent.ItemType <Battery>(), 5);

            if (batteryCount < 5)
            {
                player.QuickSpawnItem(ModContent.ItemType <Battery>(), MathUtils.FindRemainder(batteryCount, 5));
            }
            if (!player.HasItem(ModContent.ItemType <OtherItems.Consumables.BetaBlocker>()))
            {
                player.QuickSpawnItem(ModContent.ItemType <OtherItems.Consumables.BetaBlocker>(), 1);
            }
            if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
            {
                if (pages > 0)
                {
                    pages = 0;
                }
                SpookyTerrariaUtils.RemoveAllPossiblePagePositions();
                SpookyTerrariaUtils.GenerateRandomPagePositions();
            }

            player.GetModPlayer <StaminaPlayer>().Stamina = 100;
            heartRate = 80;
            if (Main.dayTime)
            {
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, SoundEngine.dayAmbienceDir));
            }
            else
            {
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, SoundEngine.cricketsSoundDir));
            }
            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/Breezes"));
        }
예제 #6
0
        private void Main_Draw(On.Terraria.Main.orig_Draw orig, Main self, GameTime gameTime)
        {
            // Main.instance.IsFixedTimeStep = false; // joke
            orig(self, gameTime);
            SpookyTerrariaUtils.HandleKeyboardInputs();

            SpookyTerrariaUtils.oldKeyboardState = SpookyTerrariaUtils.newKeyboardState;
        }
예제 #7
0
        public override void PostSetupContent()
        {
            if (ModLoader.GetMod("TerrariaOverhaul") == null)
            {
                MenuMusicSet_Slender();
            }
            SpookyConfigClient recievedInstance = ModContent.GetInstance <SpookyConfigClient>();

            if (recievedInstance.betterUI)
            {
                SpookyTerrariaUtils.ModifyUITextures();
            }
        }
예제 #8
0
        public override void Close()
        {
            int soundSlot2 = GetSoundSlot(SoundType.Music, "Sounds/Music/MainMenu/Slender_MainMenu");

            if (Utils.IndexInRange(Main.music, soundSlot2))
            {
                Music musicIndex = Main.music[soundSlot2];
                if (musicIndex != null && musicIndex.IsPlaying)
                {
                    Main.music[soundSlot2].Stop(AudioStopOptions.Immediate);
                }
            }
            SpookyTerrariaUtils.ReturnTexturesToDefaults();
            base.Close();
        }
예제 #9
0
        /*internal static void HookMenuSplash(ILContext il)
         * {
         *  var c = new ILCursor(il).Goto(0);
         *  if (!c.TryGotoNext(i => i.MatchLdsfld(typeof(Main).GetField("dayTime"))))
         *      return;
         *  c.Emit(OpCodes.Call, typeof(SpookyTerraria).GetMethod("Draw_GetWorldFileText"));
         * }
         * public static void Draw_GetWorldFileText()
         * {
         *  Vector2 origin2;
         *  origin2.X = 0.5f;
         *  origin2.Y = 0.5f;
         *  Rectangle IClickable = new Rectangle(Main.screenHeight - 25, Main.screenWidth - (Main.screenWidth + 100), 1000, 1000);
         *  bool isHovering = IClickable.Contains(Main.MouseScreen.ToPoint());
         *  Main.spriteBatch.DrawString(Main.fontMouseText, "fdsafdiuf duf gadsu fads bfdsf d bfhs bfdgfb yafdsf fbgasduf uf bdasydfbsuf", new Vector2(Main.screenWidth - origin2.X - 390f, origin2.Y + 40f), isHovering ? Color.Yellow : Color.White);
         *  string toFile = $"C://Users//" + Path.Combine($"{Environment.UserName}") + "//Documents//My Games//Terraria//ModLoader//Worlds//Slender_The_8_Pages.twld";
         *  if (isHovering)
         *  {
         *      if (Main.mouseRight && Main.mouseRightRelease)
         *      {
         *          if (!File.Exists(toFile))
         *          {
         *              Main.WorldPath = "C://Documents//My Games//Terraria//ModLoader//Mod Sources//SpookyTerraria//SlenderWorld//Slender_The_8_Pages.twld";
         *          }
         *      }
         *  }
         *  // Creating file for the slendy world
         *  // Me: Tries to sound smart
         *  // Her: Poop
         *
         *  // IL == bad
         * }*/
        public override void Unload()
        {
            IL.Terraria.Main.UpdateAudio -= new ILContext.Manipulator(ChangeMenuMusic);
            customTitleMusicSlot          = 6;
            ManualResetEvent evt = titleMusicStopped;

            if (evt != null)
            {
                evt.Set();
            }
            titleMusicStopped = null;
            // Wtf...
            Main.versionNumber = $"v1.3.5.3";
            SpookyTerrariaUtils.ReturnTexturesToDefaults();

            Sprint = null;
        }
예제 #10
0
        public override void PostUpdateRunSpeeds()
        {
            SpookyTerrariaUtils.HandleMaxRunSpeeds(4);

            // Handle stamina, etc
            var staminaIsZero  = player.GetModPlayer <StaminaPlayer>().Stamina == 0;                                // Stamina is zero.
            var sprintHandling = SpookyTerraria.Sprint.Current && player.velocity.X != 0 && player.velocity.Y == 0; // Is the player holding shift, etc.
            var tooLowStamina  = player.velocity.X != 0 && !SpookyTerraria.Sprint.Current && player.GetModPlayer <StaminaPlayer>().Stamina <= 25 && player.GetModPlayer <StaminaPlayer>().Stamina > 0;
            var notJumpingAndNotLowStaminaAndStaminaIsGreaterThan25 = player.velocity.X != 0 && player.velocity.Y == 0 && !SpookyTerraria.Sprint.Current && player.GetModPlayer <StaminaPlayer>().Stamina > 25;

            if (!player.wet)
            {
                if (notJumpingAndNotLowStaminaAndStaminaIsGreaterThan25 && !player.mount.Active)
                {
                    player.maxRunSpeed = 1.5f * (heartRate / 80f);
                    player.accRunSpeed = 1.5f * (heartRate / 80f);
                }

                if (sprintHandling && !staminaIsZero && !player.mount.Active)
                {
                    player.maxRunSpeed = 1.5f * (heartRate / 80f) * 2f;
                    player.accRunSpeed = 1.5f * (heartRate / 80f) * 2f;
                }
                else if (!tooLowStamina && !player.mount.Active)
                {
                    player.maxRunSpeed = 1.5f * (heartRate / 80f);
                    player.accRunSpeed = 1.5f * (heartRate / 80f);
                }

                if (tooLowStamina && !player.mount.Active)
                {
                    player.maxRunSpeed = 1.5f * (heartRate / 80f) / 2f;
                    player.accRunSpeed = 1.5f * (heartRate / 80f) / 2f; // Fix the sprinting
                }
            }

            // Main.NewText($"{tooLowStamina} (Stamina <= 25%) {sprintHandling} (Sprinting) {notJumpingAndNotLowStaminaAndStaminaIsGreaterThan25} (No Sprint or Low Stamina) {staminaIsZero} (Stamina is Zero)");
            if (ModLoader.GetMod("TerrariaOverhaul") == null)
            {
                var instance = new SpookyTerrariaUtils();
                // x.PlayStepSound("Sounds/Custom/Ambient/HootOne", "Sounds/Custom/Ambient/HootTwo", "Sounds/Custom/Ambient/HootOne", "Sounds/Custom/Ambient/HootTwo", "Sounds/Custom/Ambient/HootOne", "Sounds/Custom/Ambient/HootTwo");
                instance.PlayStepSound();
            }
        }
예제 #11
0
        public override void OnEnterWorld(Player player)
        {
            var batteryCount = player.CountItem(ModContent.ItemType <Battery>(), 5);

            if (batteryCount < 5)
            {
                player.QuickSpawnItem(ModContent.ItemType <Battery>(), MathUtils.FindRemainder(batteryCount, 5));
            }

            if (!player.HasItem(ModContent.ItemType <BetaBlocker>()))
            {
                player.QuickSpawnItem(ModContent.ItemType <BetaBlocker>());
            }

            if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
            {
                if (Pages > 0)
                {
                    Pages = 0;
                }

                SpookyTerrariaUtils.RemoveAllPossiblePagePositions();
                SpookyTerrariaUtils.GenerateRandomPagePositions();
            }
            else if (Pages > 0)
            {
                var randChoice = Main.rand.Next(0, 2);
                NPC.NewNPC(randChoice == 0 ? (int)player.Center.X + -2500 : 2500, (int)player.Center.Y + Main.rand.Next(-100, 100), ModContent.NPCType <Slenderman>());
            }

            player.GetModPlayer <StaminaPlayer>().Stamina = 100;
            heartRate = 80;
            if (Main.dayTime)
            {
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, AmbienceHandler.dayAmbienceDir));
            }
            else
            {
                Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, AmbienceHandler.cricketsSoundDir));
            }

            Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Ambient/Breezes"));
        }
예제 #12
0
        public override bool HoldItemFrame(Item item, Player player)
        {
            if (item.type == ItemID.CarriageLantern)
            {
                SpookyTerrariaUtils.SetBodyFrame((int)SpookyTerrariaUtils.BodyFrames.armDiagonalUp);
                return(true);
            }

            /*if (item.type == ItemID.FallenStar)
             * {
             *  SpookyTerrariaUtils.SetBodyFrame((int)SpookyTerrariaUtils.BodyFrames.armDiagonalDown);
             *  return true;
             * }
             * if (item.type == ItemID.ManaCrystal)
             * {
             *  SpookyTerrariaUtils.SetBodyFrame((int)SpookyTerrariaUtils.BodyFrames.armDiagonalDown);
             *  return true;
             * }*/
            return(base.HoldItemFrame(item, player));
        }
        private void Main_DrawMenu(On.Terraria.Main.orig_DrawMenu orig, Main self, GameTime gameTime)
        {
            ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontDeathText, $"{DiscordInfo.userName}", new Vector2(Main.screenWidth / 2, Main.screenHeight - 8), Color.LightGray, 0f, Main.fontDeathText.MeasureString("Added a world to your worlds!") / 2, new Vector2(0.275f, 0.275f));
            UIHelper.ClickHandling();
            if (Main.menuMode == MenuModeID.HowToPlay)
            {
                MenuHelper.DrawHTP();
            }

            fileAddedNoticeTimer--;
            if (fileAddedNoticeTimer >= 0)
            {
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontDeathText, "Added a world to your worlds!", new Vector2(Main.screenWidth / 2, Main.screenHeight - 8), Color.LightGray, 0f, Main.fontDeathText.MeasureString("Added a world to your worlds!") / 2, new Vector2(0.275f, 0.275f));
            }

            // UIHelper.CreateSimpleUIButton(Main.fontDeathText, new Vector2(300, 100), $"{Environment.OSVersion.Platform} {Environment.OSVersion.Version}", null, ref scaleTimer_BasedOnSineWave);
            if (Main.menuMode == 0)
            {
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontDeathText, $"Authenticated as: {SteamUser.GetSteamID().GetAccountID()} ({SteamFriends.GetPersonaName()})", new Vector2(6, 6), Color.LightGray, 0f, Vector2.Zero, new Vector2(0.275f, 0.275f));
            }
            MenuHelper.DrawUserStatistics();
            AmbienceHandler.StopAllAmbientSounds();
            MenuHelper.DrawSlenderMenuUI();
            MenuHelper.DrawChangeLogs();

            if (volRaisedNotifTimer >= 0)
            {
                ChatManager.DrawColorCodedStringWithShadow(Main.spriteBatch, Main.fontDeathText, "Volume Adjusted Automatically.", new Vector2(Main.screenWidth / 2, Main.screenHeight - 10), Color.Gray * volRaisedNotifTimer, 0f, Main.fontDeathText.MeasureString("Volume Adjusted Automatically.") / 2, new Vector2(0.3f, 0.3f));
            }

            if (Main.menuMode == MenuModeID.SlenderExtras)
            {
                MenuHelper.DrawSocials();
            }

            volRaisedNotifTimer--;
            SpookyTerrariaUtils.HandleKeyboardInputs();
            SpookyTerrariaUtils.oldKeyboardState = SpookyTerrariaUtils.newKeyboardState;
            UIHelper.MSOld = UIHelper.MSNew;
            orig(self, gameTime);
        }
예제 #14
0
        public override void PostDrawTiles()
        {
            Player player = Main.player[Main.myPlayer];

            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            Main.spriteBatch.Draw(mod.GetTexture("Assets/WhiteSquare"), player.position, null, Color.White * 0.25f, 0f, new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), new Vector2(player.Hitbox.Width, player.Hitbox.Height), SpriteEffects.None, 1f);
            Main.spriteBatch.End();
            if (player.dead)
            {
                Main.hideUI = true;
                fadeScale   = 0f;
            }
            if (!Main.hasFocus)
            {
                timerToLightStatic  = 0;
                timerToMediumStatic = 0;
                timerToSevereStatic = 0;
            }
            for (int ll = 0; ll < Main.maxNPCs; ll++)
            {
                NPC   npc      = Main.npc[ll];
                float distance = npc.Distance(Main.player[Main.myPlayer].Center);
                if (npc.active && distance <= 1000f)
                {
                    if (npc.type == ModContent.NPCType <Slenderman>())
                    {
                        if (Main.GameUpdateCount % 3 == 0)
                        {
                            staticFrame.Y += 650;
                        }
                        if (staticFrame.Y >= 1950)
                        {
                            staticFrame.Y = 0;
                        }
                        bool facingTowardsSlendermanLeft  = npc.Center.X < player.Center.X && player.direction == -1;
                        bool facingTowardsSlendermanRight = npc.Center.X > player.Center.X && player.direction == 1;
                        Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); // sourceRectangle: new Rectangle((int)Main.screenPosition.X, (int)Main.screenPosition.Y
                        Main.spriteBatch.Draw(mod.GetTexture("Assets/Static"), new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), sourceRectangle: staticFrame, Color.White * fadeScale, 0f, new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), 5f, SpriteEffects.None, 1f);
                        Main.spriteBatch.End();
                        if (facingTowardsSlendermanLeft || facingTowardsSlendermanRight)
                        {
                            if (fadeScale > 0f && fadeScale < 0.4f)
                            {
                                timerToMediumStatic = 0;
                                timerToSevereStatic = 0;
                                timerToLightStatic++;
                                if (Main.hasFocus)
                                {
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticMedium");
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticSevere");
                                }
                                if (timerToLightStatic == 2)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticLight"));
                                }
                                if (timerToLightStatic >= 480)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticLight"));
                                    timerToLightStatic = 0;
                                }
                            }
                            if (fadeScale >= 0.4 && fadeScale < 0.8f)
                            {
                                timerToLightStatic  = 0;
                                timerToSevereStatic = 0;
                                timerToMediumStatic++;
                                if (Main.hasFocus)
                                {
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticLight");
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticSevere");
                                }
                                if (timerToMediumStatic == 2)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticMedium"));
                                }
                                if (timerToMediumStatic >= 480)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticMedium"));
                                    timerToMediumStatic = 0;
                                }
                            }
                            if (fadeScale >= 0.8f)
                            {
                                timerToMediumStatic = 0;
                                timerToLightStatic  = 0;
                                timerToSevereStatic++;
                                if (Main.hasFocus)
                                {
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticLight");
                                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticMedium");
                                }
                                if (timerToSevereStatic == 2)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticSevere"));
                                }
                                if (timerToSevereStatic >= 132)
                                {
                                    Main.PlaySound(mod.GetLegacySoundSlot(SoundType.Custom, "Sounds/Custom/Slender/StaticSevere"));
                                    timerToSevereStatic = 0;
                                }
                            }
                            // Main.NewText($"L: {timerToLightStatic} | M: {timerToMediumStatic} | S: {timerToSevereStatic}");
                            // MAJOR TODO: MAKE STATIC
                            if (!Collision.SolidCollision(npc.position, npc.width, 20))
                            {
                                if (Main.GameUpdateCount % 3 == 0)
                                {
                                    fadeScale += 0.005f;
                                }
                            }
                        }
                        else if (!facingTowardsSlendermanLeft && !facingTowardsSlendermanRight)
                        {
                            timerToLightStatic  = 0;
                            timerToMediumStatic = 0;
                            timerToSevereStatic = 0;
                            if (Main.GameUpdateCount % 3 == 0)
                            {
                                fadeScale -= 0.005f;
                            }
                        }
                        else if (distance > 1000f)
                        {
                            if (Main.GameUpdateCount % 3 == 0)
                            {
                                fadeScale -= 0.005f;
                            }
                        }
                        if (fadeScale > 1f)
                        {
                            fadeScale = 1f;
                        }
                        if (fadeScale < 0f)
                        {
                            fadeScale = 0f;
                        }
                        if (fadeScale >= 1f)
                        {
                            // player.KillMe(Terraria.DataStructures.PlayerDeathReason.ByCustomReason($"{player.name} stared at death for too long."), player.statLife + 50, 0, false);
                        }
                    }
                    if (npc.type == ModContent.NPCType <Slenderman>() && !npc.active)
                    {
                        timerToLightStatic  = 0;
                        timerToMediumStatic = 0;
                        timerToSevereStatic = 0;
                        fadeScale          -= 0.005f;
                    }
                }
                if (npc.type == ModContent.NPCType <Stalker>() && !npc.active)
                {
                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticMedium");
                    SoundEngine.StopAmbientSound("Sounds/Custom/Slender/StaticLight");
                }
            }

            if (player.GetModPlayer <SpookyPlayer>().deathTextTimer == 1)
            {
                deathTextChoice = Main.rand.Next(0, 10);
            }
            int countCached = player.GetModPlayer <SpookyPlayer>().cachedPageCount;

            Color lighterRed   = new Color(255, 50, 50);
            Color lerpable     = SpookyTerrariaUtils.ColorSwitcher(Color.Red, lighterRed, 30f);
            Color moreLerpable = Color.Lerp(Color.Red, Color.Green, player.GetModPlayer <SpookyPlayer>().cachedPageCount * 0.125f);
            // 205, 92, 92, a: 255

            string displayableString = SpookyTerrariaUtils.ChooseRandomDeathText(deathTextChoice);
            string subString         = "Returning to Main Menu...";
            string pagesFound        = $"Pages Found: {player.GetModPlayer<SpookyPlayer>().cachedPageCount} / 8";

            float x1 = Main.screenWidth / 2;
            float y1 = Main.screenHeight / 2;

            float b = y1 - 75f;

            float x = Main.rand.NextFloat(x1 - 5, x1 + 5);
            float y = Main.rand.NextFloat(y1 - 5, y1 + 5);

            float m = y1 - 100f;

            float j = y1 + 40f;

            Vector2 middle1 = Main.fontDeathText.MeasureString(displayableString) / 2;
            Vector2 middle2 = Main.fontDeathText.MeasureString(subString) / 2;
            Vector2 middle3 = Main.fontDeathText.MeasureString(pagesFound) / 2;

            if (player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(countCached, x1 - 88, b);
                // Main.hideUI = true;
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
                // Text with shake
                Main.spriteBatch.DrawString(Main.fontDeathText, displayableString, new Vector2(x, y), Color.IndianRed * 0.6f, 0f, middle1, 1f, SpriteEffects.None, 0f);
                // Text without shake
                Main.spriteBatch.DrawString(Main.fontDeathText, displayableString, new Vector2(x1, y1), Color.IndianRed, 0f, middle1, 1f, SpriteEffects.None, 0f);
                // Pages Found
                Main.spriteBatch.DrawString(Main.fontDeathText, pagesFound, new Vector2(x1, m), moreLerpable, 0f, middle3, 0.4f, SpriteEffects.None, 0f);
                if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
                {
                    Main.spriteBatch.DrawString(Main.fontDeathText, subString, new Vector2(x1, j), lerpable, 0f, middle2, 0.5f, SpriteEffects.None, 0f);
                }
                Main.spriteBatch.End();
            }
            if (player.GetModPlayer <SpookyPlayer>().pageDisplayTimer < 99 && player.GetModPlayer <SpookyPlayer>().pageDisplayTimer > 0)
            {
                // player.GetModPlayer<SpookyPlayer>().displayTimes++;
                SpookyTerrariaUtils.DrawPageInterface(choice);
            }
            if (player.GetModPlayer <SpookyPlayer>().pageDisplayTimer == 99)
            {
                choice = Main.rand.Next(1, 9);
            }
            float lighting = Lighting.GetSubLight(Main.MouseWorld).X;

            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            if (lighting > 0.05f)
            {
                if (!Main.gameMenu)
                {
                    if (Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageLeft || Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageRight || Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageWall)
                    {
                        string  pickUp = $"Right click to pick up";
                        Vector2 g      = Main.fontMouseText.MeasureString(pickUp);
                        // Main.spriteBatch.DrawString(Main.fontMouseText, pickUp, Main.MouseScreen + new Vector2(25, 25), Color.White, 0f, new Vector2(0, 0), Main.essScale * 5/*1f*/, SpriteEffects.None, 0f);
                        Main.spriteBatch.DrawString(Main.fontMouseText, pickUp, Main.MouseWorld + new Vector2(15, -35) - Main.screenPosition, Color.White * lighting, 0f, new Vector2(g.X / 2, 5), 1f, SpriteEffects.None, 0f);
                    }
                }
            }
            Main.spriteBatch.End();
            if (Main.hasFocus && Main.worldName == SpookyTerrariaUtils.slenderWorldName)
            {
                SoundEngine.StopAmbientSound(SoundEngine.wavesSoundDir);
                oceanWavesTimer = 0;
            }
            if (!Main.hasFocus)
            {
                SoundEngine.StopAllAmbientSounds();
                SoundEngine.StopAmbientSound(SoundEngine.wavesSoundDir);
                player.GetModPlayer <SpookyPlayer>().hootTimer   = 0;
                player.GetModPlayer <SpookyPlayer>().breezeTimer = 0;

                jungleAmbTimer   = 0;
                dayAmbienceTimer = 0;

                oceanWavesTimer = 0;
                cricketsTimer   = 0;
                blizzTimer      = 0;
                caveRumbleTimer = 0;
            }

            // TODO: FINISH DRAWN RANDOMIZATION
            int count = SpookyPlayer.pages;

            if (!Main.playerInventory && player.CountBuffs() == 0 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 100f);
            }
            if (!Main.playerInventory && player.CountBuffs() <= 11 && player.CountBuffs() > 0 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 150f);
            }
            if (!Main.playerInventory && player.CountBuffs() > 11 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 210f);
            }
            if (Main.playerInventory && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 325f);
            }
        }
        public override void PostUpdateEverything()
        {
            // ModContent.GetInstance<AmbienceHelper>().HandleAmbiences();
            Main.raining  = false;
            Main.rainTime = 0;
            Main.maxRain  = 0;
            musicType     = ModContent.GetInstance <SpookyConfigClient>().musicType;
            playMusicTimer_UseOnce++;
            // Main.NewText($"X: {(int)Main.MouseWorld.X / 16} | Y: {(int)Main.MouseWorld.Y / 16}");
            updateGameZoomTargetValue = Main.GameZoomTarget;
            var player = Main.player[Main.myPlayer];

            if (Main.hasFocus)
            {
                player.GetModPlayer <SpookyPlayer>().deathTextTimer--;
                if (player.GetModPlayer <SpookyPlayer>().deathTextTimer < 0)
                {
                    player.GetModPlayer <SpookyPlayer>().deathTextTimer = 0;
                }
            }

            if (player.respawnTimer == 25)
            {
                if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
                {
                    SpookyPlayer.Pages = 0;
                    SpookyTerrariaUtils.RemoveAllPossiblePagePositions();
                    Main.SaveSettings();

                    if (Main.netMode == NetmodeID.SinglePlayer)
                    {
                        WorldFile.CacheSaveTime();
                    }

                    Main.invasionProgress            = 0;
                    Main.invasionProgressDisplayLeft = 0;
                    Main.invasionProgressAlpha       = 0f;
                    Main.menuMode = 10;
                    Main.StopTrackedSounds();
                    CaptureInterface.ResetFocus();
                    Main.ActivePlayerFileData.StopPlayTimer();

                    Player.SavePlayer(Main.ActivePlayerFileData);

                    if (Main.netMode == NetmodeID.SinglePlayer)
                    {
                        WorldFile.saveWorld();
                    }
                    else
                    {
                        Netplay.disconnect = true;
                        Main.netMode       = NetmodeID.SinglePlayer;
                    }

                    Main.fastForwardTime = false;
                    Main.UpdateSundial();
                    Main.menuMode = MenuModeID.MainMenu;
                }
            }

            Main.soundInstanceMenuTick.Volume  = 0f;
            Main.soundInstanceMenuOpen.Volume  = 0f;
            Main.soundInstanceMenuClose.Volume = 0f;
            if (Main.netMode != NetmodeID.Server)
            {
                for (var i = 0; i < Main.maxNPCs; i++)
                {
                    var npc = Main.npc[i];
                    if (npc.type == ModContent.NPCType <Stalker>())
                    {
                        Filters.Scene["Darkness"].GetShader().UseIntensity(player.Distance(npc.Center) / 8);
                    }
                }
            }

            Main.slimeRain        = false;
            Main.invasionSize     = 0;
            Main.invasionProgress = 0;
            if (!beatGame)
            {
                Main.dayTime = false;
                Main.time    = 1800;
            }
            else
            {
                Main.dayTime = true;
                Main.time    = 18000;
            }
        }
예제 #16
0
        public override void PostUpdateEverything()
        {
            playMusicTimer_UseOnce++;
            // Main.NewText($"X: {(int)Main.MouseWorld.X / 16} | Y: {(int)Main.MouseWorld.Y / 16}");
            updateGameZoomTargetValue = Main.GameZoomTarget;
            Player player = Main.player[Main.myPlayer];

            if (Main.hasFocus)
            {
                player.GetModPlayer <SpookyPlayer>().deathTextTimer--;
                if (player.GetModPlayer <SpookyPlayer>().deathTextTimer < 0)
                {
                    player.GetModPlayer <SpookyPlayer>().deathTextTimer = 0;
                }
            }
            if (player.respawnTimer == 25)
            {
                if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
                {
                    SpookyPlayer.pages = 0;
                    SpookyTerrariaUtils.RemoveAllPossiblePagePositions();
                    Main.SaveSettings();

                    if (Main.netMode == NetmodeID.SinglePlayer)
                    {
                        WorldFile.CacheSaveTime();
                    }
                    Main.invasionProgress            = 0;
                    Main.invasionProgressDisplayLeft = 0;
                    Main.invasionProgressAlpha       = 0f;
                    Main.menuMode = 10;
                    Main.StopTrackedSounds();
                    CaptureInterface.ResetFocus();
                    Main.ActivePlayerFileData.StopPlayTimer();

                    Player.SavePlayer(Main.ActivePlayerFileData, false);

                    if (Main.netMode == NetmodeID.SinglePlayer)
                    {
                        WorldFile.saveWorld();
                    }
                    else
                    {
                        Netplay.disconnect = true;
                        Main.netMode       = NetmodeID.SinglePlayer;
                    }

                    Main.fastForwardTime = false;
                    Main.UpdateSundial();
                    Main.menuMode = 0;
                }
            }

            /*
             * if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
             * {
             *  Rectangle insideBathrooms = new Rectangle(2091 * SpookyTerrariaUtils.tileScaling, 367 * SpookyTerrariaUtils.tileScaling, 85 * SpookyTerrariaUtils.tileScaling, 26 * SpookyTerrariaUtils.tileScaling);
             *  if (player.Hitbox.Intersects(insideBathrooms))
             *  {
             *      Main.NewText(updateGameZoomTargetValue + ", " + Main.GameZoomTarget);
             *      updateGameZoomTargetValue += 0.05f;
             *      if (updateGameZoomTargetValue > 8.75f)
             *      {
             *          updateGameZoomTargetValue = 8.75f;
             *      }
             *  }
             * }
             */
            // Fix for lerping
            Main.soundInstanceMenuTick.Volume  = 0f;
            Main.soundInstanceMenuOpen.Volume  = 0f;
            Main.soundInstanceMenuClose.Volume = 0f;
            if (Main.netMode != NetmodeID.Server)
            {
                for (int i = 0; i < Main.maxNPCs; i++)
                {
                    NPC npc = Main.npc[i];
                    if (npc.type == ModContent.NPCType <Stalker>())
                    {
                        Filters.Scene["Darkness"].GetShader().UseIntensity(player.Distance(npc.Center) / 8);
                    }
                }
            }
            Main.slimeRain        = false;
            Main.invasionSize     = 0;
            Main.invasionProgress = 0;
            if (!beatGame)
            {
                Main.dayTime = false;
                Main.time    = 1800;
            }
            else
            {
                Main.dayTime = true;
                Main.time    = 18000;
            }
        }
예제 #17
0
        public const int maxArmor = 9; // Max armor slots (up to 9, the max)

        public void HandleSprinting()
        {
            for (var i = 0; i < maxArmor; i++)
            {
                var accItem      = player.armor[i];
                var accRightItem = accItem.type == ItemID.DivingGear || accItem.type == ItemID.JellyfishDivingGear ||
                                   accItem.type == ItemID.ArcticDivingGear;
                if (accRightItem)
                {
                    if (player.wet && player.velocity.Y < 0)
                    {
                        staminaDecrementTimer = 0;
                        staminaIncrementTimer++;
                        if (staminaIncrementTimer >= 12)
                        {
                            Stamina--;
                            staminaIncrementTimer = 0;
                        }
                    }
                }
            }

            var isSprinting = SpookyTerraria.Sprint.Current && Stamina != 0 && Math.Abs(player.velocity.X) > 1.5f &&
                              player.velocity.Y == 0;
            var currentlyJumping = player.velocity.Y < 0 && !player.mount.Active;

            if (isSprinting)
            {
                SpookyTerrariaUtils.NegateStaminaValue(Main.player[Main.myPlayer], 4);
            }

            if (currentlyJumping && !player.wet)
            {
                SpookyTerrariaUtils.NegateStaminaValue(Main.player[Main.myPlayer], 1);
            }

            if (currentlyJumping && player.wet)
            {
                SpookyTerrariaUtils.NegateStaminaValue(Main.player[Main.myPlayer], 5);
            }

            // Main.NewText(currentlyJumping + " " + staminaIncrementTimer + " " + isSprinting);
            if (!isSprinting && !currentlyJumping && !player.wet)
            {
                staminaIncrementTimer = 0;
                staminaDecrementTimer++;
                if (staminaDecrementTimer >= 6)
                {
                    Stamina++;
                    staminaDecrementTimer = 0;
                }
            }

            if (!isSprinting && !currentlyJumping && player.wet && player.velocity.Y >= 0)
            {
                staminaIncrementTimer = 0;
                staminaDecrementTimer++;
                if (staminaDecrementTimer >= 12)
                {
                    Stamina++;
                    staminaDecrementTimer = 0;
                }
            }

            if (!isSprinting && !currentlyJumping && player.wet && player.mount.Active)
            {
                staminaIncrementTimer = 0;
                staminaDecrementTimer++;
                if (staminaDecrementTimer >= 12)
                {
                    Stamina++;
                    staminaDecrementTimer = 0;
                }
            }

            if (Stamina < 0)
            {
                Stamina = 0;
            }

            if (Stamina > 100)
            {
                Stamina = 100;
            }
        }
예제 #18
0
        public override void PostDrawTiles()
        {
            var player = Main.player[Main.myPlayer];

            var count = SpookyPlayer.Pages;

            if (!Main.playerInventory && player.CountBuffs() == 0 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 100f);
            }

            if (!Main.playerInventory && player.CountBuffs() <= 11 && player.CountBuffs() > 0 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 150f);
            }

            if (!Main.playerInventory && player.CountBuffs() > 11 && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 210f);
            }

            if (Main.playerInventory && !Main.hideUI && !player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(count, 35f, 325f);
            }

            if (player.GetModPlayer <SpookyPlayer>().deathTextTimer == 1)
            {
                deathTextChoice = Main.rand.Next(0, 10);
            }

            var countCached = player.GetModPlayer <SpookyPlayer>().cachedPageCount;

            var lighterRed   = new Color(255, 50, 50);
            var lerpable     = SpookyTerrariaUtils.ColorSwitcher(Color.Red, lighterRed, 30f);
            var moreLerpable = Color.Lerp(Color.Red, Color.Green, player.GetModPlayer <SpookyPlayer>().cachedPageCount * 0.125f);
            // 205, 92, 92, a: 255

            var displayableString = SpookyTerrariaUtils.ChooseRandomDeathText(deathTextChoice);
            var subString         = "Returning to Main Menu...";
            var pagesFound        = $"Pages Found: {player.GetModPlayer<SpookyPlayer>().cachedPageCount} / 8";

            float x1 = Main.screenWidth / 2;
            float y1 = Main.screenHeight / 2;

            var b = y1 - 75f;

            var x = Main.rand.NextFloat(x1 - 5, x1 + 5);
            var y = Main.rand.NextFloat(y1 - 5, y1 + 5);

            var m = y1 - 100f;

            var j = y1 + 40f;

            var middle1 = Main.fontDeathText.MeasureString(displayableString) / 2;
            var middle2 = Main.fontDeathText.MeasureString(subString) / 2;
            var middle3 = Main.fontDeathText.MeasureString(pagesFound) / 2;

            if (player.dead)
            {
                SpookyTerrariaUtils.DrawPageUI(countCached, x1 - 88, b);
                // Main.hideUI = true;
                Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
                // Text with shake
                Main.spriteBatch.DrawString(Main.fontDeathText, displayableString, new Vector2(x, y), Color.IndianRed * 0.6f, 0f, middle1, 1f, SpriteEffects.None, 0f);
                // Text without shake
                Main.spriteBatch.DrawString(Main.fontDeathText, displayableString, new Vector2(x1, y1), Color.IndianRed, 0f, middle1, 1f, SpriteEffects.None, 0f);
                // Pages Found
                Main.spriteBatch.DrawString(Main.fontDeathText, pagesFound, new Vector2(x1, m), moreLerpable, 0f, middle3, 0.4f, SpriteEffects.None, 0f);
                if (Main.worldName == SpookyTerrariaUtils.slenderWorldName)
                {
                    Main.spriteBatch.DrawString(Main.fontDeathText, subString, new Vector2(x1, j), lerpable, 0f, middle2, 0.5f, SpriteEffects.None, 0f);
                }

                Main.spriteBatch.End();
            }

            if (player.GetModPlayer <SpookyPlayer>().pageDisplayTimer < 99 && player.GetModPlayer <SpookyPlayer>().pageDisplayTimer > 0)
            {
                // player.GetModPlayer<SpookyPlayer>().displayTimes++;
                SpookyTerrariaUtils.DrawPageInterface(choice);
            }

            if (player.GetModPlayer <SpookyPlayer>().pageDisplayTimer == 99)
            {
                choice = Main.rand.Next(1, 9);
            }

            var lighting = Lighting.GetSubLight(Main.MouseWorld).X;

            Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            if (lighting > 0.05f)
            {
                if (!Main.gameMenu)
                {
                    if (Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageLeft || Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageRight || Main.LocalPlayer.GetModPlayer <SpookyPlayer>().hoveringPageWall)
                    {
                        var pickUp = "Right click to pick up";
                        var g      = Main.fontMouseText.MeasureString(pickUp);
                        // Main.spriteBatch.DrawString(Main.fontMouseText, pickUp, Main.MouseScreen + new Vector2(25, 25), Color.White, 0f, new Vector2(0, 0), Main.essScale * 5/*1f*/, SpriteEffects.None, 0f);
                        Main.spriteBatch.DrawString(Main.fontMouseText, pickUp, Main.MouseWorld + new Vector2(15, -35) - Main.screenPosition, Color.White * lighting, 0f, new Vector2(g.X / 2, 5), 1f, SpriteEffects.None, 0f);
                    }
                }
            }

            Main.spriteBatch.End();
        }