/// <summary> /// Callback to manage changes to the type preset slider. /// </summary> /// <param name="field">Field that changed (unused).</param> /// <param name="oldFieldValueObj">Previous value (unused).</param> private void TypePresetChanged(BaseField field, object oldFieldValueObj) { TypePreset newtype = presetTypes[typePreset]; FlashOn = newtype.flashOn; FlashOff = newtype.flashOff; Interval = newtype.interval; Intensity = newtype.intensity; Range = newtype.range; actualEnergyReq = EnergyReq * Mathf.Max(0.25f, Intensity * Intensity); if (applySymmetry) { foreach (Part p in part.symmetryCounterparts) { ModuleNavLight ml = p.FindModuleImplementing <ModuleNavLight>(); if (ml != null) // shouldn't ever be null? { ml.FlashOn = FlashOn; ml.FlashOff = FlashOff; ml.Interval = Interval; ml.Intensity = Intensity; ml.Range = Range; } } } }
/// <summary> /// Callback to handle slider values changing, allowing for symmetry updates /// </summary> /// <param name="field">The field that's changing.</param> /// <param name="oldFieldValueObj">The old value (unused).</param> private void ValueChanged(BaseField field, object oldFieldValueObj) { if (applySymmetry) { if (field.name == "spotLight") { bool newValue = field.GetValue <bool>(field.host); foreach (Part p in part.symmetryCounterparts) { ModuleNavLight ml = p.FindModuleImplementing <ModuleNavLight>(); if (ml != null) // shouldn't ever be null? { ml.spotLight = newValue; } } } else { float newValue = field.GetValue <float>(field.host); Action <ModuleNavLight, float> paramUpdate = null; switch (field.name) { case "Intensity": paramUpdate = delegate(ModuleNavLight lt, float val) { lt.Intensity = val; }; break; case "Range": paramUpdate = delegate(ModuleNavLight lt, float val) { lt.Range = val; }; break; case "lightR": paramUpdate = delegate(ModuleNavLight lt, float val) { lt.lightR = val; }; break; case "lightG": paramUpdate = delegate(ModuleNavLight lt, float val) { lt.lightG = val; }; break; case "lightB": paramUpdate = delegate(ModuleNavLight lt, float val) { lt.lightB = val; }; break; } foreach (Part p in part.symmetryCounterparts) { ModuleNavLight ml = p.FindModuleImplementing <ModuleNavLight>(); if (ml != null) // shouldn't ever be null? { paramUpdate(ml, newValue); } } } } }
private void UpdateSymmetry() { if (HighLogic.LoadedSceneIsEditor && applySymmetry) { foreach (Part p in part.symmetryCounterparts) { ModuleNavLight ml = p.FindModuleImplementing <ModuleNavLight>(); if (ml != null) // shouldn't ever be null? { ml.navLightSwitch = navLightSwitch; ml.toggleMode = toggleMode; ml.UpdateMode(); } } } }
/// <summary> /// Callback to manage changes to the preset colors slider. /// </summary> /// <param name="field">Field that changed (unused).</param> /// <param name="oldFieldValueObj">Previous value (unused).</param> private void ColorPresetChanged(BaseField field, object oldFieldValueObj) { Color = presetColorValues[colorPreset]; lightR = Color.x; lightG = Color.y; lightB = Color.z; if (applySymmetry) { foreach (Part p in part.symmetryCounterparts) { ModuleNavLight ml = p.FindModuleImplementing <ModuleNavLight>(); if (ml != null) // shouldn't ever be null? { ml.Color = Color; ml.lightR = lightR; ml.lightG = lightG; ml.lightB = lightB; } } } }