Ejemplo n.º 1
0
        void DisplayHohmannMode()
        {
            double mySMA  = _currentKE.SemiMajorAxis;
            float  smaMin = 1;
            float  smaMax = (float)OrbitProcessor.GetSOI_m(Entity.GetSOIParentEntity(_orderEntity));

            if (ImGui.Combo("Target Object", ref _selectedSibling, _siblingNames, _siblingNames.Length))
            {
                Entity selectedSib = _siblingEntities[_selectedSibling];
                if (selectedSib.HasDataBlob <OrbitDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <OrbitDB>().SemiMajorAxis;
                }
                if (selectedSib.HasDataBlob <OrbitUpdateOftenDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <OrbitUpdateOftenDB>().SemiMajorAxis;
                }
                if (selectedSib.HasDataBlob <NewtonMoveDB>())
                {
                    _targetSMA = (float)_siblingEntities[_selectedSibling].GetDataBlob <NewtonMoveDB>().GetElements().SemiMajorAxis;
                }
            }

            //TODO this should be radius from orbiting body not major axies.
            ImGui.SliderFloat("Target SemiMajorAxis", ref _targetSMA, smaMin, smaMax);
            var manuvers = InterceptCalcs.Hohmann2(_sgp, mySMA, _targetSMA);



            double totalManuverDV = 0;

            foreach (var manuver in manuvers)
            {
                ImGui.Text(manuver.deltaV.Length() + "Δv");
                totalManuverDV += manuver.deltaV.Length();
            }

            if (totalManuverDV > _totalDV)
            {
                ImGui.TextColored(new Vector4(0.9f, 0, 0, 1), "Total Δv for all manuvers: " + Stringify.Velocity(totalManuverDV));
            }
            else
            {
                ImGui.Text("Total Δv for all manuvers: " + Stringify.Velocity(totalManuverDV));
            }

            if (ImGui.Button("Make it so"))
            {
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, _atDatetime, manuvers[0].deltaV);
                DateTime futureDate = _atDatetime + TimeSpan.FromSeconds(manuvers[1].timeInSeconds);
                NewtonThrustCommand.CreateCommand(_orderEntity.FactionOwner, _orderEntity, futureDate, manuvers[1].deltaV);
            }
        }