Files
CalamityModPublic/Items/Weapons/DraedonsArsenal/CompactRailgun.cs
T
2025-04-09 13:46:22 -07:00

85 lines
3.7 KiB
C#

using System;
using System.Collections.Generic;
using CalamityMod.CustomRecipes;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.DraedonsArsenal;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.DraedonsArsenal
{
[LegacyName("GaussRifle")]
public class CompactRailgun : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.DraedonsArsenal";
public override void SetStaticDefaults()
{
ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true;
ItemID.Sets.IsRangedSpecialistWeapon[Type] = true;
}
public override void SetDefaults()
{
CalamityGlobalItem modItem = Item.Calamity();
Item.width = 70;
Item.height = 30;
Item.DamageType = DamageClass.Ranged;
Item.damage = 60;
Item.knockBack = 7f;
Item.useTime = Item.useAnimation = 8;
Item.autoReuse = true;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.channel = true;
Item.noUseGraphic = true;
Item.value = CalamityGlobalItem.RarityYellowBuyPrice;
Item.rare = ItemRarityID.Yellow;
Item.shoot = ModContent.ProjectileType<CompactRailgunHoldout>();
Item.shootSpeed = 7f;
}
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] <= 0;
public override bool AltFunctionUse(Player player) => true;
public override void HoldItem(Player player)
{
if (Main.myPlayer == player.whoAmI)
player.Calamity().rightClickListener = true;
player.Calamity().mouseWorldListener = true;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float gunType = 0;
if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse && player.Calamity().arsenalCooldown <= 0)
gunType = 5;
Projectile holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, gunType);
// 14NOV2024: Ozzatron: clamped mouse position unnecessary, only used for direction
// We set the rotation to the direction to the mouse so the first frame doesn't appear bugged out.
holdout.velocity = (player.Calamity().mouseWorld - player.MountedCenter).SafeNormalize(Vector2.Zero);
return false;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/DraedonsArsenal/CompactRailgunGlow").Value);
}
public override void ModifyTooltips(List<TooltipLine> tooltips) => CalamityGlobalItem.InsertKnowledgeTooltip(tooltips, 3);
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<MysteriousCircuitry>(18).
AddIngredient<DubiousPlating>(12).
AddIngredient<LifeAlloy>(5).
AddIngredient<InfectedArmorPlating>(10).
AddCondition(ArsenalTierGatedRecipe.ConstructRecipeCondition(3, out Func<bool> condition), condition).
AddTile(TileID.MythrilAnvil).
Register();
}
}
}