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(); }
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); }
private void SpawnNewWave(int waveIndex) { if (m_currentWave < m_waves.Count) { m_waveShipCount = 0; foreach (var spawnpointId in m_waves[m_currentWave]) { MyScriptWrapper.ActivateSpawnPoint(spawnpointId); MySpawnPoint spawnpoint = MyScriptWrapper.TryGetEntity(spawnpointId) as MySpawnPoint; if (spawnpoint != null) { m_waveShipCount += spawnpoint.GetShipCount(); } } } }
public override void Load(MyMissionBase sender) { base.Load(sender); m_spawnPoints.Clear(); if (m_spawnPointIDs == null) { //Add all spawnpoints in mission List <uint> list = new List <uint>(); foreach (MyEntity entity in MyEntities.GetEntities()) { MySpawnPoint spawnPoint = entity as MySpawnPoint; if (spawnPoint != null && MyFactions.GetFactionsRelation(MySession.PlayerShip.Faction, spawnPoint.Faction) == MyFactionRelationEnum.Enemy && !m_excludedSpawnPointIDs.Contains(spawnPoint.EntityId.Value.NumericValue)) { list.Add(spawnPoint.EntityId.Value.NumericValue); spawnPoint.OnActivatedChanged += new Action <MySpawnPoint>(spawnPoint_OnActivatedChanged); } } m_spawnPointIDs = list.ToArray(); } foreach (uint spawnPointID in m_spawnPointIDs) { m_spawnPoints.Add(MyEntities.GetEntityById(new MyEntityIdentifier(spawnPointID)) as MySpawnPoint); } MyScriptWrapper.OnSpawnpointBotSpawned += OnSpawnpointBotSpawned; m_currentBotsCount = 0; foreach (MySpawnPoint spawnPoint in m_spawnPoints) { spawnPoint.LeftToSpawn = 0; spawnPoint.FirstSpawnTimer = 0; spawnPoint.RespawnTimer = 0; m_currentBotsCount += spawnPoint.GetShipCount(); spawnPoint.Deactivate(); } UpdateCurrentBotCount(); }
/// <summary> /// Inits destroy counts and hud markers /// </summary> private void Init() { // show asserts for ill defined spawnpoints if (m_toKillSpawnpoints != null) { foreach (var spawnpointId in m_toKillSpawnpoints) { MySpawnPoint spawnpointEntity; if (MyEntities.TryGetEntityById(new MyEntityIdentifier(spawnpointId), out spawnpointEntity)) { Debug.Assert(spawnpointEntity.Activated, "DestroyObjective: spawnpointEntity.Activated == false"); } else { Debug.Assert(spawnpointEntity != null, "DestroyObjective - bad spawnpoint"); } } } m_destroyTotalCount = 0; m_destroyCount = 0; if (m_toKill != null) { foreach (var entityId in m_toKill) { if (!MyScriptWrapper.IsEntityDead(entityId)) { MyEntity entity = MyScriptWrapper.GetEntity(entityId); if (m_showMarks) { MarkAsDestroy(entity); } } else { m_destroyCount++; } m_destroyTotalCount++; } } if (m_toKillSpawnpoints != null) { foreach (var entityId in m_toKillSpawnpoints) { foreach (var bot in MyScriptWrapper.GetSpawnPointBots(entityId)) { if (bot.Ship != null && !bot.Ship.IsDead()) { if (m_showMarks) { MarkAsDestroy(bot.Ship); } } } MySpawnPoint spawnPoint = MyScriptWrapper.GetEntity(entityId) as MySpawnPoint; //int totalForThisSpawnpoint = (spawnPoint.MaxSpawnCount <= 0) ? spawnPoint.GetBots().Count : spawnPoint.MaxSpawnCount; int totalForThisSpawnpoint = spawnPoint.MaxSpawnCount; m_destroyTotalCount += totalForThisSpawnpoint; if (spawnPoint.IsActive()) { int botsToKillCount = spawnPoint.LeftToSpawn + spawnPoint.GetShipCount(); m_destroyCount += totalForThisSpawnpoint - botsToKillCount; } } } }
public MyGuiScreenEditorSpawnPoint(MySpawnPoint spawnPoint) : base(spawnPoint, new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null, MyTextsWrapperEnum.SpawnPoint) { m_spawnPoint = spawnPoint; Init(); }
void spawnPoint_OnActivatedChanged(MySpawnPoint obj) { UpdateCurrentBotCount(); }