5#include "CoreMinimal.h"
6#include "AIController.h"
8#include "Components/ActorComponent.h"
10#include "CharacterComponent.generated.h"
18struct FRadialWheelMenuData;
30 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Character")
31 bool bController = false;
32 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
33 bool bPlayerController = false;
34 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
35 bool bAIController = false;
36 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
37 bool bSkeletalMesh = false;
38 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
39 bool bAnimationInstance = false;
40 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
42 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
43 bool bHUDReference = false;
44 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
45 bool bHasWidgets = false;
47 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character")
48 bool bShouldDestroyOnDeath = false;
50 bool GetAnyRequirementsSet()
const
52 if(bController || bPlayerController || bAIController || bSkeletalMesh || bAnimationInstance
53 || bPawn || bHUDReference)
62 if(Requirements.
bController && bController ==
false)
74 if(Requirements.
bPawn && bPawn ==
false)
106UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent), Abstract)
114 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
119 T* GetController()
const
121 static_assert(TPointerIsConvertibleFromTo<T, AController>::Value,
"'T' template parameter to GetController must be derived from AController");
122 return Cast<T>(GetPawnChecked<APawn>()->GetController());
125 T* GetControllerChecked()
const
127 static_assert(TPointerIsConvertibleFromTo<T, AController>::Value,
"'T' template parameter to GetControllerChecked must be derived from AController");
128 return CastChecked<T>(GetPawnChecked<APawn>()->GetController());
133 static_assert(TPointerIsConvertibleFromTo<T, APawn>::Value,
"'T' template parameter to GetPawn must be derived from APawn");
134 return Cast<T>(GetOwner());
137 T* GetPawnChecked()
const
139 static_assert(TPointerIsConvertibleFromTo<T, APawn>::Value,
"'T' template parameter to GetPawnChecked must be derived from APawn");
140 return CastChecked<T>(GetOwner());
144 T* GetPlayerState()
const
146 static_assert(TPointerIsConvertibleFromTo<T, APlayerState>::Value,
"'T' template parameter to GetPlayerState must be derived from APlayerState");
147 return GetControllerChecked<AController>()->GetPlayerState<T>();
150 bool IsLocalController()
const;
163 static_assert(TPointerIsConvertibleFromTo<T, UPlayer>::Value,
"'T' template parameter to GetPlayer must be derived from UPlayer");
164 APlayerController* PC = GetController<APlayerController>();
165 return PC ? Cast<T>(PC->Player) : nullptr;
169 UPROPERTY(BlueprintAssignable, Category=
"Character Component")
170 FOnRequestFriendlyActors OnRequestFriendlyActors;
175 UFUNCTION(BlueprintCallable, Category="
Character Component")
176 virtual
void SetupComponentWidgets();
179 virtual
void ComponentSetupComplete() override;
182 UFUNCTION(BlueprintImplementableEvent, Category="
Character Component")
183 void OnComponentSetupComplete();
185 void SetIsCrouched(const
bool bCrouching);
186 void SetIsDead(const
bool bDead);
187 void SetIsKnockedOut(const
bool bKnocked, const UDamageType* DamageType);
194 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
195 TArray<AActor*> GetFriendlyActors() const;
196 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
197 float GetLastAnimationDuration()
const {
return LastAnimationDuration;}
201 virtual FVector GetCameraTraceLocation()
const;
203 virtual FVector GetPlayerTraceLocation()
const;
204 virtual FRotator GetCameraTraceRotation()
const;
205 virtual FTransform GetCameraTraceTransform()
const;
211 virtual int32 CloseRadialMenu();
212 bool GetIsRadialMenuOpen()
const;
214 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Traits")
215 bool bUseCharacterTraits = true;
218 virtual
void BeginPlay() override;
220 virtual
void AutoDetect() override;
221 virtual
void Server_AutoDetect() override;
224 virtual
void ComponentActivated(UActorComponent* Component, const
bool bReset) override;
225 virtual
void ComponentDeactivated(UActorComponent* Component) override;
227 UUserWidget* PushContentToLayer(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
228 UUserWidget* AddWidgetToLayer(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
229 UUserWidget* GetContentFromLayer(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
230 UUserWidget* AddWidgetToLayerWithSlot(const FGameplayTag& LayerName, const FGameplayTag& SlotTag, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
235 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
236 USceneComponent* GetThrowPoint() const;
238 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
239 AController* GetOwnerController() const;
240 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
241 APlayerController* GetOwnerPlayerController() const;
242 UFUNCTION(BlueprintPure,BlueprintCallable, Category = "
Character")
243 USkeletalMeshComponent* GetOwnerMesh() const;
246 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
247 AAIController* GetOwnerAIController() const;
248 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
249 APawn* GetOwnerPawn() const;
253 UFUNCTION(BlueprintPure, BlueprintCallable, Category = "
Character")
254 FString GetOwnerName()
const {
return OwnerObjectName;};
260 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Character")
261 bool GetIsDead()
const {
return bIsDead;};
262 UFUNCTION(BlueprintPure, Category =
"Character")
263 bool GetIsOwnerKnockedOut()
const {
return bIsKnockedOut;};
264 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Character")
265 bool GetIsNPC()
const {
return bIsNPC;};
266 UFUNCTION(BlueprintPure, BlueprintCallable, Category =
"Character")
267 bool GetIsCrouched()
const {
return bIsCrouching;};
270 UFUNCTION(BlueprintCallable, Category =
"Character")
276 UFUNCTION(BlueprintCallable, Category="
Character")
277 virtual
void OwnerKnockedOut(const UDamageType* DamageType);
278 UFUNCTION(BlueprintCallable, Category="
Character")
279 virtual
void OwnerWakeUp();
280 UFUNCTION(BlueprintCallable, Category="
Character")
281 virtual
void OwnerDeath();
282 UFUNCTION(BlueprintImplementableEvent, Category="
Character")
285 void SetInputModeGameAndUI(const
bool bGameAndUI, const
bool bShowMouse, class UWidget* InWidgetToFocus =
nullptr) const;
287 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Setup")
289 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Setup")
293 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Setup")
294 bool bHasWidgets = false;
295 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Setup")
296 bool bUsesHUDWidgets = false;
297 bool bBindAnimationEvent = false;
299 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Debugging")
300 bool bUsingEnhancedInput = true;
301 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Character|Debugging")
302 float MultiplayerStartDelay = 0.5f;
310 float PlayMontageAnimation(UAnimMontage* MontageToPlay, const
float InPlayRate = 1.0f, const EMontagePlayReturnType ReturnValueType = EMontagePlayReturnType::Duration, const
float InTimeToStartMontageAt = 0.0f, const
bool bStopAllMontages = true);
312 void StopMontageAnimation(const
float InBlendOutTime, const UAnimMontage* Montage);
314 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Animation")
315 float LastAnimationDuration = 0.0f;
318 virtual
void OnMontageNotifyBegin(FName NotifyName, const FBranchingPointNotifyPayload& BranchingPointPayload);
320 virtual
void OnMontageNotifyEnd(FName NotifyName, const FBranchingPointNotifyPayload& BranchingPointPayload);
334 void Server_SetOwnerMesh(USkeletalMeshComponent* SkeletalMesh);
337 bool DetectOwnerMesh();
338 bool DetectOwnerAnimInst();
340 bool DetectOwnerHUD();
341 bool BindAnimation();
343 void SetOwnerMesh(USkeletalMeshComponent* SkeletalMesh);
344 void SetAnimInstance(UAnimInstance* AnimationInstance);
346 void SetIsNPC(const
bool bNPC){bIsNPC = bNPC;};
347 void SetHUDReference(AActor* HUDReference);
349 void TrySetupAgain();
353 bool bIsDead =
false;
354 bool bIsKnockedOut =
false;
355 bool bIsCrouching =
false;
362 UPROPERTY(Replicated)
363 TObjectPtr<USkeletalMeshComponent> OwnerMesh =
nullptr;
365 TObjectPtr<UAnimInstance> MainAnimInstance =
nullptr;
369 TObjectPtr<AActor> OwnerHUDReference =
nullptr;
381 UPROPERTY(VisibleAnywhere, Category="
Character")
382 FString OwnerObjectName = "Name";
386 UPROPERTY(EditAnywhere, Category="
Character|Setup")
387 int32 SetupAttempts = 5;
388 UPROPERTY(EditAnywhere, Category="
Character|Setup")
389 float SetupAttemptDelay = 1.0f;
391 int32 CurrentSetupAttempt = 0;
392 FTimerHandle SetupCompleteDelayTimerHandle;
393 FTimerHandle UpdateCameraTimerHandle;
394 FTimerHandle SetupComponentDelayTimerHandle;
DECLARE_LOG_CATEGORY_EXTERN(LogCharacterComponent, Display, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRequestFriendlyActors, TArray< AActor * > &, Actors)
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Definition CustomCharacter.h:19
Definition ControllerInterface.h:20
Definition HUDInterface.h:23
Definition PlayerControllerInterface.h:21
Represents a character component that can be added to an actor.
Definition BaseData.h:815
Definition CharacterComponent.h:26
bool GetHasFoundRequirements(const FCharacterComponentRequirements &Requirements) const
Definition CharacterComponent.h:60
bool bController
Definition CharacterComponent.h:31
bool bPawn
Definition CharacterComponent.h:41
bool bSkeletalMesh
Definition CharacterComponent.h:37
bool bHUDReference
Definition CharacterComponent.h:43
bool bAIController
Definition CharacterComponent.h:35
bool bAnimationInstance
Definition CharacterComponent.h:39
bool bPlayerController
Definition CharacterComponent.h:33