Nelaric Unreal Gameplay
Gameplay framework API
Loading...
Searching...
No Matches
NelaricPawnComponent.h
Go to the documentation of this file.
1// Copyright (c) 2026 Nelaric
2
6
7#pragma once
8
9#include "Components/ActorComponent.h"
10#include "Templates/UnrealTypeTraits.h"
11#include "Templates/Casts.h"
12
13#include "NelaricPawnComponent.generated.h"
14
15class AController;
16class APawn;
17class APlayerController;
18class APlayerState;
19
29UCLASS(Abstract, MinimalAPI, Blueprintable)
30class UNelaricPawnComponent : public UActorComponent
31{
32 GENERATED_BODY()
33
34public:
41 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
42 GAMEPLAYRUNTIME_API APawn* GetPawn() const;
43
50 template <typename T> T* GetPawn() const
51 {
52 static_assert(TIsDerivedFrom<T, APawn>::IsDerived, "T must derive from APawn.");
53 return Cast<T>(GetPawn());
54 }
55
62 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
63 GAMEPLAYRUNTIME_API AController* GetController() const;
64
71 template <typename T> T* GetController() const
72 {
73 static_assert(TIsDerivedFrom<T, AController>::IsDerived, "T must derive from AController.");
74 return Cast<T>(GetController());
75 }
76
83 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
84 GAMEPLAYRUNTIME_API APlayerController* GetPlayerController() const;
85
92 template <typename T> T* GetPlayerController() const
93 {
94 static_assert(TIsDerivedFrom<T, APlayerController>::IsDerived, "T must derive from APlayerController.");
95 return Cast<T>(GetPlayerController());
96 }
97
104 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
105 GAMEPLAYRUNTIME_API APlayerState* GetPlayerState() const;
106
113 template <typename T> T* GetPlayerState() const
114 {
115 static_assert(TIsDerivedFrom<T, APlayerState>::IsDerived, "T must derive from APlayerState.");
116 return Cast<T>(GetPlayerState());
117 }
118
124 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
125 GAMEPLAYRUNTIME_API bool IsLocallyControlled() const;
126
133 UFUNCTION(BlueprintPure, Category = "Nelaric|Pawn")
134 GAMEPLAYRUNTIME_API bool IsPlayerControlled() const;
135
136public:
137 GAMEPLAYRUNTIME_API UNelaricPawnComponent(const FObjectInitializer& ObjectInitializer);
138 GAMEPLAYRUNTIME_API virtual void OnRegister() override;
139};
GAMEPLAYRUNTIME_API APlayerState * GetPlayerState() const
Gets player state directly from the owning pawn.
GAMEPLAYRUNTIME_API bool IsPlayerControlled() const
Queries the pawn's native player-control semantics.
GAMEPLAYRUNTIME_API AController * GetController() const
Gets the pawn's current controller on this machine.
GAMEPLAYRUNTIME_API APlayerController * GetPlayerController() const
Gets the current controller when it is a player controller.
GAMEPLAYRUNTIME_API bool IsLocallyControlled() const
Queries the pawn's native local-control semantics.
GAMEPLAYRUNTIME_API APawn * GetPawn() const
Gets the pawn that directly owns this component.