Ejemplo n.º 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);
                }
            }
        }