Esempio n. 1
0
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            var containerEquipment = character.SharedGetPlayerContainerEquipment();

            if (this.List.Count == 1)
            {
                var requiredProtoItem = this.List[0];
                foreach (var item in containerEquipment.Items)
                {
                    if (item.ProtoItem == requiredProtoItem)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                foreach (var item in containerEquipment.Items)
                {
                    if (this.List.Contains(item.ProtoItem))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            if (base.ServerIsCompleted(character, state))
            {
                return(true);
            }

            if (!this.IsSharedWithPartyMembers ||
                !(this.TaskTarget is IProtoQuest))
            {
                return(false);
            }

            // check whether any of the other party members has this requirement satisfied
            var partyMembers = PartySystem.ServerGetPartyMembersReadOnly(character);

            if (partyMembers.Count <= 1)
            {
                // no party or single-player party
                return(false);
            }

            var currentCharacterName = character.Name;

            foreach (var partyMemberName in partyMembers)
            {
                if (partyMemberName == currentCharacterName)
                {
                    continue;
                }

                var partyMember = Api.Server.Characters
                                  .GetPlayerCharacter(partyMemberName);

                if (partyMember == null)
                {
                    continue;
                }

                if (partyMember.SharedGetQuests()
                    .SharedHasCompletedTask(this))
                {
                    // party member has satisfied this requirement
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 3
0
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            var characterContainers = new AggregatedItemsContainers(character, includeEquipmentContainer: true);

            if (this.RequiredCount == 1)
            {
                // only one item is required
                foreach (var protoItem in this.List)
                {
                    if (characterContainers.ContainsItemsOfType(protoItem, requiredCount: 1))
                    {
                        // found at least one item of the required item type
                        state.SetCountCurrent(1, countMax: 1);
                        return(true);
                    }
                }

                state.SetCountCurrent(0, countMax: 1);
                return(false);
            }

            // more than a single item is required
            var availableCount = 0;

            foreach (var protoItem in this.List)
            {
                availableCount += characterContainers.CountItemsOfType(protoItem);
                if (availableCount >= this.RequiredCount)
                {
                    break;
                }
            }

            state.SetCountCurrent(this.IsReversible
                                      ? availableCount
                                      : Math.Max(state.CountCurrent, availableCount),
                                  this.RequiredCount);
            return(state.CountCurrent >= this.RequiredCount);
        }
Esempio n. 4
0
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            var characterTechnologies = character.SharedGetTechnologies();
            var unlockedCount         = 0;

            foreach (var entry in this.List)
            {
                if (!characterTechnologies.SharedIsGroupUnlocked(entry))
                {
                    continue;
                }

                unlockedCount++;
                if (unlockedCount > this.RequiredCount)
                {
                    break;
                }
            }

            state.SetCountCurrent(unlockedCount, this.RequiredCount);

            return(base.ServerIsCompleted(character, state));
        }
Esempio n. 5
0
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            var characterSkills = character.SharedGetSkills();
            var unlockedCount   = 0;

            foreach (var entry in this.List)
            {
                if (!characterSkills.SharedHasSkill(entry, this.MinLevel))
                {
                    continue;
                }

                unlockedCount++;
                if (unlockedCount > this.RequiredCount)
                {
                    break;
                }
            }

            state.SetCountCurrent(unlockedCount, this.RequiredCount);

            return(base.ServerIsCompleted(character, state));
        }
Esempio n. 6
0
        protected override bool ServerIsCompleted(ICharacter character, PlayerTaskStateWithCount state)
        {
            if (base.ServerIsCompleted(character, state))
            {
                return(true);
            }

            if (!this.IsSharedWithPartyAndFactionMembers ||
                this.TaskTarget is not IProtoQuest)
            {
                return(false);
            }

            // check whether any of the other party members has this requirement satisfied
            var currentCharacterName = character.Name;
            var partyMembers         = PartySystem.ServerGetPartyMembersReadOnly(character);

            if (partyMembers.Count > 1)
            {
                foreach (var partyMemberName in partyMembers)
                {
                    if (partyMemberName == currentCharacterName)
                    {
                        continue;
                    }

                    var partyMember = Api.Server.Characters
                                      .GetPlayerCharacter(partyMemberName);

                    if (partyMember is null)
                    {
                        continue;
                    }

                    if (partyMember.SharedGetQuests()
                        .SharedHasCompletedTask(this))
                    {
                        // party member has satisfied this requirement
                        return(true);
                    }
                }
            }

            // check whether any of the other faction members has this requirement satisfied
            if (FactionSystem.ServerGetFaction(character) is { } faction &&
                FactionSystem.SharedGetFactionKind(faction) != FactionKind.Public)
            {
                var factionMembers = FactionSystem.ServerGetFactionMembersReadOnly(faction);
                if (factionMembers.Count > 1)
                {
                    foreach (var factionMemberEntry in factionMembers)
                    {
                        var factionMemberName = factionMemberEntry.Name;
                        if (factionMemberName == currentCharacterName)
                        {
                            continue;
                        }

                        var factionMember = Api.Server.Characters
                                            .GetPlayerCharacter(factionMemberName);

                        if (factionMember is null)
                        {
                            continue;
                        }

                        if (factionMember.SharedGetQuests()
                            .SharedHasCompletedTask(this))
                        {
                            // faction member has satisfied this requirement
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }