Space Plunder
Loading...
Searching...
No Matches
CustomPlayerCharacter.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"
9#include "CustomPlayerCharacter.generated.h"
10
11UCLASS()
13{
14 GENERATED_BODY()
15public:
16 ACustomPlayerCharacter(const FObjectInitializer& ObjectInitializer);
17
18 virtual void Tick(float DeltaTime) override;
19
20 virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
21
22 // void SetPlayerController(class ACustomPlayerController* OwnerController){PlayerController = OwnerController;};
23 virtual void SetupComponents(AController* ControllerReference = nullptr, AActor* HUDReference = nullptr, const bool bIsLocallyControlled = false) override;
24 virtual void OnPawnSpawned() override;
25
26 //- INPUT FUNCTIONS //
27 UFUNCTION(BlueprintCallable, Category = "Player|Input")
28 void UseAction(const bool bValue);
29 UFUNCTION(BlueprintCallable, Category = "Player|Input")
30 void GrabAction(const bool bValue) const;
31 UFUNCTION(BlueprintCallable, Category = "Player|Input")
32 void ShootAction(const bool bValue);
33 UFUNCTION(BlueprintCallable, Category = "Player|Input")
34 void ReloadAction(const bool bValue) const;
35 UFUNCTION(BlueprintCallable, Category = "Player|Input")
36 void AutoModeAction(const bool bValue) const;
37 UFUNCTION(BlueprintCallable, Category = "Player|Input")
38 void ThrowAction(const bool bValue) const;
39 UFUNCTION(BlueprintCallable, Category = "Player|Input")
40 void SwapWeaponAction(const bool bValue) const;
41 UFUNCTION(BlueprintCallable, Category = "Player|Input")
42 void HolsterAction(const bool bValue) const;
43 UFUNCTION(BlueprintCallable, Category = "Player|Input")
44 void MeleeAction(const bool bValue) const;
45 UFUNCTION(BlueprintCallable, Category = "Player|Input")
46 void QuickSaveAction(const bool bValue);
47 UFUNCTION(BlueprintCallable, Category = "Player|Input")
48 void QuickLoadAction(const bool bValue);
49 UFUNCTION(BlueprintCallable, Category = "Player|Input")
50 void PingAction(const bool bValue) const;
51 UFUNCTION(BlueprintCallable, Category = "Player|Input")
52 void PingMenuAction() const;
53
54 // UFUNCTION(BlueprintCallable, Category = "Player|Input")
55 // void SetCharacterMode(const FGameplayTag& GameplayTag);
56
57 UFUNCTION(BlueprintCallable, Category = "Player|Input")
58 void SelectionUpAction(const bool bValue) const;
59
60 virtual void AimAction(const bool bValue) override;
61
62
63 //~ Hitmarker Interface //
64 virtual void HitMarker(const AActor* ActorHit, const float Damage, const UDamageType* DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit = false, const bool bInjuredPart = false) override;
65 //~ Hitmarker Interface //
66
67 UFUNCTION(Client, Reliable, Category="Hit Markers")
68 virtual void Client_HitMarker(const AActor* ActorHit, const float Damage, const UDamageType* DamageType, const FName HitBone, const FVector HitLocation, const bool bKillingHit = false, const bool bInjuredPart = false);
69
70 //~ Character Interface //
71 virtual void StartThreatIndication(AActor* PawnThreat) override;
72 virtual void UpdateThreatIndication(const FVector& Location, const float DetectionAmount) override;
73 virtual void StopThreatIndication() override;
74 //~ Character Interface //
75
76
77 UFUNCTION()
78 virtual void OnCapsuleBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
79 UFUNCTION()
80 virtual void OnCapsuleEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
81
82
83 //- Aim Assist //
84 UFUNCTION()
85 virtual void InteractionTraceEventHit(const FHitResult& HitResult);
86
87 //- ALS Overridden /
88 virtual void CameraUpAction_Implementation(float Value) override;
89 virtual void CameraRightAction_Implementation(float Value) override;
90 virtual EALSGait GetAllowedGait() const override;
91
92 virtual FVector GetAimDownSightCameraTarget() const override;
93 virtual float GetAimDownSightFOV() const override;
94 virtual bool GetCanAimDownSights() const override;
95
96 void CameraInputStopped();
97
98
99 //- Sliding //
100 virtual void SlideStart();
101 virtual void SlideStop();
102
103 void CalculateFloorInfluence();
104
105 UFUNCTION(BlueprintPure, BlueprintCallable, Category="Custom ALS|Slide")
106 float GetSlideTime() const {return SlideTime;};
107
108
109 bool bMovingAxis = false;
110 float CurrentCameraUp = 0.0f;
111 float CurrentCameraRight = 0.0f;
112 FTimerHandle CameraTimerHandle;
113
114 //- Debugging //
115 UFUNCTION(Exec, BlueprintCallable, Category="Debugging")
116 void SetDebugging(const FString& Component = "", const bool bOn = true);
117
118
119
120protected:
121 UFUNCTION(Server, Reliable)
122 void ServerSetFiring(const bool bFiring);
123 UFUNCTION(NetMulticast, Reliable)
124 void Multicast_SetFiring(const bool bFiring);
125
126
127 //- Used for BlindFire, when true, character plays shooting anim //
128 UPROPERTY(Replicated, VisibleAnywhere, BlueprintReadOnly, Category= "Shooting")
129 bool bFiringWeapon = false;
130 //- How long after firing do you put down your weapon //
131 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Shooting")
132 float FiringWeaponAimDownDelay = 5.0f;
133 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Shooting")
134 bool bUseGunAimDownSight = true;
135
136
137 //@ TODO Move to Aim Asssist Compoennt
138 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Aim Assist")
139 FAimAssist CurrentAimAssist;
140 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Aim Assist")
141 AActor* CurrentAimAssistTarget = nullptr;
142 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Aim Assist")
143 int32 CurrentAimAssistTargetHits = 0;
144 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Custom ALS|Grabber")
145 float GrabberThrowMultiplier = 2.0f;
146 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Custom ALS|Sliding")
147 float SlideTime = 2.0f;
148
149
150
151 //- Components //
152 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Shooting")
153 class UPlayerCharacterShootingComponent* PlayerShootingComponent;
154 //- @TODO Move to Base? //
155 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Shooting")
156 // class URecoilAnimationComponent* RecoilAnimationComponent;
157
158
159 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Companion")
160 class UCompanionMasterComponent* CompanionMasterComponent;
161 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Grabber")
162 class UCharacterGrabberComponent* GrabberComponent;
163 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Grabber")
164 class UPhysicsHandleComponent* PhysicsHandleComponent;
165
166 // UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Proximity Chat")
167 // class UPlayerVoiceComponent* ProximityVoiceComponent;
168
169 //- Character Traits //
170 // UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Category="Character Traits")
171 // FCharacterBaseSkills CharacterSkills;
172
173 virtual void BeginPlay() override;
174
175 //- Save Load Game //
176 virtual void SaveGameData() override;
177 virtual void LoadGameData() override;
178
179 virtual bool SaveCharacterData() override;
180 virtual bool LoadCharacterData() override;
181
182
183 virtual void LoadComponentsSaveData() override;
184 virtual void SaveComponentsData() override;
185
186 // Parent Functions
187 virtual void OnRotationModeChanged(EALSRotationMode PreviousRotationMode) override;
188 virtual bool CanJumpInternal_Implementation() const override;
189 virtual bool CanCrouch() const override;
190 // virtual void AimReleasedAction() override;
191
192 virtual void StanceAction() override;
193
194
195 virtual void FirePressedAction() override;
196
197 virtual void InteractionDataUpdated() const override;
198
199
200
201 //- Character Weapons Interface
202 virtual int32 PickupGunEvent(const FWeaponData_T In_WeaponData) override;
203 virtual bool PickupGunCheck(const FWeaponData_T& In_WeaponData) override;
204 virtual bool PickupAttachmentCheck(const FWeaponAttachment& In_WeaponAttachmentData) override;
205 virtual void PickupAttachmentEvent(const FString& WeaponAttachmentID) override;
206
207
208 //- Shooting Component Bind //
209 virtual void WeaponEquipped(const TArray<FWeaponData_T>& Weapons, const int32 CurrentWeaponIndex) override;
210
211
212
213 //- Overridden from CustomCharacter
214 virtual void OnFullDamageHit(AController* InstigatedBy, const float TotalDamage, const UDamageType* DamageType, const FName& HitBone, const FVector& HitLocation, const bool bKillingHit, const bool bInjuredPart) override;
215 virtual void OnDeath(AActor* OwningActor, const EDeathType DeathType, AActor* DeathCauser, AController* DeathInstigator) override;
216
217 UFUNCTION()
218 void TakeAnyDamage(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser);
219 //- Voice Chat //
220 // UFUNCTION(Server, Reliable, WithValidation)
221 // void SendVoiceChat(const TArray<uint8>& VoiceData, int32 SampleRate);
222 // UFUNCTION(BlueprintCallable, Category="Proximity Chat")
223 // void OnVoiceChatReceived(APlayerController* SenderPlayerController, const TArray<uint8>& VoiceData, int32 SampleRate);
224
225
226 virtual void UpdateStaminaHUD() override;
227
228 UFUNCTION(BlueprintImplementableEvent)
229 void OnStealthTakedown(const AActor* Victim, const bool bLethal = true);
230
231 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
232 FStealthData StealthData;
233 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
234 bool bStealthAttachToCustomMesh = true;
235 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
236 bool bStealthAttachToCapsule = false;
237 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
238 bool bStealthAttachToCharacterMesh = false;
239
240 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
241 bool bStealthWeldBodies = false;
242 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
243 EAttachmentRule StealthLocationRule = EAttachmentRule::KeepWorld;
244 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
245 EAttachmentRule StealthRotationRule = EAttachmentRule::KeepWorld;
246
247 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
248 // float StealthActorDistance = -175.0f;
249 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
250 // float StealthActorForward = 65.0f;
251 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
252 // float StealthActorZ = 90.0f;
253 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
254 // float StealthActorRight = 20.0f;
255 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
256 bool bStealthAttach = false;
257
258 //@TODO Remove this array, use in StealthData
259 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Stealth")
260 TArray<UAnimMontage*> StealthTakedownAnims;
261
262private:
263
264 UPROPERTY()
265 AActor* StealthActor = nullptr;
266 class IStealthInterface* StealthActorInterface = nullptr;
267
268 bool bStealthTakedownAvailable = false;
269 bool bPerformingStealthTakedown = false;
270
271 FTimerHandle StealthTakedownTimerHandle;
272
273
274 void StealthTakedown(const bool bLethal = true);
275
276 void StealthTakedownComplete();
277 void StealthKnockoutComplete();
278
279
280 void FiringWeaponAimDown();
281
282
283 FTimerHandle FiringWeaponTimerHandle;
284 FTimerHandle CompanionContextTimerHandle;
285 FTimerHandle SlideTimerHandle;
286
287
288 UPROPERTY()
289 AActor* HUD;
290};
EALSGait
Definition ALSCharacterEnumLibrary.h:29
EALSRotationMode
Definition ALSCharacterEnumLibrary.h:97
EDeathType
Definition BaseData.h:53
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
The base class for custom characters in the game. Inherits from various interfaces and provides imple...
Definition CustomCharacterBase.h:31
Definition CustomPlayerCharacter.h:13
FTimerHandle CameraTimerHandle
Definition CustomPlayerCharacter.h:112
Definition HitMarkerInterface.h:16
Definition StealthInterface.h:17
Structure representing the parameters for aim assist in a game.
Definition InteractionData.h:264
Definition AIDataTypes.h:220
Definition WeaponStructs.h:501
Struct representing data of a weapon that changes.
Definition WeaponStructs.h:861