Space Plunder
Loading...
Searching...
No Matches
ACharacterBase Class Reference

#include <CharacterBase.h>

Inheritance diagram for ACharacterBase:
ICharacterBaseInterface ISaveLoad IBaseInterface AInteractableCharacter AQuestExampleCharacter AALSBaseCharacter AALSCharacter ACustomCharacterBase ACustomAICharacter ACustomPlayerCharacter ACampaignAICharacter AHordeAICharacter ACampaignPlayerCharacter AMultiplayerPlayerCharacter

Public Member Functions

 ACharacterBase (const FObjectInitializer &ObjectInitializer)
 
virtual void Tick (float DeltaTime) override
 
virtual void SetupPlayerInputComponent (class UInputComponent *PlayerInputComponent) override
 
virtual void OnPawnSpawned () override
 
virtual bool SaveGame () override
 
virtual bool LoadGame () override
 
virtual USkeletalMeshComponent * GetCharacterMesh () const override
 
virtual UPrimitiveComponent * GetPrimitiveComponent () override
 
virtual void Ragdoll () override
 
virtual void RagdollStop () override
 
virtual float PlayReplicatedMontage (UAnimMontage *MontageToPlay, const float InPlayRate=1.0f, const EMontagePlayReturnType ReturnValueType=EMontagePlayReturnType::Duration, const float InTimeToStartMontageAt=0.0f, const bool bStopAllMontages=true) override
 
virtual void StopReplicatedMontage (const float InBlendOutTime, const UAnimMontage *Montage) override
 
virtual bool GetCharacterHealth (float &Health, float &MaxHealth) const override
 
virtual FCharacterBaseSkillsGetCharacterSkills () override
 
virtual bool GetAudioSocketLocation (const FName &AudioSocket, FVector &Location) const override
 
virtual USceneComponent * GetThrowPoint () const override
 
virtual FCharacterInfo GetCharacterInfo () const override
 
virtual void GetThrowStats (FTransform &OutTransform, FVector &OutThrowForce) const override
 
virtual void CharacterModeChanged (const FGameplayTag &NewMode) override
 
virtual int32 GetStrength () const
 
virtual int32 GetPerception () const
 
virtual int32 GetEndurance () const
 
virtual int32 GetCharisma () const
 
virtual int32 GetIntelligence () const
 
virtual int32 GetAgility () const
 
virtual int32 GetWeaponSkill () const
 
virtual int32 GetStealth () const
 
virtual int32 GetLuck () const
 
virtual int32 GetSkillPoints () const
 

Public Attributes

FOnCharacterDeath OnCharacterDeath
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void NotifyHit (UPrimitiveComponent *MyComp, AActor *Other, UPrimitiveComponent *OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult &Hit) override
 
virtual void FallOver (const float WaitTime)
 
void OnFallOver (const float WaitTime)
 
virtual void GetUpFromFall ()
 
void OnGetUpFromFall ()
 
void OnRep_CharacterDeath ()
 
IPlayerControllerInterfaceGetPlayerControllerInterface ()
 
IPlayerStateInterfaceGetPlayerStateInterface ()
 
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

bool bDebuggingMode = false
 
FCharacterBaseSkills CharacterSkills
 
FCharacterInfo CharacterInfo
 
bool bDead = false
 
float PickupThrowIntensity = 500.0f
 
bool bCanBePushed = false
 
float HitVelocityThreshold = 50.0f
 
float HitVelocityMultiplier = 5.0f
 
float HitReactionMultiplier = 0.01f
 
bool bPushHitReaction = true
 
bool bAddMovementInput = true
 
bool bAddCharacterMovement = true
 
float PushFallVelocityThreshold = 200.0f
 
float PushedFallVelocityThreshold = 500.0f
 
float PushedFallOverWaitTime = 2.0f
 

Private Attributes

class UCharacterSaveGameCharacterSaveGameObject = nullptr
 
FLogCategoryName CategoryName = LogBaseCharacter.GetCategoryName()
 
IPlayerControllerInterfacePlayerControllerInterface = nullptr
 
