public void TargetObject(IGalaxy galaxy, ISpaceObject target) { if (target != null) { SelectedObject = target; Objects = galaxy.GetSpaceObjectsAt(target.Position).ToArray(); OnChange(); } }
public void Refresh(IGalaxy galaxy) { if (SelectedObject != null) { SelectedObject = galaxy.GetSpaceObject(SelectedObject.ObjectId); Objects = SelectedObject != null ? galaxy.GetSpaceObjectsAt(SelectedObject.Position).ToArray() : null; OnChange(); } }
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(); } }