private void OnEditClick(MyGuiControlButton sender) { var selected = m_selectShipsListbox.GetSelectedItem(); if (selected != null) { BotTemplate template = m_bots[selected.Key]; int? selectedIndex = null; var builders = GetTemplatesForCombobox(template.m_builder, out selectedIndex); Debug.Assert(selectedIndex != null, "This shouldn't happen!"); if (selectedIndex == null) { selectedIndex = 0; } MyGuiScreenEditorSmallShip screen = new MyGuiScreenEditorSmallShip(template.m_builder, builders, selectedIndex.Value); screen.OnOk += delegate { if (template.m_builder.ShipTemplateID != null) { OnEditBot(template.m_builder, MySmallShipTemplates.GetTemplate(template.m_builder.ShipTemplateID.Value)); } else { OnEditBot(template.m_builder); } }; MyGuiManager.AddScreen(screen); } }
private void AddBot(int key, BotTemplate btmp) { String bld = GenerateNameFromBotTemplate(btmp); m_bots[key] = btmp; m_selectShipsListbox.AddItem(key, new StringBuilder(bld), null); }
private void Button_Save(object sender, RoutedEventArgs e) { BotTemplate.containerID = this.SelectedInv.definition; BotTemplate.robotID = this.SelectedBot.definition; BotTemplate.chassisID = this.SelectedChassis.definition; BotTemplate.headID = this.SelectedHead.definition; BotTemplate.legID = this.SelectedLeg.definition; RTemplate.description = BotTemplate.ToGenXY(); try { StringBuilder sb = new StringBuilder(); sb.AppendLine(RTemplate.SaveNewBotTemplate()); File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\" + RTemplate.name + Utilities.timestamp() + ".sql", sb.ToString()); MessageBox.Show("New RobotTemplate Saved!!", "Info", 0, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("Error Saving!" + ex.Message, "Error", 0, MessageBoxImage.Error); return; } this.DialogResult = true; this.Hide(); }
private void AddBot(MyMwcObjectBuilder_SmallShip bldr) { BotTemplate newTemplate = new BotTemplate(); MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot; System.Diagnostics.Debug.Assert(botBuilder != null); newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot( bldr.ShipType, bldr.Inventory, bldr.Weapons, bldr.Engine, bldr.AssignmentOfAmmo, bldr.Armor, bldr.Radar, bldr.ShipMaxHealth, bldr.ShipHealthRatio, bldr.ArmorHealth, bldr.Oxygen, bldr.Fuel, bldr.ReflectorLight, bldr.ReflectorLongRange, bldr.Faction, botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT, botBuilder != null ? botBuilder.Aggressivity : 0, botBuilder != null ? botBuilder.SeeDistance : 1000, botBuilder != null ? botBuilder.SleepDistance : 1000, MyPatrolMode.CYCLE, null, BotBehaviorType.IDLE, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType); //m_comboItems.AddItem(i, MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, bldr.ShipType); // MyMwcObjectBuilderTypeEnum.SmallShip, (int)m_inventory.SmallShips[i]).Description); newTemplate.m_name = ((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType)).Name.ToString();//bldr.ShipType.ToString(); // find nearest new non template index int index = -1; foreach (int key in m_bots.Keys) { if (index < key && key < TEMPLATE_INDEX_OFFSET) { index = key; } } index++; AddBot(index, newTemplate); }
private void AddBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate) { BotTemplate newTemplate = new BotTemplate(); MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot; newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot( smallShipTemplate.Builder.ShipType, null, null, null, smallShipTemplate.Builder.AssignmentOfAmmo, null, null, smallShipTemplate.Builder.ShipMaxHealth, smallShipTemplate.Builder.ShipHealthRatio, smallShipTemplate.Builder.ArmorHealth, smallShipTemplate.Builder.Oxygen, smallShipTemplate.Builder.Fuel, smallShipTemplate.Builder.ReflectorLight, smallShipTemplate.Builder.ReflectorLongRange, smallShipTemplate.Builder.Faction, botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT, botBuilder != null ? botBuilder.Aggressivity : 0, botBuilder != null ? botBuilder.SeeDistance : 1000, botBuilder != null ? botBuilder.SleepDistance : 1000, MyPatrolMode.CYCLE, null, BotBehaviorType.IDLE, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID; newTemplate.m_name = smallShipTemplate.Name.ToString(); // find nearest new non template index int index = -1; foreach (int key in m_bots.Keys) { if (index < key && key < TEMPLATE_INDEX_OFFSET) { index = key; } } index++; AddBot(index, newTemplate); }
private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr) { BotTemplate newTemplate = new BotTemplate(); MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot; System.Diagnostics.Debug.Assert(botBuilder != null); newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot( bldr.ShipType, bldr.Inventory, bldr.Weapons, bldr.Engine, bldr.AssignmentOfAmmo, bldr.Armor, bldr.Radar, bldr.ShipMaxHealth, bldr.ShipHealthRatio, bldr.ArmorHealth, bldr.Oxygen, bldr.Fuel, bldr.ReflectorLight, bldr.ReflectorLongRange, bldr.Faction, botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT, botBuilder != null ? botBuilder.Aggressivity : 0, botBuilder != null ? botBuilder.SeeDistance : 1000, botBuilder != null ? botBuilder.SleepDistance : 1000, MyPatrolMode.CYCLE, null, BotBehaviorType.IDLE, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation newTemplate.m_name = bldr.ShipType.ToString(); int key = m_selectShipsListbox.GetSelectedItem().Key; m_selectShipsListbox.RemoveItem(key); var itemName = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)newTemplate.m_builder.ShipType).Description; m_selectShipsListbox.AddItem(key, itemName); m_bots[key] = newTemplate; }
private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate) { BotTemplate newTemplate = new BotTemplate(); MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot; newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot( smallShipTemplate.Builder.ShipType, null, null, null, smallShipTemplate.Builder.AssignmentOfAmmo, null, null, smallShipTemplate.Builder.ShipMaxHealth, smallShipTemplate.Builder.ShipHealthRatio, smallShipTemplate.Builder.ArmorHealth, smallShipTemplate.Builder.Oxygen, smallShipTemplate.Builder.Fuel, smallShipTemplate.Builder.ReflectorLight, smallShipTemplate.Builder.ReflectorLongRange, smallShipTemplate.Builder.Faction, botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT, botBuilder != null ? botBuilder.Aggressivity : 0, botBuilder != null ? botBuilder.SeeDistance : 1000, botBuilder != null ? botBuilder.SleepDistance : 1000, MyPatrolMode.CYCLE, null, BotBehaviorType.IDLE, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID; newTemplate.m_name = smallShipTemplate.Name.ToString(); int key = m_selectShipsListbox.GetSelectedItem().Key; m_selectShipsListbox.RemoveItem(key); m_selectShipsListbox.AddItem(key, smallShipTemplate.Name); m_bots[key] = newTemplate; }
private void OnInventoryClick(MyGuiControlButton sender) { var selected = m_selectShipsListbox.GetSelectedItem(); if (selected != null) { BotTemplate template = m_bots[selected.Key]; int? selectedIndex = null; var builders = GetTemplatesForCombobox(template.m_builder, out selectedIndex); Debug.Assert(selectedIndex != null, "This shouldn't happen!"); if (selectedIndex == null) { selectedIndex = 0; } MyInventory inventory = new MyInventory(); inventory.FillInventoryWithAllItems(null, 100); MyGuiScreenInventory inventoryScreen = new MyGuiScreenInventory(builders, selectedIndex.Value, inventory.GetObjectBuilder(false), null, true); inventoryScreen.OnSave += OnEditBotFromScreen; MyGuiManager.AddScreen(inventoryScreen); } }
private String GenerateNameFromBotTemplate(BotTemplate btmp) { return(btmp.m_name + " " /* + btmp.m_minCount.ToString() + " - " + btmp.m_maxCount.ToString()*/); }