Exemple #1
0
        void DisplayPhaseChangeMode()
        {
            ImGui.SliderAngle("PhaseAngle", ref _phaseAngleRadians);

            var manuvers = InterceptCalcs.OrbitPhasingManuvers(_currentKE, _sgp, _atDatetime, _phaseAngleRadians);


            double totalManuverDV = 0;

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

            ImGui.Text("Total Δv");
            ImGui.SameLine();
            ImGui.Text("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);
            }
        }
        internal override void Display()
        {
            if (IsActive)
            {
                if (ImGui.Begin("Cargo", ref IsActive, _flags))
                {
                    if (_hasCargoAbilityLeft)
                    {
                        CargoListLeft.Display();
                        ImGui.SameLine();
                        ImGui.BeginChild("xfer", new System.Numerics.Vector2(100, 200));
                        ImGui.Text("Transfer");

                        if (SelectedCargoPannel != null && SelectedCargoPannel.selectedCargo != null)
                        {
                            if (UnselectedCargoPannel != null && UnselectedCargoPannel.CanStore(SelectedCargoPannel.selectedCargo.CargoTypeID))
                            {
                                if (ImGui.Button("x100"))
                                {
                                    MoveItems(100);
                                }
                                ImGui.SameLine();
                                if (ImGui.Button("x10"))
                                {
                                    MoveItems(10);
                                }
                                ImGui.SameLine();
                                if (ImGui.Button("x1"))
                                {
                                    MoveItems(1);
                                }
                                if (ImGui.Button("Action Order"))
                                {
                                    ActionXferOrder();
                                }
                            }
                            //else
                            //can't transfer due to target unable to store this type
                        }

                        ImGui.EndChild();
                        ImGui.SameLine();
                        if (_hasCargoAbilityRight)
                        {
                            CargoListRight.Display();
                            ImGui.Text("DeltaV Difference: " + Stringify.Velocity(_dvDifference_ms));
                            ImGui.Text("Max DeltaV Difference: " + Stringify.Velocity(_dvMaxRangeDiff_ms));
                            ImGui.Text("Transfer Rate Kg/h: " + _transferRate);
                        }
                        else
                        {
                            ImGui.Text("Select Entity For Transfer");
                        }
                    }
                }
                ImGui.End();
            }
        }
Exemple #3
0
        internal override void Display()
        {
            if (!IsActive)
            {
                return;
            }
            ImGui.SetNextWindowSize(new Vector2(600f, 400f), ImGuiCond.FirstUseEver);
            if (ImGui.Begin("Nav Control", ref IsActive, _flags))
            {
                BorderGroup.Begin("Mode");
                if (ImGui.Button("Manual Thrust"))
                {
                    _navMode = NavMode.Thrust;
                }
                if (ImGui.Button("Hohmann Transfer"))
                {
                    _navMode = NavMode.HohmannTransfer;
                }
                if (ImGui.Button("Phase Change"))
                {
                    _navMode = NavMode.PhaseChange;
                }
                if (ImGui.Button("High Δv Intercept"))
                {
                    _navMode = NavMode.HighDVIntercept;
                }
                if (ImGui.Button("Porkchop Plot"))
                {
                    _navMode = NavMode.PorkChopPlot;
                }
                BorderGroup.End();
                ImGui.NewLine();
                ImGui.Text("Availible Δv: " + Stringify.Velocity(_totalDV));
                switch (_navMode)
                {
                case NavMode.Thrust:
                {
                    DisplayThrustMode();
                    break;
                }

                case NavMode.PhaseChange:
                    DisplayPhaseChangeMode();
                    break;

                case NavMode.HohmannTransfer:
                    DisplayHohmannMode();
                    break;

                case NavMode.None:
                    break;

                default:
                    break;
                }
            }
        }
