Пример #1
0
        void TargetSelected()
        {
            TargetEntity = _state.LastClickedEntity;

            _state.Camera.PinToEntity(TargetEntity.Entity);

            var soiWorldRad_AU = GMath.GetSOI(TargetEntity.Entity);

            _apMax = soiWorldRad_AU;

            float soiViewUnits = _state.Camera.ViewDistance(soiWorldRad_AU);

            ImVec2 viewPortSize = _state.Camera.ViewPortSize;
            float  windowLen    = Math.Min(viewPortSize.x, viewPortSize.y);

            if (soiViewUnits < windowLen * 0.5)
            {
                //zoom so soi fills ~3/4 screen.
                var soilenwanted = windowLen * 0.375;
                _state.Camera.ZoomLevel = (float)(soilenwanted / _apMax);
            }


            if (_orbitWidget != null)
            {
                int index = _state.MapRendering.UIWidgets.IndexOf(_orbitWidget);
                _orbitWidget = new OrbitOrderWiget(TargetEntity.Entity);
                if (index != -1)
                {
                    _state.MapRendering.UIWidgets[index] = _orbitWidget;
                }
                else
                {
                    _state.MapRendering.UIWidgets.Add(_orbitWidget);
                }
            }
            else
            {
                _orbitWidget = new OrbitOrderWiget(TargetEntity.Entity);
                _state.MapRendering.UIWidgets.Add(_orbitWidget);
            }
            if (_moveWidget == null)
            {
                _moveWidget = new TranslateMoveOrderWidget(_state, OrderingEntity.Entity);
                _state.MapRendering.UIWidgets.Add(_moveWidget);
            }

            _moveWidget.SetArrivalTarget(TargetEntity.Entity);

            _targetRadius = TargetEntity.Entity.GetDataBlob <MassVolumeDB>().RadiusInKM;
            //_intercept = InterceptCalcs.FTLIntercept(OrderingEntity.Entity, TargetEntity.Entity.GetDataBlob<OrbitDB>(), TargetEntity.Entity.Manager.ManagerSubpulses.SystemLocalDateTime);
            //_intercept = InterceptCalcs.GetInterceptPosition(OrderingEntity.Entity, TargetEntity.Entity.GetDataBlob<OrbitDB>(), _state.CurrentSystemDateTime);
            _tooltipText = "Select Insertion Point";
            CurrentState = States.NeedsInsertionPoint;
        }
Пример #2
0
        void CloseWindow()
        {
            IsActive     = false;
            CurrentState = States.NeedsEntity;


            if (_orbitWidget != null)
            {
                _state.MapRendering.UIWidgets.Remove(_orbitWidget);
                _orbitWidget = null;
            }
            if (_moveWidget != null)
            {
                _state.MapRendering.UIWidgets.Remove(_moveWidget);
                _moveWidget = null;
            }
        }