private static ErrorCodes PrepareDeliverOneAssignment(Character character, long wrapperEid, out VolumeWrapperContainer volumeWrapperContainer) { volumeWrapperContainer = Container.GetOrThrow(wrapperEid) as VolumeWrapperContainer; if (volumeWrapperContainer == null) { return(ErrorCodes.DefinitionNotSupported); } if (volumeWrapperContainer.Owner != character.Eid) { return(ErrorCodes.AccessDenied); } var transportAssignmentInfo = GetByContainer(volumeWrapperContainer); if (transportAssignmentInfo == null) { //no assignment for this container return(ErrorCodes.NoTransportAssignmentForContainer); } var ownerCharacter = transportAssignmentInfo.ownercharacter; if (transportAssignmentInfo.Retrieved) { var targetBaseEid = transportAssignmentInfo.sourcebaseeid; if (!DockingBase.Exists(transportAssignmentInfo.sourcebaseeid)) { targetBaseEid = DefaultCorporation.GetDockingBaseEid(ownerCharacter); } Logger.Info("retrieved assignment was found " + transportAssignmentInfo); transportAssignmentInfo.RetrieveToBasePublicContainer(volumeWrapperContainer, targetBaseEid); return(ErrorCodes.NoError); } var baseOfWrapper = volumeWrapperContainer.TraverseForStructureRootEid(); if (transportAssignmentInfo.targetbaseeid != baseOfWrapper) { return(ErrorCodes.TransportAssignmentCannotBeDeliveredHere); } var publicContainer = Container.GetFromStructure(transportAssignmentInfo.targetbaseeid); publicContainer.ReloadItems(character); AdministerDelivery(transportAssignmentInfo, volumeWrapperContainer, publicContainer); return(ErrorCodes.NoError); }
public void RetrieveToBasePublicContainer(VolumeWrapperContainer volumeWrapperContainer, long targetBaseEid = 0) { var baseEid = sourcebaseeid; if (targetBaseEid != 0) { baseEid = targetBaseEid; } var volumeInitCharacter = taken ? volunteercharacter : ownercharacter; var sourcePublicContainer = Container.GetFromStructure(volumeWrapperContainer.TraverseForStructureRootEid()); sourcePublicContainer.ReloadItems(volumeInitCharacter); var wrapperContainer = sourcePublicContainer.GetItem(volumeWrapperContainer.Eid) as VolumeWrapperContainer; if (wrapperContainer != null && wrapperContainer.Parent == sourcePublicContainer.Eid) { sourcePublicContainer.RemoveItemOrThrow(wrapperContainer); } volumeWrapperContainer.ReloadItems(volumeInitCharacter); var targetPublicContainer = Container.GetFromStructure(baseEid); targetPublicContainer.ReloadItems(ownercharacter); volumeWrapperContainer.Owner = ownercharacter.Eid; volumeWrapperContainer.ClearAssignmentId(); targetPublicContainer.AddItem(volumeWrapperContainer, false); PaybackCollateral(); PaybackReward(); targetPublicContainer.Save(); sourcePublicContainer.Save(); volumeWrapperContainer.Save(); WriteLog(TransportAssignmentEvent.containerRetrieved, baseEid); DeleteFromDb(); Transaction.Current.OnCommited(() => { var info = new Dictionary <string, object> { { k.assignment, ToPrivateDictionary() }, { k.container, sourcePublicContainer.ToDictionary() } }; if (taken) { //inform volunteer Message.Builder.SetCommand(Commands.TransportAssignmentContainerRetrieved).WithData(info).ToCharacter(volunteercharacter).Send(); } //inform principal info[k.container] = targetPublicContainer.ToDictionary(); info[k.assignment] = ToDictionary(); Message.Builder.SetCommand(Commands.TransportAssignmentContainerRetrieved).WithData(info).ToCharacter(ownercharacter).Send(); }); }