private static void crewCountPerPart(object sender, VOIDForEachPartArgs args) { Part part = args.Data; crewCount += part.protoModuleCrew.Count; crewCapacity += part.CrewCapacity; }
public virtual void Update() { this.LoadBeforeUpdate(); if ( this.vesselSimActive && ( this.Vessel != null || ( HighLogic.LoadedSceneIsEditor && EditorLogic.RootPart != null && EditorLogic.SortedShipList.Count > 0 ) ) ) { Logging.PostDebugMessage(this, "Updating SimManager."); this.UpdateSimManager(); VOIDForEachPartArgs partArgs; VOIDForEachPartModuleArgs moduleArgs; Part part; PartModule partModule; bool doForEachPart = this.onForEachPart != null; bool doForEachModule = this.onForEachModule != null; if ( (doForEachPart || doForEachModule) && (this.Vessel != null) && (this.Vessel.parts != null) && this.timeToUpdate ) { if (this.onPreForEach != null) { this.onPreForEach(this); } for (int pIdx = 0; pIdx < this.Vessel.parts.Count; pIdx++) { part = this.Vessel.parts[pIdx]; partArgs = new VOIDForEachPartArgs(part); if (doForEachPart) { this.onForEachPart(this, partArgs); } if (doForEachModule && part.Modules != null) { for (int mIdx = 0; mIdx < part.Modules.Count; mIdx++) { partModule = part.Modules[mIdx]; moduleArgs = new VOIDForEachPartModuleArgs(partModule); if (doForEachModule) { this.onForEachModule(this, moduleArgs); } } } } if (this.onPostForEach != null) { this.onPostForEach(this); } } } if (!this.GUIRunning && !this.gameUIHidden) { this.StartGUI(); } IVOID_Module module; for (int idx = 0; idx < this.modules.Count; idx++) { module = this.modules[idx]; if ( !module.GUIRunning && module.Active && module.InValidScene && ( !HighLogic.LoadedSceneIsEditor || (EditorLogic.RootPart != null && EditorLogic.SortedShipList.Count > 0) ) ) { module.StartGUI(); } if ( module.GUIRunning && ( !module.Active || !this.togglePower || !module.InValidScene || this.FactoryReset || ( HighLogic.LoadedSceneIsEditor && (EditorLogic.RootPart == null || EditorLogic.SortedShipList.Count == 0) ) ) ) { module.StopGUI(); } if (module is IVOID_BehaviorModule) { ((IVOID_BehaviorModule)module).Update(); } } if (ToolbarManager.ToolbarAvailable && this.useToolbarManager) { if (this.ToolbarButton == null) { this.ToolbarButton = ToolbarManager.Instance.add(this.VoidName, "coreToggle"); this.ToolbarButton.Text = this.VoidName; this.SetIconTexture(this.powerState | this.activeState); this.ToolbarButton.Visible = true; this.ToolbarButton.OnClick += (e) => { this.ToggleMainWindow(); }; Logging.PostDebugMessage(string.Format("{0}: Toolbar Button initialized.", this.GetType().Name)); } if (this.AppLauncherButton != null) { ApplicationLauncher.Instance.RemoveModApplication(this.AppLauncherButton); this.AppLauncherButton = null; } } else { if (this.AppLauncherButton == null) { if (ApplicationLauncher.Instance != null) { this.AppLauncherButton = ApplicationLauncher.Instance.AddModApplication( this.ToggleMainWindow, this.ToggleMainWindow, this.appIconVisibleScenes, this.VOIDIconTexture ); Logging.PostDebugMessage( this, "AppLauncherButton initialized in {0}", Enum.GetName( typeof(GameScenes), HighLogic.LoadedScene ) ); } } if (this.ToolbarButton != null) { this.ToolbarButton.Destroy(); this.ToolbarButton = null; } } if (this.onUpdate != null) { this.onUpdate(this); } this.saveTimer += Time.deltaTime; if (this.modulesLoaded && this.saveTimer > 2f) { if (this.configDirty) { Logging.PostDebugMessage(string.Format( "{0}: Time to save, checking if configDirty: {1}", this.GetType().Name, this.configDirty )); this.SaveConfig(); this.saveTimer = 0; } } this.UpdateTimer += Time.deltaTime; }
public virtual void Update() { this.LoadBeforeUpdate(); if ( this.vesselSimActive && ( this.Vessel != null || ( HighLogic.LoadedSceneIsEditor && EditorLogic.RootPart != null && EditorLogic.SortedShipList.Count > 0 ) ) ) { Logging.PostDebugMessage(this, "Updating SimManager."); this.UpdateSimManager(); VOIDForEachPartArgs partArgs; VOIDForEachPartModuleArgs moduleArgs; Part part; PartModule partModule; bool doForEachPart = this.onForEachPart != null; bool doForEachModule = this.onForEachModule != null; if ( (doForEachPart || doForEachModule) && (this.Vessel != null) && (this.Vessel.parts != null) && this.timeToUpdate ) { if (this.onPreForEach != null) { this.onPreForEach(this); } for (int pIdx = 0; pIdx < this.Vessel.parts.Count; pIdx++) { part = this.Vessel.parts[pIdx]; partArgs = new VOIDForEachPartArgs(part); if (doForEachPart) { this.onForEachPart(this, partArgs); } if (doForEachModule && part.Modules != null) { for (int mIdx = 0; mIdx < part.Modules.Count; mIdx++) { partModule = part.Modules[mIdx]; moduleArgs = new VOIDForEachPartModuleArgs(partModule); if (doForEachModule) { this.onForEachModule(this, moduleArgs); } } } } if (this.onPostForEach != null) { this.onPostForEach(this); } } } if (!this.GUIRunning && !this.gameUIHidden) { this.StartGUI(); } IVOID_Module module; for (int idx = 0; idx < this.modules.Count; idx++) { module = this.modules[idx]; if ( !module.GUIRunning && module.Active && module.InValidScene && ( !HighLogic.LoadedSceneIsEditor || (EditorLogic.RootPart != null && EditorLogic.SortedShipList.Count > 0) ) ) { module.StartGUI(); } if ( module.GUIRunning && ( !module.Active || !this.togglePower || !module.InValidScene || this.FactoryReset || ( HighLogic.LoadedSceneIsEditor && (EditorLogic.RootPart == null || EditorLogic.SortedShipList.Count == 0) ) ) ) { module.StopGUI(); } if (module is IVOID_BehaviorModule) { ((IVOID_BehaviorModule)module).Update(); } } if (toolbarControl == null) { toolbarControl = ThisGameObject.thisGameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(this.ToggleMainWindow, this.ToggleMainWindow, this.appIconVisibleScenes, MODID, "voidButton", "", "", MODNAME ); } this.SetIconTexture(this.powerState | this.activeState); if (this.onUpdate != null) { this.onUpdate(this); } this.saveTimer += Time.deltaTime; if (this.modulesLoaded && this.saveTimer > 2f) { if (this.configDirty) { Logging.PostDebugMessage(string.Format( "{0}: Time to save, checking if configDirty: {1}", this.GetType().Name, this.configDirty )); this.SaveConfig(); this.saveTimer = 0; } } this.UpdateTimer += Time.deltaTime; }