Compare commits
2 Commits
2c6e4f2a89
...
08e4076f22
| Author | SHA1 | Date | |
|---|---|---|---|
| 08e4076f22 | |||
| 3a6b9042f1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
"BuildId": "37670630",
|
"BuildId": "37670630",
|
||||||
"Modules":
|
"Modules":
|
||||||
{
|
{
|
||||||
"ProjectFish": "UnrealEditor-ProjectFish-0001.dll",
|
"ProjectFish": "UnrealEditor-ProjectFish.dll",
|
||||||
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor-0001.dll"
|
"ProjectFishEditor": "UnrealEditor-ProjectFishEditor.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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="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="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="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
|
bOnlyCookProductionAssets=False
|
||||||
bShouldManagerDetermineTypeAndName=False
|
bShouldManagerDetermineTypeAndName=False
|
||||||
bShouldGuessTypeAndNameInEditor=True
|
bShouldGuessTypeAndNameInEditor=True
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,6 +2,6 @@
|
|||||||
"BuildId": "37670630",
|
"BuildId": "37670630",
|
||||||
"Modules":
|
"Modules":
|
||||||
{
|
{
|
||||||
"DeskMode": "UnrealEditor-DeskMode-0001.dll"
|
"DeskMode": "UnrealEditor-DeskMode.dll"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "ContainerInfo.h"
|
#include "ContainerInfo.h"
|
||||||
|
|
||||||
|
#include "PlayerInfoSaveGame.h"
|
||||||
#include "Engine/AssetManager.h"
|
#include "Engine/AssetManager.h"
|
||||||
#include "Engine/StreamableManager.h"
|
#include "Engine/StreamableManager.h"
|
||||||
|
|
||||||
@ -116,3 +117,51 @@ bool UContainerInfo::IsItemInContainerShape(FContainerItem NewItem, FIntPoint Po
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TArray<FContainerItemSaveData> UContainerInfo::GetSaveData() const
|
||||||
|
{
|
||||||
|
TArray<FContainerItemSaveData> 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<UShapeAsset>(ShipShapePath.TryLoad()));
|
||||||
|
;}
|
||||||
|
// 获得仓库中的物品信息
|
||||||
|
TArray<FPrimaryAssetId> AssetsToLoad;
|
||||||
|
for (const FContainerItemSaveData& ItemData : SaveGameData->ShipContainerItems)
|
||||||
|
{
|
||||||
|
FContainerItem NewItem;
|
||||||
|
NewItem.DegreeType = ItemData.DegreeType;
|
||||||
|
//获得物品形状
|
||||||
|
FSoftObjectPath RewardItemPath = UAssetManager::Get().GetPrimaryAssetPath(ItemData.RewardItemAssetId);
|
||||||
|
NewItem.RewardItem = Cast<UFishingRewardDataAsset>(RewardItemPath.TryLoad());
|
||||||
|
//添加物品到容器中
|
||||||
|
FIntPoint Position(ItemData.PosX, ItemData.PosY);
|
||||||
|
AddContainerItem(NewItem, Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -20,6 +20,25 @@ enum class EItemDegreeType: uint8
|
|||||||
|
|
||||||
class UShapeAsset;
|
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)
|
USTRUCT(BlueprintType)
|
||||||
struct FContainerItem
|
struct FContainerItem
|
||||||
{
|
{
|
||||||
@ -86,15 +105,21 @@ class PROJECTFISH_API UContainerInfo : public UObject
|
|||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
|
||||||
// void InitContainer(FPrimaryAssetId ContainerShapeId);
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||||
void InitContainerByShape(UShapeAsset* InContainerShape);
|
void InitContainerByShape(UShapeAsset* InContainerShape);
|
||||||
|
|
||||||
UFUNCTION(BlueprintPure)
|
UFUNCTION(BlueprintPure)
|
||||||
bool AddContainerItem(FContainerItem Item, FIntPoint Position);
|
bool AddContainerItem(FContainerItem Item, FIntPoint Position);
|
||||||
|
|
||||||
|
// 获取存档数据
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||||
|
TArray<FContainerItemSaveData> GetSaveData() const;
|
||||||
|
|
||||||
|
// 从存档数据加载
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "ContainerInfo")
|
||||||
|
void LoadFromSaveData(UPlayerInfoSaveGame* SaveGameData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//要添加的物品是否会覆盖其他物品
|
//要添加的物品是否会覆盖其他物品
|
||||||
bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position);
|
bool IsItemOverlapOtherItem(FContainerItem Item, FIntPoint Position);
|
||||||
|
|||||||
@ -3,30 +3,44 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "ContainerInfo.h"
|
||||||
#include "GameFramework/SaveGame.h"
|
#include "GameFramework/SaveGame.h"
|
||||||
#include "ProjectFish/Definations.h"
|
#include "ProjectFish/Definations.h"
|
||||||
#include "PlayerInfoSaveGame.generated.h"
|
#include "PlayerInfoSaveGame.generated.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS()
|
UCLASS()
|
||||||
class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame
|
class PROJECTFISH_API UPlayerInfoSaveGame : public USaveGame
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "船只资源"))
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "船只资源"))
|
||||||
FPrimaryAssetId ShipAssetID;
|
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<FContainerItemSaveData> ShipContainerItems;
|
||||||
|
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库资源"))
|
||||||
FPrimaryAssetId PlayerContainerAssetID;
|
FPrimaryAssetId PlayerContainerAssetID;
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "仓库等级"))
|
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "仓库等级"))
|
||||||
int32 PlayerContainerLevel;
|
int32 PlayerContainerLevel;
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (ToolTip = "玩家仓库信息"))
|
|
||||||
class UContainerInfo* PlayerContainer;
|
// 玩家仓库容器形状资源ID
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库容器形状"))
|
||||||
|
FPrimaryAssetId PlayerContainerShapeID;
|
||||||
|
|
||||||
|
// 玩家仓库物品存档数据
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "玩家仓库物品数据"))
|
||||||
|
TArray<FContainerItemSaveData> PlayerContainerItems;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,6 +9,11 @@ UShapeAsset::UShapeAsset()
|
|||||||
InitializeShape();
|
InitializeShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FPrimaryAssetId UShapeAsset::GetPrimaryAssetId() const
|
||||||
|
{
|
||||||
|
return FPrimaryAssetId(TEXT("ShapeAsset"), GetFName());
|
||||||
|
}
|
||||||
|
|
||||||
void UShapeAsset::InitializeShape()
|
void UShapeAsset::InitializeShape()
|
||||||
{
|
{
|
||||||
Slots.Empty();
|
Slots.Empty();
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class PROJECTFISH_API UShapeAsset : public UDataAsset
|
|||||||
public:
|
public:
|
||||||
UShapeAsset();
|
UShapeAsset();
|
||||||
|
|
||||||
|
virtual FPrimaryAssetId GetPrimaryAssetId() const override;
|
||||||
UFUNCTION(BlueprintCallable, Category="Shape")
|
UFUNCTION(BlueprintCallable, Category="Shape")
|
||||||
void InitializeShape();
|
void InitializeShape();
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ bool UGameInfoManager::LoadGameInfo()
|
|||||||
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer)
|
void UGameInfoManager::CreateGameInfo(UContainerInfo* ShipContainer)
|
||||||
{
|
{
|
||||||
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
||||||
PlayerInfo->ShipContainer = ShipContainer;
|
PlayerInfo->ShipContainerItems = ShipContainer->GetSaveData();
|
||||||
PlayerInfo->ShipLevel = 99;
|
PlayerInfo->ShipContainerShapeID = ShipContainer->ContainerShape->GetPrimaryAssetId();
|
||||||
SaveGameInfo();
|
SaveGameInfo();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user