예제 #1
0
        internal void NewDesignButton()
        {
            if (ImGui.Button("Create Design"))
            {
                int version = 0;
                var strName = ImGuiSDL2CSHelper.StringFromBytes(_designName);
                foreach (var design in _currentDesigns)
                {
                    if (design.Name == strName)
                    {
                        if (design.DesignVersion >= version)
                        {
                            version = design.DesignVersion + 1;
                        }
                    }
                }


                List <(ComponentDesign, int)> misslcomponents = new List <(ComponentDesign, int)>();
                foreach (var kvp in _selectedComponentDesigns)
                {
                    misslcomponents.Add((kvp.Key, kvp.Value));
                }
                OrdnanceDesign missileDesign = new OrdnanceDesign(_uiState.Faction.GetDataBlob <FactionInfoDB>(), strName, misslcomponents);
                //missileDesign.DesignVersion = version;
            }
        }
예제 #2
0
        public static OrdnanceDesign MissileDesign250(Game game, Entity faction)
        {
            var factionInfo = faction.GetDataBlob <FactionInfoDB>();

            List <(ComponentDesign, int)> components = new List <(ComponentDesign, int)>()
            {
                (DefaultFragPayload(game, faction), 1),
                (DefaultMissileSensors(game, faction), 1),
                (DefaultMissileSRB(game, faction), 1),
            };
            var design = new OrdnanceDesign(factionInfo, "Missile250", components);

            return(design);
        }
예제 #3
0
        internal override bool IsValidCommand(Game game)
        {
            if (CommandHelpers.IsCommandValid(game.GlobalManager, RequestingFactionGuid, EntityCommandingGuid, out _factionEntity, out _entityCommanding))
            {
                var instancesdb = _entityCommanding.GetDataBlob <ComponentInstancesDB>();

                if (instancesdb.AllComponents.TryGetValue(WeaponGuid, out ComponentInstance wpn))
                {
                    _ordnanceAssigned = _factionEntity.GetDataBlob <FactionInfoDB>().MissileDesigns[OrdnanceAssigned];
                    if (wpn.TryGetAbilityState(out WeaponState wpnState))
                    {
                        _weaponInstance = wpn;
                        return(wpnState.FireWeaponInstructions.CanLoadOrdnance(_ordnanceAssigned));
                    }
                }
            }
            return(false);
        }
예제 #4
0
        public static OrdnanceDesign MissileDesign250(Game game, Entity faction)
        {
            if (_missile != null)
            {
                return(_missile);
            }
            var factionInfo = faction.GetDataBlob <FactionInfoDB>();

            List <(ComponentDesign, int)> components = new List <(ComponentDesign, int)>()
            {
                (DefaultFragPayload(game, faction), 1),
                (DefaultMissileSensors(game, faction), 1),
                (DefaultMissileSRB(game, faction), 1),
            };
            double fuelkg = 225;

            _missile = new OrdnanceDesign(factionInfo, "Missile250", fuelkg, components);
            return(_missile);
        }
예제 #5
0
        static void GuiHintOrdnanceSelection(ComponentDesignAttribute attribute)
        {
            var dict = _state.Faction.GetDataBlob <FactionInfoDB>().MissileDesigns;

            _listNames = new string[dict.Count];
            OrdnanceDesign[] ordnances = new OrdnanceDesign[dict.Count];
            int i = 0;

            foreach (var kvp in dict)
            {
                _listNames[i] = kvp.Value.Name;
                ordnances[i]  = kvp.Value;
            }



            if (compactmod)
            {
                ImGui.TextWrapped(attribute.Name + ": " + attribute.Description);
                ImGui.NewLine();
            }
            else
            {
                ImGui.TextWrapped(attribute.Name + ":");
                ImGui.SameLine();
                ImGui.TextWrapped(attribute.Description);
                ImGui.NewLine();
            }


            ImGui.TextWrapped(attribute.Value.ToString());

            if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, _listNames.Length))
            {
                attribute.SetValueFromComponentList(ordnances[attribute.ListSelection].ID);
            }

            ImGui.NewLine();
        }
