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; // 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()) && !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()); else NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType()); return true; } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale) { Texture2D texture = ModContent.Request("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("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 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(8). AddTile(TileID.Anvils). Register(); } } }