IPlayerStateInterfacePlayerStateInterface = nullptr
 
FTimerHandle FallOverTimerHandle
 

Constructor & Destructor Documentation

◆ ACharacterBase()

ACharacterBase::ACharacterBase ( const FObjectInitializer & ObjectInitializer)
18 : Super(ObjectInitializer)
19{
20 PrimaryActorTick.bCanEverTick = true;
21 AutoPossessAI = EAutoPossessAI::PlacedInWorldOrSpawned;
22 if(GetMesh() != nullptr)
23 {
24 GetMesh()->bRenderCustomDepth = false;
25 }
26 if(GetCharacterMesh() != nullptr)
27 {
28 GetCharacterMesh()->bRenderCustomDepth = false;
29 }
30}
virtual USkeletalMeshComponent * GetCharacterMesh() const override
Definition CharacterBase.h:44

Member Function Documentation

◆ BeginPlay()

void ACharacterBase::BeginPlay ( )
overrideprotectedvirtual

Reimplemented in AALSBaseCharacter, AALSCharacter, ACampaignAICharacter, ACampaignPlayerCharacter, ACustomAICharacter, ACustomCharacterBase, ACustomPlayerCharacter, AMultiplayerPlayerCharacter, AInteractableCharacter, and AQuestExampleCharacter.

33{
34 CharacterInfo.Actor = this;
35 Super::BeginPlay();
38
39}
FCharacterInfo CharacterInfo
Definition CharacterBase.h:151
IPlayerStateInterface * GetPlayerStateInterface()
Definition CharacterBase.cpp:323
IPlayerControllerInterface * GetPlayerControllerInterface()
Definition CharacterBase.cpp:314
AActor * Actor
Definition BaseData.h:314

◆ CharacterModeChanged()

void ACharacterBase::CharacterModeChanged ( const FGameplayTag & NewMode)
overridevirtual

Implements ICharacterBaseInterface.

430{
431 for(auto& Component: GetComponents())
432 {
433 UCommonActorComponent* PlayerControllerComponent = Cast<UCommonActorComponent>(Component);
434 if(PlayerControllerComponent == nullptr){continue;}
435 PlayerControllerComponent->CharacterModeChanged(NewMode);
436 }
437
438 //@ Get all Components and trigger
439 //@
440}

◆ FallOver()

void ACharacterBase::FallOver ( const float WaitTime)
protectedvirtual

Reimplemented in ACustomAICharacter.

95{
96 Ragdoll();
97 GetWorld()->GetTimerManager().SetTimer(FallOverTimerHandle, this, &ACharacterBase::GetUpFromFall, WaitTime);
98 OnFallOver(WaitTime);
99}
void OnFallOver(const float WaitTime)
virtual void GetUpFromFall()
Definition CharacterBase.cpp:101
virtual void Ragdoll() override
Definition CharacterBase.cpp:333
FTimerHandle FallOverTimerHandle
Definition CharacterBase.h:199

◆ GetAgility()

virtual int32 ACharacterBase::GetAgility ( ) const
inlinevirtual
94{return CharacterSkills.GetAgility();};
FCharacterBaseSkills CharacterSkills
Definition CharacterBase.h:149
int32 GetAgility() const
Definition BaseData.h:850

◆ GetAudioSocketLocation()

bool ACharacterBase::GetAudioSocketLocation ( const FName & AudioSocket,
FVector & Location ) const
overridevirtual

Implements ICharacterBaseInterface.

374{
375 if(GetCharacterMesh() != nullptr && GetCharacterMesh()->DoesSocketExist(AudioSocket))
376 {
377 Location = GetCharacterMesh()->GetSocketLocation(AudioSocket);
378 return true;
379 }
380 if(GetMesh() != nullptr && GetMesh()->DoesSocketExist(AudioSocket))
381 {
382 Location = GetMesh()->GetSocketLocation(AudioSocket);
383 return true;
384 }
385 return false;
386}

◆ GetCharacterHealth()

bool ACharacterBase::GetCharacterHealth ( float & Health,
float & MaxHealth ) const
overridevirtual

