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
|
// TODO: Use Animations
|
||||||
OnDefaultReload();
|
OnDefaultReload();
|
||||||
|
GetWorldTimerManager().SetTimer(ReloadTimer, this, &ALMWeaponBase::AllowRefire, ReloadDelay);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ALMWeaponBase::AllowRefire()
|
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;
|
State = EWeaponState::EWS_Idle;
|
||||||
|
|
||||||
if (ClipAmmo <= 0)
|
if (ClipAmmo <= 0)
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
void OnDefaultReload();
|
void OnDefaultReload();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
void AllowRefire();
|
void AllowRefire();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -60,6 +61,7 @@ public:
|
|||||||
|
|
||||||
protected: /* Weapon Data */
|
protected: /* Weapon Data */
|
||||||
FTimerHandle FireTimer;
|
FTimerHandle FireTimer;
|
||||||
|
FTimerHandle ReloadTimer;
|
||||||
|
|
||||||
/** The sound to play when firing. */
|
/** The sound to play when firing. */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite,Category="Legumix|Sounds")
|
||||||
@ -84,6 +86,9 @@ protected: /* Weapon Data */
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
||||||
float RefireDelay = 0.5f;
|
float RefireDelay = 0.5f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
||||||
|
float ReloadDelay = 0.5f;
|
||||||
|
|
||||||
/** The flat damage number of one bullet. */
|
/** The flat damage number of one bullet. */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Legumix|Weapon", meta=(AllowPrivateAccess=true))
|
||||||
float Damage = 10.f;
|
float Damage = 10.f;
|
||||||
|
Reference in New Issue
Block a user