示例#1
0
        public void TargetObject(IGalaxy galaxy, ISpaceObject target)
        {
            if (target != null)
            {
                SelectedObject = target;
                Objects        = galaxy.GetSpaceObjectsAt(target.Position).ToArray();

                OnChange();
            }
        }
示例#2
0
        public void Refresh(IGalaxy galaxy)
        {
            if (SelectedObject != null)
            {
                SelectedObject = galaxy.GetSpaceObject(SelectedObject.ObjectId);

                Objects = SelectedObject != null
                                        ? galaxy.GetSpaceObjectsAt(SelectedObject.Position).ToArray()
                                        : null;

                OnChange();
            }
        }
示例#3
0
        public void TargetObject(IGalaxy galaxy, Position pos)
        {
            var previous = SelectedObject;
            var target   = galaxy.ClosestSpaceObject(pos);

            if (target != null)
            {
                SelectedObject = target;
                Objects        = galaxy.GetSpaceObjectsAt(target.Position).ToArray();

                if (previous?.Position == target.Position)
                {
                    SelectedObject = Objects
                                     .SkipWhile(obj => obj.ObjectId != previous.ObjectId)
                                     .Skip(1)
                                     .FirstOrDefault();
                }

                OnChange();
            }
        }