This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AgrarianGameArchive/Source/AgrarianGame/AgrarianCraftingComponent.h
T

55 lines
1.9 KiB
C++

// Copyright Pacificao. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "AgrarianTypes.h"
#include "AgrarianCraftingComponent.generated.h"
class UAgrarianInventoryComponent;
class UAgrarianRecipeDataAsset;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAgrarianCraftCompletedSignature, FName, RecipeId, const FAgrarianItemStack&, Result);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAgrarianCraftFailedSignature, FName, RecipeId, FText, Reason);
UCLASS(ClassGroup = (Agrarian), BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent))
class UAgrarianCraftingComponent : public UActorComponent
{
GENERATED_BODY()
public:
UAgrarianCraftingComponent();
UPROPERTY(BlueprintAssignable, Category = "Agrarian|Crafting")
FAgrarianCraftCompletedSignature OnCraftCompleted;
UPROPERTY(BlueprintAssignable, Category = "Agrarian|Crafting")
FAgrarianCraftFailedSignature OnCraftFailed;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
TArray<FAgrarianRecipe> KnownRecipes;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Agrarian|Crafting")
TArray<TObjectPtr<UAgrarianRecipeDataAsset>> KnownRecipeAssets;
UFUNCTION(BlueprintCallable, Category = "Agrarian|Crafting")
bool CanCraft(FName RecipeId, FText& FailureReason) const;
UFUNCTION(BlueprintCallable, Category = "Agrarian|Crafting")
bool Craft(FName RecipeId);
UFUNCTION(Server, Reliable, BlueprintCallable, Category = "Agrarian|Crafting")
void ServerCraft(FName RecipeId);
UFUNCTION(BlueprintCallable, Category = "Agrarian|Crafting")
bool AddKnownRecipe(const FAgrarianRecipe& Recipe);
UFUNCTION(BlueprintCallable, Category = "Agrarian|Crafting")
bool FindRecipe(FName RecipeId, FAgrarianRecipe& OutRecipe) const;
protected:
UAgrarianInventoryComponent* GetInventory() const;
void FailCraft(FName RecipeId, const FText& Reason);
};