private MemberUpdater(object obj, FieldInfo field, PropertyInfo property, UI_FloatRange floatRange) { _object = obj; _field = field; _property = property; _floatRange = floatRange; }
public static MemberUpdater Create(object obj, string name) { if (obj == null || name == null) { return(null); } Type objectType = obj.GetType(); FieldInfo field = objectType.GetField(name, LookupFlags); PropertyInfo property = objectType.GetProperty(name, LookupFlags); UI_FloatRange floatRange = null; BaseFieldList fields; if (obj is PartModule) { fields = (obj as PartModule).Fields; try { BaseField fieldData = fields[name]; if ((object)fieldData != null) { UI_Control ctrl = fieldData.uiControlEditor; if (ctrl is UI_FloatRange) { floatRange = ctrl as UI_FloatRange; } } } catch (Exception) { string debuglog = "===============================================\r\n"; ConcatSafely("objectType", () => { return(objectType.ToString()); }, ref debuglog); ConcatSafely("name", () => { return(name); }, ref debuglog); ConcatSafely("fields.ReflectType", () => { return(fields.ReflectedType.ToString().ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { return(fields.Count.ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { string acc = ""; int numFields = fields.Count; for (int i = 0; i < numFields; i++) { ConcatSafely("field", () => { return(fields[i].ToString_rec(1)); }, ref acc); } return(acc); }, ref debuglog); Log.warn(debuglog); } } if (property != null && property.GetIndexParameters().Length > 0) { Log.warn("Property {0} on {1} requires indices, which TweakScale currently does not support.", name, objectType.Name); return(null); } if (field == null && property == null) { // handle special cases if ((obj is PartModule) && (name == "inputResources" || name == "outputResources")) { return(Create((obj as PartModule).resHandler, name)); } string partname = (obj is PartModule) ? (obj as PartModule).part.name : "<unk>"; Log.warn("No valid member found for {0} in {1} for {2}", name, objectType.Name, partname); return(null); } return(new MemberUpdater(obj, field, property, floatRange)); }
public override void OnStart(PartModule.StartState state) { definitionPrimaryPowerResource = PartResourceLibrary.Instance.GetDefinition(primaryConversionEnergyResource); definitionSecondaryPowerResource = PartResourceLibrary.Instance.GetDefinition(secondaryConversionEnergResource); Fields["powerUsagePercentage"].guiActiveEditor = showPowerUsageFloatRange; Fields["powerUsagePercentage"].guiActive = showPowerUsageFloatRange; convertPercentageField = Fields["convertPercentage"]; var floatrange = convertPercentageField.uiControlFlight as UI_FloatRange; primaryResources = primaryResourceNames.Split(';').Select(m => new ResourceStats() { definition = PartResourceLibrary.Instance.GetDefinition(m.Trim()) }).ToList(); secondaryResources = secondaryResourceNames.Split(';').Select(m => new ResourceStats() { definition = PartResourceLibrary.Instance.GetDefinition(m.Trim()) }).ToList(); hasNullDefinitions = primaryResources.Any(m => m.definition == null) || secondaryResources.Any(m => m.definition == null); if (hasNullDefinitions) { convertPercentageField.guiActiveEditor = false; convertPercentageField.guiActive = false; return; } foreach (var resource in primaryResources) { if (resource.definition.density > 0) { resource.normalizedDensity = resource.definition.density; } } foreach (var resource in secondaryResources) { if (resource.definition.density > 0) { resource.normalizedDensity = resource.definition.density; } } if (primaryResources.Count == 1 && secondaryResources.Count == 1) { var primary = primaryResources.First(); var secondary = secondaryResources.First(); if (primary.normalizedDensity == 0 && secondary.normalizedDensity > 0) { primary.normalizedDensity = secondary.normalizedDensity; } else if (secondary.normalizedDensity == 0 && primary.normalizedDensity > 0) { secondary.normalizedDensity = primary.normalizedDensity; } if (primary.normalizedDensity > 0 && secondary.normalizedDensity > 0) { secondary.conversionRatio = primary.normalizedDensity / secondary.normalizedDensity; primary.conversionRatio = secondary.normalizedDensity / primary.normalizedDensity; } else if (primary.definition.unitCost > 0 && secondary.definition.unitCost > 0) { secondary.conversionRatio = primary.definition.unitCost / secondary.definition.unitCost; primary.conversionRatio = secondary.definition.unitCost / primary.definition.unitCost; } if (primary.conversionRatio == 0) { primary.conversionRatio = 1; } if (secondary.conversionRatio == 0) { secondary.conversionRatio = 1; } if (primary.normalizedDensity == 0) { primary.normalizedDensity = 0.001; } if (secondary.normalizedDensity == 0) { secondary.normalizedDensity = 0.001; } secondarynormalizedDensity = secondary.normalizedDensity; primarynormalizedDensity = primary.normalizedDensity; } primaryResources.ForEach(m => m.transferRate = maxPowerPrimary / primaryConversionEnergyCost / 1000 / m.normalizedDensity); secondaryResources.ForEach(m => m.transferRate = maxPowerSecondary / secondaryConversionEnergyCost / 1000 / m.normalizedDensity); // if slider text is missing, generate it if (string.IsNullOrEmpty(sliderText)) { convertPercentageField.guiName = String.Join("+", primaryResources.Select(m => m.definition.name).ToArray()) + "<->" + String.Join("+", secondaryResources.Select(m => m.definition.name).ToArray()); } else { convertPercentageField.guiName = sliderText; } convertPecentageFlightFloatRange = convertPercentageField.uiControlFlight as UI_FloatRange; convertPecentageFlightFloatRange.maxValue = percentageMaxValue; convertPecentageFlightFloatRange.minValue = percentageMinValue; convertPecentageFlightFloatRange.stepIncrement = percentageStepIncrement; convertPecentageFlightFloatRange.affectSymCounterparts = percentageSymetry ? UI_Scene.All : UI_Scene.None; convertPecentageEditorFloatRange = convertPercentageField.uiControlEditor as UI_FloatRange; convertPecentageEditorFloatRange.maxValue = percentageMaxValue; convertPecentageEditorFloatRange.minValue = percentageMinValue; convertPecentageEditorFloatRange.stepIncrement = percentageStepIncrement; convertPecentageEditorFloatRange.affectSymCounterparts = percentageSymetry ? UI_Scene.All : UI_Scene.None; }
/// <summary> /// For the editor, load the color presets so the player can adjust colors in the VAB. /// </summary> private void SetupChooser() { if (Tweakable) { ConfigNode[] colorPresetNodes = GameDatabase.Instance.GetConfigNodes("AVIATION_LIGHTS_PRESET_COLORS"); List <string> colorNames = new List <string>(); presetColorValues = new List <Vector3>(); for (int presetNode = 0; presetNode < colorPresetNodes.Length; ++presetNode) { ConfigNode[] colors = colorPresetNodes[presetNode].GetNodes("Color"); for (int colorIndex = 0; colorIndex < colors.Length; ++colorIndex) { string guiName = string.Empty; Vector3 value = new Vector3(0.0f, 0.0f, 0.0f); if (colors[colorIndex].TryGetValue("guiName", ref guiName) && colors[colorIndex].TryGetValue("value", ref value)) { if (colorNames.Contains(guiName) == false) { colorNames.Add(guiName); value.x = Mathf.Clamp01(value.x); value.y = Mathf.Clamp01(value.y); value.z = Mathf.Clamp01(value.z); presetColorValues.Add(value); } } } } BaseField chooseField = Fields["colorPreset"]; if (colorNames.Count > 0) { UI_ChooseOption chooseOption = (UI_ChooseOption)chooseField.uiControlEditor; chooseOption.options = colorNames.ToArray(); chooseOption.onFieldChanged = ColorPresetChanged; } else { // No colors? No preset slider. chooseField.guiActiveEditor = false; } ConfigNode[] typePresetNodes = GameDatabase.Instance.GetConfigNodes("AVIATION_LIGHTS_PRESET_TYPES"); List <string> presetNames = new List <string>(); presetTypes = new List <TypePreset>(); for (int presetNode = 0; presetNode < typePresetNodes.Length; ++presetNode) { ConfigNode[] types = typePresetNodes[presetNode].GetNodes("Type"); for (int typeIndex = 0; typeIndex < types.Length; ++typeIndex) { string guiName = string.Empty; float flashOn = 0.0f, flashOff = 0.0f, interval = 0.0f, intensity = 0.0f, range = 0.0f; if (types[typeIndex].TryGetValue("guiName", ref guiName) && types[typeIndex].TryGetValue("flashOn", ref flashOn) && types[typeIndex].TryGetValue("flashOff", ref flashOff) && types[typeIndex].TryGetValue("interval", ref interval) && types[typeIndex].TryGetValue("intensity", ref intensity) && types[typeIndex].TryGetValue("range", ref range)) { if (presetNames.Contains(guiName) == false) { presetNames.Add(guiName); TypePreset type = new TypePreset(); type.flashOn = Mathf.Max(flashOn, 0.0f); type.flashOff = Mathf.Max(flashOff, 0.0f); type.interval = Mathf.Max(interval, 0.0f); type.intensity = Mathf.Clamp(intensity, 0.0f, 8.0f); type.range = Mathf.Max(range, 0.0f); presetTypes.Add(type); } } } } chooseField = Fields["typePreset"]; if (presetNames.Count > 0) { UI_ChooseOption chooseOption = (UI_ChooseOption)chooseField.uiControlEditor; chooseOption.options = presetNames.ToArray(); chooseOption.onFieldChanged = TypePresetChanged; } else { // No types? No preset slider. chooseField.guiActiveEditor = false; } chooseField = Fields["Intensity"]; UI_FloatRange floatRange = (UI_FloatRange)chooseField.uiControlEditor; floatRange.onFieldChanged = ValueChanged; chooseField = Fields["Range"]; floatRange = (UI_FloatRange)chooseField.uiControlEditor; floatRange.onFieldChanged = ValueChanged; chooseField = Fields["lightR"]; floatRange = (UI_FloatRange)chooseField.uiControlEditor; floatRange.onFieldChanged = ValueChanged; chooseField = Fields["lightG"]; floatRange = (UI_FloatRange)chooseField.uiControlEditor; floatRange.onFieldChanged = ValueChanged; chooseField = Fields["lightB"]; floatRange = (UI_FloatRange)chooseField.uiControlEditor; floatRange.onFieldChanged = ValueChanged; chooseField = Fields["spotLight"]; chooseField.guiActiveEditor = (SpotAngle > 0.0f); UI_Toggle toggle = (UI_Toggle)chooseField.uiControlEditor; toggle.onFieldChanged = ValueChanged; } else { // The module is configured as non-Tweakable. Remove the config options from the editor. Fields["colorPreset"].guiActiveEditor = false; Fields["typePreset"].guiActiveEditor = false; Fields["Intensity"].guiActiveEditor = false; Fields["Range"].guiActiveEditor = false; Fields["lightR"].guiActiveEditor = false; Fields["lightG"].guiActiveEditor = false; Fields["lightB"].guiActiveEditor = false; } }
public float GetMaxArmor() { UI_FloatRange armorField = (UI_FloatRange)Fields["Armor"].uiControlEditor; return(armorField.maxValue); }
public static void InitializeTweakable <T>( UI_Control floatTweakable, ref float localField, ref float remoteField, float centerValue, float lowerMult, float upperMult, float stepMult, bool clobberEverywhere = false ) { if (floatTweakable == null) { Logging.PostErrorMessage("Got null Control during InitializeTweakable for type {0}; bailing out.", typeof(T).FullName); return; } Vector2 bounds; float minValue, maxValue, stepIncrement; bounds = LoadBounds <T>(); stepMult = LoadStep <T>(stepMult); // If our field is uninitialized... if (localField < 0) { // ...fetch it from the remote field localField = centerValue; } lowerMult = Mathf.Max(lowerMult, bounds.x, 0); upperMult = Mathf.Max(lowerMult, Mathf.Min(upperMult, bounds.y)); // Set the bounds and increment for our tweakable range. if (centerValue < 0) { maxValue = centerValue * lowerMult; minValue = centerValue * upperMult; } else { minValue = centerValue * lowerMult; maxValue = centerValue * upperMult; } stepIncrement = Mathf.Pow(10f, Mathf.RoundToInt(Mathf.Log10(Mathf.Abs(centerValue))) - 1); stepIncrement *= stepMult; if (floatTweakable is UI_FloatRange) { UI_FloatRange floatRange = floatTweakable as UI_FloatRange; floatRange.maxValue = maxValue; floatRange.minValue = minValue; floatRange.stepIncrement = stepIncrement; } else { Logging.PostErrorMessage( "InitializeTweakable<{0}>: Got floatTweakable of type {1}, expected {2}", typeof(T).FullName, floatTweakable.GetType().FullName, typeof(UI_FloatRange).FullName ); return; } localField = Mathf.Clamp(localField, minValue, maxValue); if (HighLogic.LoadedSceneIsFlight || clobberEverywhere) { // Clobber the remote field with ours. remoteField = localField; } }
public override void OnLoad(ConfigNode node) { if (!compatible) { return; } UI_FloatRange f = (UI_FloatRange)(Fields["utilization"].uiControlEditor); f.minValue = minUtilization; f.maxValue = maxUtilization; utilization = Mathf.Clamp(utilization, minUtilization, maxUtilization); if (MFSSettings.tankDefinitions == null) { MFSSettings.Initialize(); } // Load the volume. If totalVolume is specified, use that to calc the volume // otherwise scale up the provided volume. No KSPField support for doubles if (node.HasValue("totalVolume") && double.TryParse(node.GetValue("totalVolume"), out totalVolume)) { ChangeTotalVolume(totalVolume); } else if (node.HasValue("volume") && double.TryParse(node.GetValue("volume"), out volume)) { totalVolume = volume * 100d / utilization; } ConfigNode[] unmanagedResourceNodes = node.GetNodes("UNMANAGED_RESOURCE"); Debug.Log("[ModuleFuelTanks.OnLoad()] " + unmanagedResourceNodes.Count() + " UNMANAGED_RESOURCE nodes found"); for (int i = unmanagedResourceNodes.Count() - 1; i >= 0; --i) { string name = ""; double amount = 0; double maxAmount = 0; // we're going to be strict and demand all of these be present if (!unmanagedResourceNodes[i].HasValue("name") || !unmanagedResourceNodes[i].HasValue("amount") || !unmanagedResourceNodes[i].HasValue("maxAmount")) { Debug.Log("[ModuleFuelTanks.OnLoad()] was missing either name, amount or maxAmount for UNMANAGED_RESOURCE: " + name); continue; } name = unmanagedResourceNodes[i].GetValue("name"); if (PartResourceLibrary.Instance.GetDefinition(name) == null) { Debug.Log("[ModuleFuelTanks.OnLoad()] could not find resource by the name of " + name); continue; } double.TryParse(unmanagedResourceNodes[i].GetValue("amount"), out amount); double.TryParse(unmanagedResourceNodes[i].GetValue("maxAmount"), out maxAmount); amount = Math.Max(amount, 0d); maxAmount = Math.Max(amount, maxAmount); if (!unmanagedResources.ContainsKey(name)) { if (maxAmount > 0) { unmanagedResources.Add(name, new UnmanagedResource(name, amount, maxAmount)); Debug.Log("[ModuleFuelTanks.OnLoad()] added new UnmanagedResource " + name + " with " + amount + "/" + maxAmount); } else { Debug.Log("[ModuleFuelTanks.OnLoad()] did not add new UnmanagedResource; maxAmount = 0"); } } else { if (maxAmount > 0) { unmanagedResources[name].amount += amount; unmanagedResources[name].maxAmount += maxAmount; Debug.Log("[ModuleFuelTanks.OnLoad()] modified UnmanagedResource: " + name + "; amount = " + amount + " / maxAmount = " + maxAmount); } else { Debug.Log("[ModuleFuelTanks.OnLoad()] did not add new UnmanagedResource; maxAmount = 0"); } } } if (isDatabaseLoad) { MFSSettings.SaveOverrideList(part, node.GetNodes("TANK")); ParseBaseMass(node); ParseBaseCost(node); ParseInsulationFactor(node); typesAvailable = node.GetValues("typeAvailable"); RecordManagedResources(); } else if (isEditorOrFlight) { // The amounts initialized flag is there so that the tank type loading doesn't // try to set up any resources. They'll get loaded directly from the save. UpdateTankType(false); CleanResources(); // Destroy any resources still hanging around from the LOADING phase for (int i = part.Resources.Count - 1; i >= 0; --i) { PartResource partResource = part.Resources[i]; if (!tankList.Contains(partResource.resourceName) || unmanagedResources.ContainsKey(partResource.resourceName)) { continue; } part.Resources.Remove(partResource.info.id); part.SimulationResources.Remove(partResource.info.id); } RaiseResourceListChanged(); // Setup the mass massDirty = true; CalculateMass(); } OnLoadRF(node); }
public static MemberUpdater Create(object obj, string name) { if (obj == null || name == null) { return(null); } var objectType = obj.GetType(); var field = objectType.GetField(name, LookupFlags); var property = objectType.GetProperty(name, LookupFlags); UI_FloatRange floatRange = null; BaseFieldList fields; if (obj is PartModule) { fields = (obj as PartModule).Fields; try { var fieldData = fields[name]; if ((object)fieldData != null) { var ctrl = fieldData.uiControlEditor; if (ctrl is UI_FloatRange) { floatRange = ctrl as UI_FloatRange; } } } catch (Exception) { string debuglog = "===============================================\r\n"; ConcatSafely("objectType", () => { return(objectType.ToString()); }, ref debuglog); ConcatSafely("name", () => { return(name); }, ref debuglog); ConcatSafely("fields.ReflectType", () => { return(fields.ReflectedType.ToString().ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { return(fields.Count.ToString()); }, ref debuglog); ConcatSafely("fields.Count", () => { string acc = ""; foreach (var f in fields) { ConcatSafely("field", () => { return(f.ToString_rec(1)); }, ref acc); } return(acc); }, ref debuglog); Tools.LogWf(debuglog); } } if (property != null && property.GetIndexParameters().Length > 0) { Tools.LogWf("Property {0} on {1} requires indices, which TweakScale currently does not support.", name, objectType.Name); return(null); } if (field == null && property == null) { Tools.LogWf("No valid member found for {0} in {1}", name, objectType.Name); return(null); } return(new MemberUpdater(obj, field, property, floatRange)); }
public void Start() { _cameraGameObject = base.gameObject.GetChild(cameraTransformName); if (_cameraGameObject == null) { Debug.LogFormat("[{0}] Camera game object is missing.", DEBUG_LOG_PREFIX); return; } // Create the camera render texture. _renderTextureColor = new RenderTexture(cameraHorizontalResolution, cameraVerticalResolution, 0); _renderTextureDepth = new RenderTexture(cameraHorizontalResolution, cameraVerticalResolution, 24); _renderTextureColor.Create(); _renderTextureDepth.Create(); // Create the GUI render texture. _displayTextureColor = new RenderTexture(DISPLAY_TEXTURE_WIDTH, DISPLAY_TEXTURE_HEIGHT, 0, RenderTextureFormat.RGB565); _displayTextureDepth = new RenderTexture(DISPLAY_TEXTURE_WIDTH, DISPLAY_TEXTURE_HEIGHT, 24); _displayTextureColor.Create(); _displayTextureDepth.Create(); // Setup all the cameras. _nearGameObject = new GameObject(); _farGameObject = new GameObject(); _scaledGameObject = new GameObject(); _galaxyGameObject = new GameObject(); // Add the near camera. _nearCamera = _nearGameObject.AddComponent <Camera>(); var nearCameraReference = UnityEngine.Camera.allCameras.FirstOrDefault(cam => cam.name == NEAR_CAMERA_NAME); if (nearCameraReference != null) { _nearCamera.CopyFrom(nearCameraReference); _nearCamera.name = CAMERA_PREFIX + NEAR_CAMERA_NAME; _nearCamera.enabled = false; // The camera is attached to our object transform and does not move from there. _nearCamera.transform.parent = _cameraGameObject.transform; _nearCamera.transform.localPosition = Vector3.zero; _nearCamera.transform.localRotation = Quaternion.identity; if (cameraHasCustomNearClipPlane) { _nearCamera.nearClipPlane = cameraCustomNearClipPlane; } if (cameraHasCustomFieldOfView) { _nearCamera.fieldOfView = cameraFieldOfView; } } // Add the far camera. _farCamera = _farGameObject.AddComponent <Camera>(); var farCameraReference = UnityEngine.Camera.allCameras.FirstOrDefault(cam => cam.name == FAR_CAMERA_NAME); if (farCameraReference != null) { _farCamera.CopyFrom(farCameraReference); _farCamera.name = CAMERA_PREFIX + FAR_CAMERA_NAME; _farCamera.enabled = false; // The camera is attached to our object transform and does not move from there. _farCamera.transform.parent = _cameraGameObject.transform; _farCamera.transform.localPosition = Vector3.zero; _farCamera.transform.localRotation = Quaternion.identity; if (cameraHasCustomFieldOfView) { _farCamera.fieldOfView = cameraFieldOfView; } } // Add the scaled camera. _scaledCamera = _scaledGameObject.AddComponent <Camera>(); var scaledCameraReference = UnityEngine.Camera.allCameras.FirstOrDefault(cam => cam.name == SCALED_CAMERA_NAME); if (scaledCameraReference != null) { _scaledCamera.CopyFrom(scaledCameraReference); _scaledCamera.name = CAMERA_PREFIX + SCALED_CAMERA_NAME; _scaledCamera.enabled = false; // Scaled cam has no parent. if (cameraHasCustomFieldOfView) { _scaledCamera.fieldOfView = cameraFieldOfView; } } // Add the galaxy camera. _galaxyCamera = _galaxyGameObject.AddComponent <Camera>(); var galaxyCameraReference = UnityEngine.Camera.allCameras.FirstOrDefault(cam => cam.name == GALAXY_CAMERA_NAME); if (galaxyCameraReference != null) { _galaxyCamera.CopyFrom(galaxyCameraReference); _galaxyCamera.name = CAMERA_PREFIX + GALAXY_CAMERA_NAME; _galaxyCamera.enabled = false; // Galaxy camera renders the galaxy skybox and is not // actually moving, but only rotating to look at the galaxy cube. Transform galaxyRoot = GalaxyCubeControl.Instance.transform.parent; _galaxyCamera.transform.parent = galaxyRoot; _galaxyCamera.transform.localPosition = Vector3.zero; _galaxyCamera.transform.localRotation = Quaternion.identity; } // Configure which events are available. Actions["ActionCaptureFullColourImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR); Events["EventCaptureFullColourImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR); Actions["ActionCaptureRedImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_RED_COLOUR); Events["EventCaptureRedImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_RED_COLOUR); Actions["ActionCaptureGreenImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_GREEN_COLOUR); Events["EventCaptureGreenImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_GREEN_COLOUR); Actions["ActionCaptureBlueImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_BLUE_COLOUR); Events["EventCaptureBlueImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_BLUE_COLOUR); Actions["ActionCaptureGreyscaleImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_GREYSCALE); Events["EventCaptureGreyscaleImage"].active = (cameraType == CAMERA_TYPE_FULL_COLOUR || cameraType == CAMERA_TYPE_GREYSCALE); Actions["ActionCaptureUltravioletImage"].active = (cameraType == CAMERA_TYPE_ULTRAVIOLET); Events["EventCaptureUltravioletImage"].active = (cameraType == CAMERA_TYPE_ULTRAVIOLET); Actions["ActionCaptureInfraredImage"].active = (cameraType == CAMERA_TYPE_INFRARED); Events["EventCaptureInfraredImage"].active = (cameraType == CAMERA_TYPE_INFRARED); Actions["ActionToggleDisplayWindow"].active = cameraHasDisplayWindow; Events["EventToggleDisplayWindow"].active = cameraHasDisplayWindow; // Rename the events if using a custom title. if (cameraHasCustomTitle) { string descFullColour = $"({cameraCustomTitle}) Full Colour Image"; string descRed = $"({cameraCustomTitle}) Red Image"; string descGreen = $"({cameraCustomTitle}) Green Image"; string descBlue = $"({cameraCustomTitle}) Blue Image"; string descGreyscale = $"({cameraCustomTitle}) Greyscale Image"; string descUltraviolet = $"({cameraCustomTitle}) Ultraviolet Image"; string descInfrared = $"({cameraCustomTitle}) Infrared Image"; string descDisplayWindow = $"({cameraCustomTitle}) Toggle Display Widnow"; Actions["ActionCaptureFullColourImage"].guiName = descFullColour; Events["EventCaptureFullColourImage"].guiName = descFullColour; Actions["ActionCaptureRedImage"].guiName = descRed; Events["EventCaptureRedImage"].guiName = descRed; Actions["ActionCaptureGreenImage"].guiName = descGreen; Events["EventCaptureGreenImage"].guiName = descGreen; Actions["ActionCaptureBlueImage"].guiName = descBlue; Events["EventCaptureBlueImage"].guiName = descBlue; Actions["ActionCaptureGreyscaleImage"].guiName = descGreyscale; Events["EventCaptureGreyscaleImage"].guiName = descGreyscale; Actions["ActionCaptureUltravioletImage"].guiName = descUltraviolet; Events["EventCaptureUltravioletImage"].guiName = descUltraviolet; Actions["ActionCaptureInfraredImage"].guiName = descInfrared; Events["EventCaptureInfraredImage"].guiName = descInfrared; Actions["ActionToggleDisplayWindow"].guiName = descDisplayWindow; Events["EventToggleDisplayWindow"].guiName = descDisplayWindow; } // Setup the slider. if (cameraFieldOfViewMin == 0f) { cameraFieldOfViewMin = cameraFieldOfView; } if (cameraFieldOfViewMax == 0f) { cameraFieldOfViewMax = cameraFieldOfView; } UI_FloatRange cameraFieldOfViewEditorSlider = (UI_FloatRange)Fields["cameraFieldOfView"].uiControlEditor; cameraFieldOfViewEditorSlider.minValue = cameraFieldOfViewMin; cameraFieldOfViewEditorSlider.maxValue = cameraFieldOfViewMax; UI_FloatRange cameraFieldOfViewFlightSlider = (UI_FloatRange)Fields["cameraFieldOfView"].uiControlFlight; cameraFieldOfViewFlightSlider.minValue = cameraFieldOfViewMin; cameraFieldOfViewFlightSlider.maxValue = cameraFieldOfViewMax; }
public override void OnStart(StartState state) { int moduleCount = actionModuleIndex; bool found = false; foreach (PartModule p in this.part.Modules) { if (p.moduleName == actionModuleName) { if (moduleCount > 0) { moduleCount--; } else { found = true; anim = p as IScalarModule; if (anim != null) { anim.OnMoving.Add(OnMoving); anim.OnStop.Add(OnStop); } else { Debug.LogErrorFormat("ModuleBdbAnimationMass: Module [{0}] index [{1}] does not impliment IScalarModule", actionModuleName, actionModuleIndex); } break; } } } if (!found) { Debug.LogErrorFormat("ModuleBdbAnimationMass: Module [{0}] index [{1}] not found", actionModuleName, actionModuleIndex); } _origComOffset = part.CoMOffset; _origCopOffset = part.CoPOffset; _origColOffset = part.CoLOffset; string[] sArray = extent.Split(','); if (sArray.Length > 0) { extentV.x = float.Parse(sArray[0]); } if (sArray.Length > 1) { extentV.y = float.Parse(sArray[1]); } if (sArray.Length > 2) { extentV.z = float.Parse(sArray[2]); } Fields["weight"].guiActiveEditor = enableWeight; if (enableWeight) { UI_FloatRange edt = (Fields["weight"].uiControlEditor as UI_FloatRange); edt.minValue = part.prefabMass * 1000; if (weight < edt.minValue) { weight = edt.minValue; } } }
public void Start() { #region Formating Display Altitude Left GameObject LCDScreen = new GameObject(); Transform screenTransform = part.FindModelTransform(ScreenName); LCDScreen.transform.parent = screenTransform; LCDScreen.transform.localRotation = screenTransform.localRotation; LCDScreen.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMesh = LCDScreen.AddComponent <TextMeshPro>(); M = screenTransform.GetComponent <MeshFilter>().mesh; T = LCDTextMesh.gameObject.GetComponent <RectTransform>(); T.sizeDelta = new Vector2(M.bounds.size.y / 6, M.bounds.size.x / 6); LCDScreen.transform.localPosition = new Vector3(0, 0, (M.bounds.size.z / 2) + 0.01f); LCDTextMesh.fontSize = 0.22f; LCDTextMesh.enableAutoSizing = autoFont; LCDTextMesh.color = Color.white; LCDTextMesh.font = loadedFonts[1]; LCDTextMesh.fontSizeMin = 0.01f; LCDTextMesh.overflowMode = TextOverflowModes.Truncate; LCDTextMesh.alignment = TextAlignmentOptions.Center; LCDTextMesh.text = "0.0"; #endregion #region Formating Display Altitude Right GameObject LCDScreenR = new GameObject(); Transform screenTransformR = part.FindModelTransform(ScreenNameR); LCDScreenR.transform.parent = screenTransformR; LCDScreenR.transform.localRotation = screenTransformR.localRotation; LCDScreenR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshR = LCDScreenR.AddComponent <TextMeshPro>(); MR = screenTransformR.GetComponent <MeshFilter>().mesh; TR = LCDTextMeshR.gameObject.GetComponent <RectTransform>(); TR.sizeDelta = new Vector2(MR.bounds.size.y / 6, MR.bounds.size.x / 6); LCDScreenR.transform.localPosition = new Vector3(0, 0, (MR.bounds.size.z / 2) + 0.01f); LCDTextMeshR.fontSize = 0.22f; LCDTextMeshR.enableAutoSizing = autoFont; LCDTextMeshR.color = Color.white; LCDTextMeshR.font = loadedFonts[1]; LCDTextMeshR.fontSizeMin = 0.01f; LCDTextMeshR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshR.alignment = TextAlignmentOptions.Center; LCDTextMeshR.text = "0.0"; #endregion #region Formating Display Periapsis Left GameObject LCDScreenPe = new GameObject(); Transform screenTransformPe = part.FindModelTransform(ScreenNamePe); LCDScreenPe.transform.parent = screenTransformPe; LCDScreenPe.transform.localRotation = screenTransformPe.localRotation; LCDScreenPe.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshPe = LCDScreenPe.AddComponent <TextMeshPro>(); MPe = screenTransformPe.GetComponent <MeshFilter>().mesh; TPe = LCDTextMeshPe.gameObject.GetComponent <RectTransform>(); TPe.sizeDelta = new Vector2(MPe.bounds.size.y / 6, MPe.bounds.size.x / 6); LCDScreenPe.transform.localPosition = new Vector3(0, 0, (MPe.bounds.size.z / 2) + 0.01f); LCDTextMeshPe.fontSize = 0.12f; LCDTextMeshPe.enableAutoSizing = autoFont; LCDTextMeshPe.color = Color.white; LCDTextMeshPe.font = loadedFonts[1]; LCDTextMeshPe.fontSizeMin = 0.01f; LCDTextMeshPe.overflowMode = TextOverflowModes.Truncate; LCDTextMeshPe.alignment = TextAlignmentOptions.Center; LCDTextMeshPe.text = ""; #endregion #region Formating Display Periapsis Right GameObject LCDScreenPeR = new GameObject(); Transform screenTransformPeR = part.FindModelTransform(ScreenNamePeR); LCDScreenPeR.transform.parent = screenTransformPeR; LCDScreenPeR.transform.localRotation = screenTransformPeR.localRotation; LCDScreenPeR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshPeR = LCDScreenPeR.AddComponent <TextMeshPro>(); MPeR = screenTransformPeR.GetComponent <MeshFilter>().mesh; TPeR = LCDTextMeshPeR.gameObject.GetComponent <RectTransform>(); TPeR.sizeDelta = new Vector2(MPeR.bounds.size.y / 6, MPeR.bounds.size.x / 6); LCDScreenPeR.transform.localPosition = new Vector3(0, 0, (MPeR.bounds.size.z / 2) + 0.01f); LCDTextMeshPeR.fontSize = 0.12f; LCDTextMeshPeR.enableAutoSizing = autoFont; LCDTextMeshPeR.color = Color.white; LCDTextMeshPeR.font = loadedFonts[1]; LCDTextMeshPeR.fontSizeMin = 0.01f; LCDTextMeshPeR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshPeR.alignment = TextAlignmentOptions.Center; LCDTextMeshPeR.text = ""; #endregion #region Formating Display Apoapsis Left GameObject LCDScreenAp = new GameObject(); Transform screenTransformAp = part.FindModelTransform(ScreenNameAp); LCDScreenAp.transform.parent = screenTransformAp; LCDScreenAp.transform.localRotation = screenTransformAp.localRotation; LCDScreenAp.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshAp = LCDScreenAp.AddComponent <TextMeshPro>(); MAp = screenTransformAp.GetComponent <MeshFilter>().mesh; TAp = LCDTextMeshAp.gameObject.GetComponent <RectTransform>(); TAp.sizeDelta = new Vector2(MAp.bounds.size.y / 6, MAp.bounds.size.x / 6); LCDScreenAp.transform.localPosition = new Vector3(0, 0, (MAp.bounds.size.z / 2) + 0.01f); LCDTextMeshAp.fontSize = 0.12f; LCDTextMeshAp.enableAutoSizing = autoFont; LCDTextMeshAp.color = Color.white; LCDTextMeshAp.font = loadedFonts[1]; LCDTextMeshAp.fontSizeMin = 0.01f; LCDTextMeshAp.overflowMode = TextOverflowModes.Truncate; LCDTextMeshAp.alignment = TextAlignmentOptions.Center; LCDTextMeshAp.text = ""; #endregion #region Formating Display Apoapsis Left GameObject LCDScreenApR = new GameObject(); Transform screenTransformApR = part.FindModelTransform(ScreenNameApR); LCDScreenApR.transform.parent = screenTransformApR; LCDScreenApR.transform.localRotation = screenTransformApR.localRotation; LCDScreenApR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshApR = LCDScreenApR.AddComponent <TextMeshPro>(); MApR = screenTransformApR.GetComponent <MeshFilter>().mesh; TApR = LCDTextMeshApR.gameObject.GetComponent <RectTransform>(); TApR.sizeDelta = new Vector2(MApR.bounds.size.y / 6, MApR.bounds.size.x / 6); LCDScreenApR.transform.localPosition = new Vector3(0, 0, (MApR.bounds.size.z / 2) + 0.01f); LCDTextMeshApR.fontSize = 0.12f; LCDTextMeshApR.enableAutoSizing = autoFont; LCDTextMeshApR.color = Color.white; LCDTextMeshApR.font = loadedFonts[1]; LCDTextMeshApR.fontSizeMin = 0.01f; LCDTextMeshApR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshApR.alignment = TextAlignmentOptions.Center; LCDTextMeshApR.text = ""; #endregion #region Formating Display Speed Left GameObject LCDScreenS = new GameObject(); Transform screenTransformS = part.FindModelTransform(ScreenNameS); LCDScreenS.transform.parent = screenTransformS; LCDScreenS.transform.localRotation = screenTransformS.localRotation; LCDScreenS.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshS = LCDScreenS.AddComponent <TextMeshPro>(); MS = screenTransformS.GetComponent <MeshFilter>().mesh; TS = LCDTextMeshS.gameObject.GetComponent <RectTransform>(); TS.sizeDelta = new Vector2(MS.bounds.size.y / 7, MS.bounds.size.x / 7); LCDScreenS.transform.localPosition = new Vector3(0, 0, (MS.bounds.size.z / 2) + 0.01f); LCDTextMeshS.fontSize = 0.2f; LCDTextMeshS.enableAutoSizing = autoFont; LCDTextMeshS.color = Color.white; LCDTextMeshS.font = loadedFonts[1]; LCDTextMeshS.fontSizeMin = 0.01f; LCDTextMeshS.overflowMode = TextOverflowModes.Truncate; LCDTextMeshS.alignment = TextAlignmentOptions.Center; LCDTextMeshS.text = "0.0"; #endregion #region Formating Display Speed Right GameObject LCDScreenSR = new GameObject(); Transform screenTransformSR = part.FindModelTransform(ScreenNameSR); LCDScreenSR.transform.parent = screenTransformSR; LCDScreenSR.transform.localRotation = screenTransformSR.localRotation; LCDScreenSR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshSR = LCDScreenSR.AddComponent <TextMeshPro>(); MSR = screenTransformSR.GetComponent <MeshFilter>().mesh; TSR = LCDTextMeshSR.gameObject.GetComponent <RectTransform>(); TSR.sizeDelta = new Vector2(MSR.bounds.size.y / 7, MSR.bounds.size.x / 7); LCDScreenSR.transform.localPosition = new Vector3(0, 0, (MSR.bounds.size.z / 2) + 0.01f); LCDTextMeshSR.fontSize = 0.2f; LCDTextMeshSR.enableAutoSizing = autoFont; LCDTextMeshSR.color = Color.white; LCDTextMeshSR.font = loadedFonts[1]; LCDTextMeshSR.fontSizeMin = 0.01f; LCDTextMeshSR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshSR.alignment = TextAlignmentOptions.Center; LCDTextMeshSR.text = "0.0"; #endregion #region Formating Display Vertical Speed Left GameObject LCDScreenVS = new GameObject(); Transform screenTransformVS = part.FindModelTransform(ScreenNameVS); LCDScreenVS.transform.parent = screenTransformVS; LCDScreenVS.transform.localRotation = screenTransformVS.localRotation; LCDScreenVS.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshVS = LCDScreenVS.AddComponent <TextMeshPro>(); MVS = screenTransformVS.GetComponent <MeshFilter>().mesh; TVS = LCDTextMeshVS.gameObject.GetComponent <RectTransform>(); TVS.sizeDelta = new Vector2(MVS.bounds.size.y / 7, MVS.bounds.size.x / 7); LCDScreenVS.transform.localPosition = new Vector3(0, 0, (MVS.bounds.size.z / 2) + 0.01f); LCDTextMeshVS.fontSize = 0.12f; LCDTextMeshVS.enableAutoSizing = autoFont; LCDTextMeshVS.color = new Color32(255, 250, 200, 200); LCDTextMeshVS.font = loadedFonts[1]; LCDTextMeshVS.fontSizeMin = 0.01f; LCDTextMeshVS.overflowMode = TextOverflowModes.Truncate; LCDTextMeshVS.alignment = TextAlignmentOptions.Center; LCDTextMeshVS.text = ""; #endregion #region Formating Display Vertical Speed Right GameObject LCDScreenVSR = new GameObject(); Transform screenTransformVSR = part.FindModelTransform(ScreenNameVSR); LCDScreenVSR.transform.parent = screenTransformVSR; LCDScreenVSR.transform.localRotation = screenTransformVSR.localRotation; LCDScreenVSR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshVSR = LCDScreenVSR.AddComponent <TextMeshPro>(); MVSR = screenTransformVSR.GetComponent <MeshFilter>().mesh; TVSR = LCDTextMeshVSR.gameObject.GetComponent <RectTransform>(); TVSR.sizeDelta = new Vector2(MVSR.bounds.size.y / 7, MVSR.bounds.size.x / 7); LCDScreenVSR.transform.localPosition = new Vector3(0, 0, (MVSR.bounds.size.z / 2) + 0.01f); LCDTextMeshVSR.fontSize = 0.12f; LCDTextMeshVSR.enableAutoSizing = autoFont; LCDTextMeshVSR.color = new Color32(255, 250, 200, 200); LCDTextMeshVSR.font = loadedFonts[1]; LCDTextMeshVSR.fontSizeMin = 0.01f; LCDTextMeshVSR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshVSR.alignment = TextAlignmentOptions.Center; LCDTextMeshVSR.text = ""; #endregion #region Formating Display Horizontal Speed Left GameObject LCDScreenHS = new GameObject(); Transform screenTransformHS = part.FindModelTransform(ScreenNameHS); LCDScreenHS.transform.parent = screenTransformHS; LCDScreenHS.transform.localRotation = screenTransformHS.localRotation; LCDScreenHS.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshHS = LCDScreenHS.AddComponent <TextMeshPro>(); MHS = screenTransformHS.GetComponent <MeshFilter>().mesh; THS = LCDTextMeshHS.gameObject.GetComponent <RectTransform>(); THS.sizeDelta = new Vector2(MHS.bounds.size.y / 7, MHS.bounds.size.x / 7); LCDScreenHS.transform.localPosition = new Vector3(0, 0, (MHS.bounds.size.z / 2) + 0.01f); LCDTextMeshHS.fontSize = 0.12f; LCDTextMeshHS.enableAutoSizing = autoFont; LCDTextMeshHS.color = new Color32(255, 200, 200, 200); LCDTextMeshHS.font = loadedFonts[1]; LCDTextMeshHS.fontSizeMin = 0.01f; LCDTextMeshHS.overflowMode = TextOverflowModes.Truncate; LCDTextMeshHS.alignment = TextAlignmentOptions.Center; LCDTextMeshHS.text = ""; #endregion #region Formating Display Horizontal Speed Right GameObject LCDScreenHSR = new GameObject(); Transform screenTransformHSR = part.FindModelTransform(ScreenNameHSR); LCDScreenHSR.transform.parent = screenTransformHSR; LCDScreenHSR.transform.localRotation = screenTransformHSR.localRotation; LCDScreenHSR.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshHSR = LCDScreenHSR.AddComponent <TextMeshPro>(); MHSR = screenTransformHSR.GetComponent <MeshFilter>().mesh; THSR = LCDTextMeshHSR.gameObject.GetComponent <RectTransform>(); THSR.sizeDelta = new Vector2(MHSR.bounds.size.y / 7, MHSR.bounds.size.x / 7); LCDScreenHSR.transform.localPosition = new Vector3(0, 0, (MHSR.bounds.size.z / 2) + 0.01f); LCDTextMeshHSR.fontSize = 0.12f; LCDTextMeshHSR.enableAutoSizing = autoFont; LCDTextMeshHSR.color = new Color32(255, 200, 200, 200); LCDTextMeshHSR.font = loadedFonts[1]; LCDTextMeshHSR.fontSizeMin = 0.01f; LCDTextMeshHSR.overflowMode = TextOverflowModes.Truncate; LCDTextMeshHSR.alignment = TextAlignmentOptions.Center; LCDTextMeshHSR.text = ""; #endregion #region Formating Display Vtol Angle GameObject LCDScreenVtol = new GameObject(); Transform screenTransformVtol = part.FindModelTransform(ScreenNameVtol); LCDScreenVtol.transform.parent = screenTransformVtol; LCDScreenVtol.transform.localRotation = screenTransformVtol.localRotation; LCDScreenVtol.transform.localRotation = Quaternion.Euler(0, 0, 90); LCDTextMeshVtol = LCDScreenVtol.AddComponent <TextMeshPro>(); MVtol = screenTransformVtol.GetComponent <MeshFilter>().mesh; TVtol = LCDTextMeshVtol.gameObject.GetComponent <RectTransform>(); TVtol.sizeDelta = new Vector2(MVtol.bounds.size.y, MVtol.bounds.size.x); LCDScreenVtol.transform.localPosition = new Vector3(0, 0, (MVtol.bounds.size.z / 2) + 0.01f); LCDTextMeshVtol.fontSize = 0.22f; LCDTextMeshVtol.enableAutoSizing = autoFont; LCDTextMeshVtol.color = new Color32(255, 255, 255, 255); LCDTextMeshVtol.font = loadedFonts[1]; LCDTextMeshVtol.fontSizeMin = 0.01f; LCDTextMeshVtol.overflowMode = TextOverflowModes.Truncate; LCDTextMeshVtol.alignment = TextAlignmentOptions.Center; LCDTextMeshVtol.text = "Vtol"; #endregion #region Vtol Attitude Control (Menus, Actions, Editor and Flight) UI_FloatRange uiRange1 = (UI_FloatRange)VtolAngleAxis.uiControlEditor; UI_FloatRange uiRange2 = (UI_FloatRange)VtolAngleAxis.uiControlFlight; VtolAngleAxis.minValue = uiRange1.minValue = uiRange2.minValue = 0f; VtolAngleAxis.maxValue = uiRange1.maxValue = uiRange2.maxValue = 90f; uiRange1.stepIncrement = uiRange2.stepIncrement = 1f; VtolAngleAxis.incrementalSpeed = 25f; VtolAngleAxis.guiActiveEditor = true; VtolAngleAxis.guiActive = true; VtolAngleAxis.guiActiveUnfocused = false; VtolAngleAxis.guiInteractable = true; VtolTrans = part.transform.FindRecursive("attitude_node"); #endregion }
private static float HandleFloatRange(float fieldValue, UI_FloatRange uiFloatRange, UnityEngine.UI.Slider slider) { var lerpedValue = Mathf.Lerp(uiFloatRange.minValue, uiFloatRange.maxValue, slider.value); var moddedValue = lerpedValue % uiFloatRange.stepIncrement; var num = fieldValue; if (moddedValue != 0f) { if (moddedValue < uiFloatRange.stepIncrement * 0.5f) { fieldValue = lerpedValue - moddedValue; } else { fieldValue = lerpedValue + (uiFloatRange.stepIncrement - moddedValue); } } else { fieldValue = lerpedValue; } slider.value = Mathf.InverseLerp(uiFloatRange.minValue, uiFloatRange.maxValue, fieldValue); fieldValue = (float)Math.Round(fieldValue, 5); return Mathf.Abs(fieldValue - num) > uiFloatRange.stepIncrement * 0.98f ? fieldValue : float.NaN; }
/* * Methods * */ // Runs when each new part is started. public override void OnStart(StartState st) { // Startup the PartModule stuff first. base.OnStart(st); if (!this.part.tryGetFirstModuleOfType <ModuleDockingNode>(out this.dockingNodeModule)) { return; } if (this.dockingNodeModule.deployAnimationController != -1) { this.deployAnimation = (base.part.Modules.GetModule(this.dockingNodeModule.deployAnimationController) as ModuleAnimateGeneric); } else { this.deployAnimation = null; // return; } // this.deployAnimation = this.part.getFirstModuleOfType<ModuleAnimateGeneric>(); ModuleDockingNode prefabModule; var p = PartLoader.getPartInfoByName(base.part.partInfo.name).partPrefab; p.tryGetFirstModuleOfType(out prefabModule); if (prefabModule == null) { Debug.Log("prefabModule is null"); return; } if (this.Fields["acquireRange"].uiControlCurrent() == null) { Debug.Log("uiControlcurrent is null"); return; } #if true TweakableTools.InitializeTweakable <ModuleTweakableDockingNode>( this.Fields["acquireRange"].uiControlCurrent(), ref this.acquireRange, ref this.dockingNodeModule.acquireRange, prefabModule.acquireRange ); UI_FloatRange floatRange = this.Fields["acquireRange"].uiControlCurrent() as UI_FloatRange; floatRange.minValue = 0.2f; TweakableTools.InitializeTweakable <ModuleTweakableDockingNode>( this.Fields["acquireForce"].uiControlCurrent(), ref this.acquireForce, ref this.dockingNodeModule.acquireForce, prefabModule.acquireForce ); TweakableTools.InitializeTweakable <ModuleTweakableDockingNode>( this.Fields["acquireTorque"].uiControlCurrent(), ref this.acquireTorque, ref this.dockingNodeModule.acquireTorque, prefabModule.acquireForce ); TweakableTools.InitializeTweakable <ModuleTweakableDockingNode>( this.Fields["undockEjectionForce"].uiControlCurrent(), ref this.undockEjectionForce, ref this.dockingNodeModule.undockEjectionForce, prefabModule.undockEjectionForce ); TweakableTools.InitializeTweakable <ModuleTweakableDockingNode>( this.Fields["minDistanceToReEngage"].uiControlCurrent(), ref this.minDistanceToReEngage, ref this.dockingNodeModule.minDistanceToReEngage, prefabModule.minDistanceToReEngage ); #endif #if true this.Fields["maxCaptureRollAngle"].uiControlFlight.controlEnabled = false; this.Fields["maxAcquireRollAngle"].uiControlFlight.controlEnabled = false; this.maxCaptureRollAngle = Mathf.Acos(this.minCaptureRollDotProduct) * 180f / Mathf.PI; // this.dockingNodeModule.captureMinRollDot = Mathf.Min(this.minCaptureRollDotProduct, 0.99995f); this.maxAcquireRollAngle = Mathf.Acos(this.minAcquireRollDotProduct) * 180f / Mathf.PI; // this.dockingNodeModule.acquireMinRollDot = Mathf.Min(this.minAcquireRollDotProduct, 0.99995f); #if DEBUG this.dockingNodeModule.Fields["acquireMinRollDot"].guiActive = true; this.dockingNodeModule.Fields["acquireMinRollDot"].guiActiveEditor = true; this.dockingNodeModule.Fields["captureMinRollDot"].guiActive = true; this.dockingNodeModule.Fields["captureMinRollDot"].guiActiveEditor = true; this.Fields["maxCaptureRollAngle"].guiActive = true; this.Fields["maxCaptureRollAngle"].guiActiveEditor = true; this.Fields["maxAcquireRollAngle"].guiActive = true; this.Fields["maxAcquireRollAngle"].guiActiveEditor = true; this.Fields["minCaptureRollDotProduct"].guiActive = true; this.Fields["minCaptureRollDotProduct"].guiActiveEditor = true; this.Fields["minAcquireRollDotProduct"].guiActive = true; this.Fields["minAcquireRollDotProduct"].guiActiveEditor = true; #endif this.lastMaxCaptureRollAngle = this.maxCaptureRollAngle; this.lastMaxAcquireRollAngle = this.maxAcquireRollAngle; #if true // If we have a tweakable AttachNode, use it. if (this.TDNnodeName != string.Empty) { this.attachNode = base.part.FindAttachNode(this.TDNnodeName); } base.part.attachRules.allowStack = this.IsOpen | this.AlwaysAllowStack; #endif /* @subclass * ModuleStagingToggle stagingToggleModule; * * if (this.part.tryGetFirstModuleOfType<ModuleStagingToggle>(out stagingToggleModule)) * { * stagingToggleModule.OnToggle += new ModuleStagingToggle.ToggleEventHandler(this.OnStagingToggle); * } */ #endif // Yay debugging! this.LogDebug( "{0}: Started with assembly version {4}." + "\n\tdeployAnimationModule={1}, attachNode={2}, TDNnodeName={3}, attachedPart={5}, fuelCrossFeed={6}, AlwaysAllowStack={7} ", this.GetType().Name, this.deployAnimation, this.attachNode, this.TDNnodeName, this.GetType().Assembly.GetName().Version, this.attachedPart, base.part.fuelCrossFeed, this.AlwaysAllowStack ); }