/// <summary> /// Try to set quest as completed (if player has this quest and all the requirements are satisfied). /// </summary> public static void ServerCompleteQuest( PlayerCharacterQuests characterQuests, IProtoQuest questToComplete, bool ignoreRequirements) { characterQuests.ServerClaimReward(questToComplete, ignoreRequirements); var handler = ServerCharacterQuestCompleted; if (handler is not null) { Api.SafeInvoke(() => handler.Invoke(characterQuests.Character, questToComplete)); } // success! (no exceptions thrown) // adding dependant quests foreach (var otherQuest in AllQuests) { if (!otherQuest.Prerequisites.Contains(questToComplete) || !ServerArePrerequisitesSatisfied(otherQuest, characterQuests)) { continue; } characterQuests.ServerTryAddQuest(otherQuest, isUnlocked: true); } }
public static void ServerInitCharacterQuests(PlayerCharacterQuests characterQuests) { // add all quests which don't have any prerequisites or which are already satisfied foreach (var protoQuest in AllQuests) { var isUnlocked = ServerArePrerequisitesSatisfied(protoQuest, characterQuests); characterQuests.ServerTryAddQuest(protoQuest, isUnlocked); } }
/// <summary> /// Try to set quest as completed (if player has this quest and all the requirements are satisfied). /// </summary> public static void ServerCompleteQuest( PlayerCharacterQuests characterQuests, IProtoQuest questToComplete, bool ignoreRequirements) { characterQuests.ServerTryClaimReward(questToComplete, ignoreRequirements); // success! (no exceptions thrown) // adding dependant quests foreach (var otherQuest in AllQuests) { if (!otherQuest.Prerequisites.Contains(questToComplete) || !ServerArePrequisitesSatisfied(otherQuest, characterQuests)) { continue; } characterQuests.ServerTryAddQuest(otherQuest, isUnlocked: true); } }