Compare commits
3 Commits
c3e1ed0762
...
0513ccc3d7
| Author | SHA1 | Date | |
|---|---|---|---|
| 0513ccc3d7 | |||
| 220ea3a481 | |||
| a07bf2a19c |
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.
@ -48,4 +48,8 @@ public:
|
|||||||
// 任务存档数据
|
// 任务存档数据
|
||||||
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "任务存档数据"))
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "任务存档数据"))
|
||||||
TArray<FQuestSaveData> QuestSaveData;
|
TArray<FQuestSaveData> QuestSaveData;
|
||||||
|
|
||||||
|
//已战胜的鱼
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite, meta = (ToolTip = "被击败的鱼"))
|
||||||
|
TArray<int32> Fish_defeated_IDS;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,3 +2,35 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "FishInfoConfigAsset.h"
|
#include "FishInfoConfigAsset.h"
|
||||||
|
|
||||||
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
|
|
||||||
|
void UFishInfoConfigAsset::PostDuplicate(bool bDuplicateForPIE)
|
||||||
|
{
|
||||||
|
Super::PostDuplicate(bDuplicateForPIE);
|
||||||
|
if (!bDuplicateForPIE)
|
||||||
|
{
|
||||||
|
int32 MaxFishID = 0;
|
||||||
|
|
||||||
|
// 获取资产注册表模块
|
||||||
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
||||||
|
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
||||||
|
|
||||||
|
// 查找所有 QuestAsset 资产
|
||||||
|
TArray<FAssetData> AssetDataList;
|
||||||
|
AssetRegistry.GetAssetsByClass(UFishInfoConfigAsset::StaticClass()->GetClassPathName(), AssetDataList, true);
|
||||||
|
|
||||||
|
// 遍历所有已存在的任务资产,找到最大的 QuestID
|
||||||
|
for (const FAssetData& AssetData : AssetDataList)
|
||||||
|
{
|
||||||
|
if (UFishInfoConfigAsset* FishAsset = Cast<UFishInfoConfigAsset>(AssetData.GetAsset()))
|
||||||
|
{
|
||||||
|
if (FishAsset->FishID > MaxFishID)
|
||||||
|
{
|
||||||
|
MaxFishID = FishAsset->FishID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FishID = MaxFishID + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -15,9 +15,9 @@ class PROJECTFISH_API UFishInfoConfigAsset : public UDataAsset
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
//virtual void PostDuplicate(bool bDuplicateForPIE) override;
|
virtual void PostDuplicate(bool bDuplicateForPIE) override;
|
||||||
public:
|
public:
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = fish, meta = (ToolTip = "鱼的ID"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = fish, meta = (ToolTip = "鱼的ID"))
|
||||||
int32 FishID;
|
int32 FishID;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "鱼的名称"))
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "鱼的名称"))
|
||||||
|
|||||||
@ -81,7 +81,7 @@ void UQuestAsset::PostDuplicate(bool bDuplicateForPIE)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QuestID += 1;
|
QuestID = MaxQuestID + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -102,3 +102,22 @@ void UGameInfoManager::CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, US
|
|||||||
|
|
||||||
SaveGameInfo();
|
SaveGameInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UGameInfoManager::IsFishDefeated(int32 FishID)
|
||||||
|
{
|
||||||
|
if (!IsValid(PlayerInfo))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return PlayerInfo->Fish_defeated_IDS.Contains(FishID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UGameInfoManager::AddDefeatedFish(int32 FishID)
|
||||||
|
{
|
||||||
|
if (!IsValid(PlayerInfo))
|
||||||
|
{
|
||||||
|
PlayerInfo = NewObject<UPlayerInfoSaveGame>(this);
|
||||||
|
}
|
||||||
|
PlayerInfo->Fish_defeated_IDS.Add(FishID);
|
||||||
|
SaveGameInfo();
|
||||||
|
}
|
||||||
|
|||||||
@ -29,6 +29,12 @@ public:
|
|||||||
|
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
void CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, UShapeAsset* PlayerContainerShape);
|
void CreateGameInfoAndSave(UShapeAsset* ShipContainerShape, UShapeAsset* PlayerContainerShape);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure)
|
||||||
|
bool IsFishDefeated(int32 FishID);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
void AddDefeatedFish(int32 FishID);
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(BlueprintReadOnly)
|
UPROPERTY(BlueprintReadOnly)
|
||||||
TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
|
TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "AssetActions/FishInfoAssetAction.h"
|
||||||
|
|
||||||
|
#include "ProjectFish/DataAsset/FishInfoConfigAsset.h"
|
||||||
|
|
||||||
|
|
||||||
|
UClass* FFishInfoAssetAction::GetSupportedClass() const
|
||||||
|
{
|
||||||
|
return UFishInfoConfigAsset::StaticClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 FFishInfoAssetAction::GetCategories()
|
||||||
|
{
|
||||||
|
return MyAssetCategory;
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "Factory/FishInfoConfigAssetFactory.h"
|
||||||
|
#include "ProjectFish/DataAsset/QuestAsset.h"
|
||||||
|
#include "AssetRegistry/AssetRegistryModule.h"
|
||||||
|
#include "AssetRegistry/AssetData.h"
|
||||||
|
#include "ProjectFish/DataAsset/FishInfoConfigAsset.h"
|
||||||
|
|
||||||
|
UFishInfoConfigAssetFactory::UFishInfoConfigAssetFactory()
|
||||||
|
{
|
||||||
|
SupportedClass = UFishInfoConfigAsset::StaticClass();
|
||||||
|
bCreateNew = true;
|
||||||
|
bEditAfterNew = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UObject* UFishInfoConfigAssetFactory::FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags,
|
||||||
|
UObject* Context, FFeedbackContext* Warn)
|
||||||
|
{
|
||||||
|
UFishInfoConfigAsset* NewFishAsset = NewObject<UFishInfoConfigAsset>(InParent, Class, Name, Flags | RF_Transactional);
|
||||||
|
|
||||||
|
// 自动生成唯一的 QuestID
|
||||||
|
if (NewFishAsset)
|
||||||
|
{
|
||||||
|
int32 MaxFishID = 0;
|
||||||
|
|
||||||
|
// 获取资产注册表模块
|
||||||
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
|
||||||
|
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
|
||||||
|
|
||||||
|
// 查找所有 QuestAsset 资产
|
||||||
|
TArray<FAssetData> AssetDataList;
|
||||||
|
AssetRegistry.GetAssetsByClass(UFishInfoConfigAsset::StaticClass()->GetClassPathName(), AssetDataList, true);
|
||||||
|
|
||||||
|
// 遍历所有已存在的任务资产,找到最大的 QuestID
|
||||||
|
for (const FAssetData& AssetData : AssetDataList)
|
||||||
|
{
|
||||||
|
if (UFishInfoConfigAsset* FishAsset = Cast<UFishInfoConfigAsset>(AssetData.GetAsset()))
|
||||||
|
{
|
||||||
|
if (FishAsset->FishID > MaxFishID)
|
||||||
|
{
|
||||||
|
MaxFishID = FishAsset->FishID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NewFishAsset->FishID = MaxFishID + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewFishAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool UFishInfoConfigAssetFactory::ShouldShowInNewMenu() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
#include "ProjectFish/DataAsset/BagConfigAsset.h"
|
||||||
#include "../Public/Thumbnail/ShapeAssetThumbnailRenderer.h"
|
#include "../Public/Thumbnail/ShapeAssetThumbnailRenderer.h"
|
||||||
#include "../Public/Thumbnail/BagConfigThumbnailRenderer.h"
|
#include "../Public/Thumbnail/BagConfigThumbnailRenderer.h"
|
||||||
|
#include "AssetActions/FishInfoAssetAction.h"
|
||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "FProjectFishEditorModule"
|
#define LOCTEXT_NAMESPACE "FProjectFishEditorModule"
|
||||||
|
|
||||||
@ -64,6 +65,11 @@ void FProjectFishEditorModule::RegisterAssetTypeActions()
|
|||||||
TSharedRef<FAssetTypeActions_Base> QuestAssetAction = MakeShareable(new FQuestAssetTypeAction(BogShapeAssetCategory));
|
TSharedRef<FAssetTypeActions_Base> QuestAssetAction = MakeShareable(new FQuestAssetTypeAction(BogShapeAssetCategory));
|
||||||
AssetTools.RegisterAssetTypeActions(QuestAssetAction);
|
AssetTools.RegisterAssetTypeActions(QuestAssetAction);
|
||||||
CreatedAssetTypeActions.Add(QuestAssetAction);
|
CreatedAssetTypeActions.Add(QuestAssetAction);
|
||||||
|
|
||||||
|
//注册鱼类配置资源菜单
|
||||||
|
TSharedRef<FAssetTypeActions_Base> FishInfoAssetAction = MakeShareable(new FFishInfoAssetAction(BogShapeAssetCategory));
|
||||||
|
AssetTools.RegisterAssetTypeActions(FishInfoAssetAction);
|
||||||
|
CreatedAssetTypeActions.Add(FishInfoAssetAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FProjectFishEditorModule::UnregisterAssetTypeActions()
|
void FProjectFishEditorModule::UnregisterAssetTypeActions()
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "AssetTypeActions_Base.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务资产类型动作
|
||||||
|
*/
|
||||||
|
class PROJECTFISHEDITOR_API FFishInfoAssetAction : public FAssetTypeActions_Base
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FFishInfoAssetAction(EAssetTypeCategories::Type InAssetCategory)
|
||||||
|
: MyAssetCategory(InAssetCategory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual FText GetName() const override { return FText::FromString("FishInfo Asset"); }
|
||||||
|
virtual FColor GetTypeColor() const override { return FColor(255, 215, 0); } // 金色
|
||||||
|
virtual UClass* GetSupportedClass() const override;
|
||||||
|
virtual uint32 GetCategories() override;
|
||||||
|
virtual bool CanFilter() override { return true; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
EAssetTypeCategories::Type MyAssetCategory;
|
||||||
|
};
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Factories/Factory.h"
|
||||||
|
#include "FishInfoConfigAssetFactory.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class PROJECTFISHEDITOR_API UFishInfoConfigAssetFactory : public UFactory
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
public:
|
||||||
|
UFishInfoConfigAssetFactory();
|
||||||
|
|
||||||
|
// UFactory interface
|
||||||
|
virtual UObject* FactoryCreateNew(UClass* Class, UObject* InParent, FName Name, EObjectFlags Flags, UObject* Context, FFeedbackContext* Warn) override;
|
||||||
|
virtual bool ShouldShowInNewMenu() const override;
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user