/// <summary> /// Deliver items to a single mission /// </summary> public void DeliverSingleMission(Character character, Guid missionGuid, int locationId = 0) { Logger.Info($"++ Deliver starts for character:{character} missionGuid:{missionGuid}"); var isDocked = character.IsDocked; MissionLocation location; if (isDocked) { location = _missionDataCache.GetLocationByEid(character.CurrentDockingBaseEid); } else { //ok, let's use the optional parameter locationId.ThrowIfEqual(0, ErrorCodes.WTFErrorMedicalAttentionSuggested); if (!_missionDataCache.GetLocationById(locationId, out location)) { throw new PerpetuumException(ErrorCodes.InvalidMissionLocation); } } //safety location.ThrowIfNull(ErrorCodes.WTFErrorMedicalAttentionSuggested); //get the affected characters from the gang var charactersToProcess = GetGangMembersCached(character); MissionInProgress missionInProgress = null; //let's collect the targets foreach (var processedCharacter in charactersToProcess) { if (MissionAdministrator.RunningMissionsCount(processedCharacter) == 0) { continue; } MissionInProgressCollector collector; if (MissionAdministrator.GetMissionInProgressCollector(processedCharacter, out collector)) { foreach (var mip in collector.GetMissionsInProgress()) { if (mip.missionGuid == missionGuid) { missionInProgress = mip; break; } } } } var result = new Dictionary <string, object>(); if (missionInProgress == null) { // mission was not found Message.Builder.SetCommand(Commands.MissionDeliver) .WithError(ErrorCodes.MissionNotFound) .ToCharacter(character) .Send(); return; } if (missionInProgress.IsMissionFinished) { Message.Builder.SetCommand(Commands.MissionDeliver) .WithError(ErrorCodes.MissionAlreadyDone) .ToCharacter(character) .Send(); return; } var interestingTargets = missionInProgress.CollectTargetsWithDefinitionsToDeliverInCurrentState(location).ToList(); DeliverMissionByTargetList(interestingTargets, character, location); }