Exemplo n.º 1
0
        private void Quit(Action callback = null, bool saveWorld = false, bool savePlayer = false)
        {
            ThreadPool.QueueUserWorkItem(new WaitCallback(QuitCallBack), callback);

            void QuitCallBack(object threadContext)
            {
                if (Main.netMode == NetmodeID.SinglePlayer)
                {
                    WorldFile.CacheSaveTime();
                }

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

                if (savePlayer)
                {
                    Player.SavePlayer(Main.ActivePlayerFileData, false);
                }

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

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

                if (threadContext != null)
                {
                    ((Action)threadContext)();
                }
            }
        }
        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;
            }
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
0
        public override void AI()
        {
            if (npc.life < npc.lifeMax / 2)
            {
                PhaseValueOrSomethingIDK = 1;
            }

            npc.TargetClosest(true);
            npc.spriteDirection = npc.direction;

            Player player = Main.player[npc.target];

            SpeeeeedValue = SpeeeenBool ? 5 : 7;

            Vector2 moveTo = player.Center - npc.Center;

            moveTo.Normalize();
            moveTo = moveTo * SpeeeeedValue;

            npc.velocity = moveTo;

            if (++SpeeeeenTimer % 180 == 0)
            {
                if (SpeeeenBool)
                {
                    SpeeeenBool = true;
                }
                else
                {
                    SpeeeenBool = false;
                }
            }

            if (SpeeeenBool)
            {
                npc.rotation += npc.velocity.X * 0.1f;
            }

            if (PhaseValueOrSomethingIDK == 0)
            {
                if (++AtttaackTimer >= 250)
                {
                    for (int i = 0; i < Main.rand.Next(10, 20); i++)
                    {
                        Projectile.NewProjectile(npc.Center.X - Main.rand.Next(-600, 600), npc.Center.Y - Main.screenHeight / 2 - 60, moveTo.X * 1.5f, moveTo.Y * 1.5f, ModContent.ProjectileType <Projectiles.rum>(), 35, 2);
                    }

                    AtttaackTimer = 0;
                }
            }
            else if (PhaseValueOrSomethingIDK == 1)
            {
                GameCrashCounter++;

                if (GameCrashCounter == 1)
                {
                    CombatText.NewText(npc.Hitbox, Color.DarkRed, "Kill me in 2 minute or you get booted", dramatic: true);
                }

                if (GameCrashCounter == 3600)
                {
                    CombatText.NewText(npc.Hitbox, Color.DarkRed, "One minute kill me or terraria go back to menu", dramatic: true);
                }

                if (GameCrashCounter == 7140)
                {
                    CombatText.NewText(npc.Hitbox, Color.DarkRed, "You are going to brazil", dramatic: true);
                }

                if (GameCrashCounter == 7200)
                {
                    CombatText.NewText(npc.Hitbox, Color.DarkRed, "Whoops gotta save your stuff first", dramatic: true);
                }

                if (GameCrashCounter == 7300)
                {
                    CombatText.NewText(npc.Hitbox, Color.DarkRed, "PASTA LA VISTA!!!!!", dramatic: true);
                }

                if (GameCrashCounter >= 7320)
                {
                    Main.SaveSettings();

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

                    Main.invasionProgress            = 0;
                    Main.invasionProgressDisplayLeft = 0;
                    Main.invasionProgressAlpha       = 0f;
                    Main.menuMode = 10;
                    Main.gameMenu = true;
                    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 (++AtttaackTimer >= 40)
                {
                    Projectile.NewProjectile(npc.Center, moveTo * 4, ModContent.ProjectileType <Projectiles.beer>(), 50, 3);

                    AtttaackTimer = 0;
                }
            }
        }