-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLyraCharacter.h
More file actions
271 lines (204 loc) · 8.89 KB
/
LyraCharacter.h
File metadata and controls
271 lines (204 loc) · 8.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "AbilitySystemInterface.h"
#include "GameplayCueInterface.h"
#include "GameplayTagAssetInterface.h"
#include "ModularCharacter.h"
#include "Teams/LyraTeamAgentInterface.h"
#include "LyraCharacter.generated.h"
class AActor;
class AController;
class ALyraPlayerController;
class ALyraPlayerState;
class FLifetimeProperty;
class IRepChangedPropertyTracker;
class UAbilitySystemComponent;
class UInputComponent;
class ULyraAbilitySystemComponent;
class ULyraCameraComponent;
class ULyraHealthComponent;
class ULyraPawnExtensionComponent;
class UObject;
struct FFrame;
struct FGameplayTag;
struct FGameplayTagContainer;
/**
* FLyraReplicatedAcceleration: Compressed representation of acceleration
*/
USTRUCT()
struct FLyraReplicatedAcceleration
{
GENERATED_BODY()
UPROPERTY()
uint8 AccelXYRadians = 0; // Direction of XY accel component, quantized to represent [0, 2*pi]
UPROPERTY()
uint8 AccelXYMagnitude = 0; //Accel rate of XY component, quantized to represent [0, MaxAcceleration]
UPROPERTY()
int8 AccelZ = 0; // Raw Z accel rate component, quantized to represent [-MaxAcceleration, MaxAcceleration]
};
/** The type we use to send FastShared movement updates. */
USTRUCT()
struct FSharedRepMovement
{
GENERATED_BODY()
FSharedRepMovement();
bool FillForCharacter(ACharacter* Character);
bool Equals(const FSharedRepMovement& Other, ACharacter* Character) const;
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess);
UPROPERTY(Transient)
FRepMovement RepMovement;
UPROPERTY(Transient)
float RepTimeStamp = 0.0f;
UPROPERTY(Transient)
uint8 RepMovementMode = 0;
UPROPERTY(Transient)
bool bProxyIsJumpForceApplied = false;
UPROPERTY(Transient)
bool bIsCrouched = false;
};
template<>
struct TStructOpsTypeTraits<FSharedRepMovement> : public TStructOpsTypeTraitsBase2<FSharedRepMovement>
{
enum
{
WithNetSerializer = true,
WithNetSharedSerialization = true,
};
};
/**
* ALyraCharacter
*
* The base character pawn class used by this project.
* Responsible for sending events to pawn components.
* New behavior should be added via pawn components when possible.
*/
UCLASS(Config = Game, Meta = (ShortTooltip = "The base character pawn class used by this project."))
class LYRAGAME_API ALyraCharacter : public AModularCharacter, public IAbilitySystemInterface, public IGameplayCueInterface, public IGameplayTagAssetInterface, public ILyraTeamAgentInterface
{
GENERATED_BODY()
public:
ALyraCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
UFUNCTION(BlueprintCallable, Category = "Lyra|Character")
ALyraPlayerController* GetLyraPlayerController() const;
UFUNCTION(BlueprintCallable, Category = "Lyra|Character")
ALyraPlayerState* GetLyraPlayerState() const;
UFUNCTION(BlueprintCallable, Category = "Lyra|Character")
ULyraAbilitySystemComponent* GetLyraAbilitySystemComponent() const;
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override;
virtual bool HasMatchingGameplayTag(FGameplayTag TagToCheck) const override;
virtual bool HasAllMatchingGameplayTags(const FGameplayTagContainer& TagContainer) const override;
virtual bool HasAnyMatchingGameplayTags(const FGameplayTagContainer& TagContainer) const override;
void ToggleCrouch();
//~AActor interface
virtual void PreInitializeComponents() override;
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void Reset() override;
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
virtual void PreReplication(IRepChangedPropertyTracker& ChangedPropertyTracker) override;
//~End of AActor interface
//~APawn interface
virtual void NotifyControllerChanged() override;
//~End of APawn interface
//~ILyraTeamAgentInterface interface
virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
virtual FGenericTeamId GetGenericTeamId() const override;
virtual FOnLyraTeamIndexChangedDelegate* GetOnTeamIndexChangedDelegate() override;
//~End of ILyraTeamAgentInterface interface
/** RPCs that is called on frames when default property replication is skipped. This replicates a single movement update to everyone. */
UFUNCTION(NetMulticast, unreliable)
void FastSharedReplication(const FSharedRepMovement& SharedRepMovement);
// Last FSharedRepMovement we sent, to avoid sending repeatedly.
FSharedRepMovement LastSharedReplication;
virtual bool UpdateSharedReplication();
// @TangoAlphaDev
// Creating a variable to hold the BP_Vehicle class
UPROPERTY(BlueprintReadWrite, Category = "Lyra|Vehicle")
AActor* HitBPVehicle;
// Variable for if character is driver
UPROPERTY(BlueprintReadWrite, Replicated, Category = "Lyra|Vehicle")
bool isDriver;
// Variable for parachute
UPROPERTY(BlueprintReadWrite, Replicated, Category = "Lyra|Character")
bool isChutePulled;
// Multiplier for fall damage
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fall Damage")
float FallDamageMultiplier;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Fall Damage")
int VelocityLimit;
// Variable for left shoulder
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Lyra|Camera")
bool isLeftCamera;
// Variable for ADS
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Lyra|Camera")
bool isADS;
// Set the boolean value
void SetLeftCameraMode(bool UseLeftMode);
// Get the boolean value
bool GetLeftCameraMode() const;
// @TangoAlphaDev
protected:
virtual void OnAbilitySystemInitialized();
virtual void OnAbilitySystemUninitialized();
virtual void PossessedBy(AController* NewController) override;
virtual void UnPossessed() override;
virtual void OnRep_Controller() override;
virtual void OnRep_PlayerState() override;
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
void InitializeGameplayTags();
virtual void FellOutOfWorld(const class UDamageType& dmgType) override;
// @TangoAlphaDev
// Declaration
void Landed(const FHitResult& Hit);
// @TangoAlphaDev
// Begins the death sequence for the character (disables collision, disables movement, etc...)
UFUNCTION()
virtual void OnDeathStarted(AActor* OwningActor);
// Ends the death sequence for the character (detaches controller, destroys pawn, etc...)
UFUNCTION()
virtual void OnDeathFinished(AActor* OwningActor);
void DisableMovementAndCollision();
void DestroyDueToDeath();
void UninitAndDestroy();
// @TangoAlphaDev
// Uninitialize the ability system. Using it for unpossess.
UFUNCTION(BlueprintCallable)
void UninitializeAbilitySystemComponent();
// @TangoAlphaDev
// Called when the death sequence for the character has completed
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName="OnDeathFinished"))
void K2_OnDeathFinished();
virtual void OnMovementModeChanged(EMovementMode PrevMovementMode, uint8 PreviousCustomMode) override;
void SetMovementModeTag(EMovementMode MovementMode, uint8 CustomMovementMode, bool bTagEnabled);
virtual void OnStartCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;
virtual void OnEndCrouch(float HalfHeightAdjust, float ScaledHalfHeightAdjust) override;
virtual bool CanJumpInternal_Implementation() const;
private:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Lyra|Character", Meta = (AllowPrivateAccess = "true"))
TObjectPtr<ULyraPawnExtensionComponent> PawnExtComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Lyra|Character", Meta = (AllowPrivateAccess = "true"))
TObjectPtr<ULyraHealthComponent> HealthComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Lyra|Character", Meta = (AllowPrivateAccess = "true"))
TObjectPtr<ULyraCameraComponent> CameraComponent;
UPROPERTY(Transient, ReplicatedUsing = OnRep_ReplicatedAcceleration)
FLyraReplicatedAcceleration ReplicatedAcceleration;
UPROPERTY(ReplicatedUsing = OnRep_MyTeamID)
FGenericTeamId MyTeamID;
UPROPERTY()
FOnLyraTeamIndexChangedDelegate OnTeamChangedDelegate;
protected:
// Called to determine what happens to the team ID when possession ends
virtual FGenericTeamId DetermineNewTeamAfterPossessionEnds(FGenericTeamId OldTeamID) const
{
// This could be changed to return, e.g., OldTeamID if you want to keep it assigned afterwards, or return an ID for some neutral faction, or etc...
return FGenericTeamId::NoTeam;
}
private:
UFUNCTION()
void OnControllerChangedTeam(UObject* TeamAgent, int32 OldTeam, int32 NewTeam);
UFUNCTION()
void OnRep_ReplicatedAcceleration();
UFUNCTION()
void OnRep_MyTeamID(FGenericTeamId OldTeamID);
};