public AttackDetector(StorageSetter storage, IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { ammo = VRage.MyFixedPoint.DeserializeStringSafe(storage.getStorage()); turrets = Blocks.InGroupsNamed("Turrets"); log = new EasyLCD(Blocks.Named("LCD Panel Attacks Log")); beacon = Blocks.InGroupsNamed("Beacon Attack Detector").GetBlock(0); this.storage = storage; Every(5 * EasyAPI.Seconds, doWork); On("clear", delegate() { log.SetText(""); beacon.SetName("Beacon Attack Detector"); }); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!")); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); On("Update", delegate() { doUpdates(); }); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action<string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!")); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.timer = Blocks.Named("MenuTimer").FindOrFail("MenuTimer not found!"); this.screen = Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!"); this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(this.screen); Every(100 * Milliseconds, doUpdates); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Explore", new [] { new EasyMenuItem("Actions", delegate(EasyMenuItem actionsItem) { List <string> types = new List <string>(); for (int n = 0; n < Blocks.Count(); n++) { var block = Blocks.GetBlock(n); if (!types.Contains(block.Type())) { types.Add(block.Type()); } } types.Sort(); actionsItem.children.Clear(); for (int n = 0; n < types.Count; n++) { actionsItem.children.Add(new EasyMenuItem(types[n], delegate(EasyMenuItem typeItem) { typeItem.children.Clear(); var blocks = Blocks.OfType(typeItem.Text); for (int o = 0; o < blocks.Count(); o++) { var block = blocks.GetBlock(o); typeItem.children.Add(new EasyMenuItem(block.Name(), delegate(EasyMenuItem blockItem) { blockItem.children.Clear(); var actions = block.GetActions(); for (int p = 0; p < actions.Count; p++) { var action = actions[p]; blockItem.children.Add(new EasyMenuItem(action.Name + "", delegate(EasyMenuItem actionItem) { block.ApplyAction(action.Id); return(false); })); } blockItem.children.Sort(); return(true); })); } typeItem.children.Sort(); return(true); })); } actionsItem.children.Sort(); return(true); }) }); // Get blocks this.screen = Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!"); this.lcd = new EasyLCD(this.screen); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); On("Update", delegate() { doUpdates(); }); }