Exemple #4
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);
            }
        }
        internal override void Display()
        {
            if (IsActive && ImGui.Begin("Ordnance Design"))
            {
                ImGui.Combo("Current Designs", ref _payloadSelectedIndex, _currentDesignNames, _currentDesignNames.Length);

                ImGui.NewLine();
                BorderGroup.BeginBorder("Payload:");
                if (ImGui.Combo("Payload type", ref _payloadSelectedIndex, _payload, _payload.Length))
                {
                    //_selectedPayload = _payloadTypes[_payloadSelectedIndex].GetAttribute<OrdnancePayloadAtb>();
                    _selectedComponentDesigns[_payloadTypes[_payloadSelectedIndex]] = _payloadCount;
                    RefreshMass();
                }
                if (ImGui.SliderInt("Payload Count", ref _payloadCount, 1, 100))
                {
                    _selectedComponentDesigns[_payloadTypes[_payloadSelectedIndex]] = _payloadCount;
                    RefreshMass();
                }
                var whmass = _payloadTypes[_payloadSelectedIndex].Mass * _payloadCount;
                ImGui.Text("Mass: " + Stringify.Mass(whmass));
                //ImGui.Text("Payload Trigger Type: " + _selectedPayload.Trigger);
                BorderGroup.EndBoarder();
                ImGui.NewLine();

                BorderGroup.BeginBorder("Electronics Suite:");
                if (ImGui.Combo("ElectronicsSuite", ref _electronicsSelectedIndex, _electronicsPackage, _electronicsPackage.Length))
                {
                    _selectedComponentDesigns[_eleccPackTypes[_electronicsSelectedIndex]] = 1;
                    RefreshMass();
                }
                var mass = _eleccPackTypes[_electronicsSelectedIndex].Mass;
                ImGui.Text("Mass: " + Stringify.Mass(mass));
                BorderGroup.EndBoarder();

                ImGui.NewLine();

                BorderGroup.BeginBorder("Engine:");

                if (ImGui.Combo("Engine Designs", ref _engineSelectedIndex, _engineDesigns, _engineDesigns.Length))
                {
                    ComponentDesign engineDesign = _engineTypes[_engineSelectedIndex];
                    _selectedComponentDesigns[engineDesign] = _engineCount;
                    RefreshMass();
                }
                if (ImGui.SliderInt("Engine Count", ref _engineCount, 1, 256))
                {
                    _selectedComponentDesigns[_engineTypes[_engineSelectedIndex]] = _engineCount;
                    RefreshMass();
                }
                var emass = _engineTypes[_engineSelectedIndex].Mass * _engineCount;
                ImGui.Text("Mass: " + Stringify.Mass(emass));
                BorderGroup.EndBoarder();

                ImGui.NewLine();
                ImGui.Text("Total Mass: " + Stringify.Mass(_totalMass));
                var enginedesign = _engineTypes[_engineSelectedIndex];
                var atb          = enginedesign.GetAttribute <NewtonionThrustAtb>();

                double burnRate      = atb.FuelBurnRate * _engineCount;
                double exaustVel     = atb.ExhaustVelocity;
                double thrustNewtons = burnRate * exaustVel;
                double burnTime      = _fuelKG / burnRate;
                double dv            = OrbitMath.TsiolkovskyRocketEquation(_totalMass, _totalMass - _fuelKG, exaustVel);
                ImGui.Text("Burn Time: " + burnTime + "s");
                ImGui.Text("Thrust: " + Stringify.Thrust(thrustNewtons));
                ImGui.Text("DeltaV: " + Stringify.Velocity(dv));

                ImGui.InputText("Design Name", _designName, (uint)_designName.Length);
                NewDesignButton();
            }
        }
        internal override void Display()
        {
            if (IsActive && ImGui.Begin("Ordnance Design"))
            {
                ImGui.Combo("Current Designs", ref _payloadSelectedIndex, _currentDesignNames, _currentDesignNames.Length);

                ImGui.NewLine();
                BorderGroup.Begin("Payload:");
                if (ImGui.Combo("Payload type", ref _payloadSelectedIndex, _payload, _payload.Length))
                {
                    //_selectedPayload = _payloadTypes[_payloadSelectedIndex].GetAttribute<OrdnancePayloadAtb>();
                    _selectedComponentDesigns[_payloadTypes[_payloadSelectedIndex]] = _payloadCount;
                    RefreshMass();
                }
                if (ImGui.SliderInt("Payload Count", ref _payloadCount, 1, 100))
                {
                    _selectedComponentDesigns[_payloadTypes[_payloadSelectedIndex]] = _payloadCount;
                    RefreshMass();
                }
                var whmass = _payloadTypes[_payloadSelectedIndex].MassPerUnit * _payloadCount;
                ImGui.Text("Mass: " + Stringify.Mass(whmass));
                //ImGui.Text("Payload Trigger Type: " + _selectedPayload.Trigger);
                BorderGroup.End();
                ImGui.NewLine();

                BorderGroup.Begin("Electronics Suite:");
                if (ImGui.Combo("ElectronicsSuite", ref _electronicsSelectedIndex, _electronicsPackage, _electronicsPackage.Length))
                {
                    _selectedComponentDesigns[_eleccPackTypes[_electronicsSelectedIndex]] = 1;
                    RefreshMass();
                }
                var mass = _eleccPackTypes[_electronicsSelectedIndex].MassPerUnit;
                ImGui.Text("Mass: " + Stringify.Mass(mass));
                BorderGroup.End();

                ImGui.NewLine();

                BorderGroup.Begin("Engine:");

                if (ImGui.Combo("Engine Types", ref _engineDesignTypeIndex, _engineTypeNames, _engineTypeNames.Length))
                {
                    _engineDesigner = new ComponentDesigner(_engineTemplates[_engineDesignTypeIndex], _factionTech);
                    _engineDesigner.SetAttributes();
                }

                if (_engineDesigner != null)
                {
                    PartDesignUI.GuiDesignUI(_engineDesigner);
                    _thrusterSizeKG = _engineDesigner.MassValue;
                    RefreshMass();
                }

                if (ImGui.SliderFloat("Fuel", ref _fuelKG, 1, 1000))
                {
                    RefreshMass();
                }

                BorderGroup.End();

                ImGui.NewLine();
                ImGui.Text("Total Mass: " + Stringify.Mass(_totalMass));

                double burnRate  = 0;
                double exaustVel = 0;

                if (_engineDesigner != null)
                {
                    var atb = _engineDesigner.GetAttribute <NewtonionThrustAtb>();
                    burnRate  = atb.FuelBurnRate;
                    exaustVel = atb.ExhaustVelocity;
                }

                double thrustNewtons = burnRate * exaustVel;
                double burnTime      = _fuelKG / burnRate;
                double dv            = OrbitMath.TsiolkovskyRocketEquation(_totalMass, _totalMass - _fuelKG, exaustVel);
                ImGui.Text("Burn Time: " + burnTime + "s");
                ImGui.Text("Thrust: " + Stringify.Thrust(thrustNewtons));
                ImGui.Text("Acceleration (wet): " + Stringify.Velocity(thrustNewtons / _totalMass));
                ImGui.Text("Acceleration (dry): " + Stringify.Velocity(thrustNewtons / (_totalMass - _fuelKG)));
                ImGui.Text("DeltaV: " + Stringify.Velocity(dv));

                ImGui.InputText("Design Name", _designName, (uint)_designName.Length);
                NewDesignButton();
            }
        }
        public void Display()
        {
            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(260, 200), true);
            ImGui.Text(_entityState.Name);
            ImGui.Text("Transfer Rate: " + _volStorageDB.TransferRateInKgHr);
            ImGui.Text("At DeltaV < " + Stringify.Velocity(_volStorageDB.TransferRangeDv_mps));

            foreach (var typeStore in _stores)
            {
                CargoTypeSD stype        = _staticData.CargoTypes[typeStore.Key];
                var         freeVolume   = typeStore.Value.FreeVolume;
                var         maxVolume    = typeStore.Value.MaxVolume;
                var         storedVolume = maxVolume - freeVolume;

                string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free";
                ImGui.PushID(_entityState.Entity.Guid.ToString());
                if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    ImGui.Columns(3);
                    ImGui.Text("Item");
                    ImGui.NextColumn();
                    ImGui.Text("Count");
                    ImGui.NextColumn();
                    ImGui.Text("Total Mass");
                    ImGui.NextColumn();
                    ImGui.Separator();

                    foreach (var cargoItemKvp in typeStore.Value.CurrentStoreInUnits.ToArray())
                    {
                        ICargoable cargoItem = _stores[typeStore.Key].Cargoables[cargoItemKvp.Key];
                        if (cargoItem == null)
                        {
                            FactionInfoDB factionInfoDB;
                            //factionInfoDB.
                        }

                        var cname         = cargoItem.Name;
                        var unitsStored   = cargoItemKvp.Value;
                        var volumePerItem = cargoItem.VolumePerUnit;
                        var volumeStored  = _volStorageDB.GetVolumeStored(cargoItem);
                        var massStored    = _volStorageDB.GetMassStored(cargoItem);

                        bool isSelected = selectedCargo == cargoItem;
                        if (ImGui.Selectable(cname, isSelected))
                        {
                            selectedCargo = cargoItem;
                            CargoItemSelectedEvent.Invoke(this);
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Number(unitsStored));


                        if (_cargoToMove.ContainsKey(cargoItem))
                        {
                            var    unitsMoving = _cargoToMove[cargoItem];
                            string text        = Stringify.Number(unitsMoving);
                            ImGui.SameLine();

                            float blue = 0f;
                            if (_cargoToMoveDatablob.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveDatablob[cargoItem] != 0)
                                {
                                    blue = 0.25f;
                                }
                            }
                            if (_cargoToMoveOrders.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveOrders[cargoItem] != 0)
                                {
                                    blue = 0.5f;
                                }
                            }
                            if (_cargoToMoveUI.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveUI[cargoItem] != 0)
                                {
                                    blue = 0.75f;
                                }
                            }

                            if (unitsMoving > 0)
                            {
                                ImGui.TextColored(new Vector4(0.5f, 1, blue, 1), text);
                            }
                            else
                            {
                                ImGui.TextColored(new Vector4(1f, 0.5f, blue, 1), text);
                            }
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Mass(massStored));
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
            }


            ImGui.EndChild();
        }