RealtimeStyleTransferRuntime/Plugins/CommonGame/Source/Private/CommonPlayerController.cpp

72 lines
1.6 KiB
C++
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "CommonPlayerController.h"
2022-09-13 07:18:28 +00:00
2022-05-23 18:41:30 +00:00
#include "CommonLocalPlayer.h"
2022-09-13 07:18:28 +00:00
#include "Templates/Casts.h"
#include "UObject/ObjectPtr.h"
class APawn;
2022-05-23 18:41:30 +00:00
ACommonPlayerController::ACommonPlayerController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void ACommonPlayerController::ReceivedPlayer()
{
Super::ReceivedPlayer();
if (UCommonLocalPlayer* LocalPlayer = Cast<UCommonLocalPlayer>(Player))
{
LocalPlayer->OnPlayerControllerSet.Broadcast(LocalPlayer, this);
if (PlayerState)
{
LocalPlayer->OnPlayerStateSet.Broadcast(LocalPlayer, PlayerState);
}
}
}
void ACommonPlayerController::SetPawn(APawn* InPawn)
{
Super::SetPawn(InPawn);
if (UCommonLocalPlayer* LocalPlayer = Cast<UCommonLocalPlayer>(Player))
{
LocalPlayer->OnPlayerPawnSet.Broadcast(LocalPlayer, InPawn);
}
}
void ACommonPlayerController::OnPossess(APawn* APawn)
{
Super::OnPossess(APawn);
if (UCommonLocalPlayer* LocalPlayer = Cast<UCommonLocalPlayer>(Player))
{
LocalPlayer->OnPlayerPawnSet.Broadcast(LocalPlayer, APawn);
}
}
void ACommonPlayerController::OnUnPossess()
{
Super::OnUnPossess();
if (UCommonLocalPlayer* LocalPlayer = Cast<UCommonLocalPlayer>(Player))
{
LocalPlayer->OnPlayerPawnSet.Broadcast(LocalPlayer, nullptr);
}
}
void ACommonPlayerController::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
if (PlayerState)
{
if (UCommonLocalPlayer* LocalPlayer = Cast<UCommonLocalPlayer>(Player))
{
LocalPlayer->OnPlayerStateSet.Broadcast(LocalPlayer, PlayerState);
}
}
}