Space Plunder
Loading...
Searching...
No Matches
CharacterBase.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"
6#include "GameFramework/Character.h"
11#include "Interfaces/SaveLoad.h"
12#include "CharacterBase.generated.h"
13
14DECLARE_LOG_CATEGORY_CLASS(LogBaseCharacter, Display, All);
15
16DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnCharacterDeath, FPlayerDeath&, PlayerDeath, APawn*, OwnerPawn);
17
18
19UCLASS()
20class BASEHELPERS_API ACharacterBase : public ACharacter, public ICharacterBaseInterface, public ISaveLoad, public IBaseInterface
21{
22 GENERATED_BODY()
23
24public:
25 ACharacterBase(const FObjectInitializer& ObjectInitializer);
26
27 virtual void Tick(float DeltaTime) override;
28 virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
29
30 virtual void OnPawnSpawned() override;
31
32 //~ ISaveLoad ~//
33 virtual bool SaveGame() override;
34 virtual bool LoadGame() override;
35 //~ ISaveLoad ~//
36
37
38 UPROPERTY(BlueprintAssignable)
39 FOnCharacterDeath OnCharacterDeath;
40
41
42 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
43 //~~ ICustomCharacter ~~//
44 virtual USkeletalMeshComponent* GetCharacterMesh() const override {return GetMesh();};
45 virtual UPrimitiveComponent* GetPrimitiveComponent() override {return Cast<UPrimitiveComponent>(RootComponent);};
46 virtual void Ragdoll() override;
47 virtual void RagdollStop() override;
48
49 //@ override in ALS //
50 virtual float PlayReplicatedMontage(UAnimMontage* MontageToPlay, const float InPlayRate = 1.0f, const EMontagePlayReturnType ReturnValueType = EMontagePlayReturnType::Duration,
51 const float InTimeToStartMontageAt = 0.0f, const bool bStopAllMontages = true) override;
52 //@ override in ALS //
53 virtual void StopReplicatedMontage(const float InBlendOutTime, const UAnimMontage* Montage) override;
54 virtual bool GetCharacterHealth(float& Health, float& MaxHealth) const override;
55
56 //@TODO Check if this can be used in C++ to Edit the Skills, if not create a seperate function for Blueprints
57 // virtual bool GetCharacterSkills(FCharacterBaseSkills& Skills) override;
58 virtual FCharacterBaseSkills& GetCharacterSkills() override;
59 virtual bool GetAudioSocketLocation(const FName& AudioSocket, FVector& Location) const override;
60 virtual USceneComponent* GetThrowPoint() const override;
61 virtual FCharacterInfo GetCharacterInfo() const override;
62 virtual void GetThrowStats(FTransform& OutTransform, FVector& OutThrowForce) const override;
63
64 virtual void CharacterModeChanged(const FGameplayTag& NewMode) override;
65
66 //~~ ICustomCharacter ~~//
67 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
68
69 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
70 //~~ IBaseInterface ~~//
71 // virtual void SetGravityEnabled(const bool bValue) override;
72 // virtual FString GetObjectDisplayName() const override;
73 // virtual bool GetIsCharacter() const override;
74
75 // @TODO maybe move ICharacter from AITOolKit to Base //
76 // virtual UTexture2D* GetDisplayIcon(bool& bSuccess) const {bSuccess = false; return nullptr;};
77
78public:
79
80
81
82 //~ Access the Skills ~//
83 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
84 virtual int32 GetStrength() const{return CharacterSkills.GetStrength();};
85 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
86 virtual int32 GetPerception() const{return CharacterSkills.GetPerception();};
87 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
88 virtual int32 GetEndurance() const{return CharacterSkills.GetEndurance();};
89 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
90 virtual int32 GetCharisma() const{return CharacterSkills.GetCharisma();};
91 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
92 virtual int32 GetIntelligence() const{return CharacterSkills.GetIntelligence();};
93 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
94 virtual int32 GetAgility() const{return CharacterSkills.GetAgility();};
95 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
96 virtual int32 GetWeaponSkill() const{return CharacterSkills.GetWeaponSkill();};
97 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
98 virtual int32 GetStealth() const{return CharacterSkills.GetStealth();};
99 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
100 virtual int32 GetLuck() const{return CharacterSkills.GetLuck();};
101 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Character|Skills")
102 virtual int32 GetSkillPoints() const{return CharacterSkills.GetSkillPoints();};
103 //~ Access the Skills ~//
104
105
106protected:
107 virtual void BeginPlay() override;
108
109
110 virtual void NotifyHit(UPrimitiveComponent* MyComp, AActor* Other, UPrimitiveComponent* OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult& Hit) override;
111
112 //@ TODO Add in Turn to Actor-? Maybe in ControllerBase Interface, so for AI controller aswell
113 // virtual void TurnToActor(AActor* Actor);
114
115 virtual void FallOver(const float WaitTime);
116 UFUNCTION(BlueprintImplementableEvent, Category="Player")
117 void OnFallOver(const float WaitTime);
118 virtual void GetUpFromFall();
119 UFUNCTION(BlueprintImplementableEvent, Category="Player")
120 void OnGetUpFromFall();
121
122 UFUNCTION()
123 void OnRep_CharacterDeath();
124 // IHUDInterface* GetHUDInterface();
125 IPlayerControllerInterface* GetPlayerControllerInterface();
126 IPlayerStateInterface* GetPlayerStateInterface();
127
128
129 void LogDebugError(const FString& Message) const;
130 void LogDebugError(const FString& Message, const int32 Value) const;
131 void LogDebugError(const FString& Message, const float Value) const;
132 void LogDebugWarning(const FString& Message) const;
133 void LogDebugWarning(const FString& Message, const int32 Value) const;
134 void LogDebugWarning(const FString& Message, const float Value) const;
135
136 void LogDebugMessage(const FString& Message, const bool bWarning = false, const bool bError = false) const;
137 void LogDebugMessage(const FString& Message, const int32 Value, const bool bWarning = false, const bool bError = false) const;
138 void LogDebugMessage(const FString& Message, const float Value, const bool bWarning = false, const bool bError = false) const;
139 void LogDebugMessage(const FString& Message, const bool bValue, const bool bWarning, const bool bError) const;
140 void LogOnScreenMessage(const int32 Key, const FString& Message, FColor Color = FColor::Green) const;
141
142 void SetCategoryName(const FLogCategoryBase& Category){CategoryName = Category.GetCategoryName();};
143
144 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Debugging")
145 bool bDebuggingMode = false;
146
147 // /** Use GetCharacter Skills to Edit */
148 UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Category= "Character|Core")
149 FCharacterBaseSkills CharacterSkills;
150 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Core")
151 FCharacterInfo CharacterInfo;
152 UPROPERTY(ReplicatedUsing=OnRep_CharacterDeath, EditAnywhere, BlueprintReadWrite, Category= "Character|Core")
153 bool bDead = false;
154
155 // @TODO Move These to Skills componnet
156 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character|Pickup")
157 float PickupThrowIntensity = 500.0f;
158
159 //- Hit/Pushing //
160 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
161 bool bCanBePushed = false;
162 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
163 float HitVelocityThreshold = 50.0f;
164 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
165 float HitVelocityMultiplier = 5.0f;
166 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
167 float HitReactionMultiplier = 0.01f;
168 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
169 bool bPushHitReaction = true;
170 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
171 bool bAddMovementInput = true;
172 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
173 bool bAddCharacterMovement = true;
174 //- How much Velocity by self to fall over //
175 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
176 float PushFallVelocityThreshold = 200.0f;
177 //- How much Velocity by someone Pushing to fall over //
178 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
179 float PushedFallVelocityThreshold = 500.0f;
180 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Pushing")
181 float PushedFallOverWaitTime = 2.0f;
182
183
184 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Character|Interaction")
185 // FInteractionData InteractionData;
186
187private:
188
189 UPROPERTY(VisibleAnywhere, Category="Character|Save")
190 class UCharacterSaveGame* CharacterSaveGameObject = nullptr;
191
192
193 FLogCategoryName CategoryName = LogBaseCharacter.GetCategoryName();
194
195 IPlayerControllerInterface* PlayerControllerInterface = nullptr;
196 //@@ TODO AI Controller Interface
197 // IPlayerControllerInterface* PlayerControllerInterface = nullptr;
198 IPlayerStateInterface* PlayerStateInterface = nullptr;
199 FTimerHandle FallOverTimerHandle;
200
201
202};
DECLARE_LOG_CATEGORY_CLASS(LogBaseCharacter, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnCharacterDeath, FPlayerDeath &, PlayerDeath, APawn *, OwnerPawn)
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition CharacterBase.h:21
virtual UPrimitiveComponent * GetPrimitiveComponent() override
Definition CharacterBase.h:45
Definition Health.Build.cs:6
Definition BaseInterface.h:17
Definition CustomCharacter.h:19
Definition PlayerControllerInterface.h:21
Definition PlayerStateInterface.h:22
Definition SaveLoad.h:20
Definition CharacterSaveGame.h:14
Definition BaseData.h:815
Definition BaseData.h:310
Definition BaseData.h:613