示例#1
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var character  = request.Session.Character;
                var locationId = 0;

                var  guidString = request.Data.GetOrDefault <string>(k.guid);
                Guid missionGuid;
                Guid.TryParse(guidString, out missionGuid).ThrowIfFalse(ErrorCodes.SyntaxError);

                if (!character.IsDocked)
                {
                    var eid      = request.Data.GetOrDefault <long>(k.eid);
                    var location = _missionDataCache.GetLocationByEid(eid);

                    location.ThrowIfNull(ErrorCodes.InvalidMissionLocation);

                    locationId = location.id;
                }

                _missionProcessor.DeliverSingleMission(character, missionGuid, locationId);

                scope.Complete();
            }
        }
        protected override void OnRemovedFromZone(IZone zone)
        {
            var location = _missionDataCache.GetLocationByEid(Eid);

            //delete mission related stuff
            location?.DeleteFromDb();

            //delete from zone entities
            zone.UnitService.RemoveDefaultUnit(this, false);

            //remove it from ram, etc...
            base.OnRemovedFromZone(zone);
        }
示例#3
0
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var category = request.Data.GetOrDefault <int>(k.missionCategory);
                var level    = request.Data.GetOrDefault <int>(k.missionLevel);
                level = level.Clamp(-1, 9);

                var character = request.Session.Character;

                var missionCategory = (MissionCategory)category;
                Enum.IsDefined(typeof(MissionCategory), category).ThrowIfFalse(ErrorCodes.MissionCategoryNotDefined);

                MissionLocation location;

                if (character.IsDocked)
                {
                    var dockedLocation = _missionDataCache.GetLocationByEid(character.CurrentDockingBaseEid).ThrowIfNull(ErrorCodes.ItemNotFound);

                    location = dockedLocation;
                }
                else
                {
                    var locationEid = request.Data.GetOrDefault <long>(k.location);

                    var someLocation = _missionDataCache.GetLocationByEid(locationEid).ThrowIfNull(ErrorCodes.ItemNotFound);

                    location = someLocation;
                }

                var result = _missionProcessor.MissionStartForRequest(character, missionCategory, level, location);

                Message.Builder.FromRequest(request).WithData(result).Send();

                scope.Complete();
            }
        }
示例#4
0
        public int MyMissionLocationId()
        {
            var entity = this.GetOrLoadParentEntity().ThrowIfNull(ErrorCodes.ConsistencyError);

            var location = MissionDataCache.GetLocationByEid(entity.Eid);

            var locationId = -1; //not a mission location, gamma base for example

            if (location != null)
            {
                locationId = location.id;
            }

            return(locationId);
        }
        public void HandleRequest(IRequest request)
        {
            var  character = request.Session.Character;
            long locationEid;

            if (character.IsDocked)
            {
                //the base we the player is docked
                locationEid = character.CurrentDockingBaseEid;
            }
            else
            {
                //use the optional parameter
                locationEid = request.Data.GetOrDefault <long>(k.eid);
            }

            var location = _missionDataCache.GetLocationByEid(locationEid).ThrowIfNull(ErrorCodes.ItemNotFound);

            _missionProcessor.GetOptionsByRequest(character, location);
        }
示例#6
0
        public void HandleRequest(IZoneRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var category  = request.Data.GetOrDefault <int>(k.missionCategory);
                var level     = request.Data.GetOrDefault <int>(k.missionLevel);
                var eid       = request.Data.GetOrDefault <long>(k.eid);
                var spreading = request.Data.GetOrDefault <int>(k.spreading) == 1;

                var character = request.Session.Character;
                var player    = request.Zone.GetPlayerOrThrow(character);

                var fieldTerminal = request.Zone.GetUnitOrThrow <FieldTerminal>(eid);
                fieldTerminal.IsInRangeOf3D(player, DistanceConstants.FIELD_TERMINAL_USE).ThrowIfFalse(ErrorCodes.ItemOutOfRange);

                var location = _missionDataCache.GetLocationByEid(eid).ThrowIfNull(ErrorCodes.InvalidMissionLocation);
                _missionProcessor.MissionStartFromFieldTerminal(character, location.id, (MissionCategory)category, level);

                scope.Complete();
            }
        }