Beispiel #1
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var id = request.Data.GetOrDefault <int>(k.ID);

                var character = request.Session.Character;

                var teleport = _sparkTeleportHelper.Get(id);
                if (teleport.Character != character)
                {
                    return;
                }

                _sparkTeleportHelper.DeleteAndInform(teleport);

                Transaction.Current.OnCommited(() =>
                {
                    var info = _sparkTeleportHelper.GetSparkTeleportDescriptionInfos(character);
                    Message.Builder.FromRequest(request).WithData(info).Send();
                });

                scope.Complete();
            }
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var id        = request.Data.GetOrDefault <int>(k.ID);
                var character = request.Session.Character;

                character.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked);
                character.CheckNextAvailableUndockTimeAndThrowIfFailed();
                CheckExtensionLevelAndThrowIfFailed(character);

                var sparkTeleport      = _sparkTeleportHelper.Get(id);
                var currentDockingBase = character.GetCurrentDockingBase();

                character.SubtractFromWallet(TransactionType.SparkTeleportUse, SparkTeleport.SPARK_TELEPORT_USE_FEE);

                if (sparkTeleport.DockingBase == currentDockingBase)
                {
                    throw new PerpetuumException(ErrorCodes.YouAreHereAlready);
                }

                sparkTeleport.DockingBase.IsDockingAllowed(character).ThrowIfError();
                sparkTeleport.DockingBase.DockIn(character, Player.NormalUndockDelay);

                var robot = sparkTeleport.DockingBase.GetPublicContainerWithItems(character)
                            .GetFullTree()
                            .OfType <Robot>()
                            .FirstOrDefault(r => !r.IsRepackaged && ItemExtensions.HaveAllEnablerExtensions(r, character));

                character.SetActiveRobot(robot);

                Transaction.Current.OnCommited(() =>
                {
                    currentDockingBase.LeaveChannel(character);

                    Message.Builder.FromRequest(request)
                    .WithData(sparkTeleport.ToDictionary())
                    .Send();
                });

                scope.Complete();
            }
        }