DRG-Femboy-Voice/Source/FSD/Public/ResourcesComponent.h
2025-04-15 12:39:31 -07:00

73 lines
2.6 KiB
C++
Executable file

#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "ResourceAddedDelegate.h"
#include "ResourceAddedSignatureDelegate.h"
#include "ResourceChangedSignatureDelegate.h"
#include "ResourceFullSignatureDelegate.h"
#include "ResourcesComponent.generated.h"
class UCappedResource;
class UResourceData;
UCLASS(Blueprintable, ClassGroup=Custom, meta=(BlueprintSpawnableComponent))
class UResourcesComponent : public UActorComponent {
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
FResourceChangedSignature OnResourceChanged;
UPROPERTY(BlueprintAssignable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
FResourceAddedSignature OnResourceIncreased;
UPROPERTY(BlueprintAssignable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
FResourceFullSignature OnResourceFull;
UPROPERTY(BlueprintAssignable, BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
FResourceAdded OnResourceAdded;
protected:
UPROPERTY(BlueprintReadWrite, EditAnywhere, ReplicatedUsing=OnRep_Resources, meta=(AllowPrivateAccess=true))
TArray<UCappedResource*> Resources;
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta=(AllowPrivateAccess=true))
float ResourceCap;
public:
UResourcesComponent();
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
protected:
UFUNCTION(BlueprintCallable)
void ResourceIncreased(UCappedResource* Resource, float Delta);
UFUNCTION(BlueprintCallable)
void ResourceFull(UCappedResource* Resource);
UFUNCTION(BlueprintCallable)
void ResourceChanged(UCappedResource* Resource, float currentAmount);
UFUNCTION(BlueprintCallable)
void OnRep_Resources();
public:
UFUNCTION(BlueprintCallable, BlueprintPure)
static int32 GetXPFromResourceMap(const TMap<UResourceData*, float>& NewResources);
UFUNCTION(BlueprintCallable, BlueprintPure)
int32 GetXpFromMining() const;
UFUNCTION(BlueprintCallable)
static TMap<UResourceData*, float> GetSeparateResourcesFromMap(const TMap<UResourceData*, float>& NewResources);
UFUNCTION(BlueprintCallable, BlueprintPure)
UCappedResource* GetResource(UResourceData* Data, bool createIfAmountIsZero);
UFUNCTION(BlueprintCallable, BlueprintPure)
float GetCapacityPct() const;
UFUNCTION(BlueprintCallable, BlueprintPure)
TArray<UCappedResource*> GetAllResources();
};