private bool CheckRetractConditions() { var canRetract = true; if (inflatable) { if (part.protoModuleCrew.Count > 0) { var msg = string.Format("Unable to deflate {0} as it still contains crew members.", part.partInfo.title); ScreenMessages.PostScreenMessage(msg, 5f, ScreenMessageStyle.UPPER_CENTER); canRetract = false; } if (canRetract) { part.CrewCapacity = 0; if (inflatedMultiplier > 0) { CompressResourceCapacity(); } var modList = GetAffectedMods(); var count = modList.Count; for (int i = 0; i < count; ++i) { modList[i].DisableModule(); } MonoUtilities.RefreshContextWindows(part); } } return(canRetract); }
private void onVariantApplied(Part variantPart, PartVariant variant) { if (variantPart != part) { return; } if (string.IsNullOrEmpty(resourceName)) { return; } if (!part.Resources.Contains(resourceName)) { return; } string amountString = variant.GetExtraInfoValue(resourceName); if (string.IsNullOrEmpty(amountString)) { return; } double amount = 0; if (double.TryParse(amountString, out amount)) { part.Resources[resourceName].maxAmount = amount; if (!updateMaxOnly) { part.Resources[resourceName].amount = amount; } MonoUtilities.RefreshContextWindows(part); GameEvents.onPartResourceListChange.Fire(part); } }
private void ToggleArm(bool state) { armed = state; Events["Disarm"].active = state; Events["Arm"].active = !state; if (!state) { var animationstate1 = armmodule.GetState(); if (animationstate1.normalizedTime == 1f) { armmodule.Toggle(); } dockingmodule.isEnabled = false; } if (state) { var animationstate1 = armmodule.GetState(); if (animationstate1.normalizedTime == 0f) { armmodule.Toggle(); } dockingmodule.isEnabled = true; } MonoUtilities.RefreshContextWindows(part); }
private void ToggleMagnet(bool state) { magnetIsEnabled = state; Events["EnableMagnet"].guiActive = !state; Events["DisableMagnet"].guiActive = state; MonoUtilities.RefreshContextWindows(part); }
private void EnableMenus(bool enable) { Events["NextSetup"].active = enable; Events["PrevSetup"].active = enable; Events["LoadSetup"].active = enable; MonoUtilities.RefreshContextWindows(part); }
protected override void RefreshPAW() { if (HighLogic.LoadedSceneIsEditor) { base.RefreshPAW(); } else { Actions[nameof(DeployAction)].active = false; Actions[nameof(RetractAction)].active = false; Actions[nameof(ToggleAction)].active = false; Events[nameof(DeployEvent)].guiActive = false; Events[nameof(DeployEvent)].guiActiveEditor = false; Events[nameof(RetractEvent)].guiActive = false; Events[nameof(RetractEvent)].guiActiveEditor = false; if (PartialDeployPercentage >= 1d) { Actions[nameof(PayAction)].active = false; Events[nameof(PayEvent)].guiActive = false; Fields[nameof(PartialDeployPercentage)].guiActive = false; } MonoUtilities.RefreshContextWindows(part); } }
private void SetupLoadouts() { //Get our Module List Loadouts = new List <LoadoutInfo>(); int id = 0; var loadoutNames = new List <string>(); var mods = part.FindModulesImplementing <BaseConverter>(); var count = mods.Count; for (int i = 0; i < count; ++i) { var con = mods[i]; var loadout = new LoadoutInfo(); loadout.LoadoutName = con.ConverterName; loadout.ModuleId = id; loadoutNames.Add(con.ConverterName); Loadouts.Add(loadout); if (!con.IsActivated) { con.DisableModule(); } id++; } MonoUtilities.RefreshContextWindows(part); }
public void applyVariant(Part part, string meshSet) { Debug.Log("[SWVariant] - Applying variant: " + name); if (!string.IsNullOrEmpty(meshSet)) { Debug.Log("[SWVariant] - For mesh set: " + meshSet); } // Mesh sets are applied before any other fields in the variant. if (!string.IsNullOrEmpty(meshSet) && meshSets != null && meshSets.ContainsKey(meshSet)) { meshSets[meshSet].applyVariant(part, meshSet); } if (textureVariant != null) { textureVariant.applyVariant(part); } // Now apply any game object variants if (meshVariant != null) { meshVariant.applyVariant(part); } // Now apply any colliders. if (colliderVariant != null) { colliderVariant.applyVariant(part, false); } applyAnimationVariant(part); MonoUtilities.RefreshContextWindows(part); }
protected virtual void RefreshPAW() { if (_resourceCosts != null && _resourceCosts.Count > 0 && PartialDeployPercentage < 1d) { Actions[nameof(DeployAction)].active = false; Actions[nameof(RetractAction)].active = false; Actions[nameof(ToggleAction)].active = false; Events[nameof(DeployEvent)].guiActive = false; Events[nameof(RetractEvent)].guiActive = false; } else { Actions[nameof(PayAction)].active = false; Actions[nameof(DeployAction)].active = !StartDeployed; Actions[nameof(RetractAction)].active = StartDeployed; Events[nameof(PayEvent)].guiActive = false; Events[nameof(DeployEvent)].guiActive = !StartDeployed; Events[nameof(RetractEvent)].guiActive = StartDeployed; Fields[nameof(PartialDeployPercentage)].guiActive = false; } MonoUtilities.RefreshContextWindows(part); }
private void ToggleTransfer(bool state) { transferEnabled = state; Events["DisableTransfer"].active = state; Events["EnableTransfer"].active = !state; MonoUtilities.RefreshContextWindows(part); }
private void onEditorVariantApplied(Part part, PartVariant variant) { // This should never be called in flight, but somehow it was, so just // have a check to be safe if (HighLogic.LoadedSceneIsFlight) { return; } if (part != base.part || part == null) { return; } if (variant == null || variant.DisplayName == null) { return; } ModSegSRBs.GetExtraInfo(variant, ref this.part.segmentHeight, ref this.part.segmentWidth); RecalculateFuelAndMass(); var f = GetMaxThrust(); if (baseEngine != null) { baseEngine.ScheduleSegmentUpdate("MSSRB_Fuel_Segment.onEditorVariantApplied", 5); } #if true MonoUtilities.RefreshContextWindows(part); #else MonoUtilities.RefreshPartContextWindow(part); #endif }
private void ToggleTarget(bool state) { targetOnly = state; Events["EnableTargeting"].guiActive = !state; Events["DisableTargeting"].guiActive = state; MonoUtilities.RefreshContextWindows(part); }
/// <summary> /// Sets up the thrust transforms. /// </summary> public void SetupThrustTransform() { if (engine == null) { return; } if (!canReverseThrust) { return; } Debug.Log("[WBIPropSpinner] - SetupThrustTransform called. reverseThrust: " + reverseThrust); //We have separate forward and reverse thrust transforms. Switch them out. engine.thrustTransforms.Clear(); if (reverseThrust) { Events["ToggleThrustTransform"].guiName = Localizer.Format(forwardThrustActionName); for (int i = 0; i < revThrustTransform.Length; i++) { engine.thrustTransforms.Add(revThrustTransform[i]); } engine.thrustVectorTransformName = reverseThrustTransform; } else { Events["ToggleThrustTransform"].guiName = Localizer.Format(reverseThrustActionName); for (int i = 0; i < fwdThrustTransform.Length; i++) { engine.thrustTransforms.Add(fwdThrustTransform[i]); } engine.thrustVectorTransformName = thrustTransform; } MonoUtilities.RefreshContextWindows(this.part); }
public override bool SeekVolume(float targetVolume, int dir = 0) { BaseField field = Fields[nameof(length)]; float orig = (float)field.GetValue(this); float maxLength = (field.uiControlEditor as UI_FloatEdit).maxValue; float minLength = (field.uiControlEditor as UI_FloatEdit).minValue; float precision = (field.uiControlEditor as UI_FloatEdit).incrementSlide; // Solve length directly, taken from AdjustDimensionBounds float targetLength = (-3f * (Pi - 4f) * Pi * diameter * pow(fillet, 2) + Pi * (3f * Pi - 10f) * pow(fillet, 3) + 24f * targetVolume) / (6f * Pi * pow(diameter, 2)); targetLength = RoundToDirection(targetLength / precision, dir) * precision; float clampedTargetLength = Mathf.Clamp(targetLength, minLength, maxLength); bool closeEnough = Mathf.Abs((clampedTargetLength / targetLength) - 1) < 0.01; field.SetValue(targetLength, this); foreach (Part p in part.symmetryCounterparts) { // Propagate the change to other parts in symmetry group if (FindAbstractShapeModule(p, this) is ProceduralAbstractShape pm) { field.SetValue(targetLength, pm); } } OnShapeDimensionChanged(field, orig); MonoUtilities.RefreshPartContextWindow(part); return(closeEnough); }
private void ClampFillet(BaseField f, object obj) { if (fillet > Mathf.Min(diameter, length)) { fillet = Mathf.Min(diameter, length); MonoUtilities.RefreshPartContextWindow(part); } }
public void SetActive(bool isActive) { this.isActive = isActive; Events[nameof(ToggleDampenEvent)].guiName = $"Ground tether: {(isActive ? "On" : "Off")}"; MonoUtilities.RefreshContextWindows(part); }
private void OnTankTypeChangedWithSymmetry(BaseField f, object obj) { OnTankTypeChanged(f, obj); foreach (Part p in part.symmetryCounterparts) { p.FindModuleImplementing <TankContentSwitcher>()?.OnTankTypeChanged(f, obj); } MonoUtilities.RefreshPartContextWindow(part); }
private void SetDeployedState(int speed) { isDeployed = true; Events["DeployModule"].active = false; Events["RetractModule"].active = true; PlayDeployAnimation(speed); EnableModules(); MonoUtilities.RefreshContextWindows(part); }
protected void ExpandCrewCapacity() { if (CrewCapacity > 0) { part.CrewCapacity = CrewCapacity; part.CheckTransferDialog(); MonoUtilities.RefreshContextWindows(part); } }
private void UpdateMenu() { selectedRecipeName = _recipeOptions[selectedRecipeIndex].RecipeDisplayName; var nextRecipeName = _recipeOptions[_nextRecipeIndex].RecipeDisplayName; Events["SwapRecipe"].guiName = selectedRecipeName + " => " + nextRecipeName; MonoUtilities.RefreshPartContextWindow(part); }
private void ApplyHarvesterChanges(ModuleResourceHarvester_USI harvester, ModuleSwapOption loadout) { harvester.Efficiency = loadout.Efficiency; harvester.ResourceName = loadout.ResourceName; harvester.ConverterName = loadout.ConverterName; harvester.StartActionName = loadout.StartActionName; harvester.StopActionName = loadout.StopActionName; MonoUtilities.RefreshContextWindows(part); }
private void Setup() { Events["DeployModule"].guiName = "Deploy " + moduleType; Events["RetractModule"].guiName = "Retract " + moduleType; Actions["DeployModuleAction"].guiName = "Deploy " + moduleType; Actions["RetractModuleAction"].guiName = "Retract " + moduleType; Actions["ToggleModuleAction"].guiName = "Toggle " + moduleType; MonoUtilities.RefreshContextWindows(part); }
protected void setManageOpsButtonVisible() { Events["ReconfigureStorage"].guiActive = fieldReconfigurable || ShowGUI; Events["ReconfigureStorage"].guiActiveUnfocused = fieldReconfigurable || ShowGUI; Events["ReconfigureStorage"].guiActiveEditor = fieldReconfigurable || ShowGUI; //Dirty the GUI MonoUtilities.RefreshContextWindows(this.part); }
private void ClampFillet(BaseField f, object obj) { if (fillet > Mathf.Min((outerDiameter - innerDiameter) / 2f, length) + 0.001f) { float oldFillet = fillet; fillet = Mathf.Min((outerDiameter - innerDiameter) / 2f, length); MonoUtilities.RefreshPartContextWindow(part); } }
public virtual void ApplyConverterChanges(T converter) { converter.ConverterName = ConverterName; converter.StartActionName = StartActionName; converter.StopActionName = StopActionName; converter.UseSpecialistBonus = UseSpecialistBonus; converter.ExperienceEffect = ExperienceEffect; MonoUtilities.RefreshContextWindows(part); }
private void EnableMenus(bool enable) { Events["NextSetup"].guiActiveEditor = enable; Events["PrevSetup"].guiActiveEditor = enable; Events["LoadSetup"].guiActiveEditor = enable; Events["NextSetup"].externalToEVAOnly = !enable; Events["PrevSetup"].externalToEVAOnly = !enable; Events["LoadSetup"].externalToEVAOnly = !enable; MonoUtilities.RefreshContextWindows(part); }
private void ClampControllableMass() { var maxControllableMass = GetMaximumControllableMass(); if (controllableMass > maxControllableMass * FloatTolerance) { Log($"Resetting procedural mass limit to {maxControllableMass}, was {controllableMass}"); controllableMass = maxControllableMass; MonoUtilities.RefreshContextWindows(part); } }
public void ChangeMenu() { Events["NextSetup"].guiName = (bayName + " Next " + _controller.typeName).Trim(); Events["PrevSetup"].guiName = (bayName + " Prev. " + _controller.typeName).Trim(); Fields["curTemplate"].guiName = (bayName + " Active " + _controller.typeName).Trim(); curTemplate = _controller.Loadouts[currentLoadout].ConverterName; Events["LoadSetup"].guiName = (bayName + " " + curTemplate + "=>" + _controller.Loadouts[displayLoadout].ConverterName).Trim(); MonoUtilities.RefreshContextWindows(part); }
/// <summary> /// Used to toggle PAW items on or off based on conditions /// </summary> protected virtual void TogglePawItems() { Events[nameof(CancelRouteEvent)].active = IsConnectedToOrigin; Events[nameof(ConnectToDepotEvent)].active = IsConnectedToOrigin; Events[nameof(ConnectToOriginEvent)].active = !IsConnectedToOrigin; Fields[nameof(OriginDepotDisplay)].guiActive = IsConnectedToOrigin && !string.IsNullOrEmpty(OriginDepotDisplay); Fields[nameof(RoutePayload)].guiActive = IsConnectedToOrigin; Fields[nameof(RoutePayloadCost)].guiActive = IsConnectedToOrigin; MonoUtilities.RefreshPartContextWindow(part); }
public override void OnStart(StartState state) { //_broker = new ResourceBroker(); _bays = part.FindModulesImplementing <ModuleSwappableConverter>(); if (autoActivate || HighLogic.LoadedSceneIsEditor) { SetModuleState(null, true); } GameEvents.OnAnimationGroupStateChanged.Add(SetModuleState); MonoUtilities.RefreshContextWindows(part); }