public IUnitOrder RegisterBuildingOrder(IFactoryController factorycontroller, IUnitDef orderedunittype, Float3 orderedpos) { Order order = new Order(factorycontroller, orderedunittype, orderedpos); orders.Add(order); return(order); }
public void Activate() { if (!Active) { factorycontroller = playstyle.GetFirstControllerOfType(typeof(IFactoryController)) as IFactoryController; factorycontroller.RegisterRequester(this); enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler(EnemyAdded); enemycontroller.EnemyRemovedEvent += new EnemyController.EnemyRemovedHandler(EnemyRemoved); csai.TickEvent += new CSAI.TickHandler(Tick); csai.UnitIdleEvent += new CSAI.UnitIdleHandler(UnitIdle); csai.RegisterVoiceCommand("tankscount", new CSAI.VoiceCommandHandler(VoiceCommandCountTanks)); csai.RegisterVoiceCommand("tanksmoveto", new CSAI.VoiceCommandHandler(VoiceCommandMoveTo)); csai.RegisterVoiceCommand("tanksattackpos", new CSAI.VoiceCommandHandler(VoiceCommandAttackPos)); // unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded ); unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved); TankDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded)); //PackCoordinatorSelector.Activate(); Active = true; } }
public void Activate() { if (!Active) { factorycontroller = playstyle.GetFirstControllerOfType(typeof(IFactoryController)) as IFactoryController; factorycontroller.RegisterRequester(this); csai.TickEvent += new CSAI.TickHandler(Tick); csai.RegisterVoiceCommand("countscouts", new CSAI.VoiceCommandHandler(VoiceCommandCountScouts)); enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler(EnemyAdded); unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler(UnitAdded); unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler(UnitRemoved); ScoutUnitDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one unitcontroller.RefreshMyMemory(new UnitController.UnitAddedHandler(UnitAdded)); searchcoordinator.Activate(); Active = true; } }
public DockingStationEvent Execute() { string funcMsg = Name + ".Execute"; Log.Debug(funcMsg); // create return event InstrumentDisableReplacedEvent returnEvent = new InstrumentDisableReplacedEvent(this); returnEvent.DetectedReplacedSerialNumber = this.ReplacedSerialNumber; try { // record docking station and docked instrument on return event, // instrument serial number will be stored in the event journal returnEvent.DockingStation = Configuration.DockingStation; returnEvent.DockedInstrument = (ISC.iNet.DS.DomainModel.Instrument)Master.Instance.SwitchService.Instrument.Clone(); // check that the instrument is still docked if (!Controller.IsDocked()) { throw new InstrumentUndockedDuringDisableReplacedException(); } // establish communication with the docked instrument, verify it has the expected // serial number, and then disable it using (IFactoryController factoryController = SwitchService.CreateFactoryInstrumentController()) { factoryController.InstrumentController.Initialize(InstrumentController.Mode.Batch); returnEvent.SerialNumberBefore = factoryController.InstrumentController.GetSerialNumber(); // ensure the docked instrument serial number, the instrument serial number that will be saved to the event journal, and the detected // replaced instrument serial number all match before continuing if (returnEvent.SerialNumberBefore == this.ReplacedSerialNumber && returnEvent.DockedInstrument.SerialNumber == this.ReplacedSerialNumber) { Log.Warning(string.Format("DISABLING REPLACED INSTRUMENT: {0}", returnEvent.SerialNumberBefore)); factoryController.DisableReplacedInstrument(); Log.Warning(string.Format("INSTRUMENT DISABLED")); // set flag on switch service to stop anything else from happening until the disabled instrument is undocked Master.Instance.SwitchService.IsInstrumentReplaced = true; returnEvent.Passed = true; returnEvent.SerialNumberAfter = factoryController.InstrumentController.GetSerialNumber(); } } } catch (InstrumentUndockedDuringDisableReplacedException) { throw; } catch (Exception ex) { Log.Error(string.Format("{0} - Caught Exception", funcMsg), ex); // check that the instrument is still docked if (!Master.Instance.SwitchService.IsDocked()) { throw new InstrumentUndockedDuringDisableReplacedException(); } } finally { // log operation results Log.Debug(string.Format("WAS INSTRUMENT DISABLED: {0} - Detected Replaced S/N: {1} - S/N (before): {2} - S/N (after): {3}", returnEvent.Passed, returnEvent.DetectedReplacedSerialNumber, returnEvent.SerialNumberBefore, returnEvent.SerialNumberAfter)); } return(returnEvent); }
public void Activate() { if( !Active ) { factorycontroller = playstyle.GetFirstControllerOfType( typeof( IFactoryController ) ) as IFactoryController; factorycontroller.RegisterRequester( this ); csai.TickEvent += new CSAI.TickHandler( Tick ); csai.RegisterVoiceCommand( "countscouts", new CSAI.VoiceCommandHandler( VoiceCommandCountScouts ) ); enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler( EnemyAdded ); unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded ); unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved ); ScoutUnitDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one unitcontroller.RefreshMyMemory( new UnitController.UnitAddedHandler( UnitAdded ) ); searchcoordinator.Activate(); Active = true; } }
public Order(IFactoryController factorycontroller, IUnitDef orderedunit, Float3 pos) { this.factorycontroller = factorycontroller; this.orderedunit = orderedunit; this.pos = pos; }
public void Activate() { if( !Active ) { factorycontroller = playstyle.GetFirstControllerOfType( typeof( IFactoryController ) ) as IFactoryController; factorycontroller.RegisterRequester( this ); enemycontroller.NewEnemyAddedEvent += new EnemyController.NewEnemyAddedHandler( EnemyAdded ); enemycontroller.EnemyRemovedEvent += new EnemyController.EnemyRemovedHandler( EnemyRemoved ); csai.TickEvent += new CSAI.TickHandler( Tick ); csai.UnitIdleEvent += new CSAI.UnitIdleHandler( UnitIdle ); csai.RegisterVoiceCommand( "tankscount", new CSAI.VoiceCommandHandler( VoiceCommandCountTanks ) ); csai.RegisterVoiceCommand( "tanksmoveto", new CSAI.VoiceCommandHandler( VoiceCommandMoveTo ) ); csai.RegisterVoiceCommand( "tanksattackpos", new CSAI.VoiceCommandHandler( VoiceCommandAttackPos ) ); // unitcontroller.UnitAddedEvent += new UnitController.UnitAddedHandler( UnitAdded ); unitcontroller.UnitRemovedEvent += new UnitController.UnitRemovedHandler( UnitRemoved ); TankDefsById.Clear(); // note, dont just make a new one, because searchpackcoordinator wont get new one unitcontroller.RefreshMyMemory( new UnitController.UnitAddedHandler( UnitAdded ) ); //PackCoordinatorSelector.Activate(); Active = true; } }
public Order( IFactoryController factorycontroller, IUnitDef orderedunit, Float3 pos ) { this.factorycontroller = factorycontroller; this.orderedunit = orderedunit; this.pos = pos; }
public IUnitOrder RegisterBuildingOrder( IFactoryController factorycontroller, IUnitDef orderedunittype, Float3 orderedpos) { Order order = new Order(factorycontroller, orderedunittype, orderedpos); orders.Add(order); return order; }