コード例 #1
0
 public MyBotCollection(MyBehaviorTreeCollection behaviorTreeCollection)
 {
     m_behaviorTreeCollection = behaviorTreeCollection;
     m_allBots              = new Dictionary <int, IMyBot>(8);
     m_botActions           = new Dictionary <Type, ActionCollection>(8);
     m_botsQueue            = new List <int>(8);
     m_botsCountPerBehavior = new Dictionary <string, int>();
 }
コード例 #2
0
        public override void LoadData()
        {
            base.LoadData();

            if (MyPerGameSettings.EnableAi)
            {
                Sync.Players.NewPlayerRequestSucceeded += PlayerCreated;
                Sync.Players.LocalPlayerLoaded += LocalPlayerLoaded;
                Sync.Players.NewPlayerRequestFailed += Players_NewPlayerRequestFailed;
                if (Sync.IsServer)
                {
                    Sync.Players.PlayerRemoved += Players_PlayerRemoved;
                    Sync.Players.PlayerRequesting += Players_PlayerRequesting;
                }

                if (MyPerGameSettings.PathfindingType != null)
                {
                    m_pathfinding = Activator.CreateInstance(MyPerGameSettings.PathfindingType) as IMyPathfinding;
                }
                m_behaviorTreeCollection = new MyBehaviorTreeCollection();
                m_botCollection = new MyBotCollection(m_behaviorTreeCollection);
                m_loadedLocalPlayers = new List<int>();
                m_loadedBotObjectBuildersByHandle = new Dictionary<int, MyObjectBuilder_Bot>();
                m_agentsToSpawn = new Dictionary<int, AgentSpawnData>();
                m_removeQueue = new MyConcurrentQueue<BotRemovalRequest>();
                m_maxBotNotification = new MyHudNotification(MyCommonTexts.NotificationMaximumNumberBots, 2000, MyFontEnum.Red);
                m_processQueue = new MyConcurrentQueue<AgentSpawnData>();
                m_lock = new FastResourceLock();

#if !XB1
                if (MyFakes.ENABLE_BEHAVIOR_TREE_TOOL_COMMUNICATION)
                {
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_UPLOAD_TREE, OnUploadNewTree);
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_STOP_SENDING, OnBreakDebugging);
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_RESUME_SENDING, OnResumeDebugging);
                }
#endif

                MyToolbarComponent.CurrentToolbar.SelectedSlotChanged += CurrentToolbar_SelectedSlotChanged;
                MyToolbarComponent.CurrentToolbar.SlotActivated += CurrentToolbar_SlotActivated;
                MyToolbarComponent.CurrentToolbar.Unselected += CurrentToolbar_Unselected;
            }
        }
コード例 #3
0
 private void OnUploadNewTree(ref System.Windows.Forms.Message msg)
 {
     if (this.m_behaviorTreeCollection != null)
     {
         MyBehaviorTree       outBehaviorTree = null;
         MyBehaviorDefinition definition      = null;
         if (MyBehaviorTreeCollection.LoadUploadedBehaviorTree(out definition) && this.m_behaviorTreeCollection.HasBehavior(definition.Id.SubtypeId))
         {
             this.m_botCollection.ResetBots(definition.Id.SubtypeName);
             this.m_behaviorTreeCollection.RebuildBehaviorTree(definition, out outBehaviorTree);
             this.m_botCollection.CheckCompatibilityWithBots(outBehaviorTree);
         }
         IntPtr zero = IntPtr.Zero;
         if (this.m_behaviorTreeCollection.TryGetValidToolWindow(out zero))
         {
             WinApi.PostMessage(zero, 0x404, IntPtr.Zero, IntPtr.Zero);
         }
     }
 }
コード例 #4
0
        private void OnUploadNewTree(ref Message msg)
        {
            if (m_behaviorTreeCollection != null)
            {
                MyBehaviorTree behaviorTree = null;
                MyBehaviorDefinition behaviorDefinition = null;
                bool success = MyBehaviorTreeCollection.LoadUploadedBehaviorTree(out behaviorDefinition);
                if (success && m_behaviorTreeCollection.HasBehavior(behaviorDefinition.Id.SubtypeId))
                {
                    m_botCollection.ResetBots(behaviorDefinition.Id.SubtypeName);
                    m_behaviorTreeCollection.RebuildBehaviorTree(behaviorDefinition, out behaviorTree);
                    m_botCollection.CheckCompatibilityWithBots(behaviorTree);
                }
                IntPtr toolWindowHandle = IntPtr.Zero;
#if !XB1
                if (m_behaviorTreeCollection.TryGetValidToolWindow(out toolWindowHandle))
                    WinApi.PostMessage(toolWindowHandle, MyWMCodes.BEHAVIOR_TOOL_TREE_UPLOAD_SUCCESS, IntPtr.Zero, IntPtr.Zero);
#endif // !XB1
            }
        }
