添加船舱UI

This commit is contained in:
997146918 2025-10-20 19:44:19 +08:00
parent df2e59ac80
commit a8f426c2fc
17 changed files with 70 additions and 34 deletions

View File

@ -2,7 +2,7 @@
"BuildId": "37670630", "BuildId": "37670630",
"Modules": "Modules":
{ {
"ProjectFish": "UnrealEditor-ProjectFish.dll", "ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll" "ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
} }
} }

Binary file not shown.

View File

@ -2,6 +2,6 @@
"BuildId": "37670630", "BuildId": "37670630",
"Modules": "Modules":
{ {
"DeskMode": "UnrealEditor-DeskMode.dll" "DeskMode": "UnrealEditor-DeskMode-0001.dll"
} }
} }

View File

@ -6,20 +6,36 @@
#include "Engine/AssetManager.h" #include "Engine/AssetManager.h"
#include "Engine/StreamableManager.h" #include "Engine/StreamableManager.h"
void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId) // void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId)
{ // {
//加载形状资源 // //加载形状资源
TSharedPtr<FStreamableHandle> LoadHandle = GEngine->AssetManager->LoadPrimaryAsset(ContainerShapeId); // TSharedPtr<FStreamableHandle> LoadHandle = GEngine->AssetManager->LoadPrimaryAsset(ContainerShapeId);
if (LoadHandle.IsValid()) // if (LoadHandle.IsValid())
{ // {
// 等待加载完成,这会阻塞线程 // // 等待加载完成,这会阻塞线程
LoadHandle->WaitUntilComplete(); // LoadHandle->WaitUntilComplete();
//
// // 加载完成后,通过句柄获取资源
// UObject* LoadedObject = LoadHandle->GetLoadedAsset();
// if (LoadedObject)
// {
// ContainerShape = Cast<UShapeAsset>(LoadedObject);
// for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
// {
// for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
// {
// SlotInUsing.Add(FIntPoint(x, y), false);
// }
// }
// }
// LoadHandle->ReleaseHandle();
// }
//
// }
// 加载完成后,通过句柄获取资源 void UContainerInfo::InitContainerByShape(UShapeAsset* InContainerShape)
UObject* LoadedObject = LoadHandle->GetLoadedAsset();
if (LoadedObject)
{ {
ContainerShape = Cast<UShapeAsset>(LoadedObject); ContainerShape = InContainerShape;
for (int x = 0; x < ContainerShape->GetShapeWidth(); x++) for (int x = 0; x < ContainerShape->GetShapeWidth(); x++)
{ {
for (int y = 0; y < ContainerShape->GetShapeHeight(); y++) for (int y = 0; y < ContainerShape->GetShapeHeight(); y++)
@ -28,10 +44,6 @@ void UContainerInfo::InitContainer(FPrimaryAssetId ContainerShapeId)
} }
} }
} }
LoadHandle->ReleaseHandle();
}
}
bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position) bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
{ {
@ -39,11 +51,12 @@ bool UContainerInfo::AddContainerItem(FContainerItem Item, FIntPoint Position)
{ {
return false; return false;
} }
if (!IsItemOverlapOtherItem(Item, Position)) if (IsItemOverlapOtherItem(Item, Position))
{ {
return false; return false;
} }
Items.Add(Position, Item);
//设置容器指定位置的占用状态 //设置容器指定位置的占用状态
for (int x = 0; x < Item.GetItemWIdth(); x++) for (int x = 0; x < Item.GetItemWIdth(); x++)
{ {

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "ProjectFish/DataAsset/FishingRewardDataAsset.h"
#include "ProjectFish/DataAsset/ShapeAsset.h" #include "ProjectFish/DataAsset/ShapeAsset.h"
#include "UObject/Object.h" #include "UObject/Object.h"
#include "ContainerInfo.generated.h" #include "ContainerInfo.generated.h"
@ -27,19 +28,19 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
EItemDegreeType DegreeType; EItemDegreeType DegreeType;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
UShapeAsset* ItemShape; UFishingRewardDataAsset* RewardItem;
//旋转后的水平宽度 //旋转后的水平宽度
int32 GetItemWIdth() int32 GetItemWIdth()
{ {
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeHeight() return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeHeight()
: ItemShape->GetShapeWidth(); : RewardItem->RewardShape->GetShapeWidth();
} }
//旋转后的垂直高度 //旋转后的垂直高度
int32 GetItemHeight() int32 GetItemHeight()
{ {
return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? ItemShape->GetShapeWidth() return DegreeType == EItemDegreeType::Ninety || DegreeType == EItemDegreeType::TwentySeven? RewardItem->RewardShape->GetShapeWidth()
: ItemShape->GetShapeHeight(); : RewardItem->RewardShape->GetShapeHeight();
} }
bool IsSlotUsing(FIntPoint Position) bool IsSlotUsing(FIntPoint Position)
@ -70,7 +71,7 @@ public:
break; break;
} }
return ItemShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y); return RewardItem->RewardShape->IsSlotActive(BeforeRotationPos.X, BeforeRotationPos.Y);
} }
}; };
@ -79,13 +80,18 @@ public:
/** /**
* *
*/ */
UCLASS() UCLASS(BlueprintType)
class PROJECTFISH_API UContainerInfo : public UObject class PROJECTFISH_API UContainerInfo : public UObject
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
void InitContainer(FPrimaryAssetId ContainerShapeId); // UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
// void InitContainer(FPrimaryAssetId ContainerShapeId);
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
void InitContainerByShape(UShapeAsset* InContainerShape);
UFUNCTION(BlueprintPure) UFUNCTION(BlueprintPure)
bool AddContainerItem(FContainerItem Item, FIntPoint Position); bool AddContainerItem(FContainerItem Item, FIntPoint Position);
@ -97,7 +103,7 @@ private:
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
TMap<int32, FContainerItem> Items; TMap<FIntPoint, FContainerItem> Items;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
UShapeAsset* ContainerShape; UShapeAsset* ContainerShape;

View File

@ -4,6 +4,7 @@
#include "FishFunctionLibrary.h" #include "FishFunctionLibrary.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "ProjectFish/Data/ContainerInfo.h"
void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs) void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName, TMap<FString, FString> OptionsPaairs)
{ {
@ -14,3 +15,13 @@ void UFishFunctionLibrary::OpenLevelWithOptions(const UObject* WorldContextObjec
} }
UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr); UGameplayStatics::OpenLevel(WorldContextObject, LevelName, true,OptionStr);
} }
int32 UFishFunctionLibrary::GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem)
{
return ContainerItem.GetItemWIdth();
}
int32 UFishFunctionLibrary::GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem)
{
return ContainerItem.GetItemWIdth();
}

View File

@ -17,4 +17,10 @@ class PROJECTFISH_API UFishFunctionLibrary : public UBlueprintFunctionLibrary
public: public:
UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject")) UFUNCTION(BlueprintCallable, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs); static void OpenLevelWithOptions(const UObject* WorldContextObject, FName LevelName,TMap<FString, FString> OptionsPaairs);
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
static int32 GetContainerItemWiidth(const UObject* WorldContextObject, FContainerItem ContainerItem);
UFUNCTION(BlueprintPure, Category = "FishFunctionLibrary", meta=(WorldContext="WorldContextObject"))
static int32 GetContainerItemHeight(const UObject* WorldContextObject, FContainerItem ContainerItem);
}; };