Ejemplo n.º 1
0
        ////

        private static bool CanSpiritWalkWithMana(Player player)
        {
            if (SpiritWalkLogic.ManaCostDuration > 0)
            {
                return(true);
            }

            var config       = SpiritWalkingConfig.Instance;
            int manaCostRate = config.Get <int>(nameof(config.PerRateSpiritWalkManaCost));

            return(SpiritWalkLogic.HasMana(player, manaCostRate, out string _));
        }
Ejemplo n.º 2
0
        private static void ApplySpiritWalkCollisionFriction_Mana(Player player)
        {
            var config = SpiritWalkingConfig.Instance;

            if (SpiritWalkLogic.ManaCostDuration > 0)
            {
                return;
            }

            int manaDraw = config.Get <int>(nameof(config.PerRateSpiritWalkFrictionAddedManaCost));

            SpiritWalkLogic.ApplyManaDraw(player, manaDraw);
        }
Ejemplo n.º 3
0
        public static void ApplySpiritWalkOpenAirFriction_Mana(Player player)
        {
            var config = SpiritWalkingConfig.Instance;

            if (SpiritWalkLogic.ManaCostDuration > 0)
            {
                return;
            }

            int manaDraw = config.Get <int>(nameof(config.PerRateSpiritWalkManaCostInOpenAir));

            SpiritWalkLogic.ApplyManaDraw(player, manaDraw);
        }
Ejemplo n.º 4
0
        ////////////////

        public static void ActivateIf(Player player, bool syncIfClient)
        {
            var config   = SpiritWalkingConfig.Instance;
            var myplayer = player.GetModPlayer <SpiritWalkingPlayer>();

            if (myplayer.IsSpiritWalking)
            {
                return;
            }

            if (SpiritWalkLogic.IsUponOpenAir(player))
            {
                if (!config.Get <bool>(nameof(config.OpenAirAllowsEngagingSpiritWalk)))
                {
                    Main.NewText("Cannot enage spirit walking upon open air.", Color.Yellow);

                    return;
                }
            }

            if (!SpiritWalkLogic.ApplyActivateCostIf(player))
            {
                return;
            }

            //

            SpiritWalkFlightLogic.ActivateFlightBehavior(myplayer);

            SpiritWalkLogic.ActivatePlayerForm(player);

            SpiritWalkFxLogic.ActivationFx(myplayer);

            SpiritWalkPelletsLogic.ActivationPreparations(myplayer);

            //

            myplayer.IsSpiritWalking = true;

            SpiritWalkingAPI.RunSpiritWalkActivationHooks(player, true);

            //

            if (syncIfClient)
            {
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    SpiritWalkStateProtocol.Broadcast(myplayer);
                }
            }
        }
Ejemplo n.º 5
0
        public static void UpdateTriggersForSpiritWalk(SpiritWalkingPlayer myplayer, TriggersSet triggersSet)
        {
            bool jump  = triggersSet.Jump;
            bool down  = triggersSet.KeyStatus["Down"];
            bool up    = triggersSet.KeyStatus["Up"];
            bool left  = triggersSet.KeyStatus["Left"];
            bool right = triggersSet.KeyStatus["Right"];

            SpiritWalkLogic.HandleWalkControls(myplayer, jump, down, up, left, right);

            triggersSet.QuickMount = false;
            triggersSet.Grapple    = false;
            triggersSet.Jump       = false;
        }
Ejemplo n.º 6
0
        private static bool ApplyActivateCostIf(Player player)
        {
            var config = SpiritWalkingConfig.Instance;

            if (SpiritWalkingConfig.SpiritWalkUsesAnima)
            {
                SpiritWalkLogic.ApplyActivateAnimaCostIf(player);
            }
            else
            {
                SpiritWalkLogic.ApplyActivateManaCostIf(player);
            }

            return(true);
        }