Return if Success

Implements ICharacterBaseInterface.

Reimplemented in ACustomCharacterBase.

357{
358 return false;
359}

◆ GetCharacterInfo()

FCharacterInfo ACharacterBase::GetCharacterInfo ( ) const
overridevirtual

Implements ICharacterBaseInterface.

395{
396 return CharacterInfo;
397}

◆ GetCharacterMesh()

virtual USkeletalMeshComponent * ACharacterBase::GetCharacterMesh ( ) const
inlineoverridevirtual

Implements ICharacterBaseInterface.

44{return GetMesh();};

◆ GetCharacterSkills()

FCharacterBaseSkills & ACharacterBase::GetCharacterSkills ( )
overridevirtual

Implements ICharacterBaseInterface.

362{
363 //@TODO change to
364 // PlayerStateInterface
365 if(PlayerStateInterface != nullptr)
366 {
368 }
369 LogDebugMessage("ACharacterBase::GetCharacterSkills PlayerState Interface");
370 return CharacterSkills;
371}
void LogDebugMessage(const FString &Message, const bool bWarning=false, const bool bError=false) const
Definition CharacterBase.cpp:241
IPlayerStateInterface * PlayerStateInterface
Definition CharacterBase.h:198
virtual FCharacterBaseSkills & GetCharacterSkills()=0

◆ GetCharisma()

virtual int32 ACharacterBase::GetCharisma ( ) const
inlinevirtual
int32 GetCharisma() const
Definition BaseData.h:839

◆ GetEndurance()

virtual int32 ACharacterBase::GetEndurance ( ) const
inlinevirtual
int32 GetEndurance() const
Definition BaseData.h:833

◆ GetIntelligence()

virtual int32 ACharacterBase::GetIntelligence ( ) const
inlinevirtual
int32 GetIntelligence() const
Definition BaseData.h:844

◆ GetLuck()

virtual int32 ACharacterBase::GetLuck ( ) const
inlinevirtual
100{return CharacterSkills.GetLuck();};
int32 GetLuck() const
Definition BaseData.h:866

◆ GetPerception()

virtual int32 ACharacterBase::GetPerception ( ) const
inlinevirtual
int32 GetPerception() const
Definition BaseData.h:827

◆ GetPlayerControllerInterface()

IPlayerControllerInterface * ACharacterBase::GetPlayerControllerInterface ( )
protected
315{
316 if(PlayerControllerInterface == nullptr)
317 {
318 PlayerControllerInterface = Cast<IPlayerControllerInterface>(GetController());
319 }
321}
IPlayerControllerInterface * PlayerControllerInterface
Definition CharacterBase.h:195

◆ GetPlayerStateInterface()

IPlayerStateInterface * ACharacterBase::GetPlayerStateInterface ( )
protected
324{
325 if(PlayerStateInterface == nullptr)
326 {
327 PlayerStateInterface = Cast<IPlayerStateInterface>(GetPlayerState());
328 }
330}

◆ GetPrimitiveComponent()

virtual UPrimitiveComponent * ACharacterBase::GetPrimitiveComponent ( )
inlineoverridevirtual

Implements ICharacterBaseInterface.

45{return Cast<UPrimitiveComponent>(RootComponent);};

◆ GetSkillPoints()

virtual int32 ACharacterBase::GetSkillPoints ( ) const
inlinevirtual
int32 GetSkillPoints() const
Definition BaseData.h:869

◆ GetStealth()

virtual int32 ACharacterBase::GetStealth ( ) const
inlinevirtual
98{return CharacterSkills.GetStealth();};
int32 GetStealth() const
Definition BaseData.h:861

◆ GetStrength()

virtual int32 ACharacterBase::GetStrength ( ) const
inlinevirtual
int32 GetStrength() const
Definition BaseData.h:821

◆ GetThrowPoint()

USceneComponent * ACharacterBase::GetThrowPoint ( ) const
overridevirtual

Implements ICharacterBaseInterface.

Reimplemented in AInteractableCharacter.

