using Microsoft.Xna.Framework;
using System;
using Terraria;
using Terraria.ModLoader;
using Terraria.Audio;
using YoshiMount.Common.Players;
using Terraria.ID;
namespace YoshiMount.Content.Mounts
{
public class Yoshi : ModMount
{
protected class YoshiSpecificData
{
internal static SoundStyle YoshiJump;
internal static SoundStyle YoshiSwim;
public YoshiSpecificData()
{
YoshiJump = new SoundStyle("YoshiMount/Assets/Sounds/YoshiJump") with { Volume = 0.4f };
YoshiSwim = new SoundStyle("YoshiMount/Assets/Sounds/YoshiSwim") with { Volume = 0.4f };
}
}
public override void SetStaticDefaults()
{
MountData.jumpHeight = 5;
MountData.acceleration = 0.3f;
MountData.jumpSpeed = 10f;
MountData.blockExtraJumps = false;
MountData.constantJump = true;
MountData.heightBoost = 19;
MountData.fallDamage = 0f;
MountData.runSpeed = 4.8f;
MountData.dashSpeed = 5.8f;
MountData.flightTimeMax = 0;
MountData.fatigueMax = 0;
MountData.totalFrames = 30;
int[] array = new int[MountData.totalFrames];
for (int i = 0; i < array.Length; i++)
{
array[i] = 18;
}
array[1] = 16;
array[2] = 16;
array[3] = 16;
array[4] = 16;
array[5] = 16;
array[6] = 16;
// Frame data and player offsets
MountData.playerYOffsets = array;
MountData.xOffset = 15;
MountData.yOffset = 4;
MountData.playerHeadOffset = 20;
MountData.bodyFrame = 3;
// Standing
MountData.standingFrameCount = 7;
MountData.standingFrameDelay = 8;
MountData.standingFrameStart = 9;
// Running
MountData.runningFrameCount = 6;
MountData.runningFrameDelay = 10;
MountData.runningFrameStart = 0;
// Flying
MountData.flyingFrameCount = 1;
MountData.flyingFrameDelay = 12;
MountData.flyingFrameStart = 21;
// In-air
MountData.inAirFrameCount = 1;
MountData.inAirFrameDelay = 12;
MountData.inAirFrameStart = 20;
// Idle
MountData.idleFrameCount = 4;
MountData.idleFrameDelay = 10;
MountData.idleFrameStart = 16;
MountData.idleFrameLoop = false;
// Swim
MountData.swimFrameCount = 8;
MountData.swimFrameDelay = 25;
MountData.swimFrameStart = 22;
if (!Main.dedServ)
{
MountData.textureWidth = MountData.frontTexture.Width();
MountData.textureHeight = MountData.frontTexture.Height();
}
}
public override void UpdateEffects(Player player)
{
if (Math.Abs(player.velocity.X) > 4f)
{
Rectangle rect = player.getRect();
Dust.NewDust(new Vector2(rect.X, rect.Y + rect.Height), 8, 8, DustID.Smoke);
}
}
public override bool UpdateFrame(Player mountedPlayer, int state, Vector2 velocity)
{
if (mountedPlayer.controlJump && mountedPlayer.justJumped)
{
SoundEngine.PlaySound(mountedPlayer.wet ? YoshiSpecificData.YoshiSwim : YoshiSpecificData.YoshiJump);
}
return true;
}
public override void Dismount(Player player, ref bool skipDust)
{
player.GetModPlayer<YoshiPlayer>().isMounted = false;
}
public override void SetMount(Player player, ref bool skipDust)
{
player.GetModPlayer<YoshiPlayer>().isMounted = true;
player.mount._mountSpecificData = new YoshiSpecificData();
if (!Main.dedServ)
{
for (int i = 0; i < 16; i++)
{
Dust.NewDustPerfect(player.Center + new Vector2(80, 0).RotatedBy(i * Math.PI * 2 / 16f), MountData.spawnDust);
}
skipDust = true;
}
}
}
}