public static void ShowPanel(Docks type) { ModuleControl moduleControl = ModuleManager.CurrentModuleControl as ModuleControl; if (moduleControl != null) { moduleControl.ShowDockPanel(type); } }
public void RemoveBoat() { int[] result = Docks .Select((b, i) => b != null && b.Docked == false ? i : -1) .Where(i => i != -1) .ToArray(); foreach (var item in result) { Docks.SetValue(null, item); } Boats .RemoveAll(b => b != null && b.Docked == false); }
public void ShowDockPanel(Docks dock) { DockManager dockMgr = DockManager; if (dockMgr == null || dockMgr.Panels.Count == 0) { return; } List <DockPanel> panels = new List <DockPanel>(dockMgr.Panels.Count); foreach (DockPanel panel in dockMgr.Panels) { panels.Add(panel); } foreach (var panel in panels) { if (panel.Tag != null && panel.Tag is Docks && ((Docks)panel.Tag) == dock) { switch (panel.Visibility) { case DockVisibility.Visible: if (panel.ParentPanel != null && panel.ParentPanel.ActiveChild != panel) { panel.ParentPanel.ActiveChild = panel; } else { panel.Visibility = DockVisibility.AutoHide; } break; case DockVisibility.Hidden: case DockVisibility.AutoHide: panel.Visibility = DockVisibility.Visible; if (panel.ParentPanel != null) { panel.ParentPanel.ActiveChild = panel; } break; } break; } } }
public void DisplayInfo() { Console.WriteLine("Additional dock info: "); Console.WriteLine(); int row = Boats .OfType <RowingBoat>() .Count(); int pow = Boats .OfType <PowerBoat>() .Count(); int sail = Boats .OfType <SailBoat>() .Count(); int cata = Boats .OfType <Catamaran>() .Count(); int carg = Boats .OfType <CargoShip>() .Count(); var weight = Boats .GroupBy(b => b.Weight) .Sum(b => b.Key); var speed = Boats .GroupBy(b => b.MaxSpeed) .Sum(b => b.Key); var emptySlot = Docks .Count(b => b == null); int speedInKMH = speed / Boats.Count(); Console.WriteLine("Number of docked boats: "); Console.WriteLine($"Rowingboat: {row}"); Console.WriteLine($"Powerboat: {pow}"); Console.WriteLine($"Sailboat: {sail}"); Console.WriteLine($"Catamaran: {cata}"); Console.WriteLine($"Cargoship: {carg}"); Console.WriteLine($"Total weight in dock: {weight} kg"); Console.WriteLine($"Average maximum speed in dock: {(speedInKMH * 1.85200)} km/h"); Console.WriteLine($"Empty slots in dock: {emptySlot/2}"); Console.WriteLine($"Number of total boats added: {AddedBoats}"); Console.WriteLine($"Number of total boats rejected: {RejectedBoats}"); }
protected void RegisterDockPanel(DockPanel dockPanel, Control ctrl, Docks dock) { if (dockPanel == null || ctrl == null) { return; } if (!_containers.ContainsKey(dockPanel)) { dockPanel.Tag = dock; if (DockMap != null && DockMap.ContainsKey(dock)) { dockPanel.Text = DockMap[dock]; } ctrl.Dock = DockStyle.Fill; _containers[dockPanel] = ctrl; } }
/// <summary> /// Start the interpolation and set it's needed values /// </summary> private void StartupInterpolation() { try { if (Body == null) { Body = FlightGlobals.Bodies.Find(b => b.bodyName == BodyName); } if (Vessel == null) { Vessel = FlightGlobals.Vessels.FindLast(v => v.id == VesselId); } InterpolationStarted = true; if (Body != null && Vessel != null) { PlanetariumDifference = Planetarium.GetUniversalTime() - PlanetTime; Vessel.ActionGroups.SetGroup(KSPActionGroup.Gear, Target.ActionGrpControls[0]); Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, Target.ActionGrpControls[1]); Vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, Target.ActionGrpControls[2]); Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, Target.ActionGrpControls[3]); Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, Target.ActionGrpControls[4]); var stage = Vessel.currentStage; if (stage != Stage) { Vessel.ActionGroups.ToggleGroup(KSPActionGroup.Stage); Vessel.currentStage = Stage; } else { var engines = Vessel.FindPartModulesImplementing <ModuleEngines>(); var enginesToActivate = engines.Where(e => !e.EngineIgnited && ActiveEngines.Contains(e.part.craftID)); var enginesToStop = engines.Where(e => e.EngineIgnited && StoppedEngines.Contains(e.part.craftID)); var decouplersToLaunch = Vessel.FindPartModulesImplementing <ModuleDecouple>() .Where(d => !d.isDecoupled && !Decouplers.Contains(d.part.craftID)); var anchoredDecouplersToLaunch = Vessel.FindPartModulesImplementing <ModuleAnchoredDecoupler>() .Where(d => !d.isDecoupled && !Decouplers.Contains(d.part.craftID)); var clamps = Vessel.FindPartModulesImplementing <LaunchClamp>() .Where(c => !Clamps.Contains(c.part.craftID)); var docks = Vessel.FindPartModulesImplementing <ModuleDockingNode>() .Where(d => !d.IsDisabled && !Docks.Contains(d.part.craftID)); foreach (var engine in enginesToActivate) { engine.Activate(); } foreach (var engine in enginesToStop) { engine.Shutdown(); } foreach (var decoupler in decouplersToLaunch) { decoupler.Decouple(); } foreach (var anchoredDecoupler in anchoredDecouplersToLaunch) { anchoredDecoupler.Decouple(); } foreach (var clamp in clamps) { clamp.Release(); } foreach (var dock in docks) { dock.Decouple(); } } //Here we use the interpolation facor to make the interpolation duration //shorter or longer depending on the amount of updates we have in queue. //We never exceed the MaxSInterpolationTime _interpolationDuration = Target.SentTime - SentTime - VesselUpdateInterpolationSystem.GetInterpolationFactor(VesselId); _interpolationDuration = Mathf.Clamp(_interpolationDuration, 0, VesselUpdateInterpolationSystem.MaxSInterpolationTime); } } catch (Exception e) { Debug.LogError($"[LMP]: Coroutine error in StartupInterpolation {e}"); } }