88 lines
2.8 KiB
C#
88 lines
2.8 KiB
C#
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Rarities;
|
|
using CalamityMod.Tiles.Furniture.CraftingStations;
|
|
using Terraria;
|
|
using Terraria.Localization;
|
|
using Terraria.ModLoader;
|
|
using System.IO;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria.ModLoader.IO;
|
|
|
|
namespace CalamityMod.Items.Armor.Demonshade
|
|
{
|
|
[AutoloadEquip(EquipType.Legs)]
|
|
public class DemonshadeGreaves : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Armor.PostMoonLord";
|
|
|
|
// Shadow Speed... (elusive)
|
|
public static float MoveSpeedBoost = 0.3f;
|
|
public static float AccelerationBoost = 0.5f;
|
|
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(MoveSpeedBoost.ToPercent(), AccelerationBoost.ToPercent());
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 18;
|
|
Item.height = 18;
|
|
Item.defense = 50;
|
|
|
|
Item.value = CalamityGlobalItem.RarityHotPinkBuyPrice;
|
|
Item.rare = ModContent.RarityType<HotPink>();
|
|
Item.Calamity().devItem = true;
|
|
}
|
|
|
|
#region Toggleable Acceleration effect
|
|
|
|
bool toggleEnabled = true;
|
|
|
|
public override bool CanRightClick() => Main.keyState.PressingShift();
|
|
public override void RightClick(Player player)
|
|
{
|
|
toggleEnabled = !toggleEnabled;
|
|
Item.NetStateChanged();
|
|
}
|
|
public override bool ConsumeItem(Player player) => false;
|
|
public override void SaveData(TagCompound tag)
|
|
{
|
|
tag.Add("toggleEffect", toggleEnabled);
|
|
}
|
|
|
|
public override void LoadData(TagCompound tag)
|
|
{
|
|
toggleEnabled = tag.GetBool("toggleEffect");
|
|
}
|
|
|
|
public override void NetSend(BinaryWriter writer)
|
|
{
|
|
writer.Write(toggleEnabled);
|
|
}
|
|
|
|
public override void NetReceive(BinaryReader reader)
|
|
{
|
|
toggleEnabled = reader.ReadBoolean();
|
|
}
|
|
|
|
public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
|
{
|
|
CalamityUtils.DrawInventoryDot(spriteBatch, position, new Vector2(16, 16) * Main.inventoryScale, toggleEnabled);
|
|
}
|
|
#endregion
|
|
|
|
public override void UpdateEquip(Player player)
|
|
{
|
|
var modPlayer = player.Calamity();
|
|
modPlayer.shadowSpeed = toggleEnabled;
|
|
player.moveSpeed += MoveSpeedBoost;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient<ShadowspecBar>(15).
|
|
AddTile<DraedonsForge>().
|
|
Register();
|
|
}
|
|
}
|
|
}
|