389{
390 LogDebugError("Throw Point needs to be Overriden");
391 return nullptr;
392}
void LogDebugError(const FString &Message) const
Definition CharacterBase.cpp:203

◆ GetThrowStats()

void ACharacterBase::GetThrowStats ( FTransform & OutTransform,
FVector & OutThrowForce ) const
overridevirtual

Implements ICharacterBaseInterface.

400{
401 //@TODO TEMP ACCURACY MOVE TO SKILLS Or similar
402 const float Accuracy = 1.0f;
403 if(GetThrowPoint() == nullptr)
404 {
405 LogDebugError("Throw Point");
406 OutTransform = FTransform(FVector::ZeroVector);
407 //@TODO Get Throw intensity from Character/SkillComponnet
408 OutThrowForce = FVector(1) * PickupThrowIntensity;
409 return;
410 }
411 OutTransform.SetLocation(GetThrowPoint()->GetComponentLocation());
412 //- Regular Scale //
413 OutTransform.SetScale3D(GetThrowPoint()->GetComponentScale());
414 //- Random Rotation //
415 FRotator Rotation;
416 Rotation.Yaw = UKismetMathLibrary::RandomFloatInRange(-180.0f, 180.0f);
417 Rotation.Roll = UKismetMathLibrary::RandomFloatInRange(-180.0f, 180.0f);
418 Rotation.Pitch = UKismetMathLibrary::RandomFloatInRange(-180.0f, 180.0f);
419 OutTransform.SetRotation(Rotation.Quaternion());
420 //- Calculate Force //
421 const FRotator ThrowRotation = GetThrowPoint()->GetComponentRotation();
422 const FVector ForwardVector = (FRotationMatrix(ThrowRotation).GetScaledAxis(EAxis::X));
423 const float OwnerVelocity =(GetOwner()->GetVelocity().Size() / 5);
424 //- Added in Accuracy to have greater control of throw and velocity for some momentum
425 const FVector FullThrowForce = ForwardVector * (PickupThrowIntensity / Accuracy + OwnerVelocity);
426 OutThrowForce = FullThrowForce;
427}
virtual USceneComponent * GetThrowPoint() const override
Definition CharacterBase.cpp:388
float PickupThrowIntensity
Definition CharacterBase.h:157

◆ GetUpFromFall()

void ACharacterBase::GetUpFromFall ( )
protectedvirtual

Reimplemented in ACustomAICharacter.

102{
103 // SCOPE_CYCLE_COUNTER(STATGROUP_Custom_ALS_Character);
104 // if(GetIsDead()){return;}
106 GetWorld()->GetTimerManager().ClearTimer(FallOverTimerHandle);
107 RagdollStop();
108}
virtual void RagdollStop() override
Definition CharacterBase.cpp:338
void OnGetUpFromFall()

◆ GetWeaponSkill()

virtual int32 ACharacterBase::GetWeaponSkill ( ) const
inlinevirtual
int32 GetWeaponSkill() const
Definition BaseData.h:856

◆ LoadGame()

bool ACharacterBase::LoadGame ( )
overridevirtual

Implements ISaveLoad.

