diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll deleted file mode 100644 index 9a9dea3..0000000 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish-0001.dll and /dev/null differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll index 512a1fd..858b916 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFish.dll differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll deleted file mode 100644 index 33341e4..0000000 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor-0001.dll and /dev/null differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll index f05a11b..15d26c3 100644 Binary files a/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll and b/ProjectFish/Binaries/Win64/UnrealEditor-ProjectFishEditor.dll differ diff --git a/ProjectFish/Binaries/Win64/UnrealEditor.modules b/ProjectFish/Binaries/Win64/UnrealEditor.modules index fe900f8..22c08e6 100644 --- a/ProjectFish/Binaries/Win64/UnrealEditor.modules +++ b/ProjectFish/Binaries/Win64/UnrealEditor.modules @@ -2,7 +2,7 @@ "BuildId": "37670630", "Modules": { - "ProjectFish": "UnrealEditor-ProjectFish-0001.dll", - "ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll" + "ProjectFish": "UnrealEditor-ProjectFish.dll", + "ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll" } } \ No newline at end of file diff --git a/ProjectFish/Config/DefaultGame.ini b/ProjectFish/Config/DefaultGame.ini index 7d28fff..d51ea61 100644 --- a/ProjectFish/Config/DefaultGame.ini +++ b/ProjectFish/Config/DefaultGame.ini @@ -12,6 +12,7 @@ FixedCameraDistance=1500.0 +PrimaryAssetTypesToScan=(PrimaryAssetType="Map",AssetBaseClass="/Script/Engine.World",bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game/Maps")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown)) +PrimaryAssetTypesToScan=(PrimaryAssetType="PrimaryAssetLabel",AssetBaseClass="/Script/Engine.PrimaryAssetLabel",bHasBlueprintClasses=False,bIsEditorOnly=True,Directories=((Path="/Game")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=Unknown)) +PrimaryAssetTypesToScan=(PrimaryAssetType="FishingRewardDataAsset",AssetBaseClass="/Script/ProjectFish.FishingRewardDataAsset",bHasBlueprintClasses=False,bIsEditorOnly=False,Directories=((Path="/Game/DataAssets/FishReward")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook)) ++PrimaryAssetTypesToScan=(PrimaryAssetType="ShapeAsset",AssetBaseClass="/Script/ProjectFish.ShapeAsset",bHasBlueprintClasses=False,bIsEditorOnly=False,Directories=((Path="/Game/DataAssets")),SpecificAssets=,Rules=(Priority=-1,ChunkId=-1,bApplyRecursively=True,CookRule=AlwaysCook)) bOnlyCookProductionAssets=False bShouldManagerDetermineTypeAndName=False bShouldGuessTypeAndNameInEditor=True diff --git a/ProjectFish/Content/Maps/TestUI.umap b/ProjectFish/Content/Maps/TestUI.umap index 2a4ddbe..ed3cec2 100644 Binary files a/ProjectFish/Content/Maps/TestUI.umap and b/ProjectFish/Content/Maps/TestUI.umap differ diff --git a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset index 9d37c0e..b95eb41 100644 Binary files a/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset and b/ProjectFish/Content/UI/Fishing/Widgets/ManagerRewards/UMG_ShipContainer_Grid.uasset differ diff --git a/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode-0001.dll b/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode-0001.dll deleted file mode 100644 index 77c254b..0000000 Binary files a/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor-DeskMode-0001.dll and /dev/null differ diff --git a/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules b/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules index b19fd1c..437a3ab 100644 --- a/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules +++ b/ProjectFish/Plugins/DeskMode/Binaries/Win64/UnrealEditor.modules @@ -2,6 +2,6 @@ "BuildId": "37670630", "Modules": { - "DeskMode": "UnrealEditor-DeskMode-0001.dll" + "DeskMode": "UnrealEditor-DeskMode.dll" } } \ No newline at end of file diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp index 3baf2f3..e105761 100644 --- a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.cpp @@ -3,6 +3,7 @@ #include "ContainerInfo.h" +#include "PlayerInfoSaveGame.h" #include "Engine/AssetManager.h" #include "Engine/StreamableManager.h" @@ -116,3 +117,51 @@ bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem, FIntPoint Po } return true; } + +TArray UContainerInfo::GetSaveData() const +{ + TArray SaveDataArray; + FPrimaryAssetId TestID = ContainerShape->GetPrimaryAssetId(); + for (const auto& ItemPair : Items) + { + FContainerItemSaveData SaveData; + SaveData.PosX = ItemPair.Key.X; + SaveData.PosY = ItemPair.Key.Y; + SaveData.DegreeType = ItemPair.Value.DegreeType; + + if (ItemPair.Value.RewardItem) + { + SaveData.RewardItemAssetId = ItemPair.Value.RewardItem->GetPrimaryAssetId(); + } + + SaveDataArray.Add(SaveData); + } + + return SaveDataArray; +} + +void UContainerInfo::LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData) +{ + // 清空当前数据 + Items.Empty(); + SlotInUsing.Empty(); + //从存档中加载仓库形状 + if (IsValid(SaveGameData)) + { + FSoftObjectPath ShipShapePath = UAssetManager::Get().GetPrimaryAssetPath(SaveGameData->ShipContainerShapeID); + InitContainerByShape(Cast(ShipShapePath.TryLoad())); + ;} + // 获得仓库中的物品信息 + TArray AssetsToLoad; + for (const FContainerItemSaveData& ItemData : SaveGameData->ShipContainerItems) + { + FContainerItem NewItem; + NewItem.DegreeType = ItemData.DegreeType; + //获得物品形状 + FSoftObjectPath RewardItemPath = UAssetManager::Get().GetPrimaryAssetPath(ItemData.RewardItemAssetId); + NewItem.RewardItem = Cast(RewardItemPath.TryLoad()); + //添加物品到容器中 + FIntPoint Position(ItemData.PosX, ItemData.PosY); + AddContainerItem(NewItem, Position); + } +} diff --git a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h index 6335375..8b01bad 100644 --- a/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h +++ b/ProjectFish/Source/ProjectFish/Data/ContainerInfo.h @@ -20,6 +20,25 @@ enum class EItemDegreeType: uint8 class UShapeAsset; +// 可序列化的容器物品数据(仅用于存档) +USTRUCT(BlueprintType) +struct FContainerItemSaveData +{ + GENERATED_BODY() + + UPROPERTY(SaveGame) + int32 PosX; + + UPROPERTY(SaveGame) + int32 PosY; + + UPROPERTY(SaveGame) + EItemDegreeType DegreeType; + + UPROPERTY(SaveGame) + FPrimaryAssetId RewardItemAssetId; +}; + USTRUCT(BlueprintType) struct FContainerItem { @@ -86,15 +105,21 @@ class PROJECTFISH_API UContainerInfo : public UObject GENERATED_BODY() public: - // UFUNCTION(BlueprintCallable, Category = "ContainerInfo") - // void InitContainer(FPrimaryAssetId ContainerShapeId); UFUNCTION(BlueprintCallable, Category = "ContainerInfo") void InitContainerByShape(UShapeAsset* InContainerShape); - + UFUNCTION(BlueprintPure) bool AddContainerItem(FContainerItem Item, FIntPoint Position); + // 获取存档数据 + UFUNCTION(BlueprintCallable, Category = "ContainerInfo") + TArray GetSaveData() const; + + // 从存档数据加载 + UFUNCTION(BlueprintCallable, Category = "ContainerInfo") + void LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData); + private: //要添加的物品是否会覆盖其他物品 bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position); diff --git a/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h b/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h index ea7e008..5c83104 100644 --- a/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h +++ b/ProjectFish/Source/ProjectFish/Data/PlayerInfoSaveGame.h @@ -3,30 +3,44 @@ #pragma once #include "CoreMinimal.h" +#include "ContainerInfo.h" #include "GameFramework/SaveGame.h" #include "ProjectFish/Definations.h" #include "PlayerInfoSaveGame.generated.h" /** - * + * */ UCLASS() class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame { GENERATED_BODY() public: - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只资源")) + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船只资源")) FPrimaryAssetId ShipAssetID; - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只等级")) - int32 ShipLevel; - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船舱信息")) - class UContainerInfo* ShipContainer; - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库资源")) + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船只等级")) + int32 ShipLevel; + + // 船舱容器形状资源ID + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船舱容器形状")) + FPrimaryAssetId ShipContainerShapeID; + + // 船舱物品存档数据 + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船舱物品数据")) + TArray ShipContainerItems; + + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库资源")) FPrimaryAssetId PlayerContainerAssetID; - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库等级")) + + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库等级")) int32 PlayerContainerLevel; - UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "玩家仓库信息")) - class UContainerInfo* PlayerContainer; - + + // 玩家仓库容器形状资源ID + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库容器形状")) + FPrimaryAssetId PlayerContainerShapeID; + + // 玩家仓库物品存档数据 + UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库物品数据")) + TArray PlayerContainerItems; }; diff --git a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp index 296a2a4..1482da4 100644 --- a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp +++ b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.cpp @@ -9,6 +9,11 @@ UShapeAsset::UShapeAsset() InitializeShape(); } +FPrimaryAssetId UShapeAsset::GetPrimaryAssetId() const +{ + return FPrimaryAssetId(TEXT("ShapeAsset"), GetFName()); +} + void UShapeAsset::InitializeShape() { Slots.Empty(); diff --git a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h index 5c148f6..4fa56cc 100644 --- a/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h +++ b/ProjectFish/Source/ProjectFish/DataAsset/ShapeAsset.h @@ -41,6 +41,7 @@ class PROJECTFISH_API UShapeAsset : public UDataAsset public: UShapeAsset(); + virtual FPrimaryAssetId GetPrimaryAssetId() const override; UFUNCTION(BlueprintCallable, Category="Shape") void InitializeShape(); diff --git a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/GameInfoManager.cpp b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/GameInfoManager.cpp index a2e274b..c18e616 100644 --- a/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/GameInfoManager.cpp +++ b/ProjectFish/Source/ProjectFish/Gameplay/Subsystem/GameInfoManager.cpp @@ -47,7 +47,7 @@ bool UGameInfoManager::LoadGameInfo() void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer) { PlayerInfo = NewObject(this); - PlayerInfo->ShipContainer = ShipContainer; - PlayerInfo->ShipLevel = 99; + PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData(); + PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId(); SaveGameInfo(); }