添加任务追踪功能
This commit is contained in:
parent
3c084a8795
commit
f07e298eb8
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -86,6 +86,25 @@ bool UQuestManager::AcceptQuest(UQuestAsset* QuestAsset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UQuestManager::FollowQuest(int32 QuestID, bool Follow)
|
||||||
|
{
|
||||||
|
FQuestRuntimeData* RuntimeData = ActiveQuestsMap.Find(QuestID);
|
||||||
|
if (!RuntimeData)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Follow)
|
||||||
|
{
|
||||||
|
FollowingQuestIDs.Add(QuestID);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FollowingQuestIDs.Remove(QuestID);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool UQuestManager::CompleteQuest(int32 QuestID)
|
bool UQuestManager::CompleteQuest(int32 QuestID)
|
||||||
{
|
{
|
||||||
FQuestRuntimeData* RuntimeData = ActiveQuestsMap.Find(QuestID);
|
FQuestRuntimeData* RuntimeData = ActiveQuestsMap.Find(QuestID);
|
||||||
@ -206,6 +225,11 @@ EQuestState UQuestManager::GetQuestState(int32 QuestID) const
|
|||||||
return EQuestState::NotStarted;
|
return EQuestState::NotStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UQuestManager::IsQuestFollowing(int32 QuestID) const
|
||||||
|
{
|
||||||
|
return FollowingQuestIDs.Contains(QuestID);
|
||||||
|
}
|
||||||
|
|
||||||
TArray<UQuestAsset*> UQuestManager::GetActiveQuests() const
|
TArray<UQuestAsset*> UQuestManager::GetActiveQuests() const
|
||||||
{
|
{
|
||||||
TArray<UQuestAsset*> Result;
|
TArray<UQuestAsset*> Result;
|
||||||
@ -278,7 +302,15 @@ TArray<FQuestSaveData> UQuestManager::GetQuestSaveData() const
|
|||||||
SaveData.ObjectiveProgress.Add(Progress.CurrentProgress);
|
SaveData.ObjectiveProgress.Add(Progress.CurrentProgress);
|
||||||
SaveData.ObjectiveCompleted.Add(Progress.bCompleted);
|
SaveData.ObjectiveCompleted.Add(Progress.bCompleted);
|
||||||
}
|
}
|
||||||
|
//设置追踪状态
|
||||||
|
if (FollowingQuestIDs.Contains(Pair.Key))
|
||||||
|
{
|
||||||
|
SaveData.bFollowing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SaveData.bFollowing = false;
|
||||||
|
}
|
||||||
SaveDataArray.Add(SaveData);
|
SaveDataArray.Add(SaveData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +322,8 @@ void UQuestManager::LoadFromSaveData(const TArray<FQuestSaveData>& SaveData)
|
|||||||
// 清空现有数据
|
// 清空现有数据
|
||||||
ActiveQuestsMap.Empty();
|
ActiveQuestsMap.Empty();
|
||||||
CompletedQuestIDs.Empty();
|
CompletedQuestIDs.Empty();
|
||||||
|
FollowingQuestIDs.Empty();
|
||||||
|
|
||||||
LoadAllQuests();
|
LoadAllQuests();
|
||||||
|
|
||||||
for (const FQuestSaveData& Data : SaveData)
|
for (const FQuestSaveData& Data : SaveData)
|
||||||
@ -313,7 +347,11 @@ void UQuestManager::LoadFromSaveData(const TArray<FQuestSaveData>& SaveData)
|
|||||||
|
|
||||||
RuntimeData.State = EQuestState::InProgress;
|
RuntimeData.State = EQuestState::InProgress;
|
||||||
ActiveQuestsMap.Add(questAsset->QuestID, RuntimeData);
|
ActiveQuestsMap.Add(questAsset->QuestID, RuntimeData);
|
||||||
|
//添加追踪任务列表
|
||||||
|
if (Data.bFollowing)
|
||||||
|
{
|
||||||
|
FollowingQuestIDs.Add(questAsset->QuestID);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,6 +59,10 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Quest")
|
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||||
bool AcceptQuest(UQuestAsset* QuestAsset);
|
bool AcceptQuest(UQuestAsset* QuestAsset);
|
||||||
|
|
||||||
|
/** 接受任务 */
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||||
|
bool FollowQuest(int32 QuestID, bool Follow);
|
||||||
|
|
||||||
/** 完成任务 */
|
/** 完成任务 */
|
||||||
UFUNCTION(BlueprintCallable, Category = "Quest")
|
UFUNCTION(BlueprintCallable, Category = "Quest")
|
||||||
bool CompleteQuest(int32 QuestID);
|
bool CompleteQuest(int32 QuestID);
|
||||||
@ -83,6 +87,10 @@ public:
|
|||||||
UFUNCTION(BlueprintPure, Category = "Quest")
|
UFUNCTION(BlueprintPure, Category = "Quest")
|
||||||
EQuestState GetQuestState(int32 QuestID) const;
|
EQuestState GetQuestState(int32 QuestID) const;
|
||||||
|
|
||||||
|
/** 任务是否正在被追踪 */
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Quest")
|
||||||
|
bool IsQuestFollowing(int32 QuestID) const;
|
||||||
|
|
||||||
/** 获取所有进行中的任务 */
|
/** 获取所有进行中的任务 */
|
||||||
UFUNCTION(BlueprintPure, Category = "Quest")
|
UFUNCTION(BlueprintPure, Category = "Quest")
|
||||||
TArray<UQuestAsset*> GetActiveQuests() const;
|
TArray<UQuestAsset*> GetActiveQuests() const;
|
||||||
@ -131,6 +139,10 @@ private:
|
|||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TMap<int32, FQuestRuntimeData> ActiveQuestsMap;
|
TMap<int32, FQuestRuntimeData> ActiveQuestsMap;
|
||||||
|
|
||||||
|
/** 正在追踪的任务列表 */
|
||||||
|
UPROPERTY()
|
||||||
|
TSet<int32> FollowingQuestIDs;
|
||||||
|
|
||||||
/** 已完成的任务ID列表 */
|
/** 已完成的任务ID列表 */
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
TSet<int32> CompletedQuestIDs;
|
TSet<int32> CompletedQuestIDs;
|
||||||
|
|||||||
@ -103,6 +103,10 @@ struct FQuestSaveData
|
|||||||
UPROPERTY(SaveGame, BlueprintReadWrite)
|
UPROPERTY(SaveGame, BlueprintReadWrite)
|
||||||
int32 QuestID = 0;
|
int32 QuestID = 0;
|
||||||
|
|
||||||
|
/** 是否正在追踪 */
|
||||||
|
UPROPERTY(SaveGame, BlueprintReadWrite)
|
||||||
|
bool bFollowing = false;
|
||||||
|
|
||||||
/** 任务状态 */
|
/** 任务状态 */
|
||||||
UPROPERTY(SaveGame, BlueprintReadWrite)
|
UPROPERTY(SaveGame, BlueprintReadWrite)
|
||||||
EQuestState QuestState = EQuestState::NotStarted;
|
EQuestState QuestState = EQuestState::NotStarted;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user