166{
167 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
168 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LoadGame);
169 bool bSaveFile = false;
170 const FString SaveSlotName = FString::Printf(TEXT("%s%s"), *GetCharacterInfo().DisplayName.ToString(), *GetName());
171 if(UGameplayStatics::DoesSaveGameExist(SaveSlotName, 0))
172 {
173 USaveGame* LoadedSaveGame = UGameplayStatics::LoadGameFromSlot(SaveSlotName, 0);
174 CharacterSaveGameObject = Cast<UCharacterSaveGame>(LoadedSaveGame);
175 if(CharacterSaveGameObject != nullptr)
176 {
177 bSaveFile = true;
180 if(GetController() != nullptr)
181 {
182 GetController()->SetControlRotation(CharacterSaveGameObject->ControlRotation);
183 }
184 }
185 }
186 else
187 {
188 USaveGame* NewSaveGame = UGameplayStatics::CreateSaveGameObject(UCharacterSaveGame::StaticClass());
189 CharacterSaveGameObject = Cast<UCharacterSaveGame>(NewSaveGame);
190 }
191 const bool bComponentsLoaded = USaveLoadBPLib::LoadAllComponents(this);
192 if(bComponentsLoaded == false)
193 {
194 LogDebugError("Load components Failed");
195 }
196 if(GetCharacterMovement() != nullptr)
197 {
198 GetCharacterMovement()->StopMovementImmediately();
199 }
200 return bSaveFile;
201}
class UCharacterSaveGame * CharacterSaveGameObject
Definition CharacterBase.h:190
virtual FCharacterInfo GetCharacterInfo() const override
Definition CharacterBase.cpp:394
bool bDead
Definition CharacterBase.h:153
virtual bool LoadGame() override
Definition CharacterBase.cpp:165
bool bDead
Definition CharacterSaveGame.h:21
FRotator ControlRotation
Definition CharacterSaveGame.h:23
FTransform SavedCharacterTransform
Definition CharacterSaveGame.h:19
static bool LoadAllComponents(AActor *Actor)
Definition SaveLoadBPLib.cpp:112

◆ LogDebugError() [1/3]

void ACharacterBase::LogDebugError ( const FString & Message) const
protected
204{
205 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogDebugError);
206 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
207 LogDebugMessage(Message, true, true);
208}

◆ LogDebugError() [2/3]

void ACharacterBase::LogDebugError ( const FString & Message,
const float Value ) const
protected
216{
217 LogDebugMessage(Message, Value, true, true);
218}

◆ LogDebugError() [3/3]

void ACharacterBase::LogDebugError ( const FString & Message,
const int32 Value ) const
protected
211{
212 LogDebugMessage(Message, Value, true, true);
213}

◆ LogDebugMessage() [1/4]

void ACharacterBase::LogDebugMessage ( const FString & Message,
const bool bValue,
const bool bWarning,
const bool bError ) const
protected
294{
295 LogDebugMessage(FString::Printf(TEXT("%s: %s"), *Message, bValue ? *FString("true") : *FString("false")), bWarning, bError);
296}

◆ LogDebugMessage() [2/4]

void ACharacterBase::LogDebugMessage ( const FString & Message,
const bool bWarning = false,
const bool bError = false ) const
protected
242{
243 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogDebugMessage);
244 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
245 if(bDebuggingMode == false && bError == false){return;}
246 FOutputDevice* OutputDevice = GWarn;
247 if(OutputDevice == nullptr){return;}
248 FString NetModeString;
249 switch(GetWorld()->GetNetMode())
250 {
251 case NM_Standalone:
252 NetModeString = FString("SDL");
253 break;
254 case NM_DedicatedServer:
255 NetModeString = FString("DServer");
256 break;
257 case NM_ListenServer:
258 NetModeString = FString("LServer");
259 break;
260 case NM_Client:
261 NetModeString = FString("Client");
262 break;
263 default:
264 NetModeString = FString("Unknown");
265 break;
266 }
267 const FString FullMessage = FString::Printf(TEXT("%s: %s::%s"), *NetModeString, *GetName(), *Message);
268 if(bError)
269 {
270 OutputDevice->Log(CategoryName, ELogVerbosity::Error, FullMessage);
271 }
272 else if(bWarning)
273 {
274 OutputDevice->Log(CategoryName, ELogVerbosity::Warning, FullMessage);
275 }
276 else
277 {
278 OutputDevice->Log(CategoryName, ELogVerbosity::Log, FullMessage);
279 }
280
281}
FLogCategoryName CategoryName
Definition CharacterBase.h:193
bool bDebuggingMode
Definition CharacterBase.h:145

◆ LogDebugMessage() [3/4]

void ACharacterBase::LogDebugMessage ( const FString & Message,
const float Value,
const bool bWarning = false,
const bool bError = false ) const
protected
289{
290 LogDebugMessage(FString::Printf(TEXT("%s: %f"), *Message, Value), bWarning, bError);
291}

◆ LogDebugMessage() [4/4]

