protected override MyMwcObjectBuilder_Base GetObjectBuilderInternal(bool getExactCopy) { MyMwcObjectBuilder_SpawnPoint objectBuilder = (MyMwcObjectBuilder_SpawnPoint)base.GetObjectBuilderInternal(getExactCopy); objectBuilder.SpawnInGroups = SpawnInGroups; objectBuilder.SpawnCount = LeftToSpawn; objectBuilder.FirstSpawnTimer = FirstSpawnTimer; objectBuilder.RespawnTimer = RespawnTimer; objectBuilder.BoundingRadius = BoundingSphereRadius; objectBuilder.ShipTemplates = new List <MyMwcObjectBuilder_SmallShip_Bot>(); objectBuilder.Faction = Faction; objectBuilder.WayPointPath = m_wayPointPath; objectBuilder.Activated = m_spawnActivated; objectBuilder.PatrolMode = PatrolMode; foreach (Bot bot in m_botShips) { if (bot.Builder.Inventory == null) { bot.Builder.Inventory = new MyMwcObjectBuilder_Inventory(new List <MyMwcObjectBuilder_InventoryItem>(), MyInventory.DEFAULT_MAX_ITEMS); } objectBuilder.ShipTemplates.Add(bot.Builder); } return(objectBuilder); }
public override void OnOkClick(MyGuiControlButton sender) { base.OnOkClick(sender); Debug.Assert(m_radiusSlider.GetValue() > 30 || m_bots.Count <= 1, "Spawnpoint radius is too small, you will probably get failed spawn attempts!"); if (!HasEntity()) { MyMwcObjectBuilder_SpawnPoint builder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.SpawnPoint, null) as MyMwcObjectBuilder_SpawnPoint; builder.BoundingRadius = m_radiusSlider.GetValue(); float cameraDistance = builder.BoundingRadius / (float)Math.Sin(MathHelper.ToRadians(MyCamera.FieldOfViewAngle / 2)) * 1.2f; m_spawnPoint = MyEntities.CreateFromObjectBuilderAndAdd(null, builder, Matrix.CreateWorld(MyCamera.Position + cameraDistance * MyCamera.ForwardVector, Vector3.Forward, Vector3.Up)) as MySpawnPoint; } MyMwcObjectBuilder_FactionEnum shipFaction = (MyMwcObjectBuilder_FactionEnum) Enum.ToObject(typeof(MyMwcObjectBuilder_FactionEnum), m_selectShipFactionCombobox.GetSelectedKey()); List <BotTemplate> templates = new List <BotTemplate>(); foreach (int key in m_bots.Keys) { BotTemplate btmp; m_bots.TryGetValue(key, out btmp); btmp.m_builder.Faction = shipFaction; templates.Add(btmp); } m_spawnPoint.SpawnInGroups = m_spawnInGroupsCheckbox.Checked; m_spawnPoint.LeftToSpawn = GetSpawnCount(); m_spawnPoint.MaxSpawnCount = m_spawnPoint.LeftToSpawn; m_spawnPoint.FirstSpawnTimer = m_firstSpawnTimeSlider.GetValue(); m_spawnPoint.RespawnTimer = m_respawnTimeSlider.GetValue(); m_spawnPoint.Faction = shipFaction; m_spawnPoint.SetWayPointPath(m_waypointPathCombobox.GetSelectedValue().ToString()); m_spawnPoint.PatrolMode = (MyPatrolMode)m_patrolModeCombobox.GetSelectedKey(); m_spawnPoint.ApplyBotTemplates(templates); m_spawnPoint.BoundingSphereRadius = m_radiusSlider.GetValue(); if (m_activeCheckbox.Checked && !m_spawnPoint.IsActive()) { m_spawnPoint.Activate(); } else if (!m_activeCheckbox.Checked && m_spawnPoint.IsActive()) { m_spawnPoint.Deactivate(); } MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static); }
public virtual void Init(string hudLabelText, MyMwcObjectBuilder_SpawnPoint objectBuilder, Matrix matrix) { Visible = MyGuiScreenGamePlay.Static == null || !MyGuiScreenGamePlay.Static.IsGameActive(); StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText); base.Init(hudLabelTextSb, objectBuilder); m_botTemplates = new List <BotTemplate>(); CastShadows = false; SpawnInGroups = objectBuilder.SpawnInGroups; LeftToSpawn = objectBuilder.SpawnCount; MaxSpawnCount = LeftToSpawn; FirstSpawnTimer = objectBuilder.FirstSpawnTimer; RespawnTimer = objectBuilder.RespawnTimer; BoundingSphereRadius = objectBuilder.BoundingRadius; PatrolMode = objectBuilder.PatrolMode; m_wayPointPath = objectBuilder.WayPointPath; m_allKilledEventRaised = false; foreach (MyMwcObjectBuilder_SmallShip_Bot shipBuilder in objectBuilder.ShipTemplates) { // Disable names on spawned bots (in this way, thay can be changed when faction changes) shipBuilder.DisplayName = null; Bot nb = new Bot(); nb.Ship = null; nb.Builder = shipBuilder; nb.SpawnTime = MyMinerGame.TotalGamePlayTimeInMilliseconds; nb.FirstSpawned = false; m_botShips.Add(nb); BotTemplate bt = new BotTemplate(); bt.m_builder = shipBuilder; bt.m_name = ""; m_botTemplates.Add(bt); } this.LocalVolume = new BoundingSphere(Vector3.Zero, objectBuilder.BoundingRadius); if (Physics == null) { base.InitSpherePhysics(MyMaterialType.GLASS, WorldMatrix.Translation, BoundingSphereRadius, 1.0f, 1.0f, MyConstants.COLLISION_LAYER_UNCOLLIDABLE, RigidBodyFlag.RBF_RBO_STATIC); } VisibleInGame = false; Flags |= EntityFlags.EditableInEditor; Faction = objectBuilder.Faction; SetWorldMatrix(matrix); NeedsUpdate = true; if (objectBuilder.Activated) { Activate(); } else { Deactivate(); } m_spawnFailedTime = null; }