public static void ContainerDestroyed(VolumeWrapperContainer container)
        {
            var transportAssignmentInfo = GetByContainer(container);

            if (transportAssignmentInfo == null)
            {
                //container is not connected to any transport assignment
                //nothing to do
                return;
            }


            Logger.Info("assignment cancelling on container destroy " + transportAssignmentInfo);

            transportAssignmentInfo.PaybackReward();
            transportAssignmentInfo.PayCollateralToPrincipal();
            transportAssignmentInfo.WriteLog(TransportAssignmentEvent.failed, transportAssignmentInfo.sourcebaseeid);
            transportAssignmentInfo.DeleteFromDb();

            Transaction.Current.OnCommited(() =>
            {
                var result = new Dictionary <string, object>
                {
                    { k.assignment, transportAssignmentInfo.ToDictionary() }
                };

                Message.Builder.SetCommand(Commands.TransportAssignmentFailed)
                .WithData(result)
                .ToCharacters(transportAssignmentInfo.ownercharacter, transportAssignmentInfo.volunteercharacter)
                .Send();
            });
        }
예제 #2
0
        private void GetLocalPublicContainer(Character characterForVolumeWrapper, out VolumeWrapperContainer volumeWrapperContainer, Character characterForPublicContainer, out PublicContainer publicContainer)
        {
            volumeWrapperContainer = (VolumeWrapperContainer)Container.GetWithItems(containereid, characterForVolumeWrapper, ContainerAccess.List);
            var storage = Container.GetOrThrow(volumeWrapperContainer.Parent);

            publicContainer = Container.GetFromStructure(storage.Parent);
            publicContainer.ReloadItems(characterForPublicContainer);
        }
        public void Visit(VolumeWrapperContainer container)
        {
            container.IsInAssignment().ThrowIfTrue(ErrorCodes.ContainerInAssignment);

            Visit((Container)container);

            container.ClearAssignmentId();
        }
예제 #4
0
        //storage => base => public container -> owner character
        public void ReturnToLocalPublicContainer(out VolumeWrapperContainer volumeWrapperContainer, out PublicContainer publicContainer)
        {
            GetLocalPublicContainer(ownercharacter, out volumeWrapperContainer, ownercharacter, out publicContainer);

            publicContainer.AddItem(volumeWrapperContainer, false);
            volumeWrapperContainer.Owner = ownercharacter.Eid;
            volumeWrapperContainer.ClearAssignmentId();

            volumeWrapperContainer.Save();
        }
예제 #5
0
        public void GiveToVolunteer(out VolumeWrapperContainer volumeWrapperContainer, out PublicContainer publicContainer)
        {
            if (volunteercharacter == Character.None)
            {
                throw new PerpetuumException(ErrorCodes.WTFErrorMedicalAttentionSuggested);
            }

            GetLocalPublicContainer(ownercharacter, out volumeWrapperContainer, volunteercharacter, out publicContainer);

            volumeWrapperContainer.Owner = volunteercharacter.Eid;
            publicContainer.AddItem(volumeWrapperContainer, false);
            volumeWrapperContainer.Save();
        }
 public void Visit(VolumeWrapperContainer container)
 {
     container.SetRandomName();
     container.PrincipalCharacter = container.GetOwnerAsCharacter();
     container.IsRepackaged       = false;
 }
        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);
        }
        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);
        }
예제 #9
0
        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();
            });
        }