Files
CalamityModPublic/Items/SummonItems/CryoKey.cs
T
Altixal 0694d1fd32 quickfire suggestions
also fixed sorting priorities AGAIN urngiudrgnju
2024-05-25 04:55:39 +07:00

91 lines
3.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using CalamityMod.Events;
using CalamityMod.Items.Materials;
using CalamityMod.NPCs.Cryogen;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Audio;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.SummonItems
{
public class CryoKey : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.SummonItems";
public override void SetStaticDefaults()
{
ItemID.Sets.SortingPriorityBossSpawns[Type] = 7; // Ocram's Razor (1 below Mechanical Eye)
}
public override void SetDefaults()
{
Item.width = 26;
Item.height = 48;
Item.rare = ItemRarityID.Pink;
Item.useAnimation = 10;
Item.useTime = 10;
Item.useStyle = ItemUseStyleID.HoldUp;
}
public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
{
itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem;
}
public override bool CanUseItem(Player player)
{
return player.ZoneSnow && !NPC.AnyNPCs(ModContent.NPCType<Cryogen>()) && !BossRushEvent.BossRushActive;
}
public override bool? UseItem(Player player)
{
SoundEngine.PlaySound(SoundID.Roar, player.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
NPC.SpawnOnPlayer(player.whoAmI, ModContent.NPCType<Cryogen>());
else
NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType<Cryogen>());
return true;
}
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/SummonItems/CryoKey").Value;
Color overlay = Main.zenithWorld ? Color.Red : Color.White;
spriteBatch.Draw(texture, position, null, overlay, 0f, origin, scale, 0, 0);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/SummonItems/CryoKey").Value;
Color overlay = Main.zenithWorld ? Color.Red : lightColor;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, overlay, 0f, Vector2.Zero, 1f, 0, 0);
return false;
}
public override void UpdateInventory(Player player)
{
if (Main.zenithWorld)
Item.SetNameOverride(this.GetLocalizedValue("GFBName"));
}
public override void ModifyTooltips(List<TooltipLine> list) => list.FindAndReplace("[SPAWN]", this.GetLocalizedValue(Main.zenithWorld ? "SpawnGFB" : "SpawnNormal"));
public override void AddRecipes()
{
CreateRecipe().
AddRecipeGroup("AnyIceBlock", 50).
AddIngredient(ItemID.SoulofLight, 5).
AddIngredient(ItemID.SoulofNight, 5).
AddIngredient<EssenceofEleum>(8).
AddTile(TileID.Anvils).
Register();
}
}
}