Cleanup of old seed stuff

This commit is contained in:
2026-09-17 21:43:02 +02:00
parent 69372fde46
commit 0af47d7bc3
36 changed files with 39 additions and 358 deletions

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.

View File

@@ -74,18 +74,6 @@ TArray<UItemDataAsset*> UItemDatabase::GetItemsOfElement(Element InElement, Cate
return ItemList; return ItemList;
} }
void UItemDatabase::WaterAllSeeds()
{
for (ASeedCarousel* Seed : SeedsPlanted)
{
if (IsValid(Seed))
{
Seed->Water();
}
}
}
bool UItemDatabase::DoChemicalAlignmentsMatch(TArray<int32> Alignments, TArray<int32> PotionAlignments) bool UItemDatabase::DoChemicalAlignmentsMatch(TArray<int32> Alignments, TArray<int32> PotionAlignments)
{ {
for (int32 i = 0; i < PotionAlignments.Num(); i++) for (int32 i = 0; i < PotionAlignments.Num(); i++)

View File

@@ -4,8 +4,6 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Actor.h" #include "GameFramework/Actor.h"
#include "PotionItem.h"
#include "SeedCarousel.h"
#include "ItemContainer.h" #include "ItemContainer.h"
#include "DataAssets/ItemDataAsset.h" #include "DataAssets/ItemDataAsset.h"
@@ -72,13 +70,7 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Database") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Database")
TMap<Category, FArrayOfItemRefs> LoadedItemsByCategory; TMap<Category, FArrayOfItemRefs> LoadedItemsByCategory;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Item Database")
TArray<ASeedCarousel*> SeedsPlanted;
public: public:
UFUNCTION(BlueprintCallable, Category = "Item Database")
void WaterAllSeeds();
UFUNCTION(BlueprintCallable, Category = "Item Database") UFUNCTION(BlueprintCallable, Category = "Item Database")
bool DoChemicalAlignmentsMatch(TArray<int32> Alignments, TArray<int32> PotionAlignments); bool DoChemicalAlignmentsMatch(TArray<int32> Alignments, TArray<int32> PotionAlignments);

View File

@@ -1,92 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "SeedCarousel.h"
#include "ItemDatabase.h"
#include "Kismet/GameplayStatics.h"
#include "MyCharacter.h"
#include "ProjectEleri/System/MainBlueprintFunctionLibrary.h"
#include "ProjectEleri/System/EleriGameplayTags.h"
FSeedSaveData::FSeedSaveData(): SeedGrowTime(0), ProduceGrowTime(0), SeedAge(0), ProduceDaysSinceLastBloom(0),
SeedWateredTimes(0),
bBloomed(false),
bWatered(false),
bPlanted(false), bDied(false),
bPlayerInside(false),
bInfoDialogueOpen(false)
{
}
FSeedSaveData::FSeedSaveData(const ASeedCarousel* SeedActorRef)
{
if(!SeedActorRef) return;
ObjectTransform = SeedActorRef->GetTransform();
SeedGrowTime = SeedActorRef->SeedGrowTime;
ProduceGrowTime = SeedActorRef->ProduceGrowTime;
SeedAge = SeedActorRef->SeedAge;
ProduceDaysSinceLastBloom = SeedActorRef->ProduceDaysSinceLastBloom;
SeedWateredTimes = SeedActorRef->SeedWateredTimes;
bBloomed = SeedActorRef->bBloomed;
bWatered = SeedActorRef->bWatered;
bPlanted = SeedActorRef->bPlanted;
bDied = SeedActorRef->bDied;
bPlayerInside = SeedActorRef->bPlayerInside;
bInfoDialogueOpen = SeedActorRef->bInfoDialogueOpen;
bHighQuality = SeedActorRef->bHighQuality;
SeedAssetId = SeedActorRef->SeedAssetData->GetPrimaryAssetId();
}
void ASeedCarousel::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ASeedCarousel::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ASeedCarousel::Water()
{
OnWatered.Broadcast();
}
void ASeedCarousel::LoadDataFromSaveStruct(FSeedSaveData& SaveStruct, UItemDatabase* ItemDatabase)
{
SeedGrowTime = SaveStruct.SeedGrowTime;
ProduceGrowTime = SaveStruct.ProduceGrowTime;
SeedAge = SaveStruct.SeedAge;
ProduceDaysSinceLastBloom = SaveStruct.ProduceDaysSinceLastBloom;
SeedWateredTimes = SaveStruct.SeedWateredTimes;
bBloomed = SaveStruct.bBloomed;
bWatered = SaveStruct.bWatered;
bPlanted = SaveStruct.bPlanted;
bDied = SaveStruct.bDied;
bHighQuality = SaveStruct.bHighQuality;
bPlayerInside = false;
bInfoDialogueOpen = false;
SeedAssetData = ItemDatabase->GetDataAssetFromId(SaveStruct.SeedAssetId);
}
void ASeedCarousel::SetSeedData(UItemDataAsset* InSeedAssetData)
{
if (!InSeedAssetData) return;
SeedAssetData = InSeedAssetData;
DataAssetId = InSeedAssetData->GetPrimaryAssetId();
}
bool ASeedCarousel::CanPlace()
{
/*if (UGameplayStatsComponent* GSC = UMainBlueprintFunctionLibrary::GetGameplayStatsComponentFromPlayer(this))
{
return GSC->GetGameplayStatValue(Stats::Energy) > 0;
}*/
return false;
}

View File

@@ -1,137 +0,0 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "DataAssets/ItemDataAsset.h"
#include "GameFramework/Actor.h"
#include "../GameObjects/RemovableStaticMeshActor.h"
#include "SeedCarousel.generated.h"
class UItemDatabase;
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWatered);
USTRUCT(BlueprintType)
struct FSeedSaveData {
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform ObjectTransform;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedGrowTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProduceGrowTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedAge;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProduceDaysSinceLastBloom;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedWateredTimes;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bBloomed;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bWatered;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPlanted;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDied;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPlayerInside;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfoDialogueOpen;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FPrimaryAssetId SeedAssetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bHighQuality;
FSeedSaveData();
FSeedSaveData(const ASeedCarousel* SeedActorRef);
};
UCLASS()
class PROJECTELERI_API ASeedCarousel : public ARemovableStaticMeshActor
{
GENERATED_BODY()
virtual void BeginPlay() override;
public:
UPROPERTY(BlueprintAssignable)
FOnWatered OnWatered;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedGrowTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProduceGrowTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedAge;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProduceDaysSinceLastBloom;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 SeedWateredTimes;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bBloomed;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bWatered;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPlanted;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDied;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPlayerInside;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfoDialogueOpen;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UItemDataAsset* SeedAssetData;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bHighQuality;
protected:
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void OnUpdatePlantEvent();
UFUNCTION(BlueprintCallable)
void Water();
void LoadDataFromSaveStruct(FSeedSaveData& SaveStruct, UItemDatabase* ItemDatabase);
UFUNCTION(BlueprintCallable)
void SetSeedData(UItemDataAsset* InSeedAssetData);
virtual bool CanPlace() override;
};

