From 1fa1a725b330be062ac3292000deb993fbe45b71 Mon Sep 17 00:00:00 2001 From: Stefan Stefanov Date: Sun, 12 Nov 2023 11:31:51 +0200 Subject: [PATCH] Added a cookspot class for creating prefabs in BP --- Source/minicook/OvenCookspot.cpp | 32 +++++++++++++++++++++++++++++ Source/minicook/OvenCookspot.h | 35 ++++++++++++++++++++++++++++++++ Source/minicook/OvenPawn.h | 15 ++++++++------ 3 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 Source/minicook/OvenCookspot.cpp create mode 100644 Source/minicook/OvenCookspot.h diff --git a/Source/minicook/OvenCookspot.cpp b/Source/minicook/OvenCookspot.cpp new file mode 100644 index 0000000..94d40fd --- /dev/null +++ b/Source/minicook/OvenCookspot.cpp @@ -0,0 +1,32 @@ +// Stefan Stefanov 2023 + + +#include "OvenCookspot.h" + +// Sets default values +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; + + FireMesh = CreateDefaultSubobject("FireSM"); + FireMesh->SetupAttachment(RootComponent); + FireElementMesh = CreateDefaultSubobject("FireElementSM"); + FireElementMesh->SetupAttachment(RootComponent); + CookpotMesh = CreateDefaultSubobject("CookpotSM"); + CookpotMesh->SetupAttachment(RootComponent); +} + +// Called when the game starts or when spawned +void AOvenCookspot::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void AOvenCookspot::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + +} \ No newline at end of file diff --git a/Source/minicook/OvenCookspot.h b/Source/minicook/OvenCookspot.h new file mode 100644 index 0000000..804c1d2 --- /dev/null +++ b/Source/minicook/OvenCookspot.h @@ -0,0 +1,35 @@ +// Stefan Stefanov 2023 + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "OvenCookspot.generated.h" + +UCLASS() +class MINICOOK_API AOvenCookspot : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + AOvenCookspot(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") + TObjectPtr FireMesh; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") + TObjectPtr FireElementMesh; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") + TObjectPtr CookpotMesh; +}; \ No newline at end of file diff --git a/Source/minicook/OvenPawn.h b/Source/minicook/OvenPawn.h index bf0c106..03ca07b 100644 --- a/Source/minicook/OvenPawn.h +++ b/Source/minicook/OvenPawn.h @@ -33,7 +33,8 @@ public: )) double HeatHalfRange{0.1}; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Meal", meta=(Tooltip = "The total cooking time for this meal recipe, in milliseconds")) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Meal", + meta=(Tooltip = "The total cooking time for this meal recipe, in milliseconds")) double TotalCookingTimeMS{5000.0}; }; @@ -138,13 +139,15 @@ public: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Oven Settings") int32 CurrentPlayerScore{0}; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") + TObjectPtr CookstovePrefab; + + // ReSharper disable once CppUE4ProbableMemoryIssuesWithUObject + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") + TObjectPtr RecipesDataTable; + private: // An array of all the cookstoves, from left to right on the screen TArray> CookstoveObjects; TArray Cookstoves; - -public: - // ReSharper disable once CppUE4ProbableMemoryIssuesWithUObject - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Oven Settings") - TObjectPtr RecipesDataTable; }; \ No newline at end of file