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;
|
|
|
|
|
|
|
|
namespace SupaLidlGame.Items
|
|
|
|
{
|
|
|
|
public abstract partial class Weapon : Item
|
|
|
|
{
|
|
|
|
public double RemainingUseTime { get; protected set; } = 0;
|
|
|
|
|
2022-11-19 21:21:12 -08:00
|
|
|
public bool IsUsing => RemainingUseTime > 0;
|
2022-11-13 19:52:09 -08:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// How much damage in HP that this weapon deals.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float Damage { get; set; } = 0;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The time in seconds it takes for this weapon to become available
|
|
|
|
/// again after using.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public double UseTime { get; set; } = 0;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The magnitude of the knockback force of the weapon.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float Knockback { get; set; } = 0;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The initial velocity of any projectile the weapon may spawn.
|
|
|
|
/// </summary>
|
|
|
|
[Export]
|
|
|
|
public float InitialVelocity { get; set; } = 0;
|
|
|
|
|
2022-11-25 09:11:46 -08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether or not the weapon can parry other weapons and is
|
|
|
|
/// parryable by other weapons.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool IsParryable { get; protected set; } = false;
|
|
|
|
|
|
|
|
public bool IsParried { get; set; }
|
|
|
|
|
|
|
|
public ulong ParryTimeOrigin { get; protected set; }
|
|
|
|
|
2022-11-13 19:52:09 -08:00
|
|
|
public Character Character { get; set; }
|
|
|
|
|
|
|
|
public override void Equip(Character character)
|
|
|
|
{
|
|
|
|
Character = character;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Unequip(Character character)
|
|
|
|
{
|
|
|
|
Character = null;
|
|
|
|
}
|
|
|
|
|
2022-11-19 21:21:12 -08:00
|
|
|
public override void Use()
|
|
|
|
{
|
|
|
|
RemainingUseTime = UseTime;
|
|
|
|
}
|
|
|
|
|
2022-11-13 19:52:09 -08:00
|
|
|
public override void Deuse()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2022-11-19 21:21:12 -08:00
|
|
|
|
|
|
|
public override void _Process(double delta)
|
|
|
|
{
|
|
|
|
if (RemainingUseTime > 0)
|
|
|
|
{
|
|
|
|
if ((RemainingUseTime -= delta) <= 0)
|
|
|
|
{
|
|
|
|
Deuse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-25 09:11:46 -08:00
|
|
|
|
|
|
|
public virtual void _on_hitbox_hit(BoundingBox box)
|
|
|
|
{
|
|
|
|
if (box is Hurtbox hurtbox)
|
|
|
|
{
|
|
|
|
hurtbox.InflictDamage(Damage, Character, Knockback);
|
|
|
|
}
|
|
|
|
}
|
2022-11-13 19:52:09 -08:00
|
|
|
}
|
|
|
|
}
|