private void CallUpdaters() { // two passes, to depend less on the order of this list int len = _updaters.Length; for (int i = 0; i < len; i++) { // first apply the exponents IRescalable updater = _updaters[i]; if (updater is TSGenericUpdater) { try { float oldMass = part.mass; updater.OnRescale(ScalingFactor); part.mass = oldMass; // make sure we leave this in a clean state } catch (Exception e) { Log.error("Exception on rescale: {0}", e); } } } if (_prefabPart.CrewCapacity > 0) { UpdateCrewManifest(); } if (part.Modules.Contains("ModuleDataTransmitter")) { UpdateAntennaPowerDisplay(); } // MFT support UpdateMftModule(); // TF support updateTestFlight(); // send scaling part message BaseEventDetails data = new BaseEventDetails(BaseEventDetails.Sender.USER); data.Set <float>("factorAbsolute", ScalingFactor.absolute.linear); data.Set <float>("factorRelative", ScalingFactor.relative.linear); part.SendEvent("OnPartScaleChanged", data, 0); len = _updaters.Length; for (int i = 0; i < len; i++) { IRescalable updater = _updaters[i]; // then call other updaters (emitters, other mods) if (updater is TSGenericUpdater) { continue; } updater.OnRescale(ScalingFactor); } }
private void CallUpdaters() { // two passes, to depend less on the order of this list { int len = _updaters.Length; for (int i = 0; i < len; i++) { // first apply the exponents IRescalable updater = _updaters [i]; if (updater is TSGenericUpdater) { float oldMass = part.mass; // Why resetting the mass? What happens if I write a updater for the Mass? // I suspect I found the source of some mass related idiossyncrasies - todo: INVESTIGATE try { updater.OnRescale(ScalingFactor); } catch (Exception e) { Log.error("Exception on rescale while TSGenericUpdater: {0}", e); } finally { part.mass = oldMass; // make sure we leave this in a clean state } } } } // Why this code was here? We already registered it on the EditorOnChange. Perhaps for older KSP? //if (_prefabPart.CrewCapacity > 0 && HighLogic.LoadedSceneIsEditor) // UpdateCrewManifest(); if (part.Modules.Contains("ModuleDataTransmitter")) { UpdateAntennaPowerDisplay(); } // MFT support UpdateMftModule(); // TF support updateTestFlight(); { int len = _updaters.Length; for (int i = 0; i < len; i++) { IRescalable updater = _updaters [i]; // then call other updaters (emitters, other mods) if (updater is TSGenericUpdater) { continue; } try { updater.OnRescale(ScalingFactor); } catch (Exception e) { Log.error("Exception on rescale while ¬TSGenericUpdater: {0}", e); } } } }
private void CallUpdaters() { // two passes, to depend less on the order of this list int len = _updaters.Length; for (int i = 0; i < len; i++) { // first apply the exponents IRescalable updater = _updaters[i]; if (updater is TSGenericUpdater) { try { float oldMass = part.mass; updater.OnRescale(ScalingFactor); part.mass = oldMass; // make sure we leave this in a clean state } catch (Exception e) { Log.error("Exception on rescale: {0}", e); } } } if (_prefabPart.CrewCapacity > 0) { UpdateCrewManifest(); } if (part.Modules.Contains("ModuleDataTransmitter")) { UpdateAntennaPowerDisplay(); } // MFT support UpdateMftModule(); // TF support updateTestFlight(); // send scaling part message { BaseEventDetails data = new BaseEventDetails(BaseEventDetails.Sender.USER); data.Set <float>("factorAbsolute", ScalingFactor.absolute.linear); data.Set <float>("factorRelative", ScalingFactor.relative.linear); part.SendEvent("OnPartScaleChanged", data, 0); } len = _updaters.Length; for (int i = 0; i < len; i++) { IRescalable updater = _updaters[i]; // then call other updaters (emitters, other mods) if (updater is TSGenericUpdater) { continue; } updater.OnRescale(ScalingFactor); } // Problem: We don't have the slightest idea if the OnPartScaleChanged was handled or not. // So whoever has received that event, will need to issue OnPartResourceChanged too. // send Resource Changed message to KSP Recall if needed if (0 != this.part.Resources.Count) { BaseEventDetails data = new BaseEventDetails(BaseEventDetails.Sender.USER); data.Set <int> ("InstanceID", this.part.GetInstanceID()); part.SendEvent("OnPartResourceChanged", data, 0); } }