public void HandleRequest(IRequest request)
        {
            var zoneId = request.Data.GetOrDefault <int>(k.zoneID);
            var all    = request.Data.GetOrDefault <int>(k.all) == 1;

            if (_zoneManager.GetZone(zoneId) is TrainingZone)
            {
                all = true;
            }

            IList <IDataRecord> records;

            var publicContainer = _entityServices.Defaults.GetByName(DefinitionNames.PUBLIC_CONTAINER);

            var character = request.Session.Character;

            if (all)
            {
                records = Db.Query().CommandText("itemCountOnBases")
                          .SetParameter("@owner", character.Eid)
                          .SetParameter("@publicContainerDefinition", publicContainer.Definition)
                          .Execute();
            }
            else
            {
                records = Db.Query().CommandText("itemCountOnZone")
                          .SetParameter("@owner", character.Eid)
                          .SetParameter("@publicContainerDefinition", publicContainer.Definition)
                          .SetParameter("@zoneId", zoneId)
                          .Execute();
            }


            var result = new Dictionary <string, object>(records.Count + 1);

            var perTerminal =
                records.ToDictionary("c", r =>
            {
                return(new Dictionary <string, object>(3)
                {
                    { "ftEid", r.GetValue <long>("fteid") },
                    { k.containerEID, r.GetValue <long>("containereid") },
                    { k.amount, r.GetValue <int>("amount") }
                });
            });

            result.Add(k.data, perTerminal);

            Message.Builder.FromRequest(request).WithData(result).Send();
        }
        public static TargetSelectionValidator CreateValidator(IZoneManager zoneManager)
        {
            var initValues = new List <IZone>();

            foreach (var zoneId in _manualConfig)
            {
                var zone = zoneManager.GetZone(zoneId);
                if (zone == null)
                {
                    continue;
                }

                initValues.Add(zone);
            }

            return(new TargetSelectionValidator(initValues));
        }
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var targetZoneId = request.Data.GetOrDefault <int>(k.zoneID);
                var x            = request.Data.GetOrDefault <int>(k.x);
                var y            = request.Data.GetOrDefault <int>(k.y);

                var targetZone = _zoneManager.GetZone(targetZoneId);
                var player     = request.Zone.GetPlayer(request.Session.Character);
                var s          = _teleportStrategyFactories.TeleportToAnotherZoneFactory(targetZone);
                s.TargetPosition = new Position(x, y).Clamp(targetZone.Size);
                s.DoTeleport(player);

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var characterid  = request.Data.GetOrDefault <int>(k.characterID);
                var targetZoneId = request.Data.GetOrDefault <int>(k.zoneID);
                var x            = request.Data.GetOrDefault <int>(k.x);
                var y            = request.Data.GetOrDefault <int>(k.y);

                var TargetPosition   = new Position(x, y);
                var charactersession = _sessionManager.GetByCharacter(characterid);
                var targetZone       = _zoneManager.GetZone(targetZoneId);
                var player           = request.Session.ZoneMgr.GetZone((int)charactersession.Character.ZoneId).GetPlayer(charactersession.Character.ActiveRobotEid);
                var s = _teleportStrategyFactories.TeleportToAnotherZoneFactory(targetZone);

                // cannot teleport players in training out of a training zone.
                // this allows GMs or devs to teleport themselves in and out of training zones.
                // player can still be moved around in the training zone.
                if (charactersession.Character.IsInTraining() && targetZone.GetType() != typeof(TrainingZone))
                {
                    Message.Builder.FromRequest(request).WithError(ErrorCodes.AccessDenied).Send();
                    return;
                }

                var position = new ClosestWalkablePositionFinder(targetZone, TargetPosition);
                if (!position.Find(out Position validPosition))
                {
                    return;
                }
                s.TargetPosition = validPosition;
                s.DoTeleport(player);

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
예제 #5
0
        public TeleportDescriptionBuilder SetSourceZone(int zoneID)
        {
            var zone = _zoneManager.GetZone(zoneID);

            return(SetSourceZone(zone));
        }