public override void OnStart(StartState st) { base.OnStart(st); GameEvents.onSameVesselDock.Add(onSameVesselDock); GameEvents.OnGameSettingsApplied.Add(onGameSettingsApplied); GameEvents.onPartUndock.Add(onPartUndock); dockingNode = this.part.FindModuleImplementing <ModuleDockingNode>(); dockingLight = this.part.FindModuleImplementing <WBILight>(); onGameSettingsApplied(); //Hide the native events if (dockingNode != null) { dockingNode.Events["SetAsTarget"].guiActiveUnfocused = false; dockingNode.Events["UnsetTarget"].guiActiveUnfocused = false; dockingNode.Events["MakeReferenceTransform"].guiActive = false; originalsnapOffset = dockingNode.snapOffset; originalAcquireTorque = dockingNode.acquireTorque; originalAcquireTorqueRoll = dockingNode.acquireTorqueRoll; } //Update GUI UpdateWeldGUI(); updateAngleSnap(); //Update docking state if (dockingNode != null && dockingNode.vesselInfo != null) { OnDockingStateChanged(); } }
public void GetPartModules() { BaseEvent cmdEvent; int totalEvents; commandModule = this.part.FindModuleImplementing <ModuleCommand>(); if (commandModule != null) { totalEvents = commandModule.Events.Count; for (int index = 0; index < totalEvents; index++) { cmdEvent = commandModule.Events.GetByIndex(index); cmdEvent.guiActive = false; cmdEvent.guiActiveUnfocused = false; } } switcher = this.part.FindModuleImplementing <WBIResourceSwitcher>(); if (switcher != null) { switcher.Events["ToggleDecals"].guiActive = false; switcher.Events["ToggleDecals"].guiActiveUnfocused = false; switcher.Events["DumpResources"].guiActive = false; switcher.Events["DumpResources"].guiActiveUnfocused = false; } lightModule = this.part.FindModuleImplementing <WBILight>(); qualityControl = this.part.FindModuleImplementing <BaseQualityControl>(); }
public void GetPartModules() { commandModule = this.part.FindModuleImplementing <ModuleCommand>(); if (commandModule != null) { foreach (BaseEvent cmdEvent in commandModule.Events) { cmdEvent.guiActive = false; cmdEvent.guiActiveUnfocused = false; } } switcher = this.part.FindModuleImplementing <WBIResourceSwitcher>(); if (switcher != null) { switcher.Events["ToggleDecals"].guiActive = false; switcher.Events["ToggleDecals"].guiActiveUnfocused = false; } lightModule = this.part.FindModuleImplementing <WBILight>(); if (lightModule != null) { lightModule.showGui(false); } }
public override void OnStart(StartState state) { base.OnStart(state); foreach (PartModule module in this.part.Modules) { if (module.moduleName == "ExSurveyStation") { exSurveyStation = module; break; } } light = this.part.FindModuleImplementing <WBILight>(); }
public virtual void ToggleInflation() { //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated. if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0) { ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } //make sure we don't have parts attached if (isInflatable && isDeployed) { if (this.part.children.Count > 0) { ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } } //Play animation for current state animationStarted = true; PlayAnimation(isDeployed); //Toggle state isDeployed = !isDeployed; if (isDeployed) { this.part.CrewCapacity = inflatedCrewCapacity; Events["ToggleInflation"].guiName = endEventGUIName; } else { this.part.CrewCapacity = 0; Events["ToggleInflation"].guiName = startEventGUIName; //Turn off the lights if deflating the module. WBILight light = this.part.FindModuleImplementing <WBILight>(); if (light != null) { if (light.isDeployed) { light.TurnOffLights(); } } } Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName); }
protected void setupLightGUI() { WBILight light = this.part.FindModuleImplementing <WBILight>(); if (light != null) { light.Events["ToggleAnimation"].active = isDeployed; } ModuleColorChanger colorChanger = this.part.FindModuleImplementing <ModuleColorChanger>(); if (colorChanger != null) { colorChanger.Events["ToggleEvent"].active = isDeployed; } //Dirty the GUI MonoUtilities.RefreshContextWindows(this.part); }
protected void drawCommandView() { commandModule = this.part.FindModuleImplementing <ModuleCommand>(); switcher = this.part.FindModuleImplementing <WBIResourceSwitcher>(); lightModule = this.part.FindModuleImplementing <WBILight>(); GUILayout.BeginVertical(); GUILayout.BeginScrollView(new Vector2(), new GUIStyle(GUI.skin.textArea), new GUILayoutOption[] { GUILayout.Height(480) }); if (!HighLogic.LoadedSceneIsFlight) { GUILayout.Label("This configuration is working, but the contents can only be accessed in flight."); GUILayout.EndScrollView(); GUILayout.EndVertical(); return; } //Control From Here if (commandModule != null) { if (GUILayout.Button("Control From Here")) { commandModule.MakeReference(); } //Rename Vessel if (GUILayout.Button("Rename Base")) { commandModule.RenameVessel(); } } //Toggle Decals if (switcher != null) { if (!string.IsNullOrEmpty(switcher.logoPanelTransforms)) { if (GUILayout.Button("Toggle Decals")) { switcher.ToggleDecals(); } } //Dump Resources if (GUILayout.Button("Dump Resources")) { switcher.DumpResources(); } } //Toggle Lights if (lightModule != null) { if (lightModule.isDeployed) { if (GUILayout.Button(lightModule.endEventGUIName)) { lightModule.TurnOffLights(); } } else { if (GUILayout.Button(lightModule.startEventGUIName)) { lightModule.TurnOnLights(); } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
public virtual void ToggleInflation() { //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated. if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0) { ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } //make sure we don't have parts radially attached if (isInflatable && isDeployed && !overridePartAttachRestriction) { if (this.part.children.Count > 0) { foreach (Part childPart in this.part.children) { if (childPart.attachMode == AttachModes.SRF_ATTACH) { ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } } } } //Play animation for current state animationStarted = true; PlayAnimation(isDeployed); //Toggle state isDeployed = !isDeployed; if (isDeployed) { this.part.CrewCapacity = inflatedCrewCapacity; this.part.crewTransferAvailable = true; if (HighLogic.LoadedSceneIsFlight) { this.part.SpawnIVA(); } Events["ToggleInflation"].guiName = endEventGUIName; } else { this.part.CrewCapacity = 0; this.part.crewTransferAvailable = false; if (HighLogic.LoadedSceneIsFlight) { this.part.DespawnIVA(); } Events["ToggleInflation"].guiName = startEventGUIName; //Turn off the lights if deflating the module. WBILight light = this.part.FindModuleImplementing <WBILight>(); if (light != null) { if (light.isDeployed) { light.TurnOffLights(); } } } //Setup colliders and inventories setupColliders(); //setupInventories(); Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName); }
public void Start() { lightModule = this.part.FindModuleImplementing <WBILight>(); if (lightModule != null) { if (lightModule.isDeployed && !setLightColor) { lightState = ELightStates.On; } else if (lightModule.isDeployed && setLightColor) { lightState = ELightStates.MainColor; } } propStateHelper = this.part.FindModuleImplementing <WBIPropStateHelper>(); if (propStateHelper != null) { string value = propStateHelper.LoadProperty(internalProp.propID, "lightState"); if (string.IsNullOrEmpty(value) == false) { lightState = (ELightStates)(int.Parse(value)); } } //Get the transform and setup click watcher Transform trans = internalProp.FindModelTransform(buttonName); if (trans != null) { GameObject goButton = trans.gameObject; if (goButton != null) { ButtonClickWatcher clickWatcher = goButton.GetComponent <ButtonClickWatcher>(); if (clickWatcher == null) { clickWatcher = goButton.AddComponent <ButtonClickWatcher>(); } clickWatcher.clickDelegate = OnButtonClick; } } //Setup button string[] rgbString = buttonColorOn.Split(new char[] { ',' }); colorButtonOn = new Color(float.Parse(rgbString[0]), float.Parse(rgbString[1]), float.Parse(rgbString[2])); rgbString = buttonColorOff.Split(new char[] { ',' }); colorButtonOff = new Color(float.Parse(rgbString[0]), float.Parse(rgbString[1]), float.Parse(rgbString[2])); Renderer colorShiftRenderer = internalProp.FindModelComponent <Renderer>(buttonName); colorShiftMaterial = colorShiftRenderer.material; if (setLightColor) { rgbString = primaryLightColor.Split(new char[] { ',' }); mainLightColor = new Color(float.Parse(rgbString[0]), float.Parse(rgbString[1]), float.Parse(rgbString[2])); rgbString = secondaryLightColor.Split(new char[] { ',' }); altLightColor = new Color(float.Parse(rgbString[0]), float.Parse(rgbString[1]), float.Parse(rgbString[2])); } SetButtonColor(); //Setup lights SetupLights(); }
public virtual void ToggleInflation() { //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated. if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0) { ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } //make sure we don't have parts radially attached if (isInflatable && isDeployed && !overridePartAttachRestriction) { if (this.part.children.Count > 0) { foreach (Part childPart in this.part.children) { if (childPart.attachMode == AttachModes.SRF_ATTACH) { ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } } } } //Play animation for current state isMoving = true; PlayAnimation(isDeployed); //Toggle state isDeployed = !isDeployed; if (isDeployed) { this.part.CrewCapacity = inflatedCrewCapacity; this.part.crewTransferAvailable = true; if (HighLogic.LoadedSceneIsFlight) { this.part.SpawnIVA(); } Events["ToggleInflation"].guiName = endEventGUIName; if (inventory != null) { inventory.packedVolumeLimit = packedVolumeLimit; } } else { this.part.CrewCapacity = 0; this.part.crewTransferAvailable = false; if (HighLogic.LoadedSceneIsFlight) { this.part.DespawnIVA(); } Events["ToggleInflation"].guiName = startEventGUIName; //Turn off the lights if deflating the module. WBILight light = this.part.FindModuleImplementing <WBILight>(); if (light != null) { if (light.isDeployed) { light.TurnOffLights(); } } if (inventory != null) { inventory.packedVolumeLimit = 0; } } //If this is a one-shot then hide the animation button. if (isOneShot && isDeployed && HighLogic.LoadedSceneIsEditor == false) { Events["ToggleInflation"].active = false; } Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName); MonoUtilities.RefreshContextWindows(this.part); GameEvents.onPartResourceListChange.Fire(this.part); }