public InventoriesGroomer(GridManager gridManager, ContainerManager contManager, AssemblerManager assemblerManager, MiscInventoryManager miscInventoryManager, RefineryManager refineryManager, IProcessSpawner spawner, Action <string> logger) { this.logger = logger; this._outputInventories = new List <IOutputInventoryCollection> { assemblerManager, miscInventoryManager, refineryManager }; spawner.Spawn(p => this._groomContainers(contManager), "container-groomer", period: 100); spawner.Spawn(p => this.groomOutputInventories(gridManager, contManager), "producer-groomer", period: 47); }
/// <summary>Creates the watcher</summary> /// <param name="b">Block whose <see cref="IMyTerminalBlock.CustomData"/> we're intersted in</param> /// <param name="spawner">To spawn the watch process</param> public IniWatcher(IMyTerminalBlock b, IProcessSpawner spawner) { this.block = b; this.Parse(b.CustomData); this.previous = this.block.CustomData; spawner.Spawn(this.update, "ini-update", period: 100); }
public AutoConnectionServer(IMyIntergridCommunicationSystem igc, AutoConnector connector, IProcessSpawner spawner) { this.connector = connector; this.igc = igc; this.mainProcess = spawner.Spawn(p => this.Update(), $"ac-server '{this.Name}'", onDone => this.connector.Stop()); this.logger?.Invoke($"Connector {this.Name} ready"); }
public DoorManager(MyGridProgram program, IProcessSpawner spawner, Action <string> logger) { this.logger = logger; this.mainProcess = spawner.Spawn(this._handleDoors, "autodoors-main"); this.Scan(program); this.mainProcess.Spawn(p => this.Scan(program), "scan", period: 431); }
/// <summary>Creates a new network</summary> /// <param name="remote">The remote doing the autopilot, and whose position is used as a referential</param> /// <param name="logger">Optional logger</param> /// <param name="spawner">Used to spawn the update processes</param> public WPNetwork(IMyRemoteControl remote, Action <string> logger, IProcessSpawner spawner) { this.logger = logger; this.remote = remote; this.updateData(); spawner.Spawn(p => this.updateData(), "wpn-update", period: 100); }
public InventoriesController(CoordinatesTransformer tformer, IMyGridTerminalSystem gts, IMyCockpit cockpit, double idealCenterOfMass, IProcessSpawner spawner) { this._cpit = cockpit; this._idealCoM = idealCenterOfMass; var containers = new List <IMyCargoContainer>(); gts.GetBlocksOfType(containers, c => c.CubeGrid == cockpit.CubeGrid); this._invs = containers .Select(c => new Inventory(c, tformer.Pos(c.GetPosition()).Z)) .OrderBy(inv => inv.Z) .ToList(); gts.GetBlocksOfType(this._lights, light => light.DisplayNameText.StartsWith("BM Spotlight") && !light.DisplayNameText.Contains("Rear")); spawner.Spawn(p => this.updateDrills(), "drill-updater"); this._invAction = spawner.Spawn(p => this.updateInventories(tformer.Pos(cockpit.CenterOfMass).Z), "inv-handle", period: 100); }
public CameraTurret(IMyGridTerminalSystem gts, IProcessSpawner spawner) { this.camera = gts.GetBlockWithName("SMB Turret Camera") as IMyCameraBlock; this.pitch = gts.GetBlockWithName("SMB Camera Turret Rotor") as IMyMotorStator; this.yaw = gts.GetBlockWithName("SMB Camera Turret Base Rotor") as IMyMotorStator; gts.GetBlocksOfType(this.controllers); spawner.Spawn(this.main, "camera-turret"); }
public GridManager(MyGridProgram program, MyIni ini, IProcessSpawner spawner, Action <string> logger) { this.logger = logger; this._block = program.Me; this.Scan(program.GridTerminalSystem); spawner.Spawn(p => this.Scan(program.GridTerminalSystem), "grid-scanner", period: 100); this._managedGrids = new HashSet <string>(ini.Get(INI_SECTION, "managed-grids").ToString().Split(SPLIT_VALUES_CHAR, StringSplitOptions.RemoveEmptyEntries)); this.log($"We manage {this._managedGrids.Count} grids"); }
public FabricatorDisplay(IMyTextSurface statusDisplay, IMyTextSurface mandatoryDisplay, IMyTextSurface otherDisplay, string name, Projector projector, Welder welder, InventoryManager invManager, IProcessSpawner spawner) { this.statusDisplay = new Display(statusDisplay); this.mandatoryDisplay = new Display(mandatoryDisplay); this.otherDisplay = new Display(otherDisplay); this.invManager = invManager; this.name = name; this.welder = welder; this.projector = projector; this.mainProcess = spawner.Spawn(p => this.updateDisplays(), "display-process", period: 30); }
//readonly List<Display> wheelDisplays; public ScreensController(GeneralStatus status, InventoryWatcher invWatcher, IEnumerable <IMyTextSurface> drillStatusSurfaces, IEnumerable <IMyTextSurface> wheelStatusSurfaces, ColorScheme scheme, string sprites, IProcessSpawner spawner) { this.scheme = scheme; var sprts = new ShapeCollections(this.scheme); sprts.Parse(sprites); this.drillDisplays = drillStatusSurfaces.Select(s => new Display(s, new Vector2(2, 25), scheme: this.scheme, sprites: sprts)).ToList(); //this.wheelDisplays = wheelStatusSurfaces.Select(s => new Display(s, new Vector2(2, 25), scheme: this.scheme)).ToList(); this.status = status; spawner.Spawn(p => this.updateScreens(status, invWatcher), "screens-update", period: 20); }
public Projector(IMyDoor door, IMyPistonBase piston, IMyProjector projector, IProcessSpawner spawner, Action <string, string> logger) { this.door = door; this.piston = piston; this.projector = projector; this.mainProcess = spawner.Spawn(null, "projector-process"); this.logger = logger; if (this.door.Status == DoorStatus.Closing || this.piston.Velocity < 0) { this.Retract(); } else if (this.door.Status == DoorStatus.Opening || this.piston.Velocity > 0) { this.Deploy(); } }
public ScreensController(GeneralStatus status, InventoriesController inventoryController, IMyTextSurface drillStatusSurface, IMyTextSurface wheelStatusSurface, ColorScheme scheme, string sprites, IProcessSpawner spawner) { this._scheme = scheme; if (drillStatusSurface != null) { var offset = new Vector2(2, 25); var sprts = new ShapeCollections(this._scheme); sprts.Parse(sprites); this._drillSurface = new Display(drillStatusSurface, offset, scheme: this._scheme, sprites: sprts); } if (wheelStatusSurface != null) { this._wheelSurface = new Display(wheelStatusSurface, scheme: this._scheme); } this._status = status; spawner.Spawn(p => this._updateScreens(status, inventoryController), "screens-update", period: 20); }
/// <summary>Spawns a new <see cref="Process"/>, taking into account the arguments. Can fail and return null if the arguments are incorrect.</summary> /// <param name="args">The arguments given to the command line.</param> /// <param name="logger">The logger the process can use to log.</param> /// <param name="onDone">The callback to call on process termination.</param> /// <param name="spawner">Used to spawn the process</param> /// <param name="trigger">What triggered the command</param> /// <returns>The spawned process, if successful.</returns> public Process Spawn(List <string> args, Action <string> logger, Action <Process> onDone, IProcessSpawner spawner, CommandTrigger trigger) { if (trigger < this.RequiredTrigger) { logger?.Invoke($"Permission denied for '{this.Name}'"); } else if (args.Count <= this.MaxArgs && args.Count >= this.MinArgs) { MyTuple <int, bool, Action <Process> > parameters = this.provider(args, logger); return(spawner.Spawn(parameters.Item3, this.Name, onDone, parameters.Item1, parameters.Item2)); } else { logger?.Invoke($"Wrong number of arguments for '{this.Name}'"); logger?.Invoke($"Run -help '{this.Name}' for more info"); } return(null); }
public Logger(IProcessSpawner spawner, IMyTextSurface s, Color?bgdCol = null, Color?col = null, Action <string> echo = null, float size = 0.5f) { int nMsgs = 1; if (s != null) { s.TextPadding = 0; s.ContentType = (ContentType)1; s.Alignment = 0; s.Font = "Monospace"; s.FontSize = size; s.FontColor = col ?? Color.White; s.BackgroundColor = bgdCol ?? Color.Black; var sb = new StringBuilder("G"); nMsgs = (int)((GetMultiplier(s) * s.SurfaceSize.Y / s.MeasureStringInPixels(sb, s.Font, s.FontSize).Y) + 0.1f); this.surface = s; } this.messages = new CircularBuffer <string>(nMsgs); spawner.Spawn(p => this.flush(), "logger"); this.echo = echo; }
public Welder(IEnumerable <IMyPistonBase> pistons, IMySensorBlock sensor, IEnumerable <IMyShipWelder> welders, IEnumerable <IMyLightingBlock> lights, int positionMultiplier, IProcessSpawner spawner) { this.lights = lights; this.pistons = pistons; this.positionMultiplier = positionMultiplier; this.sensor = sensor; this.welders = welders; this.mainProcess = spawner.Spawn(null, "welder-process"); this.sensor.Enabled = false; if (this.pistons.First().Velocity > 0) { this.Deploy(); } else if (this.welders.First().Enabled) { this.move(0); } else if (this.pistons.First().Velocity < 0) { this.Retract(); } }
public ContainerManager(IMyGridTerminalSystem gts, GridManager gridManager, IProcessSpawner spawner, Action <string> logger) { this.logger = logger; spawner.Spawn(p => this.Scan(gts, gridManager), "container-scanner", period: 100); this.Scan(gts, gridManager); }
public MiscInventoryManager(IMyGridTerminalSystem gts, GridManager gridManager, IProcessSpawner spawner, Action <string> logger) { this.Scan(gts, gridManager); spawner.Spawn(p => this.Scan(gts, gridManager), "misc-inventory-groomer", period: 300); this.logger = logger; }
/// <summary>Creates a new transformer</summary> /// <param name="block">Reference block, coordinates will then be </param> /// <param name="spawner">If present, a <see cref="Process"/> will be spawned to update the transformer each tick</param> public CoordinatesTransformer(IMyTerminalBlock block, IProcessSpawner spawner = null) { this.reference = block; this.update(null); spawner?.Spawn(this.update, $"coords-transformer {this.reference.DisplayNameText}"); }
public BatteryManager(Program p, IProcessSpawner spawner) { this.update(p); spawner.Spawn(process => this.update(p), "battery-manager", period: 100); }
public AssemblerManager(IMyGridTerminalSystem gts, GridManager gridManager, IProcessSpawner spawner) { this.Scan(gts, gridManager); spawner.Spawn(p => this.Scan(gts, gridManager), "assembler-scanner", period: 100); }
public InventoryManager(IProcessSpawner spawner, Action <List <IMyCargoContainer> > containersGetter) { containersGetter(this.containers); spawner.Spawn(p => this.updateStatus(containersGetter), "inventory-process", period: 100); }
public RefineryManager(IMyGridTerminalSystem gts, GridManager gridManager, IProcessSpawner spawner) { this.Scan(gts, gridManager); spawner.Spawn(p => this.Scan(gts, gridManager), "refinery-scanner", period: 100); }