Example #1
0
        public void Activate()
        {
            if (!Active)
            {
                logfile.WriteLine("Activating Constructorcontroller");

                foreach (IFactoryController factorycontroller in playstyle.GetControllersOfType(typeof(IFactoryController)))
                {
                    factorycontroller.RegisterRequester(this);
                }

                radarcontroller = playstyle.GetFirstControllerOfType(typeof(IRadarController)) as IRadarController;

                csai.UnitIdleEvent       += new CSAI.UnitIdleHandler(UnitIdle);
                csai.TickEvent           += new CSAI.TickHandler(Tick);
                csai.UnitMoveFailedEvent += new CSAI.UnitMoveFailedHandler(UnitMoveFailed);

                csai.RegisterVoiceCommand("constructorshownextbuildsiteon", new CSAI.VoiceCommandHandler(VoiceCommandShowNextBuildSiteOn));
                csai.RegisterVoiceCommand("constructorshownextbuildsiteoff", new CSAI.VoiceCommandHandler(VoiceCommandShowNextBuildSiteOff));

                unitcontroller.UnitAddedEvent   += new UnitController.UnitAddedHandler(UnitAdded);
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved);
                UnitDefByUnitId.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded));

                CheckIdleUnits();

                logfile.WriteLine("Constructorcontroller activated");
                Active = true;
            }
        }
Example #2
0
        public void Activate()
        {
            if( !Active )
            {
                logfile.WriteLine( "Activating Constructorcontroller" );

                foreach( IFactoryController factorycontroller in playstyle.GetControllersOfType( typeof( IFactoryController ) ) )
                {
                    factorycontroller.RegisterRequester( this );
                }

                radarcontroller = playstyle.GetFirstControllerOfType( typeof( IRadarController ) ) as IRadarController;

                csai.UnitIdleEvent += new CSAI.UnitIdleHandler( UnitIdle );
                csai.TickEvent += new CSAI.TickHandler( Tick );
                csai.UnitMoveFailedEvent += new CSAI.UnitMoveFailedHandler( UnitMoveFailed );

                csai.RegisterVoiceCommand( "constructorshownextbuildsiteon", new CSAI.VoiceCommandHandler( VoiceCommandShowNextBuildSiteOn ) );
                csai.RegisterVoiceCommand( "constructorshownextbuildsiteoff", new CSAI.VoiceCommandHandler( VoiceCommandShowNextBuildSiteOff ) );

                unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded );
                unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved );
                UnitDefByUnitId.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one
                unitcontroller.RefreshMyMemory( new UnitController.UnitAddedHandler( UnitAdded ) );

                CheckIdleUnits();

                logfile.WriteLine( "Constructorcontroller activated" );
                Active = true;
            }
        }