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(), 0, 0f, playerIndex, lifeStealLevel, Main.rand.NextFloat(MathHelper.TwoPi)); if (projectileIndex >= 0 && projectileIndex < Main.maxProjectiles) Main.projectile[projectileIndex].netUpdate = true; } } }