コード例 #1
0
        /// <summary>
        /// Creates a transport assignment
        /// </summary>
        public static void SubmitTransportAssignment(Character character, long wrapperContainerEid, long reward, long collateral, long sourceBaseEid, long targetBaseEid, int durationDays)
        {
            if (durationDays <= 0)
            {
                durationDays = 1;
            }

            reward.ThrowIfLessOrEqual(0, ErrorCodes.IllegalTransportAssignmentReward);
            collateral.ThrowIfLess(0, ErrorCodes.IllegalTransportAssignmentCollateral);

            targetBaseEid.ThrowIfEqual(sourceBaseEid, ErrorCodes.WTFErrorMedicalAttentionSuggested);
            DockingBase.Exists(targetBaseEid).ThrowIfFalse(ErrorCodes.TargetDockingBaseWasNotFound);

            var publicContainer = Container.GetFromStructure(sourceBaseEid);

            publicContainer.ReloadItems(character);
            var wrapperContainer = (VolumeWrapperContainer)publicContainer.GetItemOrThrow(wrapperContainerEid);

            wrapperContainer.CheckSubmitConditionsAndThrowIfFailed();

            var transportAssignmentInfo = new TransportAssignment
            {
                reward         = reward,
                ownercharacter = character,
                collateral     = collateral,
                containereid   = wrapperContainerEid,
                sourcebaseeid  = sourceBaseEid,
                targetbaseeid  = targetBaseEid,
                volume         = wrapperContainer.Volume,
                expiry         = DateTime.Now.AddDays(durationDays),
                containername  = wrapperContainer.Name,
            };

            transportAssignmentInfo.CashInOnSubmit();
            transportAssignmentInfo.InsertToDb();

            wrapperContainer.Parent       = GetTransportStorageEid(sourceBaseEid).ThrowIfLessOrEqual(0, ErrorCodes.ServerError);
            wrapperContainer.AssignmentId = transportAssignmentInfo.id;

            wrapperContainer.Save();

            transportAssignmentInfo.WriteLog(TransportAssignmentEvent.submit, sourceBaseEid);
            SendCommandWithTransportAssignmentsAndContainer(Commands.TransportAssignmentSubmit, publicContainer, character);
        }
コード例 #2
0
        private static void AdministerDelivery(TransportAssignment transportAssignmentInfo, VolumeWrapperContainer volumeWrapperContainer, PublicContainer container)
        {
            //normal procedure
            //successful delivery

            transportAssignmentInfo.PayOutReward();

            volumeWrapperContainer.ReloadItems(transportAssignmentInfo.volunteercharacter);
            volumeWrapperContainer.PrintDebug();

            container.AddItem(volumeWrapperContainer, transportAssignmentInfo.ownercharacter.Eid, false);

            volumeWrapperContainer.Owner = transportAssignmentInfo.ownercharacter.Eid;
            volumeWrapperContainer.ClearAssignmentId();
            volumeWrapperContainer.Save();

            volumeWrapperContainer.PrintDebug();

            //owner
            transportAssignmentInfo.WriteLog(TransportAssignmentEvent.deliver, container.Parent);
            transportAssignmentInfo.DeleteFromDb();
            transportAssignmentInfo.SendDeliveryMessage(container);
        }