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;
            }
        }
        protected override void UnloadData()
        {
            base.UnloadData();

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

                if (m_pathfinding != null) 
					m_pathfinding.UnloadData();
                m_botCollection.UnloadData();

                m_botCollection = null;
                m_pathfinding = null;

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

                if (MyToolbarComponent.CurrentToolbar != null)
                {
                    MyToolbarComponent.CurrentToolbar.SelectedSlotChanged -= CurrentToolbar_SelectedSlotChanged;
                    MyToolbarComponent.CurrentToolbar.SlotActivated -= CurrentToolbar_SlotActivated;
                    MyToolbarComponent.CurrentToolbar.Unselected -= CurrentToolbar_Unselected;
                }
            }
        }
Beispiel #3
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);
     }
 }
Beispiel #4
0
 protected override void UnloadData()
 {
     base.UnloadData();
     if (MyPerGameSettings.EnableAi)
     {
         Sync.Players.NewPlayerRequestSucceeded -= new Action <MyPlayer.PlayerId>(this.PlayerCreated);
         Sync.Players.LocalPlayerRemoved        -= new Action <int>(this.LocalPlayerRemoved);
         Sync.Players.LocalPlayerLoaded         -= new Action <int>(this.LocalPlayerLoaded);
         Sync.Players.NewPlayerRequestFailed    -= new Action <int>(this.Players_NewPlayerRequestFailed);
         if (Sync.IsServer)
         {
             Sync.Players.PlayerRequesting -= new PlayerRequestDelegate(this.Players_PlayerRequesting);
             Sync.Players.PlayerRemoved    -= new Action <MyPlayer.PlayerId>(this.Players_PlayerRemoved);
         }
         if (this.m_pathfinding != null)
         {
             this.m_pathfinding.UnloadData();
         }
         this.m_botCollection.UnloadData();
         this.m_botCollection = null;
         this.m_pathfinding   = null;
         if (MyFakes.ENABLE_BEHAVIOR_TREE_TOOL_COMMUNICATION)
         {
             MyMessageLoop.RemoveMessageHandler((uint)0x40a, new ActionRef <System.Windows.Forms.Message>(this.OnUploadNewTree));
             MyMessageLoop.RemoveMessageHandler((uint)0x40c, new ActionRef <System.Windows.Forms.Message>(this.OnBreakDebugging));
             MyMessageLoop.RemoveMessageHandler((uint)0x40b, new ActionRef <System.Windows.Forms.Message>(this.OnResumeDebugging));
         }
         if (MyToolbarComponent.CurrentToolbar != null)
         {
             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);
         }
     }
     Static = null;
 }