public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D? spawnPosition = null, bool createAlways = false) { AgentDefinition = agentDefinition; SpawnPosition = spawnPosition; CreatedByPlayer = createAlways; BotId = botId; }
private void CurrentToolbar_SlotActivated(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemBot)) BotToSpawn = null; if (!(toolbar.GetItemAtIndex(toolbar.SlotToIndex(args.SlotNumber.Value)) is MyToolbarItemAiCommand)) CommandDefinition = null; }
private void CurrentToolbar_SelectedSlotChanged(MyToolbar toolbar, MyToolbar.SlotArgs args) { if (!(toolbar.SelectedItem is MyToolbarItemBot)) BotToSpawn = null; if (!(toolbar.SelectedItem is MyToolbarItemAiCommand)) CommandDefinition = null; }
public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D?spawnPosition = new Vector3D?(), bool createAlways = false) { this.AgentDefinition = agentDefinition; this.SpawnPosition = spawnPosition; this.CreatedByPlayer = createAlways; this.BotId = botId; }
public int SpawnNewBot(MyAgentDefinition agentDefinition) { Vector3D spawnPosition = default(Vector3D); if (!BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition)) return 0; return SpawnNewBotInternal(agentDefinition, spawnPosition, false); }
private void SpawnBot(SpawnInfo spawnInfo, MyPlanet planet, MyPlanetAnimalSpawnInfo animalSpawnInfo) { PlanetAIInfo planetInfo = null; if (!m_planets.TryGetValue(planet.EntityId, out planetInfo)) { Debug.Assert(false, "Could not get planet info!"); return; } if (planetInfo.BotNumber >= MAX_BOTS_PER_PLANET) { return; } Debug.Assert(animalSpawnInfo != null); double spawnDistMin = animalSpawnInfo.SpawnDistMin; double spawnDistMax = animalSpawnInfo.SpawnDistMax; Vector3D center = spawnInfo.Position; Vector3D planetGravityVec = MyGravityProviderSystem.CalculateNaturalGravityInPoint(center); //GR: if gravity is zero provide a random Vector to normalize if (planetGravityVec == Vector3D.Zero) { planetGravityVec = Vector3D.Up; } planetGravityVec.Normalize(); Vector3D planetTangent = Vector3D.CalculatePerpendicularVector(planetGravityVec); Vector3D planetBitangent = Vector3D.Cross(planetGravityVec, planetTangent); planetTangent.Normalize(); planetBitangent.Normalize(); Vector3D spawnPos = MyUtils.GetRandomDiscPosition(ref center, spawnDistMin, spawnDistMax, ref planetTangent, ref planetBitangent); spawnPos = planet.GetClosestSurfacePointGlobal(ref spawnPos); Vector3D?spawnPosCorrected = MyEntities.FindFreePlace(spawnPos, 2.0f); if (spawnPosCorrected.HasValue) { spawnPos = spawnPosCorrected.Value; } planet.CorrectSpawnLocation(ref spawnPos, 2.0f); MyAgentDefinition botBehavior = GetAnimalDefinition(animalSpawnInfo) as MyAgentDefinition; if (botBehavior != null) { if (botBehavior.Id.SubtypeName == Wolf_SUBTYPE_ID && MySession.Static.EnableWolfs) { MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos); } else if (botBehavior.Id.SubtypeName != Wolf_SUBTYPE_ID && MySession.Static.EnableSpiders) { MyAIComponent.Static.SpawnNewBot(botBehavior, spawnPos); } } }
public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition) { m_player = player; m_navigation = new MyBotNavigation(); m_actionCollection = null; m_botMemory = new MyBotMemory(this); m_botDefinition = botDefinition as MyAgentDefinition; m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged; m_navigation.ChangeEntity(m_player.Controller.ControlledEntity); }
public int ForceSpawnNewBot(MyAgentDefinition agentDefinition, Vector3D?spawnPosition) { //if (!MyAIComponent.Static.CanSpawnMoreBots(agentDefinition.BehaviorType)) //{ // var botHandle = m_botCollection.GetHandleToFirstBot(agentDefinition.BehaviorType); // var player = Sync.Players.TryGetPlayerById(new MyPlayer.PlayerId(MySteam.UserId, botHandle)); // Sync.Players.RemovePlayer(player); //} return(SpawnNewBotInternal(agentDefinition, spawnPosition, true)); }
private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createdByPlayer = false) { var currentHighestBotID = MyAIComponent.GenerateBotId(m_lastSpawnedBot); var newBotId = currentHighestBotID; EnsureIdentityUniqueness(newBotId); m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createdByPlayer); m_lastSpawnedBot = newBotId; Sync.Players.RequestNewPlayer(newBotId, MyDefinitionManager.Static.GetRandomCharacterName(), agentDefinition.BotModel); return(newBotId); }
private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createAlways = false) { var currentHighestBotID = MyAIComponent.GenerateBotId(m_lastSpawnedBot); var newBotId = currentHighestBotID; EnsureIdentityUniqueness(newBotId); m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createAlways); m_lastSpawnedBot = newBotId; Sync.Players.RequestNewPlayer(newBotId, agentDefinition.DisplayNameText, agentDefinition.BotModel); return(newBotId); }
public int SpawnNewBot(MyAgentDefinition agentDefinition) { //if (!MyAIComponent.Static.CanSpawnMoreBots(agentDefinition.BehaviorType)) // return 0; Vector3D spawnPosition = default(Vector3D); if (!BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition)) { return(0); } return(SpawnNewBotInternal(agentDefinition, spawnPosition, false)); }
public MySandboxBot(MyPlayer botPlayer, MyBotDefinition botDefinition) { m_definition = botDefinition as MyAgentDefinition; m_player = botPlayer; m_navigation = new MyBotNavigation(); m_respawnRequestSent = false; m_actionCollection = null; m_botMemory = new MyBotMemory(this); m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged; m_navigation.ChangeEntity(m_player.Controller.ControlledEntity); }
public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition) { this.m_player = player; this.m_navigation = new MyBotNavigation(); this.m_actionCollection = null; this.m_botMemory = new MyBotMemory(this); this.m_botDefinition = botDefinition as MyAgentDefinition; this.m_removeAfterDeath = this.m_botDefinition.RemoveAfterDeath; this.m_respawnRequestSent = false; this.m_botRemoved = false; this.m_player.Controller.ControlledEntityChanged += new Action <IMyControllableEntity, IMyControllableEntity>(this.Controller_ControlledEntityChanged); this.m_navigation.ChangeEntity(this.m_player.Controller.ControlledEntity); MyCestmirDebugInputComponent.PlacedAction += new Action <Vector3D, MyEntity>(this.DebugGoto); }
public MyAgentBot(MyPlayer player, MyBotDefinition botDefinition) { m_player = player; m_navigation = new MyBotNavigation(); m_actionCollection = null; m_botMemory = new MyBotMemory(this); m_botDefinition = botDefinition as MyAgentDefinition; m_removeAfterDeath = m_botDefinition.RemoveAfterDeath; m_respawnRequestSent = false; m_botRemoved = false; m_player.Controller.ControlledEntityChanged += Controller_ControlledEntityChanged; m_navigation.ChangeEntity(m_player.Controller.ControlledEntity); Sandbox.Game.Gui.MyCestmirDebugInputComponent.PlacedAction += DebugGoto; }
private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createdByPlayer = false) { int newBotId = 0; foreach (var player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SteamId == Sync.MyId && player.Id.SerialId > newBotId) { newBotId = player.Id.SerialId; } } newBotId++; m_agentsToSpawn[newBotId] = new AgentSpawnData(agentDefinition, spawnPosition, createdByPlayer); Sync.Players.RequestNewPlayer(newBotId, MyDefinitionManager.Static.GetRandomCharacterName(), agentDefinition.BotModel); return(newBotId); }
private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D? spawnPosition = null, bool createdByPlayer = false) { m_lock.AcquireExclusive(); foreach (var player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SteamId == Sync.MyId && player.Id.SerialId > m_lastBotId) { m_lastBotId = player.Id.SerialId; } } m_lastBotId++; var lastBotId = m_lastBotId; m_lock.ReleaseExclusive(); m_processQueue.Enqueue(new AgentSpawnData(agentDefinition, lastBotId, spawnPosition, createdByPlayer)); return lastBotId; }
private int SpawnNewBotInternal(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = new Vector3D?(), bool createdByPlayer = false) { int lastBotId; using (this.m_lock.AcquireExclusiveUsing()) { foreach (MyPlayer player in Sync.Players.GetOnlinePlayers()) { if (player.Id.SteamId != Sync.MyId) { continue; } if (player.Id.SerialId > this.m_lastBotId) { this.m_lastBotId = player.Id.SerialId; } } this.m_lastBotId++; lastBotId = this.m_lastBotId; } this.m_processQueue.Enqueue(new AgentSpawnData(agentDefinition, lastBotId, spawnPosition, createdByPlayer)); return(lastBotId); }
public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position) { return(SpawnNewBotInternal(agentDefinition, position, true)); }
private void CurrentToolbar_Unselected(MyToolbar toolbar) { BotToSpawn = null; CommandDefinition = null; }
public AgentSpawnData(MyAgentDefinition agentDefinition, Vector3D?spawnPosition = null, bool createAlways = false) { AgentDefinition = agentDefinition; SpawnPosition = spawnPosition; CreateAlways = createAlways; }
public void TrySpawnBot(MyAgentDefinition agentDefinition) { BotToSpawn = agentDefinition; TrySpawnBot(); }
public AgentGroupData(MyAgentDefinition agentDefinition, int count) { AgentDefinition = agentDefinition; Count = count; }
public int SpawnNewBot(MyAgentDefinition agentDefinition) { Vector3D spawnPosition = new Vector3D(); return(BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition) ? this.SpawnNewBotInternal(agentDefinition, new Vector3D?(spawnPosition), false) : 0); }
public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D? spawnPosition) { return SpawnNewBotInternal(agentDefinition, spawnPosition, true); }
public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true) { return SpawnNewBotInternal(agentDefinition, position, createdByPlayer); }
public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true) => this.SpawnNewBotInternal(agentDefinition, new Vector3D?(position), createdByPlayer);
public void TrySpawnBot(MyAgentDefinition agentDefinition) { this.BotToSpawn = agentDefinition; this.TrySpawnBot(); }
public AgentGroupData(MyAgentDefinition agentDefinition, int count) { this.AgentDefinition = agentDefinition; this.Count = count; }