private void onPartCouple(GameEvents.FromToAction <Part, Part> action) { if (action.to == base.part) { module.Toggle(); } }
private void ArmGrapple(int index, TextMenu.Item ti) { ModuleGrappleNode thatClaw = null; foreach (PartModule thatModule in vessel.GetReferenceTransformPart().Modules) { thatClaw = thatModule as ModuleGrappleNode; if (thatClaw != null) { break; } } if (thatClaw != null) { try { ModuleAnimateGeneric clawAnimation = (vessel.GetReferenceTransformPart().Modules[thatClaw.deployAnimationController] as ModuleAnimateGeneric); if (clawAnimation != null) { clawAnimation.Toggle(); } } catch (Exception e) { JUtil.LogErrorMessage(this, "Exception trying to arm/disarm Grapple Node: {0}", e.Message); } } }
public void OnButtonClick() { if (buttonAnimation != null) { buttonClicked = !buttonClicked; buttonAnimation.Toggle(); } SetButtonColor(); }
public void PlayAnimation() { ModuleAnimateGeneric myAnimation = part.FindModulesImplementing <ModuleAnimateGeneric>().SingleOrDefault(); if (!myAnimation) { return; } myAnimation.Toggle(); }
public void Inflate() { ScreenMessages.PostScreenMessage("<color=#00ff00ff>[ComfortableLanding]Inflate!</color>", 3f, ScreenMessageStyle.UPPER_CENTER); audioSource.PlayOneShot(playSound); InflateAnim.allowManualControl = true; InflateAnim.Toggle(); InflateAnim.allowManualControl = false; this.part.buoyancy = buoyancyAfterInflated;//This is a really buoy! Debug.Log("<color=#FF8C00ff>Comfortable Landing:</color>Inflate!"); }
void retract() { ModuleAnimateGeneric aModuleAnimateGeneric = new ModuleAnimateGeneric(); aModuleAnimateGeneric = part.Modules.OfType <ModuleAnimateGeneric>().FirstOrDefault(); if (aModuleAnimateGeneric.Events["Toggle"].guiName == "Retract" && aModuleAnimateGeneric.Events["Toggle"].guiActive == true) { aModuleAnimateGeneric.Toggle(); } }
internal override void Toggle() { if (animationModule.CanMove) { if (Extended()) { if (action == ActionType.Toggle || action == ActionType.Deactivate) { animationModule.Toggle(); } } else { if (action == ActionType.Toggle || action == ActionType.Activate) { animationModule.Toggle(); } } } }
public void Inflate() { ScreenMessages.PostScreenMessage("<color=#00ff00ff>[ComfortableLanding]Inflate!</color>", 3f, ScreenMessageStyle.UPPER_CENTER); audioSource.PlayOneShot(inflateSound); InflateAnim.allowManualControl = true; InflateAnim.Toggle(); //InflateAnim.allowManualControl = false; this.part.crashTolerance = crashToleranceAfterInflated;//This is an really airbag! this.part.CenterOfBuoyancy = COBAfterInflated; this.part.buoyancy = buoyancyAfterInflated; Debug.Log("<color=#FF8C00ff>[Comfortable Landing]</color>Inflate!"); }
/// <summary>Fires instance of MAG when retracting/deploying.</summary> public void PlayAnimation() { if (!isReady || isPaused) { return; } if (!retractionAnimation) { return; } retractionAnimation.Toggle(); }
public void BeaconShutdown() { ModuleAnimateGeneric MAG = part.FindModuleImplementing <ModuleAnimateGeneric>(); print("Deactivating beacon! Toggling MAG from " + MAG.status + "-" + MAG.Progress); MAG.Toggle(); beaconStatus = "Offline."; part.deactivate(); activated = false; Fields["constantEC"].guiActive = false; Events["BeaconShutdown"].active = false; Events["BeaconInitialize"].active = true; }
public override void FixModule(bool hasEnergy) { if (animateGeneric != null) { if (animateGeneric.animSpeed > 0 && !hasEnergy) animateGeneric.Toggle(); ToggleActions(animateGeneric, hasEnergy); } else if (colorChanger != null) { if (colorChanger.animState && !hasEnergy) colorChanger.ToggleEvent(); ToggleActions(colorChanger, hasEnergy); } }
void extend() { ModuleAnimateGeneric aModuleAnimateGeneric = new ModuleAnimateGeneric(); aModuleAnimateGeneric = part.Modules.OfType <ModuleAnimateGeneric>().FirstOrDefault(); if (aModuleAnimateGeneric == null) { return; } if (aModuleAnimateGeneric.Events["Toggle"].guiName == "Extend" && aModuleAnimateGeneric.Events["Toggle"].guiActive == true) { aModuleAnimateGeneric.Toggle(); } }
public void TurnAnimationOff() { ModuleAnimateGeneric glowAnim = this.part.FindModuleImplementing <ModuleAnimateGeneric>(); if (glowAnim == null) { return; } //Turn off the glow animation if (glowAnim.Events["Toggle"].guiName == glowAnim.endEventGUIName) { glowAnim.Toggle(); } }
internal void DeployCanards() { // start the animation and adjust aero for deployed canards if (_deployAnimation != null) { _deployAnimation.Toggle(); } if (_liftingSurface != null) { _liftingSurface.deflectionLiftCoeff = 1f; _liftingSurface.useInternalDragModel = true; } Debug.Log(string.Format("{0} Deploying canards", _myModTag)); }
public void BeaconInitialize() { checkOwnTechBoxes(); print("Crew bonus: Engineers on board reduce electrical usage by:"); print(getCrewBonuses(vessel, "Engineer", 0.5, 5)); print("Crew bonus: Scientists on board reduce Karborundum costs by:"); print(getCrewBonuses(vessel, "Scientist", 0.5, 5)); print("Crew bonus: Pilots on board reduce drift by:"); print(getCrewBonuses(vessel, "Pilot", 0.5, 5)); if (!requireResource(vessel, "Karborundum", 0.1, false)) { ScreenMessages.PostScreenMessage("Cannot activate! Insufficient Karborundum to initiate reaction.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } if (FlightGlobals.getGeeForceAtPosition(vessel.GetWorldPos3D()).magnitude > gLimit) // Check our G forces. { print("Too deep in gravity well to activate!"); string thevar = (vessel.mainBody.name == "Mun" || vessel.mainBody.name == "Sun") ? "the " : string.Empty; ScreenMessages.PostScreenMessage("Cannot activate! Gravity from " + thevar + vessel.mainBody.name + " is too strong.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } if (vessel.altitude < (vessel.mainBody.Radius * .25f)) // Check for radius limit. { string thevar = (vessel.mainBody.name == "Mun" || vessel.mainBody.name == "Sun") ? "the " : string.Empty; ScreenMessages.PostScreenMessage("Cannot activate! Beacon is too close to " + thevar + vessel.mainBody.name + ".", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } if (!requireResource(vessel, "ElectricCharge", neededEC, true)) { ScreenMessages.PostScreenMessage("Cannot activate! Insufficient electric power to initiate reaction.", 5.0f, ScreenMessageStyle.UPPER_CENTER); return; } // part.AddThermalFlux(neededEC * 10); ModuleAnimateGeneric MAG = part.FindModuleImplementing <ModuleAnimateGeneric>(); print("Activating beacon! Toggling MAG from " + MAG.status + "-" + MAG.Progress); print("EC Activation charge at " + neededEC + "(" + FlightGlobals.getGeeForceAtPosition(vessel.GetWorldPos3D()).magnitude + "/" + gLimit + ", " + fuelOnBoard + ")"); MAG.Toggle(); activated = true; part.force_activate(); Fields["neededEC"].guiActive = false; Fields["constantEC"].guiActive = true; Events["BeaconInitialize"].active = false; Events["BeaconShutdown"].active = true; beaconStatus = "Active."; }
public void TurnAnimationOn() { ModuleAnimateGeneric glowAnim = null; //Get our glow animation (if any) glowAnim = this.part.FindModuleImplementing <ModuleAnimateGeneric>(); if (glowAnim == null) { return; } //Ok, now turn on our glow panel if it isn't already. if (glowAnim.Events["Toggle"].guiName == glowAnim.startEventGUIName) { glowAnim.Toggle(); } }
public void OnVesselWasModified(Vessel vessel) { if (anim == null) { return; } //Have we released our target? if (vessel == this.part.vessel) { if (dockedPartUId == 0 || otherVesselInfo == null) { if (anim.Events["Toggle"].guiName == anim.startEventGUIName) { anim.Toggle(); } } } }
public void ScanAsteroid() { ModuleAnimateGeneric animation = this.part.FindModuleImplementing <ModuleAnimateGeneric>(); ModuleAsteroidAnalysis asteroidAnalysis = this.part.FindModuleImplementing <ModuleAsteroidAnalysis>(); ModuleAsteroid asteroid = null; ModuleAsteroidInfo asteroidInfo = null; //Make sure we have an analysis module if (asteroidAnalysis == null) { ScreenMessages.PostScreenMessage(kNoAnalysisModule, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); return; } //See if we can find the asteroid modules asteroid = this.part.vessel.FindPartModuleImplementing <ModuleAsteroid>(); if (asteroid == null) { ScreenMessages.PostScreenMessage(kNoPotato, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); return; } asteroidInfo = asteroid.part.FindModuleImplementing <ModuleAsteroidInfo>(); if (asteroidInfo == null) { ScreenMessages.PostScreenMessage(kNoPotato, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); return; } //Good to go //Extend the arm if needed. if (animation != null) { if (animation.Events["Toggle"].guiName == animation.startEventGUIName) { animation.Toggle(); } } //Display the window scannerInfo.asteroid = asteroid; scannerInfo.asteroidInfo = asteroidInfo; scannerInfo.SetVisible(true); }
void retract() { if (HasMod("ModuleAnimateGenericEffects")) { retractEffects(); } else { ModuleAnimateGeneric aModuleAnimateGeneric = new ModuleAnimateGeneric(); aModuleAnimateGeneric = part.Modules.OfType <ModuleAnimateGeneric>().FirstOrDefault(); if (aModuleAnimateGeneric == null) { return; } if (aModuleAnimateGeneric.Events["Toggle"].guiName == "Retract" && aModuleAnimateGeneric.Events["Toggle"].guiActive == true) { aModuleAnimateGeneric.Toggle(); } } }
public static void Off(PartModule light) { switch (light.moduleName) { case "ModuleColorChanger": case "ModuleColorChangerConsumer": ModuleColorChanger castMCC = (ModuleColorChanger)light; if (castMCC.animState) { castMCC.ToggleEvent(); } break; case "ModuleLight": case "ModuleStockLightColoredLens": case "ModuleMultiPointSurfaceLight": case "ModuleColoredLensLight": ModuleLight castML = (ModuleLight)light; castML.LightsOff(); break; case "ModuleAnimateGeneric": case "ModuleAnumateGenericConsumer": ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light; castMAG.Toggle(); break; case "WBILight": light.GetType().InvokeMember("TurnOffLights", BindingFlags.InvokeMethod, null, light, null); break; case "ModuleNavLight": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 0 }); break; case "ModuleKELight": light.GetType().InvokeMember("LightsOff", BindingFlags.InvokeMethod, null, light, null); break; } }
private void DeployCanards() { // start the animation and adjust aero for deployed canards Debug.Log(string.Format("{0} Deploying canards", _myModTag)); if (_deployAnimation != null) { _deployAnimation.Toggle(); } // Debug.Log(string.Format("{0} re-setting CoMOffset in Y axis from {1} to {2}", _myModTag, part.CoMOffset.y.ToString(), _origComOffset.y.ToString())); part.CoMOffset.Set(_origComOffset.x, _origComOffset.y, _origComOffset.z); part.CoLOffset.Set(_origColOffset.x, _origColOffset.y + 1.45f, _origColOffset.z); if (_liftingSurface != null && part.Modules.Contains <ModuleLiftingSurface>()) { _liftingSurface.useInternalDragModel = true; _liftingSurface.deflectionLiftCoeff = 0.35f; } hasDeployed = true; }
public void TurnAnimationOff() { //Turn on the docking lights if we have any if (dockingLight != null) { dockingLight.TurnOffLights(); return; } //Legacy method of turning off docking lights. ModuleAnimateGeneric glowAnim = this.part.FindModuleImplementing <ModuleAnimateGeneric>(); if (glowAnim == null) { return; } //Turn off the glow animation if (glowAnim.Events["Toggle"].guiName == glowAnim.endEventGUIName) { glowAnim.Toggle(); } }
public override void Ctrl(bool value) { switch (ModuleName) { case "ModuleDeployableAntenna": if (animDefault.deployState == DeployState.BROKEN) { return; } if (value) { animDefault.Extend(); } else { animDefault.Retract(); } break; case "ModuleAnimateGeneric": specialCase.Toggle(); break; case "ModuleRTAntenna": Lib.ReflectionValue(module, "IsRTActive", value); break; } }
public void FixedUpdate() { if (!isActive) { return; } if (_loopingAnimation != null && !_loopingAnimation.IsMoving()) { _loopingAnimation.Toggle(); } // first check available hydrogen part.GetConnectedResourceTotals(_liquidHydrogenDefinition.id, out double amount, out double maxAmount); if (amount <= 0) { return; } var availablePower = GetAvailableStableSupply(ResourceSettings.Config.ElectricPowerInMegawatt); var resourceBarRatio = GetResourceBarRatio(ResourceSettings.Config.ElectricPowerInMegawatt); var effectiveResourceThrottling = resourceBarRatio > 1d / 3d ? 1 : resourceBarRatio * 3; var requestedPower = powerPercentage * 0.01 * Math.Min(powerCapacity * powerRequirementMultiplier, effectiveResourceThrottling * availablePower); var receivedPower = CheatOptions.InfiniteElectricity ? requestedPower : ConsumeFnResourcePerSecond(requestedPower, ResourceSettings.Config.ElectricPowerInMegawatt); megajoulesPerSecond = receivedPower * efficiency; // produce wasteheat SupplyFnResourcePerSecond(receivedPower * (1 - efficiency), ResourceSettings.Config.WasteHeatInMegawatt); Produce(megajoulesPerSecond, TimeWarp.fixedDeltaTime); }
public void Update() { var antimatterResource = part.Resources.Get(_antimatterDefinition.id); _showAntimatterFields = antimatterResource != null; _temperatureStrField.guiActive = _showAntimatterFields && canExplodeFromHeat; _temperatureStrField.guiActiveEditor = _showAntimatterFields && canExplodeFromHeat; _geeforceStrField.guiActive = _showAntimatterFields && canExplodeFromGeeForce; _geeforceStrField.guiActiveEditor = _showAntimatterFields && canExplodeFromGeeForce; _capacityStrField.guiActive = _showAntimatterFields && showCapacity; _capacityStrField.guiActiveEditor = _showAntimatterFields && showCapacity; _maxAmountStrField.guiActive = _showAntimatterFields && showMaxAmount; _maxAmountStrField.guiActiveEditor = _showAntimatterFields && showMaxAmount; if (antimatterResource == null) { return; } // determine TechLevel maximum storage amount only in editor if (HighLogic.LoadedSceneIsEditor && maxStorage != 0) { var currentStorageRatio = antimatterResource.amount / antimatterResource.maxAmount; var newMaximum = maxStorage * storedResourceCostMultiplier * StorageCapacityModifier; var newAmount = antimatterResource.maxAmount * currentStorageRatio; if (Math.Abs(antimatterResource.maxAmount - newMaximum) > 1) { antimatterResource.maxAmount = newMaximum; antimatterResource.amount = newAmount; } } // charge if there is any significant antimatter _shouldCharge = antimatterResource.amount > _minimumAntimatterAmount; // restore antimatter amount when stolen if (HighLogic.LoadedSceneIsEditor) { storedAmount = antimatterResource.amount; } else if (vessel.missionTime < 1 && storedAmount > 0 && antimatterResource.amount == 0) { antimatterResource.amount = storedAmount; storedAmount = 0; } capacityStr = PluginHelper.FormatMassStr(antimatterResource.amount * antimatterDensity); maxAmountStr = PluginHelper.FormatMassStr(antimatterResource.maxAmount * antimatterDensity); var explosionPowerInTnt = antimatterResource.amount * antimatterResource.info.density * volumeMultiplier * explosionMultiplier; part.explosionPotential = (float)explosionPowerInTnt * 10; UpdateTargetMass(); UpdateTolerances(); var newRatio = antimatterResource.amount / antimatterResource.maxAmount; // if closed and changed if (_deploymentAnimation != null && _deploymentAnimation.GetScalar == 0 && newRatio != resourceRatio && HighLogic.LoadedSceneIsEditor) { // open up _deploymentAnimation.Toggle(); } resourceRatio = newRatio; partMass = part.mass; if (HighLogic.LoadedSceneIsEditor) { chargeStatus = maxCharge; Fields[nameof(maxGeeforce)].guiActiveEditor = calculatedMass && canExplodeFromGeeForce; Fields[nameof(maxTemperature)].guiActiveEditor = calculatedMass && canExplodeFromHeat; return; } chargeStatusStr = chargeStatus.ToString("0.0") + " / " + maxCharge.ToString("0.0"); TemperatureStr = part.temperature.ToString("0") + " / " + maxTemperature.ToString("0"); GeeforceStr = _effectiveMaxGeeforce == 0 ? maxGeeforce.ToString("0.0") + " when full" : currentGeeForce.ToString("0.000") + " / " + _effectiveMaxGeeforce.ToString("0.000"); _minimumAntimatterAmount = _antimatterDensityModifier * antimatterResource.maxAmount; Events[nameof(StartCharge)].active = antimatterResource.amount <= _minimumAntimatterAmount && !_shouldCharge; Events[nameof(StopCharge)].active = antimatterResource.amount <= _minimumAntimatterAmount && _shouldCharge; if (maxCharge <= 60 && !_charging && antimatterResource.amount > _minimumAntimatterAmount) { ScreenMessages.PostScreenMessage(Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Postmsg6", chargeStatus.ToString("0")), 0.5f, ScreenMessageStyle.UPPER_CENTER);//"Warning!: Antimatter storage unpowered, tank explosion in: " + + "s" } if (antimatterResource.amount > _minimumAntimatterAmount) { statusStr = _charging ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu2");//"Charging.""Discharging!" } else { statusStr = _shouldCharge ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu3");//"Charging.""No Power Required." } }
public void Update() { var antimatterResource = part.Resources[resourceName]; showAntimatterFields = antimatterResource != null && antimatterResource.resourceName == resourceName; TemperatureStrField.guiActive = canExplodeFromHeat; TemperatureStrField.guiActiveEditor = canExplodeFromHeat; GeeforceStrField.guiActive = canExplodeFromGeeForce; GeeforceStrField.guiActiveEditor = canExplodeFromGeeForce; if (antimatterResource == null) { antimatterResource = part.Resources.OrderByDescending(m => m.maxAmount).FirstOrDefault(); if (antimatterResource == null) { return; } } capacityStrField.guiActive = showAntimatterFields; capacityStrField.guiActiveEditor = showAntimatterFields; maxAmountStrField.guiActive = showAntimatterFields; maxAmountStrField.guiActiveEditor = showAntimatterFields; // restore antimatter amount when stolen if (HighLogic.LoadedSceneIsEditor) { storedAmount = antimatterResource.amount; } else if (vessel.missionTime < 1 && storedAmount > 0 && antimatterResource.amount == 0) { antimatterResource.amount = storedAmount; storedAmount = 0; } capacityStr = PluginHelper.formatMassStr(antimatterResource.amount * antimatterDensity); maxAmountStr = PluginHelper.formatMassStr(antimatterResource.maxAmount * antimatterDensity); part.explosionPotential = (float)antimatterResource.amount * explosionPotentialMultiplier; UpdateTargetMass(); UpdateTolerances(); var newRatio = antimatterResource.amount / antimatterResource.maxAmount; // if closed and changed if (deploymentAnimation != null && deploymentAnimation.GetScalar == 0 && newRatio != resourceRatio && HighLogic.LoadedSceneIsEditor) { // open up deploymentAnimation.Toggle(); } resourceRatio = newRatio; partMass = part.mass; partCost = part.partInfo.cost; if (HighLogic.LoadedSceneIsEditor) { chargestatus = maxCharge; Fields["maxGeeforce"].guiActiveEditor = canExplodeFromGeeForce; Fields["maxTemperature"].guiActiveEditor = canExplodeFromHeat; return; } chargeStatusStr = chargestatus.ToString("0.0") + " / " + maxCharge.ToString("0.0"); TemperatureStr = part.temperature.ToString("0") + " / " + maxTemperature.ToString("0"); GeeforceStr = effectiveMaxGeeforce == 0 ? maxGeeforce.ToString("0.0") + " when full" : currentGeeForce.ToString("0.000") + " / " + effectiveMaxGeeforce.ToString("0.000"); minimimAnimatterAmount = antimatterDensityModifier * antimatterResource.maxAmount; Events["StartCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && !should_charge; Events["StopCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && should_charge; if (maxCharge <= 60 && !charging && antimatterResource.amount > minimimAnimatterAmount) { ScreenMessages.PostScreenMessage(Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Postmsg6", chargestatus.ToString("0")), 0.5f, ScreenMessageStyle.UPPER_CENTER);//"Warning!: Antimatter storage unpowered, tank explosion in: " + + "s" } if (antimatterResource.amount > minimimAnimatterAmount) { statusStr = charging ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu2");//"Charging.""Discharging!" } else { statusStr = should_charge ? Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu1") : Localizer.Format("#LOC_KSPIE_AntimatterStorageTank_Statu3");//"Charging.""No Power Required." } }
public static void On(PartModule light) { if (!settingsLoaded) { LoadSettings(); } switch (light.moduleName) { case "ModuleColorChanger": case "ModuleColorChangerConsumer": ModuleColorChanger castMCC = (ModuleColorChanger)light; if (!castMCC.animState) { castMCC.ToggleEvent(); } break; case "ModuleLight": case "ModuleStockLightColoredLens": case "ModuleMultiPointSurfaceLight": case "ModuleColoredLensLight": ModuleLight castML = (ModuleLight)light; castML.LightsOn(); break; case "ModuleAnimateGeneric": case "ModuleAnimateGenericConsumer": ModuleAnimateGeneric castMAG = (ModuleAnimateGeneric)light; if (castMAG.animSwitch) { castMAG.Toggle(); } break; case "WBILight": light.GetType().InvokeMember("TurnOnLights", BindingFlags.InvokeMethod, null, light, null); break; case "ModuleNavLight": if (generalSettings.useAviationLightsEffect && GameSettingsLive.inSunlight) { switch (light.part.name) { case "lightbeacon.amber": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.beaconAmber) }); break; case "lightbeacon.red": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.beaconRed) }); break; case "lightnav.blue": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navBlue) }); break; case "lightnav.green": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navGreen) }); break; case "lightnav.red": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navRed) }); break; case "lightnav.white": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.navWhite) }); break; case "lightstrobe.white": light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { ParseNavLightStr(aviationLSettings.strobeWhite) }); break; default: light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 4 }); break; } } else { light.GetType().InvokeMember("navLightSwitch", BindingFlags.SetField, null, light, new object[] { 4 }); } break; case "ModuleKELight": light.GetType().InvokeMember("LightsOn", BindingFlags.InvokeMethod, null, light, null); break; } }
public void Move() { /*foreach (Part p in this.part.children) * { * ConfigurableJoint partJoint = p.attachJoint.Joint; * partJoint.connectedBody = null; * part.rb.WakeUp(); * p.rb.isKinematic = true; * p.transform.SetParent(moveNode.nodeTransform, true); * }*/ Stack <Part> stack = new Stack <Part>(); stack.Push(this.part); while (stack.Count > 0) { Part item = stack.Pop(); //Debug.Log("[ROBOTICS] " + item.partInfo.title); if (item == this.part) { Part child = moveNode.attachedPart; ConfigurableJoint partJoint = child.attachJoint.Joint; partJoint.connectedBody = null; //item.rb.WakeUp(); child.rb.isKinematic = true; child.transform.SetParent(moveNode.nodeTransform, true); stack.Push(child); } else { foreach (Part child in item.children) { if (child.PhysicsSignificance == 1) { continue; } ConfigurableJoint partJoint = child.attachJoint.Joint; //Debug.Log("[ROBOTICS] " + child.partInfo.title); //Debug.Log("[ROBOTICS] Count " + item.attachNodes.Count); /*foreach (AttachNode n in item.attachNodes) * { * if (n.attachedPart == null) * { * Debug.Log("[ROBOTICS] attached part is null"); * continue; * } * * Debug.Log("[ROBOTICS] " + n.attachedPart.partInfo.title); * Debug.Log("[ROBOTICS] " + n.attachedPartId); * Debug.Log("[ROBOTICS] " + n.attachedPart.flightID); * }*/ AttachNode node = item.FindAttachNodeByPart(child); /*if (node == null) * { * Debug.Log("NODE IS NULL WTF KSP"); * }*/ //Debug.Log("[ROBOTICS] " + node.id); //Debug.Log("1"); partJoint.connectedBody = null; //Debug.Log("2"); //item.rb.WakeUp(); //Debug.Log("3"); child.rb.isKinematic = true; //Debug.Log("4"); if (item == this.part) { child.transform.SetParent(node.nodeTransform, true); } else { child.transform.SetParent(item.partTransform, true); } //Debug.Log("5"); stack.Push(child); //Debug.Log("6"); } } } isMoving = true; animationModule.Toggle(); }
private void MainGUI(int WindowID) { timer += Planetarium.GetUniversalTime() - storedTime; storedTime = Planetarium.GetUniversalTime(); GUILayout.BeginHorizontal(); //Top right hand corner button that exits the window. if (GUI.Button(new Rect(WindowPosition.width - 18, 2, 16, 16), "")) { Toggle(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); //What you see looking through the telescope. ScopeRect = GUILayoutUtility.GetRect(400f, 400f); Texture2D ScopeScreen = CameraModule.UpdateTexture(ActiveProcessor); GUI.DrawTexture(ScopeRect, ScopeScreen); //Draw the preview texture GUI.DrawTexture(new Rect(ScopeRect.xMin, ScopeRect.yMax - 32f, 128f, 32f), PreviewTexture); //Draw the crosshair texture GUI.DrawTexture(new Rect(ScopeRect.xMin + (0.5f * ScopeRect.width) - 64, ScopeRect.yMin + (0.5f * ScopeRect.height) - 64, 128, 128), CrosshairTexture); //Draw the notification label if (timer > 5f) { Notification = ""; } GUI.Label(new Rect(ScopeRect.xMin + 16, ScopeRect.yMin + 16, 600, 32), new GUIContent(Notification)); ControlRect = GUILayoutUtility.GetRect(300f, 20f); if (Processors.Count > 1) { //Previous button if (GUI.Button(new Rect(433f, 72f, 32, 32), Back9Icon)) { ActiveProcessor.Active = false; ActiveProcessor = GetPrevious(Processors, ActiveProcessor); ActiveProcessor.Active = true; } if (GUI.Button(new Rect(635f, 72f, 32, 32), Forward9Icon)) { ActiveProcessor.Active = false; ActiveProcessor = GetNext(Processors, ActiveProcessor); ActiveProcessor.Active = true; } } GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter; GUI.Label(new Rect(475f, 40f, 150, 32), "Active Processor"); GUI.Label(new Rect(475f, 72f, 150, 32), ActiveProcessor.GetProcessorType()); if (!isSmallOptics) { if (GUI.Button(new Rect(475f, 124f, 150, 48), ToggleAperatureIcon)) { aperature.Toggle(); } } if (FlightGlobals.fetch.VesselTarget != null && ActiveProcessor && ActiveProcessor.GetProcessorType().Contains("Wide Field")) { GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleRight; GUI.Label(new Rect(425f, 188f, 150, 32), "Store Image:"); if (GUI.Button(new Rect(585f, 188f, 32, 32), SaveScreenshotTexture)) { //DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName)); Notification = " Screenshot saved to " + WriteTextureToDrive(CameraModule.TakeScreenshot(ActiveProcessor)); timer = 0f; } } else { GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(475f, 188f, 150, 32), "Imaging not available."); } if (FlightGlobals.fetch.VesselTarget != null && ActiveProcessor && HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) { GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleRight; GUI.Label(new Rect(425f, 252f, 150, 32), "Process Data:"); if (GUI.Button(new Rect(585f, 252f, 32, 32), Atom6Icon)) { //DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName)); //ActiveProcessor.GenerateScienceReport(TakeScreenshot(ActiveProcessor.GetType())); try { Notification = ActiveProcessor.DoScience(GetTargetPos(FlightGlobals.fetch.VesselTarget.GetTransform().position, 500f), scienceMultiplier, CameraModule.FieldOfView, CameraModule.TakeScreenshot(ActiveProcessor)); } catch (Exception e) { Notification = "An error occured. Please post that you're having this error on the official CactEye 2 thread on the Kerbal Forums."; Debug.Log("CactEye 2: Exception 4: An error occured producing a science report!"); Debug.Log(e.ToString()); } timer = 0f; } } else { GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(425f, 252f, 250, 32), "Data processing not available."); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); //Draw Processor controls in bottom center of display, with observation and screenshot buttons in center. DrawTargetPointer(); if (ActiveProcessor) { //Close window down if we run out of power if (!ActiveProcessor.IsActive()) { // Toggle(); // ScreenMessages.PostScreenMessage("Image processor is out of power. Please restore power to telescope.", 6, ScreenMessageStyle.UPPER_CENTER); ActiveProcessor = null; Notification = "Image Processor is out of power. Please restore power to telescope"; ScreenMessages.PostScreenMessage(Notification, 3f, ScreenMessageStyle.UPPER_CENTER); timer = 0f; Toggle(); } //Zoom Feedback Label. string LabelZoom = "Zoom/Magnification: x"; if (CameraModule.FieldOfView > 0.0064) { LabelZoom += string.Format("{0:####0.0}", 64 / CameraModule.FieldOfView); } else { LabelZoom += string.Format("{0:0.00E+0}", (64 / CameraModule.FieldOfView)); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUILayout.Label(LabelZoom); GUILayout.EndHorizontal(); //Zoom Slider Controls. GUILayout.BeginHorizontal(); FieldOfView = GUILayout.HorizontalSlider(FieldOfView, 0f, 1f); CameraModule.FieldOfView = 0.5f * Mathf.Pow(4f - FieldOfView * (4f - Mathf.Pow(ActiveProcessor.GetMinimumFOV(), (1f / 3f))), 3); GUILayout.EndHorizontal(); //Log spam //Debug.Log("CactEye 2: MinimumFOV = " + ActiveProcessor.GetMinimumFOV().ToString()); } else { GUILayout.BeginHorizontal(); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUILayout.Label("Processor not installed; optics module cannot function without an image processor."); GUILayout.EndHorizontal(); } //Gyro GUI. Active only if the craft has an active gyro if (GyroEnabled) { //Gyro Slider Label GUILayout.BeginHorizontal(); GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft; GUILayout.Label("Gyro Sensitivity: " + GyroSensitivity.ToString("P") + " + minimum gyroscopic torgue.", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); //Gyro Slider Controls. GUILayout.BeginHorizontal(); GyroSensitivity = GUILayout.HorizontalSlider(GyroSensitivity, 0f, 1f, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); SetTorgue(); } //Make the window draggable by the top bar only. GUI.DragWindow(new Rect(0, 0, WindowPosition.width, 16)); }
public void Update() { var showAntimatterFields = antimatterResource != null && antimatterResource.resourceName == resourceName; capacityStrField.guiActive = showAntimatterFields; capacityStrField.guiActiveEditor = showAntimatterFields; maxAmountStrField.guiActive = showAntimatterFields; maxAmountStrField.guiActiveEditor = showAntimatterFields; TemperatureStrField.guiActive = canExplodeFromHeat; TemperatureStrField.guiActiveEditor = canExplodeFromHeat; GeeforceStrField.guiActive = canExplodeFromGeeForce; GeeforceStrField.guiActiveEditor = canExplodeFromGeeForce; antimatterResource = part.Resources[resourceName]; if (antimatterResource == null) { antimatterResource = part.Resources.OrderByDescending(m => m.maxAmount).FirstOrDefault(); if (antimatterResource == null) { return; } } var newRatio = antimatterResource.amount / antimatterResource.maxAmount; // if closed and changed if (deploymentAnimation != null && deploymentAnimation.GetScalar == 0 && newRatio != resourceRatio && HighLogic.LoadedSceneIsEditor) { // open up deploymentAnimation.Toggle(); } resourceRatio = newRatio; UpdateAmounts(); UpdateTargetMass(); partMass = part.mass; partCost = part.partInfo.cost; if (HighLogic.LoadedSceneIsEditor) { chargestatus = maxCharge; Fields["maxGeeforce"].guiActiveEditor = canExplodeFromGeeForce; Fields["maxTemperature"].guiActiveEditor = canExplodeFromHeat; return; } chargeStatusStr = chargestatus.ToString("0.0") + " / " + maxCharge.ToString("0.0"); TemperatureStr = part.temperature.ToString("0") + " / " + maxTemperature.ToString("0"); GeeforceStr = part.vessel.geeForce.ToString("0.0") + " / " + maxGeeforce.ToString("0.0"); minimimAnimatterAmount = antimatterDenityModifier * antimatterResource.maxAmount; Events["StartCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && !should_charge; Events["StopCharge"].active = antimatterResource.amount <= minimimAnimatterAmount && should_charge; if (maxCharge <= 60 && !charging && antimatterResource.amount > minimimAnimatterAmount) { ScreenMessages.PostScreenMessage("Warning!: Antimatter storage unpowered, tank explosion in: " + chargestatus.ToString("0") + "s", 0.5f, ScreenMessageStyle.UPPER_CENTER); } if (antimatterResource.amount > minimimAnimatterAmount) { if (charging) { statusStr = "Charging."; } else { statusStr = "Discharging!"; } } else { if (should_charge) { statusStr = "Charging."; } else { statusStr = "No Power Required."; } } UpdateAmounts(); }