Compare commits

..

No commits in common. "0513ccc3d7a6b52dd8ae28ec173bc0a112c36769" and "c3e1ed07624433a6d4e156c4e5f61730e596b4b8" have entirely different histories.

18 changed files with 3 additions and 191 deletions

View File

@ -48,8 +48,4 @@ 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;
}; };

View File

@ -2,35 +2,3 @@
#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;
}
}

View File

@ -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(EditAnywhere, BlueprintReadOnly, Category = fish, meta = (ToolTip = "鱼的ID")) UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = fish, meta = (ToolTip = "鱼的ID"))
int32 FishID; int32 FishID;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "鱼的名称")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = fish, meta = (ToolTip = "鱼的名称"))

View File

@ -81,7 +81,7 @@ void UQuestAsset::PostDuplicate(bool bDuplicateForPIE)
} }
} }
} }
QuestID = MaxQuestID + 1; QuestID += 1;
} }
} }
#endif #endif

View File

@ -102,22 +102,3 @@ 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();
}

View File

@ -29,12 +29,6 @@ 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;

View File

@ -1,16 +0,0 @@
// 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;
}

View File

@ -1,56 +0,0 @@
// 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;
}

View File

@ -11,7 +11,6 @@
#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"
@ -65,11 +64,6 @@ 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()

View File

@ -1,27 +0,0 @@
// 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;
};

View File

@ -1,22 +0,0 @@
// 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;
};