View File

@@ -30,7 +30,6 @@ void AAlchemyManager::CalculateRewardStack() {
if (!PotionOutput) return; if (!PotionOutput) return;
FinalRewardStack.ItemId = PotionOutput->GetPrimaryAssetId(); FinalRewardStack.ItemId = PotionOutput->GetPrimaryAssetId();
FinalRewardStack.Seed = false;
FinalRewardStack.HQ = PotionMinigameHqScore >= 99.f; FinalRewardStack.HQ = PotionMinigameHqScore >= 99.f;
FinalRewardStack.Stack = PotionMinigameStackNum; FinalRewardStack.Stack = PotionMinigameStackNum;
} }

View File

@@ -660,7 +660,7 @@ void AEleriPlayerController::OnPlaceObjectAction(const FInputActionValue &Value)
if (!MoveActorsComp->PlaceableActionUsed(ERemovalAction::PLACE)) if (!MoveActorsComp->PlaceableActionUsed(ERemovalAction::PLACE))
return; return;
int32 StackCount = Inventory->GetStackForItem(DataAsset->GetPrimaryAssetId(), false, false); int32 StackCount = Inventory->GetStackForItem(DataAsset->GetPrimaryAssetId(), false);
if (StackCount > 0) if (StackCount > 0)
{ {
ensure(ItemDatabase); ensure(ItemDatabase);
@@ -1267,15 +1267,15 @@ void AEleriPlayerController::TryPlantSelectedSeed()
// The seed is paid for before it is planted, so a slot can never hold a seed the inventory never had // The seed is paid for before it is planted, so a slot can never hold a seed the inventory never had
const FPrimaryAssetId SeedAssetId = SeedToPlant->GetPrimaryAssetId(); const FPrimaryAssetId SeedAssetId = SeedToPlant->GetPrimaryAssetId();
if (Inventory->HasItem(SeedAssetId, true, bSeedToPlantHighQuality) <= 0) if (Inventory->HasItem(SeedAssetId, true) <= 0)
return; return;
if (!SeedBed->PlantSeedInSlot(SlotCoordinate, SeedToPlant, bSeedToPlantHighQuality)) if (!SeedBed->PlantSeedInSlot(SlotCoordinate, SeedToPlant, bSeedToPlantHighQuality))
return; return;
Inventory->RemoveItemFromInventory(SeedAssetId, 1, true, bSeedToPlantHighQuality); Inventory->RemoveItemFromInventory(SeedAssetId, 1, true);
if (Inventory->HasItem(SeedAssetId, true, bSeedToPlantHighQuality) == INDEX_NONE) if (Inventory->HasItem(SeedAssetId, true) == INDEX_NONE)
{ {
ClearSeedToPlant(); ClearSeedToPlant();
} }

View File

@@ -36,12 +36,11 @@ void UInventoryComponent::BeginPlay()
InitializeInventory(); InitializeInventory();
} }
int32 UInventoryComponent::HasItem(FPrimaryAssetId ItemId, bool Seed, bool HQ) int32 UInventoryComponent::HasItem(FPrimaryAssetId ItemId, bool HQ)
{ {
for (int32 i = 0; i < ItemList.Num(); i++) for (int32 i = 0; i < ItemList.Num(); i++)
{ {
if (ItemId == ItemList[i].ItemId && if (ItemId == ItemList[i].ItemId &&
Seed == ItemList[i].Seed &&
HQ == ItemList[i].HQ) HQ == ItemList[i].HQ)
{ {
return i; return i;
@@ -50,11 +49,11 @@ int32 UInventoryComponent::HasItem(FPrimaryAssetId ItemId, bool Seed, bool HQ)
return -1; return -1;
} }
int32 UInventoryComponent::ItemExists(FPrimaryAssetId ItemToCheck, bool IsSeed, bool IsHq) int32 UInventoryComponent::ItemExists(FPrimaryAssetId ItemToCheck, bool IsHq)
{ {
for (int32 i = 0; i < ItemList.Num(); i++) for (int32 i = 0; i < ItemList.Num(); i++)
{ {
if (ItemList[i].ItemId == ItemToCheck && ItemList[i].Seed == IsSeed && ItemList[i].HQ == IsHq) if (ItemList[i].ItemId == ItemToCheck && ItemList[i].HQ == IsHq)
{ {
return i; return i;
} }
@@ -62,16 +61,15 @@ int32 UInventoryComponent::ItemExists(FPrimaryAssetId ItemToCheck, bool IsSeed,
return -1; return -1;
} }
bool UInventoryComponent::AddItemToInventory(FPrimaryAssetId ItemToAdd, int32 StackSize, bool Seed, bool HighQuality) bool UInventoryComponent::AddItemToInventory(FPrimaryAssetId ItemToAdd, int32 StackSize, bool HighQuality)
{ {
if (!ItemToAdd.IsValid()) return false; if (!ItemToAdd.IsValid()) return false;
int32 itemIndex = ItemExists(ItemToAdd, Seed, HighQuality); int32 itemIndex = ItemExists(ItemToAdd, HighQuality);
if (itemIndex == -1) if (itemIndex == -1)
{ {
FItemStack ItemStack; FItemStack ItemStack;
ItemStack.ItemId = ItemToAdd; ItemStack.ItemId = ItemToAdd;
ItemStack.Seed = Seed;
ItemStack.Stack = StackSize; ItemStack.Stack = StackSize;
ItemStack.HQ = HighQuality; ItemStack.HQ = HighQuality;
ItemList.Add(ItemStack); ItemList.Add(ItemStack);
@@ -85,11 +83,11 @@ bool UInventoryComponent::AddItemToInventory(FPrimaryAssetId ItemToAdd, int32 St
return true; return true;
} }
bool UInventoryComponent::RemoveItemFromInventory(FPrimaryAssetId ItemId, int32 Amount, bool Seed, bool HighQuality) bool UInventoryComponent::RemoveItemFromInventory(FPrimaryAssetId ItemId, int32 Amount, bool HighQuality)
{ {
if (ItemId.IsValid()) if (ItemId.IsValid())
{ {
int32 ItemIndex = ItemExists(ItemId, Seed, HighQuality); int32 ItemIndex = ItemExists(ItemId, HighQuality);
if (ItemIndex == -1) if (ItemIndex == -1)
{ {
return false; return false;
@@ -120,7 +118,7 @@ void UInventoryComponent::InitializeInventory()
{ {
if (IsValid(ItemData.Item)) if (IsValid(ItemData.Item))
{ {
AddItemToInventory(ItemData.Item->GetPrimaryAssetId(), ItemData.StackSize, ItemData.Seed, ItemData.HQ); AddItemToInventory(ItemData.Item->GetPrimaryAssetId(), ItemData.StackSize, ItemData.HQ);
} }
} }
} }
@@ -133,17 +131,11 @@ void UInventoryComponent::EmptyInventory()
OnInventoryUpdated.Broadcast(); OnInventoryUpdated.Broadcast();
} }
int32 UInventoryComponent::GetStackForItem(FPrimaryAssetId ItemId, bool HQ)
int UInventoryComponent::CheckItemCost(FPrimaryAssetId ItemId, bool Seed, bool HQ)
{
return 0;
}
int32 UInventoryComponent::GetStackForItem(FPrimaryAssetId ItemId, bool Seed, bool HQ)
{ {
for (int32 i = 0; i < ItemList.Num(); i++) for (int32 i = 0; i < ItemList.Num(); i++)
{ {
if (ItemList[i].ItemId == ItemId && ItemList[i].HQ == HQ && ItemList[i].Seed == Seed) if (ItemList[i].ItemId == ItemId && ItemList[i].HQ == HQ)
return ItemList[i].Stack; return ItemList[i].Stack;
} }
return 0; return 0;
@@ -175,7 +167,7 @@ void UInventoryComponent::LoadFromSave(const FInventorySaveData& LoadData)
EmptyInventory(); EmptyInventory();
for (const FItemStack& SaveDataEntry : LoadData.ItemStacks) for (const FItemStack& SaveDataEntry : LoadData.ItemStacks)
{ {
AddItemToInventory(SaveDataEntry.ItemId, SaveDataEntry.Stack, SaveDataEntry.Seed, SaveDataEntry.HQ); AddItemToInventory(SaveDataEntry.ItemId, SaveDataEntry.Stack, SaveDataEntry.HQ);
} }
} }

View File

@@ -1,7 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "TimeOfDayManager.h" #include "TimeOfDayManager.h"
#include "../Items/SeedCarousel.h"
#include "Components/DirectionalLightComponent.h" #include "Components/DirectionalLightComponent.h"
#include "Components/ExponentialHeightFogComponent.h" #include "Components/ExponentialHeightFogComponent.h"
#include "Components/SkyAtmosphereComponent.h" #include "Components/SkyAtmosphereComponent.h"

View File

@@ -24,9 +24,6 @@ class PROJECTELERI_API AEleriGameState : public AGameStateBase
public: public:
static AEleriGameState* Get(const UObject* WorldContext); static AEleriGameState* Get(const UObject* WorldContext);
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSubclassOf<ASeedCarousel> SeedCarouselBpClass;
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Game State", meta=(WorldContext="WorldContext", GameplayTagFilter = "Characters")) UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Game State", meta=(WorldContext="WorldContext", GameplayTagFilter = "Characters"))
static int32 GetFriendshipAmount(const UObject* WorldContext, FGameplayTag NpcTag); static int32 GetFriendshipAmount(const UObject* WorldContext, FGameplayTag NpcTag);
UFUNCTION(BlueprintCallable, Category = "Game State", meta = (WorldContext = "WorldContext", GameplayTagFilter = "Characters")) UFUNCTION(BlueprintCallable, Category = "Game State", meta = (WorldContext = "WorldContext", GameplayTagFilter = "Characters"))

View File

@@ -29,9 +29,6 @@ struct FDefaultItemStack {
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
int32 StackSize = 1; int32 StackSize = 1;
UPROPERTY(EditAnywhere)
bool Seed;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool HQ = false; bool HQ = false;
}; };
@@ -46,9 +43,6 @@ struct FItemStack {
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Stack = 1; int32 Stack = 1;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool Seed = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool HQ = false; bool HQ = false;
}; };
@@ -81,7 +75,7 @@ class PROJECTELERI_API UInventoryComponent : public UActorComponent
private: private:
int32 CheckIfItemExists(class UItem* item); int32 CheckIfItemExists(class UItem* item);
int32 ItemExists(FPrimaryAssetId ItemToCheck, bool IsSeed, bool IsHq); int32 ItemExists(FPrimaryAssetId ItemToCheck, bool IsHq);
UPROPERTY() UPROPERTY()
UItemDatabase* ItemDatabase; UItemDatabase* ItemDatabase;
@@ -123,10 +117,10 @@ public:
public: public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool AddItemToInventory(FPrimaryAssetId ItemToAdd, int32 StackSize = 1, bool Seed = false, bool HighQuality = false); bool AddItemToInventory(FPrimaryAssetId ItemToAdd, int32 StackSize = 1, bool HighQuality = false);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
bool RemoveItemFromInventory(FPrimaryAssetId ItemId, int32 Amount = 1, bool Seed = false, bool HighQuality = false); bool RemoveItemFromInventory(FPrimaryAssetId ItemId, int32 Amount = 1, bool HighQuality = false);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void InitializeInventory(); void InitializeInventory();
@@ -134,14 +128,11 @@ public:
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void EmptyInventory(); void EmptyInventory();
UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction)) UFUNCTION(BlueprintCallable)
int CheckItemCost(FPrimaryAssetId ItemId, bool Seed = false, bool HQ = false); int32 GetStackForItem(FPrimaryAssetId ItemId, bool HQ = false);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
int32 GetStackForItem(FPrimaryAssetId ItemId, bool Seed = false, bool HQ = false); int32 HasItem(FPrimaryAssetId ItemToCheck, bool HQ = false);
UFUNCTION(BlueprintCallable)
int32 HasItem(FPrimaryAssetId ItemToCheck, bool Seed = false, bool HQ = false);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
TArray<FPrimaryAssetId> GetItemAssetIds(); TArray<FPrimaryAssetId> GetItemAssetIds();