public override void Accept() { float dist = float.MaxValue; MySpawnPoint closestSpawn = null; foreach (var spawn in MyEntities.GetEntities().OfType <MySpawnPoint>()) { var d = (this.Location.Entity.GetPosition() - spawn.GetPosition()).LengthSquared(); if (d < dist) { dist = d; closestSpawn = spawn; } } // Spawnpoint exists and has templates if (closestSpawn != null && closestSpawn.GetBotTemplates().Any()) { // HACK: This is little hack (manually adding bot to scene), because spawnpoints are broken var template = closestSpawn.GetBotTemplates().First(); killSubmission.Target = (MySmallShipBot)MyEntities.CreateFromObjectBuilderAndAdd("Assassination target", template.m_builder, closestSpawn.WorldMatrix); } base.Accept(); }
void Init() { m_enableBackgroundFade = true; m_size = new Vector2(0.97f, 0.85f); Vector2 controlsOriginLeft = GetControlsOriginLeftFromScreenSize() + new Vector2(0.04f, 0); m_bots = new Dictionary <int, BotTemplate>(); // Add screen title AddCaption(new Vector2(0, 0.028f)); //Faction Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * CONTROLS_DELTA, null, MyTextsWrapperEnum.SetShipFaction, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_selectShipFactionCombobox = new MyGuiControlCombobox(this, (new Vector2(0.31f, 0)) + controlsOriginLeft + 1 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); foreach (MyMwcObjectBuilder_FactionEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_ShipFactionNationalityEnumValues) { MyGuiHelperBase factionNationalityHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipFactionNationality(enumValue); m_selectShipFactionCombobox.AddItem((int)enumValue, null, factionNationalityHelper.Description); } m_selectShipFactionCombobox.SelectItemByKey((int)MyMwcObjectBuilder_FactionEnum.China);//hopefuly china Controls.Add(m_selectShipFactionCombobox); //radius slider Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 2 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Radius, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_radiusSlider = new MyGuiControlSlider(this, (new Vector2(0.25f, 0) + controlsOriginLeft) + 2 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 15, 200, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_radiusSlider.SetNormalizedValue(0.2f); m_radiusSlider.OnChange = OnComponentChange; Controls.Add(m_radiusSlider); Controls.Add(m_radiusLabel = new MyGuiControlLabel(this, new Vector2(m_radiusSlider.GetPosition().X + m_radiusSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 2 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Radius, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //first spawn timer Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.FirstSpawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_firstSpawnTimeSlider = new MyGuiControlSlider(this, (new Vector2(0.25f, 0) + controlsOriginLeft) + 3 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 0, 10 * 60 * 1000, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_firstSpawnTimeSlider.OnChange = OnComponentChange; m_firstSpawnTimeSlider.SetNormalizedValue(0.0f); Controls.Add(m_firstSpawnTimeSlider); Controls.Add(m_firstSpawnLabel = new MyGuiControlLabel(this, new Vector2(m_firstSpawnTimeSlider.GetPosition().X + m_firstSpawnTimeSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //respawn timer Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_respawnTimeSlider = new MyGuiControlSlider(this, controlsOriginLeft + new Vector2(0.25f, 0) + 4 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 0, 10 * 60 * 1000, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_respawnTimeSlider.OnChange = OnComponentChange; m_respawnTimeSlider.SetNormalizedValue(0.0f); Controls.Add(m_respawnTimeSlider); Controls.Add(m_respawnLabel = new MyGuiControlLabel(this, new Vector2(m_respawnTimeSlider.GetPosition().X + m_respawnTimeSlider.GetSize().Value.X / 2 + 0.01f, controlsOriginLeft.Y) + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Respawn, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //waypoints Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.WayPointPath, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_waypointPathCombobox = new MyGuiControlCombobox(this, new Vector2(0.31f, 0) + controlsOriginLeft + 5 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); int k = 0; int selected = 0; m_waypointPathCombobox.AddItem(k++, null, MyTextsWrapper.Get(MyTextsWrapperEnum.None)); foreach (var path in MyWayPointGraph.StoredPaths) { if (HasEntity() && String.Compare(path.Name, m_spawnPoint.GetWaypointPath()) == 0) { selected = k; } m_waypointPathCombobox.AddItem(k++, null, new StringBuilder(path.Name)); } m_waypointPathCombobox.SelectItemByKey(selected);// Controls.Add(m_waypointPathCombobox); // patrol mode Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.PatrolMode, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_patrolModeCombobox = new MyGuiControlCombobox(this, new Vector2(0.31f, 0) + controlsOriginLeft + 6 * CONTROLS_DELTA, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 8); foreach (MyPatrolMode enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_PatrolModes) { MyGuiHelperBase patrolModeHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipPatrolMode(enumValue); m_patrolModeCombobox.AddItem((int)enumValue, null, patrolModeHelper.Description); } m_patrolModeCombobox.SelectItemByKey(HasEntity() ? (int)m_spawnPoint.PatrolMode : 0); Controls.Add(m_patrolModeCombobox); #region Smallship Bots To Spawn //MyGuiControlLabel smallShipLabel = new MyGuiControlLabel(this, controlsOriginLeft + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ChooseModel, MyGuiConstants.LABEL_TEXT_COLOR, // MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); //Controls.Add(smallShipLabel); m_selectShipsListbox = new MyGuiControlListbox(this, controlsOriginLeft + 7 * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LARGE_SIZE.X / 2.0f + MyGuiConstants.LISTBOX_SCROLLBAR_WIDTH / 2.0f, MyGuiConstants.COMBOBOX_LARGE_SIZE.Y * 2.5f), MyGuiConstants.LISTBOX_LONGMEDIUM_SIZE, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, null, MyGuiConstants.LABEL_TEXT_SCALE, 1, 6, 1, false, true, false); //m_selectShipsListbox.ItemSelect = OnItemSelect; m_selectShipsListbox.ItemDoubleClick += OnDoubleClick; Controls.Add(m_selectShipsListbox); Vector2 columnOriginLeft = new Vector2(0.178f, controlsOriginLeft.Y); Vector2 controlsOriginRight = new Vector2(m_size.Value.X / 2.0f - 0.05f, controlsOriginLeft.Y); // Activated Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.Active, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_activeCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + MyGuiConstants.CONTROLS_DELTA - new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f + 0.02f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_activeCheckbox); // Spawn in groups Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + 2 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.SpawnInGroups, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_spawnInGroupsCheckbox = new MyGuiControlCheckbox(this, controlsOriginRight + 2 * MyGuiConstants.CONTROLS_DELTA - new Vector2(MyGuiConstants.CHECKBOX_SIZE.X / 2.0f + 0.02f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_spawnInGroupsCheckbox); Controls.Add(new MyGuiControlLabel(this, columnOriginLeft + 3 * MyGuiConstants.CONTROLS_DELTA, null, MyTextsWrapperEnum.SpawnedBots, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_spawnedBotsTextbox = new MyGuiControlTextbox(this, columnOriginLeft + 4 * MyGuiConstants.CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2 - 0.01f, 0), MyGuiControlPreDefinedSize.MEDIUM, string.Empty, TEXTBOX_NUMBERS_MAX_LENGTH, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.DIGITS_ONLY); Controls.Add(m_spawnedBotsTextbox); #endregion #region Bots Listbox Buttons Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 7 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Add, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnAddClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 8 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Edit, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnEditClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 9 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Inventory, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnInventoryClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 10 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Copy, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDuplicateClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, controlsOriginLeft + 11 * CONTROLS_DELTA + new Vector2(0.77f, -0.005f), MyGuiConstants.PROGRESS_CANCEL_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Delete, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnDeleteClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); #endregion AddOkAndCancelButtonControls(new Vector2(0, -0.038f)); if (HasEntity()) { m_radiusSlider.SetValue(m_spawnPoint.BoundingSphereRadius); m_spawnInGroupsCheckbox.Checked = m_spawnPoint.SpawnInGroups; m_spawnedBotsTextbox.Text = m_spawnPoint.LeftToSpawn >= 0 ? m_spawnPoint.LeftToSpawn.ToString() : string.Empty; m_firstSpawnTimeSlider.SetValue(m_spawnPoint.FirstSpawnTimer); m_respawnTimeSlider.SetValue(m_spawnPoint.RespawnTimer); m_selectShipFactionCombobox.SelectItemByKey((int)m_spawnPoint.Faction); m_bots.Clear(); foreach (BotTemplate bt in m_spawnPoint.GetBotTemplates()) { if (bt.m_builder.ShipTemplateID != null) { AddBot(bt.m_builder, MySmallShipTemplates.GetTemplate(bt.m_builder.ShipTemplateID.Value)); } else { AddBot(bt.m_builder); } } m_activeCheckbox.Checked = m_spawnPoint.IsActive(); } // Just UI update OnComponentChange(null); }