void ACharacterBase::LogDebugMessage ( const FString & Message,
const int32 Value,
const bool bWarning = false,
const bool bError = false ) const
protected
284{
285 LogDebugMessage(FString::Printf(TEXT("%s: %i"), *Message, Value), bWarning, bError);
286}

◆ LogDebugWarning() [1/3]

void ACharacterBase::LogDebugWarning ( const FString & Message) const
protected
221{
222 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogDebugWarning);
223 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
224 LogDebugMessage(Message, true);
225}
void LogDebugWarning(const FString &Message) const
Definition CharacterBase.cpp:220

◆ LogDebugWarning() [2/3]

void ACharacterBase::LogDebugWarning ( const FString & Message,
const float Value ) const
protected
235{
236 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogDebugWarning);
237 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
238 LogDebugMessage(Message, Value, true);
239}

◆ LogDebugWarning() [3/3]

void ACharacterBase::LogDebugWarning ( const FString & Message,
const int32 Value ) const
protected
228{
229 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogDebugWarning);
230 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
231 LogDebugMessage(Message, Value, true);
232}

◆ LogOnScreenMessage()

void ACharacterBase::LogOnScreenMessage ( const int32 Key,
const FString & Message,
FColor Color = FColor::Green ) const
protected
299{
300 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::LogOnScreenMessage);
301 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
303 {
304 GEngine->AddOnScreenDebugMessage(Key, 2.0f, Color,
305 FString::Printf(TEXT(" %s - in %s of %s"), ToCStr(Message), ToCStr(GetName()), ToCStr(GetOwner()->GetName())));
306 }
307}
void LogOnScreenMessage(const int32 Key, const FString &Message, FColor Color=FColor::Green) const
Definition CharacterBase.cpp:298

◆ NotifyHit()

void ACharacterBase::NotifyHit ( UPrimitiveComponent * MyComp,
AActor * Other,
UPrimitiveComponent * OtherComp,
bool bSelfMoved,
FVector HitLocation,
FVector HitNormal,
FVector NormalImpulse,
const FHitResult & Hit )
overrideprotectedvirtual

Reimplemented in ACustomAICharacter, and ACustomCharacterBase.

43{
44 Super::NotifyHit(MyComp, Other, OtherComp, bSelfMoved, HitLocation, HitNormal, NormalImpulse, Hit);
45 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
46 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::NotifyHit);
47 // if(bIsDead){return;}
48 if(bCanBePushed == false){return;}
49 if(Other == nullptr){return;}
50 if(bDebuggingMode && GetWorld() != nullptr)
51 {
52 DrawDebugBox(GetWorld(), Hit.TraceStart, FVector(1.0f,1.0f,1.0f), FColor::Black, false, 1.0, 0, 1.0f);
53 DrawDebugBox(GetWorld(), HitLocation, FVector(1.0f,1.0f,1.0f), FColor::Red, false, 1.0, 0, 1.0f);
54 }
55 const float Velocity = Other->GetVelocity().Length();
56 if(Velocity < HitVelocityThreshold){return;}
57 const FRotator LookAtRot = UKismetMathLibrary::FindLookAtRotation(Hit.TraceStart, HitLocation);
58 const FVector ForwardVector = LookAtRot.Vector();
59
60 //- Normalize to get just the direction
61 // const FVector ForceDirection = HitNormal.GetSafeNormal();
62 //- Directly use the impulse from the hit
63 // const FVector Force = NormalImpulse;
65 {
66 //- Adding movement input fixes feet sticking to the floor //
67 AddMovementInput(ForwardVector * Velocity);
68
69 }
70 // if(bPushHitReaction && PhysicalHitReactionComponent != nullptr)
71 // {
72 // PhysicalHitReactionComponent->HitReaction(Hit.BoneName, HitLocation, (HitReactionMultiplier / GetStrength()));
73 // }
74
75 const FVector Force = ForwardVector * 500.0f * (Velocity * (HitVelocityMultiplier / GetStrength()));
76 if(bAddCharacterMovement && GetCharacterMovement() != nullptr)
77 {
78 GetCharacterMovement()->AddForce(FVector(Force.X,Force.Y,0.0f));
79 }
80 const float CharacterVelocity = (GetVelocity().Length() / GetStrength());
81 if(CharacterVelocity > PushFallVelocityThreshold || (Velocity / GetStrength()) > PushedFallVelocityThreshold)
82 {
84 }
85}
float HitVelocityThreshold
Definition CharacterBase.h:163
float PushFallVelocityThreshold
Definition CharacterBase.h:176
float HitVelocityMultiplier
Definition CharacterBase.h:165
virtual void FallOver(const float WaitTime)
Definition CharacterBase.cpp:94
bool bAddMovementInput
Definition CharacterBase.h:171
float PushedFallOverWaitTime
Definition CharacterBase.h:181
bool bAddCharacterMovement
Definition CharacterBase.h:173
float PushedFallVelocityThreshold
Definition CharacterBase.h:179
bool bCanBePushed
Definition CharacterBase.h:161
virtual void NotifyHit(UPrimitiveComponent *MyComp, AActor *Other, UPrimitiveComponent *OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult &Hit) override
Definition CharacterBase.cpp:41
virtual int32 GetStrength() const
Definition CharacterBase.h:84

