Files
ForgottenWawiTech/Content/Players/AvaliVanguardPlayer.cs
T

64 lines
1.9 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.Projectiles.Avali;
namespace ForgottenWawiTech.Content.Players
{
public class AvaliVanguardPlayer : ModPlayer
{
private const int DroneCount = 3;
private const float SpawnRadius = 72f;
public bool HuntingDronesActive { get; private set; }
public static int GetDroneBaseDamage(Player player)
{
const int droneBaseDamage = 240;
return (int)player.GetTotalDamage(DamageClass.Summon).ApplyTo(droneBaseDamage);
}
public override void ResetEffects()
{
HuntingDronesActive = false;
}
public void EnableHuntingDrones()
{
HuntingDronesActive = true;
}
public override void PostUpdate()
{
if (!HuntingDronesActive || Player.whoAmI != Main.myPlayer)
{
return;
}
int droneType = ModContent.ProjectileType<AvaliHuntingDrone>();
int owned = Player.ownedProjectileCounts[droneType];
if (owned >= DroneCount)
{
return;
}
var source = Player.GetSource_Misc("AvaliVanguardSet");
for (int i = owned; i < DroneCount; i++)
{
float rotationOffset = MathHelper.TwoPi * i / DroneCount;
Vector2 spawnPos = Player.Center + rotationOffset.ToRotationVector2() * SpawnRadius;
Projectile projectile = Projectile.NewProjectileDirect(
source,
spawnPos,
Vector2.Zero,
droneType,
0,
0f,
Player.whoAmI,
i,
DroneCount);
projectile.originalDamage = GetDroneBaseDamage(Player);
}
}
}
}