Added timer for reload
This commit is contained in:
parent
954ae7c36d
commit
8a385a3f86
BIN
Content/Legumix/Weapon/Revolver/BP_Revolver.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Weapon/Revolver/BP_Revolver.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset
(Stored with Git LFS)
Binary file not shown.
@ -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)
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user