Space Plunder
Loading...
Searching...
No Matches
CrosshairWidget.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Blueprint/UserWidget.h"
7#include "Components/TextBlock.h"
10#include "CrosshairWidget.generated.h"
11
16UCLASS()
17class WEAPONSYSTEM_API UCrosshairWidget : public UUserWidget, public ICrosshairInterface
18{
19 GENERATED_BODY()
20
21public:
22
23 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category="Weapon Widget")
24 void OnHitMarker(const AActor* ActorHit, const float Damage, const UDamageType* DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit, const bool bInjuredPart);
25 virtual void HitMarker(const AActor* ActorHit, const float Damage, const UDamageType* DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit, const bool bInjuredPart) override;
26 virtual void GunRecoil(const float RecoilAmount) override;
27
28
29 UFUNCTION(BlueprintCallable, Category="Weapon Widget")
30 void SetCrosshairLocation();
31 void SetCrosshairRadius();
32
33 // UFUNCTION(BlueprintCallable, Category="Weapon Widget")
34 // void SetCrosshairVisibility(const float Alpha) const;
35 UFUNCTION(BlueprintCallable, Category="Weapon Widget")
36 void SetGunRecoil(const float RecoilAmount);
37
38 virtual void StartedAiming() override;
39 virtual void StoppedAiming() override;
40 UFUNCTION(BlueprintImplementableEvent, Category="Weapon Widget")
41 void OnStartedAiming();
42 UFUNCTION(BlueprintImplementableEvent, Category="Weapon Widget")
43 void OnStoppedAiming();
44
45 virtual void SetHolstered(const bool bIsHolstered) override;
46 UFUNCTION(BlueprintImplementableEvent, Category="Weapon Widget")
47 void OnHolsteredSet(const bool bIsHolstered);
48
49 virtual void SetWeaponCrosshair(const FCrosshairData& CrosshairType, const float Spread) override;
50
51 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category="Weapon Widget")
52 void OnSetWeaponCrosshair(const FCrosshairData& CrosshairType, const float Spread);
53
54
55
56protected:
57 virtual bool Initialize() override;
58
59 virtual void NativeConstruct() override;
60
61 UFUNCTION()
62 void VisibilityChangedEvent(ESlateVisibility InVisibility);
63
64
65 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
66 float InterpSpeed = 12.0f;
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
68 float UpperBound = -80.0f;
69 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
70 float LowerBound = 25.0f;
71
72 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
73 float RecoilMultiplier = 20.0f;
74 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
75 float PlayerSpeedMultiplier = 0.15f;
76 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
77 float WeaponSpreadMultiplier = 0.15f;
78
79 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
80 float UpdateSpeed = 0.03f;
81
82 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
83 float CrosshairOpacityLow = 0.2f;
84 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
85 bool bShowDamageNumbers = false;
86 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Crosshair|General")
87 bool bShowDamageHitDot = false;
88
89 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
90 UWidget* DamageVerticalBox = nullptr;
91 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
92 UWidget* HitMarkerWidget = nullptr;
93 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
94 UTextBlock* DamageAmount = nullptr;
95
96 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
97 class UCircumferenceMarkerWidget* Crosshairs = nullptr;
98 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
99 class UWidget* HitMarkers = nullptr;
100 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
101 UWidget* CrosshairOverlay = nullptr;
102
103
104 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
105 class USizeBox* ReticleSizeBox = nullptr;
106
107 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
108 class UImage* OuterImage = nullptr;
109 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (BindWidget))
110 class UImage* OuterImageHorizontal = nullptr;
111
112 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Crosshair|Status")
113 bool bHolstered = true;
114 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Crosshair|Status")
115 bool bAiming = false;
116 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Crosshair|Status")
117 int32 CrosshairStyle = 0;
118 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Crosshair|Status")
119 FCrosshairData CrosshairData;
120 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Crosshair|Status")
121 float WeaponSpread = 0.0f;
122private:
123 void SetDamagePosition(const FVector& Location) const;
124 void SetCrosshairOpacity() const;
125
126 void SetReticleSize(const float Radius) const;
127
128 void SetHitMarkerVisibility(const float Alpha) const;
129 float ProcessNumbers(const class UCanvasPanelSlot* CanvasSlot, const bool bVertical) const;
130
131 float ComputeMaxScreenspaceSpreadRadius() const;
132
133 FTimerHandle HitMarkerTimerHandle;
134 FTimerHandle CrosshairUpdateTimerHandle;
135
136 float Recoil;
137 bool bRecoilFire = false;
138
139
140
141
142};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition CrosshairInterface.h:20
Definition CircumferenceMarkerWidget.h:17
Definition CrosshairWidget.h:18
Struct representing the data for a crosshair.
Definition WeaponStructs.h:225