Formatting, add base class for prefabs for the cookspot, add functionality to spawn the prefabs in predetermined places based on an actor ptr
This commit is contained in:
parent
873337dec5
commit
57543aa69f
23 changed files with 36 additions and 16 deletions
BIN
Content/Blueprints/OvenCookspot_BP.uasset
Normal file
BIN
Content/Blueprints/OvenCookspot_BP.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/OvenPawn_BP.uasset
Normal file
BIN
Content/Blueprints/OvenPawn_BP.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven.uasset
Normal file
BIN
Content/Meshes/lp_oven.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven_button.uasset
Normal file
BIN
Content/Meshes/lp_oven_button.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven_button_needle.uasset
Normal file
BIN
Content/Meshes/lp_oven_button_needle.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven_cookpot.uasset
Normal file
BIN
Content/Meshes/lp_oven_cookpot.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven_fire.uasset
Normal file
BIN
Content/Meshes/lp_oven_fire.uasset
Normal file
Binary file not shown.
BIN
Content/Meshes/lp_oven_hot_element.uasset
Normal file
BIN
Content/Meshes/lp_oven_hot_element.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -9,11 +9,14 @@ AOvenCookspot::AOvenCookspot()
|
|||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
RootComponent = CreateDefaultSubobject<USceneComponent>("Root");
|
||||
|
||||
FireMesh = CreateDefaultSubobject<UStaticMeshComponent>("FireSM");
|
||||
FireMesh->SetupAttachment(RootComponent);
|
||||
FireElementMesh = CreateDefaultSubobject<UStaticMeshComponent>("FireElementSM");
|
||||
FireElementMesh->SetupAttachment(RootComponent);
|
||||
CookpotMesh = CreateDefaultSubobject<UStaticMeshComponent>("CookpotSM");
|
||||
|
||||
FireElementMesh->SetupAttachment(RootComponent);
|
||||
FireMesh->SetupAttachment(RootComponent);
|
||||
CookpotMesh->SetupAttachment(RootComponent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,15 @@ public:
|
|||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
public:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<USceneComponent> RootComp;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UStaticMeshComponent> FireMesh;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UStaticMeshComponent> FireElementMesh;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TObjectPtr<UStaticMeshComponent> CookpotMesh;
|
||||
};
|
||||
|
|
@ -112,8 +112,19 @@ void AOvenPawn::BeginPlay()
|
|||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
for (const AActor *CookspotLoc : CookspotLocations)
|
||||
{
|
||||
FActorSpawnParameters SpawnParameters;
|
||||
auto *OvenCookspotActor =
|
||||
GetWorld()->SpawnActor<AOvenCookspot>(CookstovePrefab,
|
||||
CookspotLoc->GetTransform(),
|
||||
SpawnParameters);
|
||||
OvenCookspotActor->SetActorLocation(CookspotLoc->GetActorLocation());
|
||||
CookstoveObjects.Add(OvenCookspotActor);
|
||||
}
|
||||
// Setup the cookstove related items
|
||||
Cookstoves.AddDefaulted(CookstoveObjects.Num());
|
||||
Cookstoves.AddDefaulted(CookspotLocations.Num());
|
||||
checkf(Cookstoves.Num() == CookstoveObjects.Num(), TEXT("Cookstoves and CookstoveObjects have different sizes"))
|
||||
}
|
||||
|
||||
void AOvenPawn::Tick(float DeltaTime)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "Misc/DateTime.h"
|
||||
#include "Misc/Timespan.h"
|
||||
#include "Engine/DataTable.h"
|
||||
#include "OvenCookspot.h"
|
||||
|
||||
#include "OvenPawn.generated.h"
|
||||
|
||||
|
|
@ -84,24 +85,24 @@ struct FCookstove
|
|||
|
||||
/**
|
||||
* @brief Updates the cookstove for this tick, if a meal is cooking, updates the stats for it and if it finishes it calculates the score, etc...
|
||||
* @param DeltaTime Time between N-1 and N-2 frames in milliseconds
|
||||
* @param PlayerScore Takes in the current player score in case a meal gets finished and the score must be returned
|
||||
* @param DeltaTime Time between N-1 and N-2 frames in milliseconds.
|
||||
* @param PlayerScore Takes in the current player score in case a meal gets finished and the score must be returned.
|
||||
*/
|
||||
auto Update(const float DeltaTime, int32 &PlayerScore) -> void;
|
||||
|
||||
/**
|
||||
* @brief Returns the remaining cooking time
|
||||
* @brief Returns the remaining cooking time.
|
||||
*/
|
||||
auto GetRemainingCookingTime() const -> FTimespan;
|
||||
|
||||
/**
|
||||
* @brief Check if the currently cooked meal is done cooking
|
||||
* @brief Check if the currently cooked meal is done cooking.
|
||||
*/
|
||||
auto IsMealDone() const -> bool;
|
||||
|
||||
/**
|
||||
* @brief Finishes up cooking the current meal, setting up the necessary stats and state
|
||||
* @return Returns the calculated score based on the stats of the cooked meal
|
||||
* @brief Finishes up cooking the current meal, setting up the necessary stats and state.
|
||||
* @return Returns the calculated score based on the stats of the cooked meal.
|
||||
*/
|
||||
auto FinishMeal() -> int32;
|
||||
};
|
||||
|
|
@ -121,7 +122,6 @@ protected:
|
|||
public:
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent *PlayerInputComponent) override;
|
||||
|
||||
auto TrySpawningNewRandomMeal() -> bool;
|
||||
|
|
@ -140,14 +140,17 @@ public:
|
|||
int32 CurrentPlayerScore{0};
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
TObjectPtr<AActor> CookstovePrefab;
|
||||
TSubclassOf<AOvenCookspot> CookstovePrefab;
|
||||
|
||||
// ReSharper disable once CppUE4ProbableMemoryIssuesWithUObject
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
TObjectPtr<UDataTable> RecipesDataTable;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings")
|
||||
TArray<TObjectPtr<AActor>> CookspotLocations;
|
||||
|
||||
private:
|
||||
// An array of all the cookstoves, from left to right on the screen
|
||||
TArray<TObjectPtr<AActor>> CookstoveObjects;
|
||||
// An array of all the cookstoves, from left to right on the screen.
|
||||
TArray<TObjectPtr<AOvenCookspot>> CookstoveObjects;
|
||||
TArray<FCookstove> Cookstoves;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue