public void HandleRequest(IZoneRequest request)
        {
            var teleportEid = request.Data.GetOrDefault <long>(k.eid);
            var teleport    = _zoneManager.GetUnit <Teleport>(teleportEid);

            if (teleport == null)
            {
                throw new PerpetuumException(ErrorCodes.TeleportNotFound);
            }

            //Check if mobile -- Throw if character is not owner, or in owner's gang
            if (teleport is MobileTeleport mobile)
            {
                var character      = request.Session.Character;
                var ownerCharacter = mobile.GetOwnerAsCharacter();
                if (character != ownerCharacter)
                {
                    var playerGang = character.GetGang();
                    playerGang.ThrowIfNull(ErrorCodes.CharacterNotInGang);
                    playerGang.IsMember(ownerCharacter).ThrowIfFalse(ErrorCodes.CharacterNotInTheOwnerGang);
                }
            }

            var result = teleport.ToDictionary();

            Message.Builder.FromRequest(request).WithData(result).WrapToResult().Send();
        }
Exemple #2
0
        public void HandleRequest(IRequest request)
        {
            var targetEid = request.Data.GetOrDefault(k.target, 0L);
            var unit      = _zoneManager.GetUnit <Unit>(targetEid);

            unit?.RemoveFromZone();
            Message.Builder.FromRequest(request).WithOk().Send();
        }
Exemple #3
0
        public void HandleRequest(IRequest request)
        {
            var eid  = request.Data.GetOrDefault <long>(k.eid);
            var unit = _zoneManager.GetUnit <Unit>(eid);

            if (unit == null)
            {
                throw new PerpetuumException(ErrorCodes.ItemNotFound);
            }

            unit.Zone.DrawEnvironmentByUnit(unit);

            Message.Builder.FromRequest(request).WithOk().Send();
        }
        public void HandleRequest(IZoneRequest request)
        {
            var teleportEid = request.Data.GetOrDefault <long>(k.eid);
            var teleport    = _zoneManager.GetUnit <Teleport>(teleportEid);

            if (teleport == null)
            {
                throw new PerpetuumException(ErrorCodes.TeleportNotFound);
            }

            var result = teleport.ToDictionary();

            Message.Builder.FromRequest(request).WithData(result).WrapToResult().Send();
        }
        public T GetUnit <T>(long unitEid) where T : Unit
        {
            if (unitEid == 0)
            {
                return(null);
            }

            var unit = _zoneManager.GetUnit <T>(unitEid);

            if (unit == null)
            {
                Logger.DebugWarning($"{typeof(T).Name} not found on zone! eid:{unitEid}");
            }

            return(unit);
        }
Exemple #6
0
        public void HandleRequest(IRequest request)
        {
            var targetEid = request.Data.GetOrDefault <long>(k.targetEID);
            var unit      = _zoneManager.GetUnit <Unit>(targetEid);

            if (unit == null)
            {
                throw new PerpetuumException(ErrorCodes.ItemNotFound);
            }

            var info = new Dictionary <string, object>
            {
                { "targetEID", unit.Eid },
                { k.data, unit.GetDebugInfo() }
            };

            Message.Builder.FromRequest(request).WithData(info).Send();
        }
        public void HandleRequest(IRequest request)
        {
            IEnumerable <Entity> children;

            if (request.Data.ContainsKey(k.all))
            {
                children = _zoneManager.Zones.GetUnits <DockingBase>().SelectMany(b => b.Children);
            }
            else
            {
                var eid = request.Data.GetOrDefault <long>(k.baseEID);
                children = _zoneManager.GetUnit <DockingBase>(eid)?.Children ?? Enumerable.Empty <Entity>();
            }

            var childrenInfos = children.ToDictionary("i", child =>
            {
                switch (child)
                {
                case Market market:
                    {
                        return(market.ToDictionary());
                    }

                default:
                    {
                        return(new Dictionary <string, object>(3)
                        {
                            [k.eid] = child.Eid,
                            [k.definition] = child.Definition,
                            [k.parent] = child.Parent
                        });
                    }
                }
            });

            Message.Builder.FromRequest(request).SetData(k.items, childrenInfos).Send();
        }