Space Plunder
Loading...
Searching...
No Matches
MeleeComponent.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"
7#include "Data/MeleeData.h"
8#include "MeleeComponent.generated.h"
9
10
11DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMeleeHit,AActor*, HitActor);
12
13UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent) )
14class MELEECOMBATSYSTEM_API UMeleeComponent : public UCharacterComponent
15{
16 GENERATED_BODY()
17
18public:
19
20 UMeleeComponent();
21
22
23 UPROPERTY(BlueprintAssignable, Category="Melee Combat")
24 FOnMeleeHit OnMeleeHit;
25
26 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
27 void MeleeAttack(const bool bHoldingWeapon = false, const FVector& CustomStartLocation = FVector::ZeroVector, const USceneComponent* CustomStartPoint = nullptr);
28 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
29 void MeleeWeaponAttack(FVector CustomStartLocation = FVector::ZeroVector);
30 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
31 void MeleeKickAttack(bool bHoldingWeapon = false, FVector CustomStartLocation = FVector::ZeroVector);
32
33
34 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
35 void MeleeBlockStart();
36 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
37 void MeleeBlockStop();
38
39
40 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
41 void StopMeleeAttack();
42 UFUNCTION(BlueprintCallable, Category = "Melee Combat")
43 void SetCanAttack(const bool bValue){bCanAttack = bValue;}
44
45 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Melee Combat")
46 FHitResult GetLastHitResult(){return HitResult;};
47 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Melee Combat")
48 bool GetIsAttacking() const{return bIsAttacking;};
49 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Melee Combat")
50 bool GetIsBlocking() const{return bIsBlocking;};
51
52 //- Debugging //
53 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debugging")
54 float DrawDebugTime = 2.0f;
55
56
57 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Melee Combat")
58 UAnimMontage* GetMeleeAnimation(EMeleeAttackType AttackType, EUnarmedAttack Style);
59
60 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "Melee Combat")
61 bool GetCanMelee() const;
62
63
64protected:
65 virtual void OnMontageNotifyBegin(FName NotifyName, const FBranchingPointNotifyPayload& BranchingPointPayload) override;
66
67 void PlayFeedbackEffects() const;
68
69 float Damage = 0.0f;
70
71
72
73 float CalculateDamage();
74 //- Strength (5) = Damage + (Base * 5)
75 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health|Traits")
76 float StrengthDamageBase = 1.0f;
77
78
79 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Effects")
80 bool NPCDamageFriendlies = false;
81 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
82 float AttackRange = 75.0f;
83 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
84 float AttackDamage = 1.0f;
85 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
86 float AttackRadius = 40.0f;
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
88 float AttackImpulse = 50000.0f;
89 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
90 bool bLeftHand = false;
91 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
92 bool bNonLethal = false;
93 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Combo")
94 float ComboTime = 1.0f;
95 //- Combo (2 hits) = Damage + (Base * 2(Combo))
96 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Combo")
97 float ComboDamageBase = 10.0f;
99 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
100 float AttackCheckDelayTime = 1.0f;
101
102 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Push")
103 // bool bAddMovementInput = true;
104 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Push")
105 // bool bAddCharacterMovement = true;
106 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Push")
107 // float CharacterMovementMultiplier = 50.0f;
108 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
109 FName RightHandName = "hand_r";
110 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
111 FName LeftHandName = "Hand_L";
112 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Effects")
113 UForceFeedbackEffect* SingleFireControllerFeedback;
114 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Effects")
115 TSubclassOf<UCameraShakeBase> CameraShake;
116 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat|Effects")
117 float CameraShakeScale = 1.0f;
118 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
119 // TArray<TEnumAsByte<EObjectTypeQuery>> ObjectTypes;
120
121 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
122 class USoundBase* MeleeImpactSound;
123 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
124 TArray<AActor*> ActorsToIgnore;
125
126 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
127 UAnimMontage* MeleeAnimation;
128 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
129 UAnimMontage* WeaponMeleeAnimation;
130
131 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
132 TArray<UAnimMontage*> LeftHandMeleeAnimations;
133 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
134 TArray<UAnimMontage*> HeavyMeleeAnimations;
135 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
136 TArray<UAnimMontage*> JabMeleeAnimations;
137
138
139 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Melee Combat")
140 FName MeleeNotifyName = "Melee";
141
142
143private:
144
146 void MeleeDelayCheck(const float DelayTime);
147
148 void ComboReset();
149 int32 ComboHits = 1;
150
151 UPROPERTY(VisibleAnywhere, Category="Melee Combat")
152 bool bIsAttacking = false;
153 UPROPERTY(VisibleAnywhere, Category="Melee Combat")
154 bool bCanAttack = true;
155
156 UPROPERTY(VisibleAnywhere, Category="Melee Combat")
157 bool bIsBlocking = false;
158
159 FVector CustomLocation = FVector::ZeroVector;
160 UPROPERTY()
161 const USceneComponent* CustomLocationPoint = nullptr;
162
163 FHitResult HitResult;
164
165 FTimerHandle MeleeCheckTimerHandle;
166
167 FTimerHandle ComboTimerHandle;
168};
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMeleeHit, AActor *, HitActor)
EUnarmedAttack
Definition MeleeData.h:12
EMeleeAttackType
Definition MeleeData.h:27
Definition Health.Build.cs:6
Represents a character component that can be added to an actor.