Ejemplo n.º 1
0
        private OrbitOrderWindow(EntityState entity, bool smMode = false)
        {
            OrderingEntity = entity;
            _smMode        = smMode;
            IsActive       = true;

            _displayText = "Orbit Order: " + OrderingEntity.Name;
            _tooltipText = "Select target to orbit";
            CurrentState = States.NeedsTarget;

            if (OrderingEntity.Entity.HasDataBlob <OrbitDB>())
            {
                //_orbitWidget = new OrbitOrderWiget(OrderingEntity.Entity.GetDataBlob<OrbitDB>());
                //_state.MapRendering.UIWidgets.Add(_orbitWidget);
                if (_moveWidget == null)
                {
                    _moveWidget = new TranslateMoveOrderWidget(_state, OrderingEntity.Entity);
                    _state.MapRendering.UIWidgets.Add(_moveWidget);
                }
            }

            fsm = new Action[4, 4]
            {
                //selectEntity      selectPos               clickAction     altClick
                { DoNothing, DoNothing, DoNothing, AbortOrder, },                           //needsEntity
                { TargetSelected, DoNothing, DoNothing, GoBackState, },                     //needsTarget
                { DoNothing, InsertionPntSelected, DoNothing, GoBackState, },               //needsApopapsis
                //{DoNothing,         PeriapsisPntSelected,   DoNothing,      GoBackState, }, //needsPeriapsis
                { DoNothing, DoNothing, ActionCmd, GoBackState, }                           //needsActoning
            };
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;
            }
        }