Added timer for reload

This commit is contained in:
TjgL 2025-01-24 11:39:23 +01:00
parent 954ae7c36d
commit 8a385a3f86
4 changed files with 18 additions and 6 deletions

Binary file not shown.

Binary file not shown.

View File

@ -93,12 +93,19 @@ bool ALMWeaponBase::DefaultReload()
// TODO: Use Animations
OnDefaultReload();
GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay);
return true;
}
void ALMWeaponBase::AllowRefire()
{
GetWorldTimerManager().ClearTimer(FireTimer);
// TODO : improve this
if (FireTimer.IsValid())
GetWorldTimerManager().ClearTimer(FireTimer);
else if (ReloadTimer.IsValid())
GetWorldTimerManager().ClearTimer(ReloadTimer);
State = EWeaponState::EWS_Idle;
if (ClipAmmo <= 0)

View File

@ -48,6 +48,7 @@ public:
void OnDefaultReload();
protected:
UFUNCTION(BlueprintCallable)
void AllowRefire();
private:
@ -60,6 +61,7 @@ public:
protected: /* Weapon Data */
FTimerHandle FireTimer;
FTimerHandle ReloadTimer;
/** The sound to play when firing. */
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
@ -84,6 +86,9 @@ protected: /* Weapon Data */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
float RefireDelay = 0.5f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
float ReloadDelay = 0.5f;
/** The flat damage number of one bullet. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
float Damage = 10.f;