XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
UTF-8
using SoulHarvest.Common;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;

namespace SoulHarvest.Projectiles;

internal static class LifeStealVisuals
{
    public static void Spawn(Vector2 source, int playerIndex, int lifeStealLevel, int healedLife,
        bool forceFeedback = false)
    {
        if (lifeStealLevel <= 0
            || healedLife <= 0 && !forceFeedback
            || playerIndex < 0
            || playerIndex >= Main.maxPlayers
            || !Main.player[playerIndex].active
            || Main.netMode != NetmodeID.Server && playerIndex != Main.myPlayer)
        {
            return;
        }

        int count = Math.Max(1, (Math.Max(1, healedLife) + 7) / 8);
        Player player = Main.player[playerIndex];
        for (int index = 0; index < count; index++)
        {
            Vector2 velocity = Main.rand.NextVector2Circular(2.8f, 2.8f);
            int projectileIndex = Projectile.NewProjectile(
                player.GetSource_Misc("SoulHarvest:LifeStealFeedback"),
                source + Main.rand.NextVector2Circular(5f, 5f),
                velocity,
                ModContent.ProjectileType<LifeStealWispProjectile>(),
                0,
                0f,
                playerIndex,
                lifeStealLevel,
                Main.rand.NextFloat(MathHelper.TwoPi));
            if (projectileIndex >= 0 && projectileIndex < Main.maxProjectiles)
                Main.projectile[projectileIndex].netUpdate = true;
        }
    }
}