5#include "CoreMinimal.h"
7#include "Components/ActorComponent.h"
8#include "PlayerControllerComponent.generated.h"
17UCLASS(ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent), Abstract)
18class BASEHELPERS_API UPlayerControllerComponent :
public UCommonActorComponent
26 T* GetGameInstance()
const
28 static_assert(TPointerIsConvertibleFromTo<T, UGameInstance>::Value,
"'T' template parameter to GetGameInstance must be derived from UGameInstance");
29 AActor*
Owner = GetOwner();
30 return Owner ?
Owner->GetGameInstance<T>() : nullptr;
33 T* GetGameInstanceChecked()
const
35 static_assert(TPointerIsConvertibleFromTo<T, UGameInstance>::Value,
"'T' template parameter to GetGameInstance must be derived from UGameInstance");
36 AActor*
Owner = GetOwner();
38 T* GameInstance =
Owner->GetGameInstance<T>();
47 T* GetController()
const
49 static_assert(TPointerIsConvertibleFromTo<T, AController>::Value,
"'T' template parameter to GetController must be derived from AController");
50 return Cast<T>(GetOwner());
54 T* GetControllerChecked()
const
56 static_assert(TPointerIsConvertibleFromTo<T, AController>::Value,
"'T' template parameter to GetControllerChecked must be derived from AController");
57 return CastChecked<T>(GetOwner());
69 static_assert(TPointerIsConvertibleFromTo<T, APawn>::Value,
"'T' template parameter to GetPawn must be derived from APawn");
70 return Cast<T>(GetControllerChecked<AController>()->GetPawn());
75 T* GetViewTarget()
const
77 static_assert(TPointerIsConvertibleFromTo<T, AActor>::Value,
"'T' template parameter to GetViewTarget must be derived from APawn");
78 return Cast<T>(GetControllerChecked<AController>()->GetViewTarget());
83 T* GetPawnOrViewTarget()
const
85 if (T* Pawn = GetPawn<T>())
91 return GetViewTarget<T>();
96 T* GetPlayerState()
const
98 static_assert(TPointerIsConvertibleFromTo<T, APlayerState>::Value,
"'T' template parameter to GetPlayerState must be derived from APlayerState");
99 return GetControllerChecked<AController>()->GetPlayerState<T>();
103 bool IsLocalController()
const;
106 void GetPlayerViewPoint(FVector&
Location, FRotator& Rotation)
const;
116 static_assert(TPointerIsConvertibleFromTo<T, UPlayer>::Value,
"'T' template parameter to GetPlayer must be derived from UPlayer");
117 APlayerController* PC = Cast<APlayerController>(GetOwner());
118 return PC ? Cast<T>(PC->Player) : nullptr;
123 UPlayerControllerComponent();
126 virtual bool SaveGame()
override;
127 virtual bool LoadGame()
override;
130 virtual void ComponentSetupComplete()
override;
133 UFUNCTION(BlueprintImplementableEvent, Category=
"Controller Component", meta=(DisplayName =
"On Component Deactivated"))
134 void OnComponentDeactivatedEvent(UActorComponent* Component);
135 UFUNCTION(BlueprintImplementableEvent, Category="Controller Component", meta=(DisplayName = "On Component Activated"))
136 void OnComponentActivatedEvent(UActorComponent* Component, const
bool bReset);
139 UFUNCTION(BlueprintCallable, Category="Controller Component")
140 virtual FVector GetCameraTraceLocation() const;
142 UFUNCTION(BlueprintCallable, Category="Controller Component")
143 virtual FVector GetPlayerTraceLocation() const;
144 UFUNCTION(BlueprintCallable, Category="Controller Component")
145 virtual FRotator GetCameraTraceRotation() const;
146 UFUNCTION(BlueprintCallable, Category="Controller Component")
147 virtual FTransform GetCameraTraceTransform() const;
149 UUserWidget* PushContentToLayer(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
150 UUserWidget* AddWidgetToLayer(const FGameplayTag& LayerName,const TSoftClassPtr<UUserWidget>& WidgetClass) const;
151 UUserWidget* GetContentFromLayer(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
152 UUserWidget* AddWidgetToLayerWithSlot(const FGameplayTag& LayerName, const FGameplayTag& SlotTag, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
155 bool ToggleWidget(const FGameplayTag& LayerName, const TSoftClassPtr<UUserWidget>& WidgetClass) const;
157 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Controller Component")
158 bool bAllowAIControllers = false;
161 virtual
void BeginPlay() override;
163 virtual
void AutoDetect() override;
170 UFUNCTION(BlueprintCallable, Category="Controller Component")
171 FVector2D GetScreenCenter() const;
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_LOG_CATEGORY_EXTERN(LogPlayerControllerComp, Display, All)
Definition ControllerInterface.h:20
Definition PlayerControllerInterface.h:21