예제 #6
0
        internal void NewDesignButton()
        {
            if (ImGui.Button("Create Design") && _engineDesigner != null)
            {
                int version = 0;
                var strName = ImGuiSDL2CSHelper.StringFromBytes(_designName);
                foreach (var design in _currentDesigns)
                {
                    if (design.Name == strName)
                    {
                        if (design.DesignVersion >= version)
                        {
                            version = design.DesignVersion + 1;
                        }
                    }
                }


                List <(ComponentDesign, int)> misslcomponents = new List <(ComponentDesign, int)>();
                foreach (var kvp in _selectedComponentDesigns)
                {
                    misslcomponents.Add((kvp.Key, kvp.Value));
                }


                var atb = _engineDesigner.GetAttribute <NewtonionThrustAtb>();

                double burnRate      = atb.FuelBurnRate;
                double exaustVel     = atb.ExhaustVelocity;
                double thrustNewtons = burnRate * exaustVel;
                _engineDesigner.Name = "MissileEngine" + _engineDesigner.MassValue + "," + thrustNewtons;
                var engineDesign = _engineDesigner.CreateDesign(_faction);
                misslcomponents.Add((engineDesign, 1));
                OrdnanceDesign missileDesign = new OrdnanceDesign(_uiState.Faction.GetDataBlob <FactionInfoDB>(), strName, _fuelKG, misslcomponents);
                //missileDesign.DesignVersion = version;
            }
        }
예제 #7
0
 public bool TryGetOrdnance(out OrdnanceDesign ordnanceDesign)
 {
     ordnanceDesign = null;
     return(false);
 }
예제 #8
0
 public bool AssignOrdnance(OrdnanceDesign ordnanceDesign)
 {
     return(false);
 }
예제 #9
0
 public bool CanLoadOrdnance(OrdnanceDesign ordnanceDesign)
 {
     return(false);
 }
