(Feat) Add Cooking and Workbench
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "InputCoreTypes.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "InteractionPromptWidget.h"
|
||||
#include "CraftingComponent.h"
|
||||
#include "InventoryScreenWidget.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "PauseMenuWidget.h"
|
||||
@@ -420,6 +421,47 @@ void AFpsPlayerController::ToggleCrafting()
|
||||
SetInventoryScreenOpen(true, /*bShowCraftingTab=*/true);
|
||||
}
|
||||
|
||||
void AFpsPlayerController::OpenCraftingAtStation(ECraftingStation Station)
|
||||
{
|
||||
if (Station == ECraftingStation::Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Deja ouvert sur un autre poste : on rend le precedent avant d'accorder le
|
||||
// nouveau, sinon le compteur du composant ne redescendrait jamais.
|
||||
ReleaseActiveStation();
|
||||
|
||||
if (UCraftingComponent* Crafting = GetPawnCrafting())
|
||||
{
|
||||
Crafting->AddAvailableStation(Station);
|
||||
ActiveStation = Station;
|
||||
}
|
||||
|
||||
SetInventoryScreenOpen(true, /*bShowCraftingTab=*/true);
|
||||
}
|
||||
|
||||
void AFpsPlayerController::ReleaseActiveStation()
|
||||
{
|
||||
if (ActiveStation == ECraftingStation::Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (UCraftingComponent* Crafting = GetPawnCrafting())
|
||||
{
|
||||
Crafting->RemoveAvailableStation(ActiveStation);
|
||||
}
|
||||
|
||||
ActiveStation = ECraftingStation::Count;
|
||||
}
|
||||
|
||||
UCraftingComponent* AFpsPlayerController::GetPawnCrafting() const
|
||||
{
|
||||
const AFpsPlayer* PlayerPawn = Cast<AFpsPlayer>(GetPawn());
|
||||
return PlayerPawn ? PlayerPawn->GetCraftingComponent() : nullptr;
|
||||
}
|
||||
|
||||
void AFpsPlayerController::SetInventoryScreenOpen(bool bOpen, bool bShowCraftingTab)
|
||||
{
|
||||
if (!InventoryScreen)
|
||||
@@ -450,6 +492,15 @@ void AFpsPlayerController::SetInventoryScreenOpen(bool bOpen, bool bShowCrafting
|
||||
|
||||
bInventoryOpen = bOpen;
|
||||
|
||||
// Une fermeture, quelle qu'en soit la cause -- Tab, Echap, la mort --
|
||||
// rend le poste. Le faire ici et nulle part ailleurs garantit qu'aucun
|
||||
// chemin de sortie ne laisse l'etabli accessible depuis l'autre bout de
|
||||
// la carte.
|
||||
if (!bInventoryOpen)
|
||||
{
|
||||
ReleaseActiveStation();
|
||||
}
|
||||
|
||||
if (bInventoryOpen)
|
||||
{
|
||||
if (bShowCraftingTab)
|
||||
|
||||
Reference in New Issue
Block a user