public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D? spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition = spawnPosition;
     CreatedByPlayer = createAlways;
     BotId = botId;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void CurrentToolbar_SelectedSlotChanged(MyToolbar toolbar, MyToolbar.SlotArgs args)
 {
     if (!(toolbar.SelectedItem is MyToolbarItemBot))
         BotToSpawn = null;
     if (!(toolbar.SelectedItem is MyToolbarItemAiCommand))
         CommandDefinition = null;
 }
Exemplo n.º 4
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D? spawnPosition)
 {
     return SpawnNewBotInternal(agentDefinition, spawnPosition, true);
 }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        public int SpawnNewBot(MyAgentDefinition agentDefinition)
        {
            Vector3D spawnPosition = default(Vector3D);
            if (!BotFactory.GetBotSpawnPosition(agentDefinition.BehaviorType, out spawnPosition)) 
                return 0;

            return SpawnNewBotInternal(agentDefinition, spawnPosition, false);
        }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
        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);
        }
        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;
        }
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true)
 {
     return SpawnNewBotInternal(agentDefinition, position, createdByPlayer);
 }
Exemplo n.º 11
0
 public void TrySpawnBot(MyAgentDefinition agentDefinition)
 {
     BotToSpawn = agentDefinition;
     TrySpawnBot();
 }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 13
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, Vector3D? spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition = spawnPosition;
     CreateAlways = createAlways;
 }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
 private void CurrentToolbar_Unselected(MyToolbar toolbar)
 {
     BotToSpawn = null;
     CommandDefinition = null;
 }
 public AgentGroupData(MyAgentDefinition agentDefinition, int count)
 {
     AgentDefinition = agentDefinition;
     Count = count;
 }
Exemplo n.º 18
0
        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;
        }
Exemplo n.º 19
0
        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);
        }