2022-11-13 19:52:09 -08:00
|
|
|
using Godot;
|
2022-11-25 09:11:46 -08:00
|
|
|
using SupaLidlGame.BoundingBoxes;
|
2022-11-13 19:52:09 -08:00
|
|
|
using SupaLidlGame.Characters;
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
namespace SupaLidlGame.Items;
|
|
|
|
|
|
|
|
public abstract partial class Weapon : Item
|
2022-11-13 19:52:09 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
public double RemainingUseTime { get; protected set; } = 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-08-08 00:54:00 -07:00
|
|
|
public override bool IsUsing => IsUsingPrimary || IsUsingAlt;
|
|
|
|
|
|
|
|
public virtual bool IsUsingPrimary => false;
|
|
|
|
|
|
|
|
public virtual bool IsUsingAlt => false;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-09-10 12:30:26 -07:00
|
|
|
[Signal]
|
|
|
|
public delegate void UsedItemAltEventHandler(Weapon weapon);
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// How much damage in HP that this weapon deals.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float Damage { get; set; } = 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// The time in seconds it takes for this weapon to become available
|
|
|
|
/// again after using.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public double UseTime { get; set; } = 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-08-08 00:54:00 -07:00
|
|
|
[Export]
|
|
|
|
public double UseAltTime { get; set; } = 0;
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// The magnitude of the knockback force of the weapon.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float Knockback { get; set; } = 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// The initial velocity of any projectile the weapon may spawn.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float InitialVelocity { get; set; } = 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Hides the weapon if it is idle (i.e. not being used).
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public bool ShouldHideIdle { get; set; } = false;
|
2023-05-28 10:57:23 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Freezes the player's target angle if this weapon is being used.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public bool ShouldFreezeAngleOnUse { get; set; } = true;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
[Export]
|
|
|
|
public float MinDistanceHint { get; set; }
|
2023-04-01 16:25:33 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
[Export]
|
|
|
|
public float MaxDistanceHint { get; set; }
|
2023-04-01 16:25:33 -07:00
|
|
|
|
2023-09-03 17:42:32 -07:00
|
|
|
[Export]
|
|
|
|
public float PlayerLevelGain { get; set; }
|
|
|
|
|
2023-07-22 20:23:48 -07:00
|
|
|
[Export]
|
|
|
|
public Sprite2D HandAnchor { get; set; }
|
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public virtual bool IsParryable { get; protected set; } = false;
|
2023-05-28 17:54:48 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public bool IsParried { get; set; }
|
2023-05-28 17:54:48 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public Character Character { get; set; }
|
2023-05-28 17:54:48 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public Vector2 UseDirection { get; set; }
|
2023-05-28 17:54:48 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override bool StacksWith(Item item) => false;
|
2023-03-19 13:54:48 -07:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void Equip(Character character)
|
|
|
|
{
|
|
|
|
if (!ShouldHideIdle || IsUsing)
|
2022-11-13 19:52:09 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
Visible = true;
|
2022-11-13 19:52:09 -08:00
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
Character = character;
|
2023-07-22 20:23:48 -07:00
|
|
|
|
|
|
|
// set the hand textures to the character's
|
|
|
|
if (HandAnchor is not null && character.HandTexture is not null)
|
|
|
|
{
|
|
|
|
HandAnchor.Texture = character.HandTexture;
|
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
}
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void Unequip(Character character)
|
|
|
|
{
|
|
|
|
Visible = false;
|
|
|
|
Character = null;
|
|
|
|
}
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void Use()
|
|
|
|
{
|
|
|
|
RemainingUseTime = UseTime;
|
|
|
|
}
|
2022-11-19 21:21:12 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void Deuse()
|
|
|
|
{
|
2022-11-13 19:52:09 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
}
|
2022-11-19 21:21:12 -08:00
|
|
|
|
2023-06-03 18:21:46 -07:00
|
|
|
public override void _Process(double delta)
|
|
|
|
{
|
|
|
|
if (RemainingUseTime > 0)
|
2022-11-19 21:21:12 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
if ((RemainingUseTime -= delta) <= 0)
|
2022-11-19 21:21:12 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
//Deuse();
|
2022-11-19 21:21:12 -08:00
|
|
|
}
|
|
|
|
}
|
2023-06-03 18:21:46 -07:00
|
|
|
}
|
2022-11-25 09:11:46 -08:00
|
|
|
|
2023-07-23 11:05:01 -07:00
|
|
|
public virtual void OnHitboxHit(BoundingBox box)
|
2023-06-03 18:21:46 -07:00
|
|
|
{
|
|
|
|
if (box is Hurtbox hurtbox)
|
2022-11-25 09:11:46 -08:00
|
|
|
{
|
2023-06-03 18:21:46 -07:00
|
|
|
hurtbox.InflictDamage(Damage, Character, Knockback);
|
2022-11-25 09:11:46 -08:00
|
|
|
}
|
2022-11-13 19:52:09 -08:00
|
|
|
}
|
|
|
|
}
|