50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "CraftingStation.h"
|
|
|
|
#include "Components/StaticMeshComponent.h"
|
|
#include "Engine/CollisionProfile.h"
|
|
#include "FpsPlayerController.h"
|
|
#include "GameFramework/Pawn.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "CraftingStation"
|
|
|
|
ACraftingStation::ACraftingStation()
|
|
{
|
|
PrimaryActorTick.bCanEverTick = false;
|
|
|
|
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
|
|
SetRootComponent(Mesh);
|
|
|
|
// Explicite plutot que de compter sur le profil par defaut : ce composant a
|
|
// deux roles indissociables, empecher le joueur de traverser le meuble et
|
|
// bloquer le canal Visibility pour que le trace d'interaction le trouve.
|
|
// Un profil qui laisserait passer Visibility rendrait le poste inutilisable
|
|
// sans qu'aucune erreur ne le signale.
|
|
Mesh->SetCollisionProfileName(UCollisionProfile::BlockAll_ProfileName);
|
|
|
|
InteractionPrompt = LOCTEXT("UseStation", "Utiliser l'établi");
|
|
}
|
|
|
|
FText ACraftingStation::GetInteractionPrompt_Implementation(AActor* Interactor) const
|
|
{
|
|
return InteractionPrompt;
|
|
}
|
|
|
|
void ACraftingStation::Interact_Implementation(AActor* Interactor)
|
|
{
|
|
// L'ecran vit sur le controller, pas sur le pawn : c'est lui qu'on cherche.
|
|
const APawn* InteractingPawn = Cast<APawn>(Interactor);
|
|
AFpsPlayerController* PlayerController = InteractingPawn ? Cast<AFpsPlayerController>(InteractingPawn->GetController()) : nullptr;
|
|
|
|
if (!PlayerController)
|
|
{
|
|
return;
|
|
}
|
|
|
|
PlayerController->OpenCraftingAtStation(StationType);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|