Compare commits

...

2 Commits

Author SHA1 Message Date
c07849c95b 添加新游戏功能 2025-10-28 19:58:18 +08:00
4821d206c0 修改任务资源复制时 id自动增加 2025-10-28 19:50:58 +08:00
25 changed files with 51 additions and 8 deletions

View File

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

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -54,5 +54,35 @@ void UQuestAsset::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedE
}
}
}
void UQuestAsset::PostDuplicate(bool bDuplicateForPIE)
{
Super::PostDuplicate(bDuplicateForPIE);
if (!bDuplicateForPIE)
{
int32 MaxQuestID = 0;
// 获取资产注册表模块
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
// 查找所有 QuestAsset 资产
TArray<FAssetData> AssetDataList;
AssetRegistry.GetAssetsByClass(UQuestAsset::StaticClass()->GetClassPathName(), AssetDataList, true);
// 遍历所有已存在的任务资产,找到最大的 QuestID
for (const FAssetData& AssetData : AssetDataList)
{
if (UQuestAsset* QuestAsset = Cast<UQuestAsset>(AssetData.GetAsset()))
{
if (QuestAsset->QuestID > MaxQuestID)
{
MaxQuestID = QuestAsset->QuestID;
}
}
}
QuestID += 1;
}
}
#endif

View File

@ -20,6 +20,8 @@ public:
#if WITH_EDITOR
// 编辑器中属性修改后的回调
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
virtual void PostDuplicate(bool bDuplicateForPIE) override;
#endif
/** 任务编号ID */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic")

View File

@ -17,6 +17,11 @@ void UGameInfoManager::Initialize(FSubsystemCollectionBase& Collection)
}
}
void UGameInfoManager::NewSaveGame()
{
UGameplayStatics::DeleteGameInSlot(SaveGameSlotName, 0);
}
void UGameInfoManager::SaveGameInfo()
{
if (!IsValid(PlayerInfo.Get()))

View File

@ -18,6 +18,8 @@ public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
public:
UFUNCTION(BlueprintCallable)
void NewSaveGame();
UFUNCTION(BlueprintCallable)
void SaveGameInfo();
UFUNCTION(BlueprintCallable)
@ -30,5 +32,6 @@ public:
protected:
UPROPERTY(BlueprintReadOnly)
TObjectPtr<class UPlayerInfoSaveGame> PlayerInfo;
static FString SaveGameSlotName;
};

View File

@ -140,13 +140,12 @@ bool UQuestManager::CompleteQuest(int32 QuestID)
// 触发事件
OnQuestStateChanged.Broadcast(QuestID);
UE_LOG(LogTemp, Warning, TEXT("Quest id = %d Complete"), QuestID);
// 从活动任务中移除
ActiveQuestsMap.Remove(QuestID);
// // 从活动任务中移除
// ActiveQuestsMap.Remove(QuestID);
//更新存档数据
GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo();
//检测是否有其他可接受的任务
CheckAcceptableQuests();
return true;
}
@ -221,6 +220,9 @@ void UQuestManager::UpdateObjectiveByTargetID(FGameplayTag TargetTag, int32 Prog
}
}
}
//检测是否有其他可接受的任务
CheckAcceptableQuests();
}
EQuestState UQuestManager::GetQuestState(int32 QuestID) const
@ -327,7 +329,7 @@ bool UQuestManager::CanAcceptQuest(UQuestAsset* QuestAsset) const
TArray<FQuestSaveData> UQuestManager::GetQuestSaveData() const
{
TArray<FQuestSaveData> SaveDataArray;
for (const TPair<int32, FQuestRuntimeData>& Pair : ActiveQuestsMap)
{
FQuestSaveData SaveData;
@ -352,6 +354,7 @@ TArray<FQuestSaveData> UQuestManager::GetQuestSaveData() const
SaveDataArray.Add(SaveData);
}
return SaveDataArray;
}