修改任务资源复制时 id自动增加
This commit is contained in:
parent
0f942b0b77
commit
4821d206c0
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ public:
|
|||||||
#if WITH_EDITOR
|
#if WITH_EDITOR
|
||||||
// 编辑器中属性修改后的回调
|
// 编辑器中属性修改后的回调
|
||||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
|
|
||||||
|
virtual void PostDuplicate(bool bDuplicateForPIE) override;
|
||||||
#endif
|
#endif
|
||||||
/** 任务编号ID */
|
/** 任务编号ID */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Quest|Basic")
|
||||||
|
|||||||
@ -140,13 +140,12 @@ bool UQuestManager::CompleteQuest(int32 QuestID)
|
|||||||
// 触发事件
|
// 触发事件
|
||||||
OnQuestStateChanged.Broadcast(QuestID);
|
OnQuestStateChanged.Broadcast(QuestID);
|
||||||
UE_LOG(LogTemp, Warning, TEXT("Quest id = %d Complete"), QuestID);
|
UE_LOG(LogTemp, Warning, TEXT("Quest id = %d Complete"), QuestID);
|
||||||
// 从活动任务中移除
|
// // 从活动任务中移除
|
||||||
ActiveQuestsMap.Remove(QuestID);
|
// ActiveQuestsMap.Remove(QuestID);
|
||||||
//更新存档数据
|
//更新存档数据
|
||||||
GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo();
|
GetGameInstance()->GetSubsystem<UGameInfoManager>()->SaveGameInfo();
|
||||||
|
|
||||||
//检测是否有其他可接受的任务
|
|
||||||
CheckAcceptableQuests();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -221,6 +220,9 @@ void UQuestManager::UpdateObjectiveByTargetID(FGameplayTag TargetTag, int32 Prog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//检测是否有其他可接受的任务
|
||||||
|
CheckAcceptableQuests();
|
||||||
}
|
}
|
||||||
|
|
||||||
EQuestState UQuestManager::GetQuestState(int32 QuestID) const
|
EQuestState UQuestManager::GetQuestState(int32 QuestID) const
|
||||||
@ -352,6 +354,7 @@ TArray<FQuestSaveData> UQuestManager::GetQuestSaveData() const
|
|||||||
SaveDataArray.Add(SaveData);
|
SaveDataArray.Add(SaveData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return SaveDataArray;
|
return SaveDataArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user