private void RegisterNewGrid(MyCubeGrid grid) { // Logic for picking proper grids goes here IMyShipController mainControl = null; foreach (IMyShipController controller in grid.GetFatBlocks <MyShipController>()) { if (!controller.CustomData.Contains("DemoSetup")) { continue; } mainControl = controller; } if (mainControl == null) { return; } WriteToLog("RegisterNewGrid", $"Registering new grid: {mainControl.CubeGrid.DisplayName}", LogType.General); ControllableGrid controllableGrid = new ControllableGrid(grid, mainControl); controllableGrid.OnWriteToLog += WriteToLog; controllableGrid.OnClose += OnGridClose; controllableGrid.SetupGrid(); _grids.Add(controllableGrid); _grids.ApplyAdditions(); }