Files
CalamityModPublic/Items/SummonItems/Invasion/MartianDistressRemote.cs
T
Flowaria 0753b7f21a Martian Remote, Caustic Tear MP fix and possibly Cosmolight MP fix (#46)
* Fixed Cosmolight to work properly in MP

* Remove redundent WorldSync on CausticTear

* Fixed MartianRemote to work on MP
2024-07-21 22:22:50 -04:00

70 lines
2.8 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.SummonItems.Invasion
{
[LegacyName("MartianDistressBeacon")]
public class MartianDistressRemote : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.SummonItems";
public int frameCounter = 0;
public int frame = 0;
public override void SetStaticDefaults()
{
ItemID.Sets.SortingPriorityBossSpawns[Type] = 17; // Solar Tablet (1 above Lihzahrd Power Cell)
}
public override void SetDefaults()
{
Item.width = 26;
Item.height = 52;
Item.maxStack = 1;
Item.rare = ItemRarityID.Yellow;
Item.useAnimation = 10;
Item.useTime = 10;
Item.useStyle = ItemUseStyleID.HoldUp;
Item.consumable = false;
Item.UseSound = SoundID.Zombie67;
}
public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
{
itemGroup = ContentSamples.CreativeHelper.ItemGroup.EventItem;
}
public override bool CanUseItem(Player player) => Main.invasionType == InvasionID.None;
public override bool? UseItem(Player player)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
Main.invasionDelay = 0;
Main.StartInvasion(InvasionID.MartianMadness);
}
else
{
//-7.0 is hardcoded id for MartianMadness Event
NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, number: player.whoAmI, number2: -7.0f);
}
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/Invasion/MartianDistressRemote_Animated").Value;
spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 12), Color.White, 0f, origin, scale, SpriteEffects.None, 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/Invasion/MartianDistressRemote_Animated").Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 5, 12), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
return false;
}
}
}