Exemple #1
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);
                }
            }
        }
        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);
                }
            }
        }