示例#1
0
        /// <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);
            }
        }
示例#2
0
 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);
     }
 }
示例#3
0
        /// <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);
            }
        }