47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
|
|
|
|
|
|
#include "ModularGameplayActors/OLSModularPlayerController.h"
|
|
|
|
#include "Components/GameFrameworkComponentManager.h"
|
|
#include "Components/ControllerComponent.h"
|
|
|
|
void AOLSModularPlayerController::PreInitializeComponents()
|
|
{
|
|
Super::PreInitializeComponents();
|
|
UGameFrameworkComponentManager::AddGameFrameworkComponentReceiver(this);
|
|
}
|
|
|
|
void AOLSModularPlayerController::EndPlay(const EEndPlayReason::Type endPlayReason)
|
|
{
|
|
UGameFrameworkComponentManager::RemoveGameFrameworkComponentReceiver(this);
|
|
Super::EndPlay(endPlayReason);
|
|
}
|
|
|
|
void AOLSModularPlayerController::ReceivedPlayer()
|
|
{
|
|
// Player controllers always get assigned a player and can't do much until then
|
|
UGameFrameworkComponentManager::SendGameFrameworkComponentExtensionEvent(
|
|
this, UGameFrameworkComponentManager::NAME_GameActorReady);
|
|
Super::ReceivedPlayer();
|
|
|
|
TArray<UControllerComponent*> modularComponents;
|
|
GetComponents(modularComponents);
|
|
for (UControllerComponent* component : modularComponents)
|
|
{
|
|
component->ReceivedPlayer();
|
|
}
|
|
}
|
|
|
|
void AOLSModularPlayerController::PlayerTick(float deltaTime)
|
|
{
|
|
Super::PlayerTick(deltaTime);
|
|
|
|
TArray<UControllerComponent*> modularComponents;
|
|
GetComponents(modularComponents);
|
|
for (UControllerComponent* component : modularComponents)
|
|
{
|
|
component->PlayerTick(deltaTime);
|
|
}
|
|
}
|