◆ OnFallOver()

void ACharacterBase::OnFallOver ( const float WaitTime)
protected

◆ OnGetUpFromFall()

void ACharacterBase::OnGetUpFromFall ( )
protected

◆ OnPawnSpawned()

void ACharacterBase::OnPawnSpawned ( )
overridevirtual

Implements ICharacterBaseInterface.

Reimplemented in ACampaignPlayerCharacter, ACustomCharacterBase, ACustomPlayerCharacter, AInteractableCharacter, and AQuestExampleCharacter.

122{
124 if(PlayerControllerInterface == nullptr)
125 {
126 LogDebugError("Player Controller Interface");
127 }
129 if(PlayerStateInterface == nullptr)
130 {
131 LogDebugError("Player State Interface");
132 }
133 for(auto& Component: GetComponents())
134 {
135 UCommonActorComponent* CharacterComponent = Cast<UCommonActorComponent>(Component);
136 if(CharacterComponent == nullptr){continue;}
137 CharacterComponent->SetupComponent();
138 }
139}

◆ OnRep_CharacterDeath()

void ACharacterBase::OnRep_CharacterDeath ( )
protected
310{
311 // OnCharacterDeath.Broadcast();
312}

◆ PlayReplicatedMontage()

float ACharacterBase::PlayReplicatedMontage ( UAnimMontage * MontageToPlay,
const float InPlayRate = 1.0f,
const EMontagePlayReturnType ReturnValueType = EMontagePlayReturnType::Duration,
const float InTimeToStartMontageAt = 0.0f,
const bool bStopAllMontages = true )
overridevirtual

Implements ICharacterBaseInterface.

Reimplemented in AALSBaseCharacter.

346{
347 //@ override in ALS //
348 return 0.0f;
349}

◆ Ragdoll()

void ACharacterBase::Ragdoll ( )
overridevirtual

Implements ICharacterBaseInterface.

Reimplemented in AALSBaseCharacter.

334{
335 //@ override in ALS //
336}

◆ RagdollStop()

void ACharacterBase::RagdollStop ( )
overridevirtual

Implements ICharacterBaseInterface.

339{
340 //@ override in ALS //
341 //@TODO Override this in ALS
342}

◆ SaveGame()

bool ACharacterBase::SaveGame ( )
overridevirtual

Implements ISaveLoad.