コード例 #5
0
 public override void LoadData()
 {
     base.LoadData();
     if (MyPerGameSettings.EnableAi)
     {
         Sync.Players.NewPlayerRequestSucceeded += new Action <MyPlayer.PlayerId>(this.PlayerCreated);
         Sync.Players.LocalPlayerLoaded         += new Action <int>(this.LocalPlayerLoaded);
         Sync.Players.NewPlayerRequestFailed    += new Action <int>(this.Players_NewPlayerRequestFailed);
         if (Sync.IsServer)
         {
             Sync.Players.PlayerRemoved    += new Action <MyPlayer.PlayerId>(this.Players_PlayerRemoved);
             Sync.Players.PlayerRequesting += new PlayerRequestDelegate(this.Players_PlayerRequesting);
         }
         if (MyPerGameSettings.PathfindingType != null)
         {
             this.m_pathfinding = Activator.CreateInstance(MyPerGameSettings.PathfindingType) as IMyPathfinding;
         }
         this.m_behaviorTreeCollection          = new MyBehaviorTreeCollection();
         this.m_botCollection                   = new MyBotCollection(this.m_behaviorTreeCollection);
         this.m_loadedLocalPlayers              = new List <int>();
         this.m_loadedBotObjectBuildersByHandle = new Dictionary <int, MyObjectBuilder_Bot>();
         this.m_agentsToSpawn                   = new Dictionary <int, AgentSpawnData>();
         this.m_removeQueue        = new MyConcurrentQueue <BotRemovalRequest>();
         this.m_maxBotNotification = new MyHudNotification(MyCommonTexts.NotificationMaximumNumberBots, 0x7d0, "Red", MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, 0, MyNotificationLevel.Normal);
         this.m_processQueue       = new MyConcurrentQueue <AgentSpawnData>();
         this.m_lock = new FastResourceLock();
         if (MyFakes.ENABLE_BEHAVIOR_TREE_TOOL_COMMUNICATION)
         {
             MyMessageLoop.AddMessageHandler((uint)0x40a, new ActionRef <System.Windows.Forms.Message>(this.OnUploadNewTree));
             MyMessageLoop.AddMessageHandler((uint)0x40c, new ActionRef <System.Windows.Forms.Message>(this.OnBreakDebugging));
             MyMessageLoop.AddMessageHandler((uint)0x40b, new ActionRef <System.Windows.Forms.Message>(this.OnResumeDebugging));
         }
         MyToolbarComponent.CurrentToolbar.SelectedSlotChanged += new Action <MyToolbar, MyToolbar.SlotArgs>(this.CurrentToolbar_SelectedSlotChanged);
         MyToolbarComponent.CurrentToolbar.SlotActivated       += new Action <MyToolbar, MyToolbar.SlotArgs, bool>(this.CurrentToolbar_SlotActivated);
         MyToolbarComponent.CurrentToolbar.Unselected          += new Action <MyToolbar>(this.CurrentToolbar_Unselected);
     }
 }
コード例 #6
0
        public override void LoadData()
        {
            base.LoadData();

            if (MyPerGameSettings.EnableAi)
            {
                Sync.Players.NewPlayerRequestSucceeded += PlayerCreated;
                Sync.Players.LocalPlayerLoaded += LocalPlayerLoaded;
                Sync.Players.NewPlayerRequestFailed += Players_NewPlayerRequestFailed;
                if (Sync.IsServer)
                {
                    Sync.Players.PlayerRemoved += Players_PlayerRemoved;
                    Sync.Players.PlayerRequesting += Players_PlayerRequesting;
                }

                m_pathfinding = new MyPathfinding();
                m_behaviorTreeCollection = new MyBehaviorTreeCollection();
                m_botCollection = new MyBotCollection(m_behaviorTreeCollection);
                m_loadedLocalPlayers = new List<int>();
                m_loadedBotObjectBuildersByHandle = new Dictionary<int, MyObjectBuilder_Bot>();
                m_agentsToSpawn = new Dictionary<int, AgentSpawnData>();
                m_removeQueue = new Queue<int>();
                m_maxBotNotification = new MyHudNotification(MySpaceTexts.NotificationMaximumNumberBots, 2000, MyFontEnum.Red);

                if (MyFakes.ENABLE_BEHAVIOR_TREE_TOOL_COMMUNICATION)
                {
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_UPLOAD_TREE, OnUploadNewTree);
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_STOP_SENDING, OnBreakDebugging);
                    MyMessageLoop.AddMessageHandler(MyWMCodes.BEHAVIOR_GAME_RESUME_SENDING, OnResumeDebugging);
                }

                MyToolbarComponent.CurrentToolbar.SelectedSlotChanged += CurrentToolbar_SelectedSlotChanged;
                MyToolbarComponent.CurrentToolbar.SlotActivated += CurrentToolbar_SlotActivated;
                MyToolbarComponent.CurrentToolbar.Unselected += CurrentToolbar_Unselected;
            }
        }