diff --git a/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset index dbf1b72..f5d620a 100644 --- a/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset +++ b/Content/Legumix/Weapon/Revolver/BP_Revolver.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac50c4513c07edf8b9f7490a085727d27d29c53d4323b87db88e256d5f8a5b07 -size 55477 +oid sha256:7a321d23370f221f76b28bcef172d19c5603474297e34f79f13623e4717b9fff +size 52111 diff --git a/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset b/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset index 3c4b2bf..7d43b52 100644 --- a/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset +++ b/Content/Legumix/Weapon/Shotgun/BP_Shotgun.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:045c438a124e16846c0ae55f93855b2a95e60a7f571cb45ebcd92f266e951ba4 -size 57491 +oid sha256:3536f68d8d3feb88b85e0ae67de885430d07f6d5ea1bdd7cafb0aa37a3194acd +size 53921 diff --git a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp index cb68920..9b83164 100644 --- a/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp +++ b/Source/LegumeMix/Private/Weapon/LMWeaponBase.cpp @@ -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) diff --git a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h index c363662..7cad860 100644 --- a/Source/LegumeMix/Public/Weapon/LMWeaponBase.h +++ b/Source/LegumeMix/Public/Weapon/LMWeaponBase.h @@ -48,6 +48,7 @@ public: void OnDefaultReload(); protected: + UFUNCTION(BlueprintCallable) void AllowRefire(); private: @@ -57,9 +58,10 @@ public: /** The current state of the weapon. */ UPROPERTY(VisibleInstanceOnly, BlueprintReadWrite, Category="Legumix|Weapon") EWeaponState State; - + 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;