예제 #10
0
        internal override void Display()
        {
            if (IsActive && ImGui.Begin(_windowname, ref IsActive, _flags))
            {
                GuiDesignUI(); //Part design

                GuiCostText(); //Print cost
                ImGui.End();
            }

            void GuiDesignUI()//Creates all UI elements need for designing the Component
            {
                ImGui.Text("Component Specifications");
                ImGui.SameLine(ImGui.GetWindowWidth() - 70);
                if (ImGui.Button("Compact"))
                {
                    compactmod = !compactmod;
                }


                ImGui.NewLine();

                if (_componentDesigner != null)                                                                         //Make sure comp is selected
                {
                    foreach (ComponentDesignAttribute attribute in _componentDesigner.ComponentDesignAttributes.Values) //For each property of the comp type
                    {
                        ImGui.PushID(attribute.Name);


                        if (attribute.IsEnabled)
                        {
                            switch (attribute.GuiHint) //Either
                            {
                            case GuiHint.None:
                                break;

                            case GuiHint.GuiTechSelectionList:     //Let the user pick a type from a list
                                GuiHintTechSelection(attribute);
                                break;

                            case GuiHint.GuiSelectionMaxMin:     //Set a value
                                GuiHintMaxMin(attribute);
                                break;

                            case GuiHint.GuiTextDisplay:     //Display a stat
                                GuiHintText(attribute);
                                break;

                            case GuiHint.GuiEnumSelectionList:     //Let the user pick a type from a hard coded list
                                GuiHintEnumSelection(attribute);
                                break;

                            case GuiHint.GuiOrdnanceSelectionList:
                                GuiHintOrdnanceSelection(attribute);
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }

                        ImGui.PopID();
                    }



                    ImGui.Text("Name");
                    ImGui.InputText("", _nameInputBuffer, 32);
                    if (ImGui.Button("Create Design"))
                    {
                        _componentDesigner.Name = ImGuiSDL2CSHelper.StringFromBytes(_nameInputBuffer);
                        _componentDesigner.CreateDesign(_state.Faction);
                        //we reset the designer here, so we don't end up trying to edit the precious design.
                        var factionTech = _state.Faction.GetDataBlob <FactionTechDB>();
                        _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech);
                    }
                    ImGui.NewLine();
                }
                else//Tell the user they don't have a comp type selected
                {
                    ImGui.NewLine();
                    ImGui.Text("No component type selected");
                    ImGui.NewLine();
                }
            }

            void GuiCostText()//Prints a 2 col table with the costs of the part
            {
                //ImGui.BeginChild("Cost");
                if (_componentDesigner != null)//If a part time is selected
                {
                    ImGui.Columns(2);
                    ImGui.BeginTabItem("Cost");

                    ImGui.Text("Mass");
                    ImGui.Text("Volume_km3");
                    ImGui.Text("Crew Requred");
                    ImGui.Text("Cost");
                    ImGui.Text("Research Cost");
                    ImGui.Text("Build Cost");
                    ImGui.Text("Resource Costs");
                    ImGui.NextColumn();//Add all the cost names to col 1


                    ImGui.Text(Stringify.Mass(_componentDesigner.MassValue));
                    ImGui.Text(Stringify.Volume(_componentDesigner.VolumeM3Value));
                    ImGui.Text(_componentDesigner.CrewReqValue.ToString());
                    ImGui.Text(_componentDesigner.CreditCostValue.ToString());
                    ImGui.Text(_componentDesigner.ResearchCostValue.ToString() + " RP");
                    ImGui.Text(_componentDesigner.IndustryPointCostsValue.ToString() + " BP");
                    ImGui.NextColumn();//Add all the price values to col 2


                    foreach (var kvp in _componentDesigner.ResourceCostValues)
                    {
                        var resource = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key);
                        if (resource == null)
                        {
                            resource = (ICargoable)_state.Faction.GetDataBlob <FactionInfoDB>().IndustryDesigns[kvp.Key];
                        }
                        var xpos = ImGui.GetCursorPosX();
                        ImGui.SetCursorPosX(xpos + 12);
                        ImGui.Text(resource.Name);
                        ImGui.NextColumn();
                        ImGui.Text(kvp.Value.ToString());
                        ImGui.NextColumn();
                    }
                }

                //ImGui.EndChild();
            }

            void GuiHintText(ComponentDesignAttribute attribute)
            {
                if (compactmod)
                {
                    ImGui.TextWrapped(attribute.Name + ": " + attribute.Value.ToString() + " " + attribute.Unit);
                    ImGui.NewLine();
                }
                else
                {
                    ImGui.TextWrapped(attribute.Name + ":");
                    ImGui.SameLine();
                    ImGui.TextWrapped(attribute.Value.ToString() + " " + attribute.Unit);
                    ImGui.NewLine();
                }
            }

            void GuiHintMaxMin(ComponentDesignAttribute attribute)
            {
                if (compactmod)
                {
                    ImGui.TextWrapped(attribute.Name + ": " + attribute.Description);
                    ImGui.NewLine();
                }
                else
                {
                    ImGui.TextWrapped(attribute.Name + ":");
                    ImGui.SameLine();
                    ImGui.TextWrapped(attribute.Description);
                    ImGui.NewLine();
                }

                attribute.SetMax();
                attribute.SetMin();
                attribute.SetValue();
                attribute.SetStep();

                var    max   = attribute.MaxValue;
                var    min   = attribute.MinValue;
                double val   = attribute.Value;
                double step  = attribute.StepValue;
                double fstep = step * 10;
                IntPtr valPtr;
                IntPtr maxPtr;
                IntPtr minPtr;
                IntPtr stepPtr;
                IntPtr fstepPtr;

                unsafe
                {
                    valPtr   = new IntPtr(&val);
                    maxPtr   = new IntPtr(&max);
                    minPtr   = new IntPtr(&min);
                    stepPtr  = new IntPtr(&step);
                    fstepPtr = new IntPtr(&fstep);
                }
                //ImGui.DragScalar("##slider" + attribute.Name, ImGuiDataType.Double, valPtr, 1f, minPtr, maxPtr);


                if (compactmod)
                {
                }
                else
                {
                    ImGui.PushItemWidth(-1);
                    if (ImGui.SliderScalar("##scaler" + attribute.Name, ImGuiDataType.Double, valPtr, minPtr, maxPtr))
                    {
                        attribute.SetValueFromInput(val);
                    }
                }
                ImGui.PushItemWidth(-1);
                if (ImGui.InputScalar("##input" + attribute.Name, ImGuiDataType.Double, valPtr, stepPtr, fstepPtr))
                {
                    attribute.SetValueFromInput(val);
                }
                ImGui.NewLine();
            }

            void GuiHintTechSelection(ComponentDesignAttribute attribute)
            {
                if (compactmod)
                {
                    ImGui.TextWrapped(attribute.Name + ": " + attribute.Description);
                    ImGui.NewLine();
                }
                else
                {
                    ImGui.TextWrapped(attribute.Name + ":");
                    ImGui.SameLine();
                    ImGui.TextWrapped(attribute.Description);
                    ImGui.NewLine();
                }

                int i = 0;

                _techSDs   = new TechSD[attribute.GuidDictionary.Count];
                _techNames = new string[attribute.GuidDictionary.Count];
                foreach (var kvp in attribute.GuidDictionary)
                {
                    TechSD sd = StaticRefLib.StaticData.Techs[Guid.Parse((string)kvp.Key)];
                    _techSDs[i]   = sd;
                    _techNames[i] = sd.Name;
                    i++;
                }

                ImGui.TextWrapped(attribute.Value.ToString());



                if (ImGui.Combo("Select Tech", ref _techSelectedIndex, _techNames, _techNames.Length))
                {
                    attribute.SetValueFromGuidList(_techSDs[_techSelectedIndex].ID);
                }

                ImGui.NewLine();
            }

            void GuiHintEnumSelection(ComponentDesignAttribute attribute)
            {
                if (compactmod)
                {
                    ImGui.TextWrapped(attribute.Name + ": " + attribute.Description);
                    ImGui.NewLine();
                }
                else
                {
                    ImGui.TextWrapped(attribute.Name + ":");
                    ImGui.SameLine();
                    ImGui.TextWrapped(attribute.Description);
                    ImGui.NewLine();
                }


                int i = 0;

                //_techSDs = new TechSD[attribute.GuidDictionary.Count];
                _listNames = Enum.GetNames(attribute.EnumType);


                ImGui.TextWrapped(attribute.Value.ToString());

                if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, (int)attribute.MaxValue + 1))
                {
                    int enumVal = (int)Enum.Parse(attribute.EnumType, _listNames[attribute.ListSelection]);
                    attribute.SetValueFromInput(enumVal);
                }

                ImGui.NewLine();
            }

            void GuiHintOrdnanceSelection(ComponentDesignAttribute attribute)
            {
                var dict = _state.Faction.GetDataBlob <FactionInfoDB>().MissileDesigns;

                _listNames = new string[dict.Count];
                OrdnanceDesign[] ordnances = new OrdnanceDesign[dict.Count];
                int i = 0;

                foreach (var kvp in dict)
                {
                    _listNames[i] = kvp.Value.Name;
                    ordnances[i]  = kvp.Value;
                }



                if (compactmod)
                {
                    ImGui.TextWrapped(attribute.Name + ": " + attribute.Description);
                    ImGui.NewLine();
                }
                else
                {
                    ImGui.TextWrapped(attribute.Name + ":");
                    ImGui.SameLine();
                    ImGui.TextWrapped(attribute.Description);
                    ImGui.NewLine();
                }


                ImGui.TextWrapped(attribute.Value.ToString());

                if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, _listNames.Length))
                {
                    attribute.SetValueFromComponentList(ordnances[attribute.ListSelection].ID);
                }

                ImGui.NewLine();
            }
        }