Ejemplo n.º 7
0
        private static bool ApplyActivateManaCostIf(Player player)
        {
            var config   = SpiritWalkingConfig.Instance;
            int manaCost = config.Get <int>(nameof(config.InitialSpiritWalkManaCost));

            if (!SpiritWalkLogic.HasMana(player, manaCost, out string status))
            {
                Main.NewText(status, Color.Yellow);

                return(false);
            }

            SpiritWalkLogic.EmulatedMana = player.statMana;

            SpiritWalkLogic.ApplyManaDraw(player, manaCost);

            return(true);
        }
        private static void UpdateSpiritWalkCost_Mana(Player player)
        {
            var config = SpiritWalkingConfig.Instance;

            int tickRate = config.Get <int>(nameof(config.SpiritWalkManaCostTickRate));

            if (SpiritWalkLogic.ManaCostDuration++ >= tickRate)
            {
                SpiritWalkLogic.ManaCostDuration = 0;
            }

            if (SpiritWalkLogic.ManaCostDuration == 0)
            {
                int manaCost = config.Get <int>(nameof(config.PerRateSpiritWalkManaCost));

                SpiritWalkLogic.ApplyManaDraw(player, manaCost);
            }

            player.statMana = SpiritWalkLogic.EmulatedMana;
        }
Ejemplo n.º 9
0
        ////

        public static void AttemptFinalDash(SpiritWalkingPlayer myplayer, bool sync)
        {
            var config            = SpiritWalkingConfig.Instance;
            int finalDashTileDist = config.Get <int>(nameof(config.FinalDashTileDistance));

            Vector2 aim = Vector2.Normalize(myplayer.IntendedFlightVelocity);

            aim *= (float)finalDashTileDist * 16f;

            Vector2 dest = myplayer.FlightProjectile.Center + aim;

            if (SpiritWalkLogic.CanFinalDashTo(dest))
            {
                myplayer.player.Teleport(dest, 1);

                if (sync)
                {
                    NetMessage.SendData(MessageID.Teleport, -1, -1, null, 0, (float)myplayer.player.whoAmI, dest.X, dest.Y, 1, 0, 0);
                }
            }
        }
Ejemplo n.º 10
0
        ////////////////

        public static void Update(SpiritWalkingPlayer myplayer, bool isSpiritWalking)
        {
//DebugLibraries.Print( "walk?", ""+isSpiritWalking+", "+myplayer.player.width+", "+myplayer.player.height );
            if (!isSpiritWalking)
            {
                return;
            }

            bool canSW = SpiritWalkLogic.CanSpiritWalk(myplayer.player);

            if (canSW)
            {
                SpiritWalkLogic.UpdateForSpiritWalk(myplayer);
            }
            else
            {
                SpiritWalkLogic.DeactivateIf(myplayer.player, true);
            }

            SpiritWalkFxLogic.Update(myplayer, canSW);
        }
        public static void DeactivateIf(Player player, bool syncIfClient)
        {
            var myplayer = player.GetModPlayer <SpiritWalkingPlayer>();

            if (!myplayer.IsSpiritWalking)
            {
                return;
            }

            //

            SpiritWalkLogic.DeactivatePlayerForm(player);

            SpiritWalkFlightLogic.DeactivateFlightBehavior(player);

            SpiritWalkFxLogic.DeactivationFx(player);

            //

            SpiritWalkPelletsLogic.FlushCache();

            //

            myplayer.IsSpiritWalking = false;

            SpiritWalkingAPI.RunSpiritWalkActivationHooks(player, false);

            //

            if (syncIfClient)
            {
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    SpiritWalkStateProtocol.Broadcast(myplayer);
                }
            }
        }
Ejemplo n.º 12
0
        private static void UpdateForSpiritWalk(SpiritWalkingPlayer myplayer)
        {
            if (SpiritWalkLogic.IsUponOpenAir(myplayer.player))
            {
                SpiritWalkFlightLogic.ApplySpiritWalkOpenAirFriction(myplayer.player);
                SpiritWalkFxLogic.ApplySpiritWalkOpenAirFriction(myplayer.player);
            }

            //

            SpiritWalkLogic.UpdateSpiritWalkCost(myplayer.player);

            SpiritWalkLogic.RunFinalDashIf(myplayer);

            //

            myplayer.player.gravity = 0f;

            //

            SpiritWalkFlightLogic.UpdateWalk(myplayer);

            SpiritWalkPelletsLogic.UpdateWalk(myplayer);
        }