using System; using Decimation.Lib.Util; using Terraria; namespace Decimation.Lib.Items { public abstract class DecimationWeapon : DecimationItem { public enum DamageType { Melee, Magic, Throw, Ranged } protected virtual DamageType DamagesType { get; } = DamageType.Melee; [Obsolete("Use ProjectileId instead")] protected virtual string ProjectileName { get; } = null; protected virtual int ProjectileId { get; } = -1; [Obsolete("Use AmmoId instead")] protected virtual string AmmoName { get; } = null; protected virtual int AmmoId { get; } = -1; [Obsolete] protected virtual bool VanillaProjectile { get; } = false; [Obsolete] protected virtual bool VanillaAmmo { get; } = false; protected abstract int Damages { get; } protected abstract void InitWeapon(); protected override void Init() { item.useStyle = 1; item.autoReuse = false; item.useTurn = true; item.maxStack = 1; switch (DamagesType) { case DamageType.Magic: item.magic = true; break; case DamageType.Ranged: item.ranged = true; break; case DamageType.Throw: item.thrown = true; break; default: item.melee = true; break; } InitWeapon(); item.damage = Damages; if (ProjectileName != null) item.shoot = ItemUtils.GetIdFromName(ProjectileName, typeof(Projectile), VanillaProjectile); if (ProjectileId > -1) item.shoot = ProjectileId; if (AmmoName != null) item.useAmmo = ItemUtils.GetIdFromName(AmmoName, typeof(Item), VanillaAmmo); if (AmmoId > -1) item.ammo = AmmoId; if (item.melee) item.noMelee = false; } } }