5#include "CoreMinimal.h"
9#include "CharacterShootingComponent.generated.h"
28UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent))
38 UPROPERTY(BlueprintAssignable, Category = "Weapons")
39 FOnWeaponEqiupped OnWeaponEquipped;
40 UPROPERTY(BlueprintAssignable, Category = "Ammo")
41 FOnAmmoChangedSignature OnAmmoChanged;
42 UPROPERTY(BlueprintAssignable, Category = "Ammo")
43 FOnWeaponStateChanged OnWeaponStateChanged;
44 UPROPERTY(BlueprintAssignable, Category = "Recoil")
45 FOnBulletShot OnBulletShot;
48 UFUNCTION(
Server, Reliable)
49 void Server_SpawnWeaponActor_NEW();
53 void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent);
54 void SetThrowStrength(const
float Strength){PickupThrowIntensity = Strength;};
55 void SetThrowPoint(USceneComponent* ThrowPointComponent){ThrowPoint = ThrowPointComponent;};
58 UFUNCTION(
Server, Reliable)
59 void Server_SetThrowPoint(USceneComponent* ThrowPointComponent);
63 UFUNCTION(BlueprintCallable, Category =
"Shooting Component")
65 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
67 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
69 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
70 void SetTargetLocation(const FVector& TargetLocation);
76 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
77 void AimPressedAction(const
bool bRightShoulder = true);
78 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
79 void AimReleasedAction(const
bool bRightShoulder = true);
80 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
81 void ThrowWeaponAction();
83 UFUNCTION(
Server, Reliable)
85 UFUNCTION(
Client, Reliable)
90 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
92 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
93 void SwitchAutoMode();
94 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Shooting Component")
95 float GetLastReloadTime()
const {
return LastReloadDuration;};
99 UFUNCTION(BlueprintCallable, Category =
"Shooting Component")
100 void PickupWeapon(const
FWeaponData_T& WeaponToPickup, int32& RemainingAmmo);
102 void SwapWeaponPressed();
103 void SwapWeaponReleased();
105 void HolsterWeapon();
111 void GetThrowStats(FTransform& OutTransform, FVector& OutThrowForce) const;
113 UFUNCTION(
Server, Reliable)
114 void Server_AddStartingWeapons(const TArray<FString>& WeaponIDs);
118 UFUNCTION(
Server, Reliable)
119 void ServerStopShootGun();
120 UFUNCTION(
Server, Reliable)
121 void ServerSwapWeapon();
123 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
124 void PickupAttachment(const FString& WeaponAttachmentID);
127 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
129 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
130 bool CanPickupAttachment(const
FWeaponAttachment& In_WeaponAttachmentData) const;
132 UFUNCTION(
Server, Reliable)
133 void Server_PickupWeapon(
FWeaponData_T WeaponToPickup, int32 RemainingAmmo);
135 UFUNCTION(
Server, Reliable)
138 UFUNCTION(
Server, Reliable)
139 void Server_ThrowAllWeapons();
142 UFUNCTION(
Server, Reliable)
143 void ServerHideWeaponModel(const
bool bHidden);
146 virtual
void SetupComponent(USkeletalMeshComponent* SkeletalMesh, UAnimInstance* AnimationInstance, AController* Controller, AActor* HUDReference, const
bool bNPC, const
bool bDead) override;
147 virtual
void ComponentSetupComplete() override;
148 virtual
void OwnerDeath() override;
149 virtual
void OnMontageNotifyBegin(FName NotifyName, const FBranchingPointNotifyPayload& BranchingPointPayload) override;
153 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Shooting Component")
154 TArray<
FWeaponData_T>& GetWeaponInventory() {
return WeaponInventory;};
155 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Shooting Component")
156 int32 GetCurrentWeaponIndex()
const {
return CurrentWeaponIndex;};
158 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Shooting Component")
159 int32 GetCurrentWeaponAmmo(int32& Current) const;
160 UFUNCTION(BlueprintCallable, Category = "Shooting Component")
163 UFUNCTION(BlueprintCallable, Category = "Player Stats")
167 UFUNCTION(BlueprintCallable, Category=
"Shooting Component|Save Game")
170 virtual
bool LoadComponentData(const FString& SlotName) override;
171 virtual
bool SaveComponentData(const FString& SlotName) override;
175 UFUNCTION(BlueprintCallable, Category="Recoil")
176 virtual FTransform GetPivotPoint() override;
177 UFUNCTION(BlueprintCallable, Category="Recoil")
178 virtual FTransform GetRecoilTransform() override;
181 virtual
void RecoilTimer();
182 virtual
void RecoilRecoveryTimer();
183 virtual
void RecoilStart();
184 virtual
void RecoilStop();
185 virtual
void RecoilRecoveryStart();
186 virtual
void RecoilTick(
float DeltaTime);
188 virtual
void GetTraceParams(FVector&
Location, FRotator& Rotation);
190 UFUNCTION(BlueprintCallable, Category="Shooting")
191 virtual
void SetAccuracy(const
float Value){Accuracy = Value;};
195 float CalculateAccuracy()
const;
196 float CalculateRecoil()
const;
199 int32 GetBurstBulletsRemaining()
const {
return BurstBulletRemaining;};
201 AActor* GetCurrentWeaponActor()
const {
return CurrentWeaponActor;};
202 bool GetTriggerMustWait()
const {
return bTriggerMustWait;}
204 virtual void BeginPlay()
override;
208 UFUNCTION(BlueprintCallable, Category =
"Animation|Reload")
209 UAnimMontage* GetReloadAnimation(const
EWeaponOverlay WeaponType) const;
210 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Melee Combat")
212 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Melee Combat")
218 UFUNCTION(
Server, Unreliable)
221 virtual
void Recoil();
223 class
IWeapon* GetWeaponInterface() const;
227 virtual
void MeleeWeaponAttackFinished();
229 virtual
void BurstFire();
232 UPROPERTY(Replicated, BlueprintReadOnly, Category="Shooting Component|
Hit Reactions")
233 class URecoilAnimationComponent* RecoilAnimationComponent;
234 UPROPERTY(ReplicatedUsing=OnRep_CurrentWeapon, BlueprintReadOnly, Category = "Shooting Component|Weapon")
235 AActor* CurrentWeaponActor;
240 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Melee")
242 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Melee")
244 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Melee")
246 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Melee")
250 UPROPERTY(ReplicatedUsing=OnRep_PlayerWeaponState, VisibleAnywhere, BlueprintReadOnly, Category="Shooting Component|Stats")
252 UPROPERTY(ReplicatedUsing=OnRep_CurrentWeaponIndex, VisibleAnywhere, BlueprintReadOnly, Category="Shooting Component|Stats")
253 int32 CurrentWeaponIndex = 0;
254 UPROPERTY(ReplicatedUsing=OnRep_WeaponInventory, VisibleAnywhere, BlueprintReadOnly, Category="Shooting Component|Stats")
257 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Shooting Component|
Debug")
258 bool bInfiniteAmmo = false;
259 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Shooting Component|
Debug")
260 bool bBottomlessClip = false;
263 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Shooting Component|
General")
264 bool bStartingWeapons = false;
265 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Shooting Component|
General", meta=(EditCondition=bStartingWeapons))
266 TArray<FString> StartingWeaponIDs;
268 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|
General")
269 bool bUsePlayerTraceOffset = true;
273 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Shooting Component|Accuracy", meta=(UIMin = "0.1", UIMax = "10.0"))
276 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
277 float NPCAccuracyMultiplier = 0.25f;
278 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
279 float BlindFireAccuracyMultiplier = 0.5f;
280 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
281 float SlowMoAccuracyMultiplier = 2.0f;
282 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
283 float CrouchingAccuracyMultiplier = 1.5f;
284 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
285 float MaxSpeedAccuracyMultiplier = 0.5f;
286 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|Accuracy")
287 float MinSpeedAccuracyMultiplier = 1.5f;
289 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Shooting Component|NPC")
290 bool bHiddenWeaponMesh = false;
298 void UpdateCurrentWeaponInInventory();
300 UFUNCTION(
Server, Reliable)
301 void Server_UpdateCurrentWeaponInInventory();
304 UFUNCTION(Category = "Spawn Weapon")
306 UFUNCTION(
Server, Reliable, Category = "Spawn Weapon")
307 void Server_SpawnWeaponActor(const
FWeaponData_T& In_WeaponData);
308 UFUNCTION(
Server, Reliable, Category = "Spawn Weapon")
309 void Server_SetTriggerMustWait(const
bool bValue);
313 void RemoveWeaponFromInventory(const int32 WeaponToRemove);
314 UFUNCTION(
Server, Reliable, WithValidation)
315 void ServerAddWeaponToInventory(const
FWeaponData_T& NewWeapon);
316 UFUNCTION(
Server, Reliable, WithValidation)
317 void ServerRemoveWeaponFromInventory(const int32 WeaponToRemove);
319 UFUNCTION(
Server, Reliable, WithValidation)
322 UFUNCTION(
Server, Reliable)
323 void Server_SetRecoilComponent();
327 void OnRep_CurrentWeapon();
329 void OnRep_WeaponInventory();
331 void OnRep_CurrentWeaponIndex();
333 void OnRep_PlayerWeaponState() const;
335 void ReleaseTriggerSpam();
339 int32 AddAmmo(const int32 AmountToAdd, const int32 WeaponIndex);
344 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Reload")
345 UAnimMontage* PistolReloadAnim;
346 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Reload")
347 UAnimMontage* RifleReloadAnim;
348 UPROPERTY(EditAnywhere, Category= "Shooting Component|Animation|
Reload")
349 UAnimMontage* ShotgunReloadAnim;
351 UPROPERTY(EditDefaultsOnly, Category = "Shooting Component|Animation")
352 float AnimationBlendOutTime = 0.05f;
357 FRotator TargetRotation = FRotator::ZeroRotator;
362 UAnimMontage* ReloadAnimation;
363 float LastReloadDuration = 0.0f;
366 UPROPERTY(EditDefaultsOnly, Category = "Shooting Component|Weapon")
367 TSubclassOf<AActor> WeaponClass;
370 UPROPERTY(EditDefaultsOnly, Category = "Shooting Component|
Pickup")
371 TSubclassOf<AActor> WeaponToSpawn;
372 UPROPERTY(EditDefaultsOnly, Category = "Shooting Component|
Pickup")
373 float PickupThrowIntensity = 500.0f;
374 UPROPERTY(Replicated)
375 USceneComponent* ThrowPoint;
379 float SwapWeaponPressedTime = 0.0f;
380 UPROPERTY(EditDefaultsOnly, Category = "Shooting Component|
Switch Weapons")
381 float SwapWeaponHoldTime = 0.2f;
382 bool bSwapWeaponPressed = false;
383 UPROPERTY(Replicated, VisibleAnywhere, Category = "Shooting Component|
Switch Weapons")
384 bool bTriggerMustWait = false;
391 FTimerHandle ShootingTimerHandle;
392 FTimerHandle ShootingSpamTimerHandle;
393 FTimerHandle ReloadTimerHandle;
394 FTimerHandle WeaponSwapTimerHandle;
395 FTimerHandle UpdatedHUDTimerHandle;
396 FTimerHandle MeleeWeaponTimerHandle;
397 FTimerHandle BurstFireTimerHandle;
399 int32 BurstBulletRemaining = 0;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnWeaponEqiupped, const TArray< FWeaponData_T > &, Weapons, const int32, CurrentWeaponIndex)
DECLARE_LOG_CATEGORY_EXTERN(LogShootingComponent, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnWeaponStateChanged, const FPlayerWeaponState &, WeaponState)
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
EWeaponOverlay
Specifies the different weapon overlay types.
Definition WeaponStructs.h:27
EWeaponFireMode
Enum class representing the different fire modes for a weapon.
Definition WeaponStructs.h:99
EMeleeWeaponAttack
Enumeration representing different types of melee weapon attacks.
Definition WeaponStructs.h:61
Definition RecoilInterface.h:17
Represents a character component that can be added to an actor.
Component responsible for managing the shooting behavior of a character.
Definition WeaponStructs.h:260
A struct that represents the state of a player's weapon.
Definition WeaponStructs.h:118
Definition WeaponStructs.h:501
Struct representing data of a weapon that changes.
Definition WeaponStructs.h:861
Represents statistics for a weapon.
Definition WeaponStructs.h:622