|
|
|
|
| #pragma once
|
|
|
| #include "Curves/CurveFloat.h"
|
|
|
| #include "LyraWeaponInstance.h"
|
| #include "AbilitySystem/LyraAbilitySourceInterface.h"
|
|
|
| #include "LyraRangedWeaponInstance.generated.h"
|
|
|
| class UPhysicalMaterial;
|
|
|
| |
| |
| |
| |
|
|
| UCLASS()
|
| class ULyraRangedWeaponInstance : public ULyraWeaponInstance, public ILyraAbilitySourceInterface
|
| {
|
| GENERATED_BODY()
|
|
|
| public:
|
| ULyraRangedWeaponInstance(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
|
|
| virtual void PostLoad() override;
|
|
|
| #if WITH_EDITOR
|
| virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
|
|
| void UpdateDebugVisualization();
|
| #endif
|
|
|
| int32 GetBulletsPerCartridge() const
|
| {
|
| return BulletsPerCartridge;
|
| }
|
|
|
|
|
| float GetCalculatedSpreadAngle() const
|
| {
|
| return CurrentSpreadAngle;
|
| }
|
|
|
| float GetCalculatedSpreadAngleMultiplier() const
|
| {
|
| return bHasFirstShotAccuracy ? 0.0f : CurrentSpreadAngleMultiplier;
|
| }
|
|
|
| bool HasFirstShotAccuracy() const
|
| {
|
| return bHasFirstShotAccuracy;
|
| }
|
|
|
| float GetSpreadExponent() const
|
| {
|
| return SpreadExponent;
|
| }
|
|
|
| float GetMaxDamageRange() const
|
| {
|
| return MaxDamageRange;
|
| }
|
|
|
| float GetBulletTraceSweepRadius() const
|
| {
|
| return BulletTraceSweepRadius;
|
| }
|
|
|
| protected:
|
| #if WITH_EDITORONLY_DATA
|
| UPROPERTY(VisibleAnywhere, Category = "Spread|Fire Params")
|
| float Debug_MinHeat = 0.0f;
|
|
|
| UPROPERTY(VisibleAnywhere, Category = "Spread|Fire Params")
|
| float Debug_MaxHeat = 0.0f;
|
|
|
| UPROPERTY(VisibleAnywhere, Category="Spread|Fire Params", meta=(ForceUnits=deg))
|
| float Debug_MinSpreadAngle = 0.0f;
|
|
|
| UPROPERTY(VisibleAnywhere, Category="Spread|Fire Params", meta=(ForceUnits=deg))
|
| float Debug_MaxSpreadAngle = 0.0f;
|
|
|
| UPROPERTY(VisibleAnywhere, Category="Spread Debugging")
|
| float Debug_CurrentHeat = 0.0f;
|
|
|
| UPROPERTY(VisibleAnywhere, Category="Spread Debugging", meta = (ForceUnits=deg))
|
| float Debug_CurrentSpreadAngle = 0.0f;
|
|
|
|
|
| UPROPERTY(VisibleAnywhere, Category = "Spread Debugging", meta=(ForceUnits=x))
|
| float Debug_CurrentSpreadAngleMultiplier = 1.0f;
|
|
|
| #endif
|
|
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(ClampMin=0.1), Category="Spread|Fire Params")
|
| float SpreadExponent = 1.0f;
|
|
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category = "Spread|Fire Params")
|
| FRuntimeFloatCurve HeatToSpreadCurve;
|
|
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Spread|Fire Params")
|
| FRuntimeFloatCurve HeatToHeatPerShotCurve;
|
|
|
|
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Spread|Fire Params")
|
| FRuntimeFloatCurve HeatToCoolDownPerSecondCurve;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Spread|Fire Params", meta=(ForceUnits=s))
|
| float SpreadRecoveryCooldownDelay = 0.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Spread|Fire Params")
|
| bool bAllowFirstShotAccuracy = false;
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category="Spread|Player Params", meta=(ForceUnits=x))
|
| float SpreadAngleMultiplier_Aiming = 1.0f;
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params", meta=(ForceUnits=x))
|
| float SpreadAngleMultiplier_StandingStill = 1.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params")
|
| float TransitionRate_StandingStill = 5.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params", meta=(ForceUnits="cm/s"))
|
| float StandingStillSpeedThreshold = 80.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params", meta=(ForceUnits="cm/s"))
|
| float StandingStillToMovingSpeedRange = 20.0f;
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params", meta=(ForceUnits=x))
|
| float SpreadAngleMultiplier_Crouching = 1.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params")
|
| float TransitionRate_Crouching = 5.0f;
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params", meta=(ForceUnits=x))
|
| float SpreadAngleMultiplier_JumpingOrFalling = 1.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Spread|Player Params")
|
| float TransitionRate_JumpingOrFalling = 5.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Weapon Config")
|
| int32 BulletsPerCartridge = 1;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Weapon Config", meta=(ForceUnits=cm))
|
| float MaxDamageRange = 25000.0f;
|
|
|
|
|
| UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Weapon Config", meta=(ForceUnits=cm))
|
| float BulletTraceSweepRadius = 0.0f;
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category = "Weapon Config")
|
| FRuntimeFloatCurve DistanceDamageFalloff;
|
|
|
|
|
|
|
|
|
| UPROPERTY(EditAnywhere, Category = "Weapon Config")
|
| TMap<FGameplayTag, float> MaterialDamageMultiplier;
|
|
|
| private:
|
|
|
| double LastFireTime = 0.0;
|
|
|
|
|
| float CurrentHeat = 0.0f;
|
|
|
|
|
| float CurrentSpreadAngle = 0.0f;
|
|
|
|
|
| bool bHasFirstShotAccuracy = false;
|
|
|
|
|
| float CurrentSpreadAngleMultiplier = 1.0f;
|
|
|
|
|
| float StandingStillMultiplier = 1.0f;
|
|
|
|
|
| float JumpFallMultiplier = 1.0f;
|
|
|
|
|
| float CrouchingMultiplier = 1.0f;
|
|
|
| public:
|
| void Tick(float DeltaSeconds);
|
|
|
|
|
| virtual void OnEquipped();
|
| virtual void OnUnequipped();
|
|
|
|
|
| void AddSpread();
|
|
|
|
|
| virtual float GetDistanceAttenuation(float Distance, const FGameplayTagContainer* SourceTags = nullptr, const FGameplayTagContainer* TargetTags = nullptr) const override;
|
| virtual float GetPhysicalMaterialAttenuation(const UPhysicalMaterial* PhysicalMaterial, const FGameplayTagContainer* SourceTags = nullptr, const FGameplayTagContainer* TargetTags = nullptr) const override;
|
|
|
|
|
| private:
|
| void ComputeSpreadRange(float& MinSpread, float& MaxSpread);
|
| void ComputeHeatRange(float& MinHeat, float& MaxHeat);
|
|
|
| inline float ClampHeat(float NewHeat)
|
| {
|
| float MinHeat;
|
| float MaxHeat;
|
| ComputeHeatRange( MinHeat, MaxHeat);
|
|
|
| return FMath::Clamp(NewHeat, MinHeat, MaxHeat);
|
| }
|
|
|
|
|
| bool UpdateSpread(float DeltaSeconds);
|
|
|
|
|
| bool UpdateMultipliers(float DeltaSeconds);
|
| };
|
|
|