Esempio n. 1
0
        public bool ShouldHandleWeaponChangesAndContinue(Player player)
        {
            if (player.HeldItem == null)
            {
                projectile.Kill();
                return(false);
            }

            if (weaponBinding == -1)
            {
                weaponBinding = player.HeldItem.type;
            }
            else
            {
                if (player.HeldItem.type != weaponBinding)
                {
                    // do a buttload of decay dust
                    for (var i = 0; i < DisperseDustQuantity; i++)
                    {
                        ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, DisperseDustFrequency, true, ChargeSize.ToVector2());
                    }
                    projectile.Kill();
                    return(false);
                }
            }
            // weapon's correct, keep doing what you're doing.
            return(true);
        }
Esempio n. 2
0
        public void HandleChargingKi(Player player)
        {
            bool IsCharging = false;

            FinalChargeLimit = ChargeLimit + MyPlayer.ModPlayer(player).ChargeLimitAdd;

            // stop channeling if the player is out of ki
            if (MyPlayer.ModPlayer(player).IsKiDepleted())
            {
                player.channel = false;
            }

            // keep alive routine.
            if (projectile.timeLeft < 4)
            {
                projectile.timeLeft = 10;
            }

            MyPlayer modPlayer = MyPlayer.ModPlayer(player);

            // The energy in the projectile decays if the player stops channeling.
            if (!player.channel && !modPlayer.IsMouseRightHeld && !IsSustainingFire)
            {
                // kill the tracked charge sound if the player let go, immediately
                ChargeSoundSlotId = SoundUtil.KillTrackedSound(ChargeSoundSlotId);

                if (ChargeLevel > 0f)
                {
                    ChargeLevel = Math.Max(0, ChargeLevel - DecayRate());

                    // don't draw the ball when firing.
                    if (!IsSustainingFire)
                    {
                        ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, DecayDustFrequency, true, ChargeSize.ToVector2());
                    }
                }
                else
                {
                    // the charge level zeroed out, kill the projectile.
                    projectile.Kill();
                }
            }

            // charge the ball if the proper keys are held.
            // increment the charge timer if channeling and apply slowdown effect
            if (player.channel && projectile.active && modPlayer.IsMouseRightHeld && !IsSustainingFire)
            {
                // the player can hold the charge all they like once it's fully charged up. Currently this doesn't incur a movespeed debuff either.
                if (ChargeLevel < FinalChargeLimit && !modPlayer.IsKiDepleted())
                {
                    IsCharging = true;

                    // drain ki from the player when charging
                    if (DBZMOD.IsTickRateElapsed(CHARGE_KI_DRAIN_WINDOW))
                    {
                        MyPlayer.ModPlayer(player).AddKi(-ChargeKiDrainRate(), true, false);
                    }

                    // increase the charge
                    ChargeLevel = Math.Min(FinalChargeLimit, ChargeRate() + ChargeLevel);

                    // slow down the player while charging.
                    ProjectileUtil.ApplyChannelingSlowdown(player);

                    // shoot some dust into the ball to show it's charging, and to look cool.
                    if (!IsSustainingFire)
                    {
                        ProjectileUtil.DoChargeDust(GetChargeBallPosition(), DustType, ChargeDustFrequency, false, ChargeSize.ToVector2());
                    }
                }
            }

            // play the sound if the player just started charging and the audio is "off cooldown"
            if (!WasCharging && IsCharging && ChargeSoundCooldown == 0f)
            {
                if (!Main.dedServ)
                {
                    ChargeSoundSlotId = SoundUtil.PlayCustomSound(ChargeSoundKey, projectile.Center);
                }
                ChargeSoundCooldown = ChargeSoundDelay;
            }
            else
            {
                ChargeSoundCooldown = Math.Max(0f, ChargeSoundCooldown - 1);
            }

            // set the wasCharging flag for proper tracking
            WasCharging = IsCharging;
        }