142{
143 SCOPE_CYCLE_COUNTER(STATGROUP_BaseHelpers_CharacterBase);
144 TRACE_CPUPROFILER_EVENT_SCOPE(ACharacterBase::SaveGame);
145 if(CharacterSaveGameObject == nullptr)
146 {
147 USaveGame* NewSaveGame = UGameplayStatics::CreateSaveGameObject(UCharacterSaveGame::StaticClass());
148 CharacterSaveGameObject = Cast<UCharacterSaveGame>(NewSaveGame);
149 }
152 if(GetController() != nullptr)
153 {
154 CharacterSaveGameObject->ControlRotation = GetController()->GetControlRotation();
155 }
156 const bool bComponentsSaved = USaveLoadBPLib::SaveAllComponents(this);
157 if(bComponentsSaved == false)
158 {
159 LogDebugError("Save components Failed");
160 }
161 const FString SaveSlotName = FString::Printf(TEXT("%s%s"), *GetCharacterInfo().DisplayName.ToString(), *GetName());
162 return UGameplayStatics::SaveGameToSlot(CharacterSaveGameObject, SaveSlotName, 0);
163}
virtual bool SaveGame() override
Definition CharacterBase.cpp:141
static bool SaveAllComponents(AActor *Actor)
Definition SaveLoadBPLib.cpp:107

◆ SetCategoryName()

void ACharacterBase::SetCategoryName ( const FLogCategoryBase & Category)
inlineprotected
142{CategoryName = Category.GetCategoryName();};

◆ SetupPlayerInputComponent()

void ACharacterBase::SetupPlayerInputComponent ( class UInputComponent * PlayerInputComponent)
overridevirtual

Reimplemented in ACustomAICharacter, ACustomCharacterBase, ACustomPlayerCharacter, and AQuestExampleCharacter.

117{
118 Super::SetupPlayerInputComponent(PlayerInputComponent);
119}

◆ StopReplicatedMontage()

void ACharacterBase::StopReplicatedMontage ( const float InBlendOutTime,
const UAnimMontage * Montage )
overridevirtual

Implements ICharacterBaseInterface.

Reimplemented in AALSBaseCharacter.

352{
353 //@ override in ALS //
354}

◆ Tick()

void ACharacterBase::Tick ( float DeltaTime)
overridevirtual

Member Data Documentation

◆ bAddCharacterMovement

bool ACharacterBase::bAddCharacterMovement = true
protected

◆ bAddMovementInput

bool ACharacterBase::bAddMovementInput = true
protected

◆ bCanBePushed

bool ACharacterBase::bCanBePushed = false
protected

◆ bDead

bool ACharacterBase::bDead = false
protected

◆ bDebuggingMode

bool ACharacterBase::bDebuggingMode = false
protected

◆ bPushHitReaction

bool ACharacterBase::bPushHitReaction = true
protected

◆ CategoryName

FLogCategoryName ACharacterBase::CategoryName = LogBaseCharacter.GetCategoryName()
private

◆ CharacterInfo

FCharacterInfo ACharacterBase::CharacterInfo
protected

◆ CharacterSaveGameObject

class UCharacterSaveGame* ACharacterBase::CharacterSaveGameObject = nullptr
private

◆ CharacterSkills

FCharacterBaseSkills ACharacterBase::CharacterSkills
protected

◆ FallOverTimerHandle

FTimerHandle ACharacterBase::FallOverTimerHandle
private

◆ HitReactionMultiplier

float ACharacterBase::HitReactionMultiplier = 0.01f
protected

◆ HitVelocityMultiplier

float ACharacterBase::HitVelocityMultiplier = 5.0f
protected

◆ HitVelocityThreshold

float ACharacterBase::HitVelocityThreshold = 50.0f
protected

◆ OnCharacterDeath

FOnCharacterDeath ACharacterBase::OnCharacterDeath

◆ PickupThrowIntensity

float ACharacterBase::PickupThrowIntensity = 500.0f
protected

◆ PlayerControllerInterface

IPlayerControllerInterface* ACharacterBase::PlayerControllerInterface = nullptr
private

◆ PlayerStateInterface

IPlayerStateInterface* ACharacterBase::PlayerStateInterface = nullptr
private

◆ PushedFallOverWaitTime

float ACharacterBase::PushedFallOverWaitTime = 2.0f
protected

◆ PushedFallVelocityThreshold

float ACharacterBase::PushedFallVelocityThreshold = 500.0f
protected

◆ PushFallVelocityThreshold

float ACharacterBase::PushFallVelocityThreshold = 200.0f
protected

The documentation for this class was generated from the following files: