コード例 #1
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, int botId, Vector3D? spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition = spawnPosition;
     CreatedByPlayer = createAlways;
     BotId = botId;
 }
コード例 #2
0
ファイル: MySandboxBot.cs プロジェクト: fluxit/SpaceEngineers
        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);
        }
コード例 #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;
 }
コード例 #4
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D? spawnPosition)
 {
     return SpawnNewBotInternal(agentDefinition, spawnPosition, true);
 }
コード例 #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;
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #8
0
ファイル: MyAgentBot.cs プロジェクト: Krulac/SpaceEngineers
        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);
        }
コード例 #9
0
        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;
        }
コード例 #10
0
 public int SpawnNewBot(MyAgentDefinition agentDefinition, Vector3D position, bool createdByPlayer = true)
 {
     return SpawnNewBotInternal(agentDefinition, position, createdByPlayer);
 }
コード例 #11
0
 public void TrySpawnBot(MyAgentDefinition agentDefinition)
 {
     BotToSpawn = agentDefinition;
     TrySpawnBot();
 }
コード例 #12
0
ファイル: MyAIComponent.cs プロジェクト: caomw/SpaceEngineers
        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;
        }
コード例 #13
0
 public AgentSpawnData(MyAgentDefinition agentDefinition, Vector3D? spawnPosition = null, bool createAlways = false)
 {
     AgentDefinition = agentDefinition;
     SpawnPosition = spawnPosition;
     CreateAlways = createAlways;
 }
コード例 #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);
        }
コード例 #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;
 }
コード例 #16
0
 private void CurrentToolbar_Unselected(MyToolbar toolbar)
 {
     BotToSpawn = null;
     CommandDefinition = null;
 }
コード例 #17
0
 public AgentGroupData(MyAgentDefinition agentDefinition, int count)
 {
     AgentDefinition = agentDefinition;
     Count = count;
 }
コード例 #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;
        }
コード例 #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);
        }