More fixes for removal mode and cleanup of some stuff
This commit is contained in:
@@ -426,18 +426,6 @@ bool UMoveActorsComponent::PlaceableActionUsed(ERemovalAction ActionUsed)
|
||||
case ERemovalAction::PLACE:
|
||||
if (PlayerController && MovingActor->IsPlaceable())
|
||||
{
|
||||
FPrimaryAssetId ItemId = MovingActor->ItemStack.ItemId;
|
||||
if (!ItemId.IsValid())
|
||||
{
|
||||
ItemId = MovingActor->DataAssetId;
|
||||
}
|
||||
if (ItemId.IsValid())
|
||||
{
|
||||
if (UInventoryComponent* Inventory = UMainBlueprintFunctionLibrary::GetPlayerInventory(GetWorld()))
|
||||
{
|
||||
Inventory->RemoveItemFromInventory(ItemId, 1, false, false);
|
||||
}
|
||||
}
|
||||
PlaceObjectForPlacing();
|
||||
return true;
|
||||
}
|
||||
@@ -445,26 +433,16 @@ bool UMoveActorsComponent::PlaceableActionUsed(ERemovalAction ActionUsed)
|
||||
|
||||
case ERemovalAction::REMOVE:
|
||||
{
|
||||
// A world object is returned to the player's inventory before it is removed.
|
||||
if (MovingActor->DataAssetId.IsValid() && !MovingActor->bFromInventory)
|
||||
if (UObjectPersistenceSubsystem* ObjectPersistenceSubsystem = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<UObjectPersistenceSubsystem>())
|
||||
{
|
||||
if (UInventoryComponent* Inventory = UMainBlueprintFunctionLibrary::GetPlayerInventory(GetWorld()))
|
||||
{
|
||||
Inventory->AddItemToInventory(MovingActor->DataAssetId, 1, false, false);
|
||||
}
|
||||
ObjectPersistenceSubsystem->RemoveActorFromLevel(MovingActor);
|
||||
}
|
||||
|
||||
if (UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(GetWorld()))
|
||||
|
||||
if (UItemDatabase* ItemDatabase = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<UItemDatabase>())
|
||||
{
|
||||
if (UObjectPersistenceSubsystem* ObjectPersistenceSubsystem = GameInstance->GetSubsystem<UObjectPersistenceSubsystem>())
|
||||
{
|
||||
ObjectPersistenceSubsystem->RemoveActorFromLevel(MovingActor);
|
||||
return true;
|
||||
}
|
||||
ItemDatabase->RemoveDecorationItem(MovingActor);
|
||||
}
|
||||
|
||||
// Fallback if the persistence subsystem is unavailable.
|
||||
MovingActor->Destroy();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -473,9 +451,10 @@ bool UMoveActorsComponent::PlaceableActionUsed(ERemovalAction ActionUsed)
|
||||
// Cancel the current placement/move without committing it.
|
||||
if (MovingActor->bFromInventory)
|
||||
{
|
||||
// A preview spawned from the inventory: return the item and destroy the preview.
|
||||
MovingActor->ReturnToInventory();
|
||||
MovingActor->Destroy();
|
||||
if (UItemDatabase* ItemDatabase = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<UItemDatabase>())
|
||||
{
|
||||
ItemDatabase->RemoveDecorationItem(MovingActor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -519,7 +498,6 @@ bool UMoveActorsComponent::PlaceObjectForPlacing()
|
||||
}
|
||||
MovingActor->Place();
|
||||
|
||||
RemovalModePlacingStack--;
|
||||
return RemoveObjectForPlacing();
|
||||
}
|
||||
|
||||
@@ -527,22 +505,15 @@ bool UMoveActorsComponent::RemoveObjectForPlacing()
|
||||
{
|
||||
if (!PlayerController) return false;
|
||||
|
||||
// Get the Enhanced Input Local Player Subsystem from the Local Player related to our Player Controller.
|
||||
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
|
||||
{
|
||||
if (RemovalModePlacingStack <= 0)
|
||||
{
|
||||
Subsystem->RemoveMappingContext(PlayerController->RemoveModeContext);
|
||||
}
|
||||
}
|
||||
|
||||
MovingActor = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void UMoveActorsComponent::StartObjectRemoval(bool bStart, int32 Stack)
|
||||
void UMoveActorsComponent::StartObjectRemoval(bool bStart)
|
||||
{
|
||||
if (bStart && bRemovalMode) return;
|
||||
|
||||
if (!PlayerCharacter) return;
|
||||
|
||||
if (!bStart)
|
||||
@@ -551,7 +522,6 @@ void UMoveActorsComponent::StartObjectRemoval(bool bStart, int32 Stack)
|
||||
}
|
||||
PlayerCharacter->CurrentlyDoing = bStart ? ECurrentlyDoing::OBJECT_PLACING : ECurrentlyDoing::NOTHING;
|
||||
|
||||
RemovalModePlacingStack = Stack;
|
||||
if (bStart && !bRemovalModePossible) return;
|
||||
|
||||
if (!bStart)
|
||||
@@ -566,9 +536,6 @@ void UMoveActorsComponent::StartObjectRemoval(bool bStart, int32 Stack)
|
||||
bRemovalMode = bStart;
|
||||
OnRemovalModeToggled.Broadcast(bRemovalMode);
|
||||
|
||||
PlayerCharacter->SetNewCameraPitches(
|
||||
bStart ? PlayerCharacter->CameraPitchMin - 50 : PlayerCharacter->CameraPitchMin,
|
||||
bStart ? PlayerCharacter->CameraPitchMax + 5 : PlayerCharacter->CameraPitchMax);
|
||||
|
||||
if (PlayerController && PlayerController->GetMainGameWidget())
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "ProjectEleri/GameObjects/RemovableStaticMeshActor.h"
|
||||
|
||||
#include "MoveActorsComponent.generated.h"
|
||||
|
||||
@@ -53,9 +54,6 @@ public:
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
ARemovableStaticMeshActor* MovingActor;
|
||||
|
||||
UPROPERTY()
|
||||
int32 RemovalModePlacingStack;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<TSubclassOf<AActor>> ActorsToIgnore;
|
||||
@@ -135,9 +133,9 @@ protected:
|
||||
ARemovableStaticMeshActor* HighligtedMovingActor;
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
bool bRemovalModePossible;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
bool bRemovalMode;
|
||||
UPROPERTY()
|
||||
bool bGridMovementActive;
|
||||
@@ -188,6 +186,8 @@ public:
|
||||
bool IsRemovingModePossible() const { return bRemovalModePossible; }
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
bool IsRemovingMode() const { return bRemovalMode; }
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
bool IsPlacingObject() const { return IsValid(MovingActor); }
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
@@ -199,7 +199,7 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool RemoveObjectForPlacing();
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void StartObjectRemoval(bool bStart = true, int32 Stack = 9999);
|
||||
void StartObjectRemoval(bool bStart = true);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
bool HighlightRemovableObject(ARemovableStaticMeshActor* Placable);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
|
||||
@@ -98,10 +98,17 @@ bool ARemovableStaticMeshActor::IsInteractable_Implementation() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void ARemovableStaticMeshActor::BindToItem(UInventoryComponent* InInventory, FItemStack InItemStack)
|
||||
void ARemovableStaticMeshActor::Initialize(UStaticMesh* StaticMesh, UItemDataAsset* InItemDataAsset)
|
||||
{
|
||||
GetStaticMeshComponent()->SetStaticMesh(StaticMesh);
|
||||
GetStaticMeshComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
MeshMaterials = GetStaticMeshComponent()->GetMaterials();
|
||||
ItemDataAsset = InItemDataAsset;
|
||||
DataAssetId = ItemDataAsset->GetPrimaryAssetId();
|
||||
}
|
||||
|
||||
void ARemovableStaticMeshActor::BindToItem(UInventoryComponent* InInventory)
|
||||
{
|
||||
InventoryRef = InInventory;
|
||||
ItemStack = InItemStack;
|
||||
bFromInventory = true;
|
||||
}
|
||||
|
||||
@@ -126,8 +133,6 @@ void ARemovableStaticMeshActor::Place(bool ReturnToOldLocation, bool bForce)
|
||||
if (bPlaced)
|
||||
{
|
||||
//Reset this because we've placed the item in the world
|
||||
InventoryRef = nullptr;
|
||||
ItemStack = FItemStack();
|
||||
bFromInventory = false;
|
||||
|
||||
if (ReturnToOldLocation)
|
||||
@@ -147,6 +152,7 @@ void ARemovableStaticMeshActor::Place(bool ReturnToOldLocation, bool bForce)
|
||||
}
|
||||
}
|
||||
CurrentMemorizedTransform = GetActorTransform();
|
||||
GetStaticMeshComponent()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
|
||||
OnPlaced.Broadcast();
|
||||
}
|
||||
}
|
||||
@@ -192,10 +198,3 @@ void ARemovableStaticMeshActor::ReportGridFootprint()
|
||||
CellsX * Pitch - Size.X, CellsY * Pitch - Size.Y, FillScale);
|
||||
}
|
||||
|
||||
void ARemovableStaticMeshActor::ReturnToInventory()
|
||||
{
|
||||
if (InventoryRef)
|
||||
{
|
||||
InventoryRef->AddItemToInventory(ItemStack.ItemId, 1, false, ItemStack.HQ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,12 @@ public:
|
||||
|
||||
UPROPERTY()
|
||||
FTransform CurrentMemorizedTransform;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UInventoryComponent* InventoryRef;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
FItemStack ItemStack;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
AActor* PlayerRef;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
UItemDataAsset* ItemDataAsset;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bPlaced;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
@@ -115,8 +113,6 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
FORCEINLINE bool IsPlaceable() const { return bPlaceable; }
|
||||
UFUNCTION(BlueprintCallable, BLueprintPure)
|
||||
FORCEINLINE bool FromInventory() const { return InventoryRef != nullptr; }
|
||||
|
||||
UPROPERTY(BlueprintAssignable, EditAnywhere, BLueprintReadWrite)
|
||||
FOnPlaced OnPlaced;
|
||||
@@ -125,11 +121,13 @@ public:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||
UInteractionWidgetComponent* WidgetComponent;
|
||||
|
||||
void Initialize(UStaticMesh* StaticMesh, UItemDataAsset* InItemDataAsset);
|
||||
|
||||
//Used when placing stuff from inventory so we can return it to inventory
|
||||
//if we cancel placing item
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void BindToItem(UInventoryComponent* InInventory, FItemStack InItemStack);
|
||||
void BindToItem(UInventoryComponent* InInventory);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void PickUp();
|
||||
@@ -140,9 +138,6 @@ public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void Rotate(bool bPositive);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ReturnToInventory();
|
||||
|
||||
virtual bool CanPlace() { return true; }
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
|
||||
|
||||
@@ -65,7 +65,7 @@ class ARemovableStaticMeshActor;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType)
|
||||
UCLASS(BlueprintType, PrioritizeCategories = ("Default", "Info", "Placeable", "Craftable", "Property Map", "Seed"))
|
||||
class PROJECTELERI_API UItemDataAsset : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@@ -120,10 +120,16 @@ public:
|
||||
bool Stackable = true;
|
||||
|
||||
/** Mesh that the item / potion have, ignored for seeds */
|
||||
UPROPERTY()
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
|
||||
TSoftObjectPtr<UStaticMesh> ItemMesh;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides, MetaClass="/Script/ProjectEleri.RemovableStaticMeshActor"))
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
|
||||
int32 GridScale = 1;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides))
|
||||
FVector BoxExtentOverride;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Placeable", meta=(EditCondition="ItemCategory==Category::Decoration", EditConditionHides, MetaClass="/Script/ProjectEleri.RemovableStaticMeshActor"))
|
||||
FSoftClassPath DecorationActorClassPath;
|
||||
|
||||
|
||||
@@ -132,9 +138,6 @@ public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
|
||||
int32 BaseCost;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Info", AssetRegistrySearchable, meta = (AssetBundles = "Inventory, Book"))
|
||||
TSoftObjectPtr<UTexture2D> PropertyMapTexture;
|
||||
|
||||
/*--------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/** What part of the world grants faster growth and higher chance to harvest an HQ ingredient */
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
#include "Engine/AssetManager.h"
|
||||
#include "BookOfAlchemyManager.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "ProjectEleri/Components/MoveActorsComponent.h"
|
||||
#include "ProjectEleri/Settings/EleriGameSettings.h"
|
||||
#include "ProjectEleri/System/MainBlueprintFunctionLibrary.h"
|
||||
|
||||
UWorld* UItemDatabase::GetWorld() const {
|
||||
if (const UGameInstance* GameInstance = GetGameInstance()) {
|
||||
@@ -52,6 +55,9 @@ void UItemDatabase::Initialize(FSubsystemCollectionBase& Collection) {
|
||||
else {
|
||||
UAssetManager::CallOrRegister_OnCompletedInitialScan(FStopRenderingThreadDelegate::CreateLambda(LoadDataLambda));
|
||||
}
|
||||
|
||||
RemovableStaticMeshClass = GetDefault<UEleriGameSettings>()->RemovableStaticMeshClass;
|
||||
ItemSeedCarouselClass = GetDefault<UEleriGameSettings>()->ItemSeedCarouselClass;
|
||||
}
|
||||
|
||||
|
||||
@@ -427,6 +433,53 @@ Element UItemDatabase::GetStrongestElement(const TArray<UItemDataAsset*>& Potion
|
||||
return (Element)StrongestIndex;
|
||||
}
|
||||
|
||||
void UItemDatabase::SpawnDecorationItem(UItemDataAsset* ItemAsset)
|
||||
{
|
||||
if (!ItemAsset || ItemAsset->ItemMesh.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemAsset->ItemMesh.LoadAsync(FLoadSoftObjectPathAsyncDelegate::CreateUObject(this, &UItemDatabase::OnDecorationItemLoaded, ItemAsset));
|
||||
}
|
||||
|
||||
void UItemDatabase::RemoveDecorationItem(ARemovableStaticMeshActor* DecorationItem)
|
||||
{
|
||||
if (DecorationItem->ItemDataAsset && DecorationItem->bFromInventory)
|
||||
{
|
||||
UInventoryComponent* InventoryComponent = UMainBlueprintFunctionLibrary::GetPlayerInventory(GetWorld());
|
||||
InventoryComponent->AddItemToInventory(DecorationItem->ItemDataAsset->GetPrimaryAssetId(), 1);
|
||||
}
|
||||
|
||||
DecorationItem->Destroy();
|
||||
}
|
||||
|
||||
void UItemDatabase::OnDecorationItemLoaded(const FSoftObjectPath& Path, UObject* Object, UItemDataAsset* ItemAsset)
|
||||
{
|
||||
UStaticMesh* StaticMesh = Cast<UStaticMesh>(Object);
|
||||
if (!StaticMesh || !ItemAsset) return;
|
||||
|
||||
ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
|
||||
const FVector Location = PlayerCharacter->GetActorLocation() + (PlayerCharacter->GetActorForwardVector() * 1000.f);
|
||||
FActorSpawnParameters SpawnParams;
|
||||
SpawnParams.Instigator = PlayerCharacter;
|
||||
SpawnParams.Owner = PlayerCharacter;
|
||||
ARemovableStaticMeshActor* SpawnedActor = GetWorld()->SpawnActor<ARemovableStaticMeshActor>(RemovableStaticMeshClass, Location, FRotator::ZeroRotator, SpawnParams);
|
||||
if (!SpawnedActor) return;
|
||||
SpawnedActor->SetMobility(EComponentMobility::Movable);
|
||||
SpawnedActor->Initialize(StaticMesh, ItemAsset);
|
||||
|
||||
UInventoryComponent* InventoryComponent = UMainBlueprintFunctionLibrary::GetPlayerInventory(GetWorld());
|
||||
SpawnedActor->BindToItem(InventoryComponent);
|
||||
InventoryComponent->RemoveItemFromInventory(ItemAsset->GetPrimaryAssetId(), 1);
|
||||
|
||||
UMoveActorsComponent* MoveActorsComponent = PlayerCharacter->GetComponentByClass<UMoveActorsComponent>();
|
||||
if (!MoveActorsComponent) return;
|
||||
|
||||
MoveActorsComponent->StartObjectRemoval(true);
|
||||
MoveActorsComponent->PickUpObjectForPlacing(SpawnedActor);
|
||||
}
|
||||
|
||||
void FArrayOfItemRefs::SortByName()
|
||||
{
|
||||
ItemArray.Sort();
|
||||
|
||||
@@ -58,67 +58,76 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Item Database")
|
||||
TSubclassOf<AActor> ItemSeedCarouselClass;
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Item Database")
|
||||
TSubclassOf<ARemovableStaticMeshActor> RemovableStaticMeshClass;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Database")
|
||||
TArray<FPrimaryAssetId> AllAssetIds;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Database")
|
||||
TArray<UItemDataAsset*> LoadedItems;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Item Database")
|
||||
TMap<Category, FArrayOfItemRefs> LoadedItemsByCategory;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Item Database")
|
||||
TArray<ASeedCarousel*> SeedsPlanted;
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
void WaterAllSeeds();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
bool DoChemicalAlignmentsMatch(TArray<int32> Alignments, TArray<int32> PotionAlignments);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
UItemDataAsset* GetPotionFromItems(TArray<UItemDataAsset*> Items, bool& Found);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
UItemDataAsset* GetPotionDataFromItems(TArray<UItemDataAsset*> Items);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
TArray<UItemDataAsset*> GetPotionsMatchingChemicalAlignment(UItemDataAsset* Ingredient);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
TArray<UItemDataAsset*> GetPotionsMatchingProperties(const TArray<UItemDataAsset*> &PotionList, TMap<ItemProperty, int32> PropertyList);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
UItemDataAsset* GetDataAssetFromId(FPrimaryAssetId AssetId);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
TArray<UItemDataAsset*> GetDataAssetsFromIds(TArray<FPrimaryAssetId> AssetIds);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
float CalculatePotionPurity(TMap<ItemProperty, int32> PropertyList, TArray<FPropertyStrength> MainProperties);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
int32 GetCrystalCostForPotion(UItemDataAsset* Potion);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
int32 GetCrystalCostForItems(TArray<UItemDataAsset*> Items);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
Element GetStrongestElement(const TArray<UItemDataAsset*>& PotionList);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Item Database")
|
||||
void SpawnDecorationItem(UItemDataAsset* ItemAsset);
|
||||
void RemoveDecorationItem(ARemovableStaticMeshActor* DecorationItem);
|
||||
|
||||
protected:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Item Database")
|
||||
TArray<FItemPriceData> ItemPriceDataList;
|
||||
|
||||
protected:
|
||||
void PrepareItemPriceData();
|
||||
|
||||
UFUNCTION()
|
||||
void OnDecorationItemLoaded(const FSoftObjectPath& Path, UObject* Object, UItemDataAsset* ItemAsset);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Item Database")
|
||||
int32 GetCurrentPriceForItem(FPrimaryAssetId ItemId);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Item Database")
|
||||
TArray<int32> GetPriceHistoryForItem(FPrimaryAssetId ItemId);
|
||||
};
|
||||
|
||||
26
Source/ProjectEleri/Items/SeedBedActor.cpp
Normal file
26
Source/ProjectEleri/Items/SeedBedActor.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "SeedBedActor.h"
|
||||
|
||||
|
||||
// Sets default values
|
||||
ASeedBedActor::ASeedBedActor()
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void ASeedBedActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void ASeedBedActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
}
|
||||
|
||||
25
Source/ProjectEleri/Items/SeedBedActor.h
Normal file
25
Source/ProjectEleri/Items/SeedBedActor.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "SeedBedActor.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class PROJECTELERI_API ASeedBedActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
ASeedBedActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
};
|
||||
@@ -570,7 +570,6 @@ void AEleriPlayerController::OnRemoveAction(const FInputActionValue &Value)
|
||||
{
|
||||
MoveActorsComp->PlaceableActionUsed(ERemovalAction::REMOVE);
|
||||
MoveActorsComp->MovingActor = nullptr;
|
||||
MoveActorsComp->RemovalModePlacingStack = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -617,43 +616,18 @@ void AEleriPlayerController::OnPlaceObjectAction(const FInputActionValue &Value)
|
||||
|
||||
if (MoveActorsComp->MovingActor)
|
||||
{
|
||||
UClass *ClassToLoad = MoveActorsComp->MovingActor->GetClass();
|
||||
FVector Location = MoveActorsComp->MovingActor->GetActorLocation();
|
||||
UInventoryComponent *Inventory = MoveActorsComp->MovingActor->InventoryRef;
|
||||
FItemStack Stack = MoveActorsComp->MovingActor->ItemStack;
|
||||
UItemDatabase* ItemDatabase = UGameplayStatics::GetGameInstance(GetWorld())->GetSubsystem<UItemDatabase>();
|
||||
UInventoryComponent *Inventory = UMainBlueprintFunctionLibrary::GetPlayerInventory(this);
|
||||
UItemDataAsset* DataAsset = MoveActorsComp->MovingActor->ItemDataAsset;
|
||||
|
||||
if (!MoveActorsComp->PlaceableActionUsed(ERemovalAction::PLACE))
|
||||
return;
|
||||
if (Inventory)
|
||||
|
||||
int32 StackCount = Inventory->GetStackForItem(DataAsset->GetPrimaryAssetId(), false, false);
|
||||
if (StackCount > 0)
|
||||
{
|
||||
Stack.Stack = Inventory->GetStackForItem(Stack.ItemId, Stack.Seed, Stack.HQ);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stack.Stack = 0;
|
||||
}
|
||||
|
||||
if (ClassToLoad && Stack.Stack > 0)
|
||||
{
|
||||
FTransform PlaceableTransform;
|
||||
PlaceableTransform.SetLocation(Location);
|
||||
if (ARemovableStaticMeshActor *SpawnedActor = UMainBlueprintFunctionLibrary::SpawnPlaceable(GetWorld(), ClassToLoad, PlaceableTransform, FVector::OneVector))
|
||||
{
|
||||
if (!MoveActorsComp || !MoveActorsComp->IsRemovingMode())
|
||||
{
|
||||
SpawnedActor->Destroy();
|
||||
MoveActorsComp->MovingActor = nullptr;
|
||||
return;
|
||||
}
|
||||
SpawnedActor->BindToItem(Inventory, Stack);
|
||||
SpawnedActor->PickUp();
|
||||
MoveActorsComp->MovingActor = SpawnedActor;
|
||||
}
|
||||
}
|
||||
|
||||
if (MoveActorsComp->RemovalModePlacingStack <= 0)
|
||||
{
|
||||
MoveActorsComp->StartObjectRemoval(false);
|
||||
ensure(ItemDatabase);
|
||||
ItemDatabase->SpawnDecorationItem(DataAsset);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "EleriGameSettings.generated.h"
|
||||
|
||||
class ARemovableStaticMeshActor;
|
||||
class UDataTable;
|
||||
class UNpcDataAsset;
|
||||
class UNpcScheduleAsset;
|
||||
@@ -28,6 +29,10 @@ public:
|
||||
|
||||
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Items", meta = (ForceInlineRow, Categories = "Items"))
|
||||
TMap<FGameplayTag, FPrimaryAssetId> SpecialItemsMap;
|
||||
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Items")
|
||||
TSubclassOf<ARemovableStaticMeshActor> RemovableStaticMeshClass;
|
||||
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Items")
|
||||
TSubclassOf<AActor> ItemSeedCarouselClass;
|
||||
|
||||
UPROPERTY(Config, EditAnywhere, BlueprintReadOnly, Category = "Camera")
|
||||
TMap<FGameplayTag, FVector> CameraZoomLevels;
|
||||
@@ -59,7 +64,6 @@ public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Items")
|
||||
static UItemDataAsset* GetSpecialItem(UObject* WorldContext, FGameplayTag Tag);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Ability System|Professions")
|
||||
static int32 GetProfessionLevelForExp(float Exp);
|
||||
|
||||
|
||||
@@ -29,10 +29,7 @@ void UObjectPersistenceSubsystem::RemoveActorFromLevel(AActor* ActorToRemove)
|
||||
if (ActorIndex != INDEX_NONE)
|
||||
{
|
||||
PlacedActors.RemoveAt(ActorIndex);
|
||||
|
||||
}
|
||||
|
||||
ActorToRemove->Destroy();
|
||||
}
|
||||
|
||||
void UObjectPersistenceSubsystem::PlacebleActorMoved(AActor* ActorMoved, bool bNewVisiblity)
|
||||
|
||||
Reference in New Issue
Block a user