// check vessel type private void checkVesselType() { this.softDisabled = false; switch (ActiveVesselType) { case SimpleTypes.VesselType.PLANE: gpwsFunc = plane as IBasicGpwsFunction; break; case SimpleTypes.VesselType.LANDER: gpwsFunc = lander as IBasicGpwsFunction; break; default: this.softDisabled = true; break; // We can't work on these conditions! :) } }
private bool PreUpdate() { CurrentTime = Time.time - t0; ActiveVessel = FlightGlobals.ActiveVessel; // on surface if (ActiveVessel.LandedOrSplashed) { TakeOffTime = CurrentTime; } else { LandingTime = CurrentTime; } // check time, prevent problem if (CurrentTime < 2.0f) { Util.audio.SetUnavailable(); return(false); } // just switched, use new vessel if (ActiveVessel != LastActiveVessel) { OnVesselChange(ActiveVessel); } // check vessel type if (ActiveVesselType == SimpleTypes.VesselType.PLANE) { gpwsFunc = plane as IBasicGpwsFunction; } else if (ActiveVesselType == SimpleTypes.VesselType.LANDER) { gpwsFunc = lander as IBasicGpwsFunction; } else { Util.audio.SetUnavailable(); return(false); } // height in meters/feet if (UnitOfAltitude.FOOT == gpwsFunc.UnitOfAltitude) { RadarAltitude = Util.RadarAltitude(ActiveVessel) * Util.M_TO_FT; Altitude = (float)(FlightGlobals.ship_altitude * Util.M_TO_FT); } else { RadarAltitude = Util.RadarAltitude(ActiveVessel); Altitude = (float)FlightGlobals.ship_altitude; } // speed HorSpeed = (float)ActiveVessel.horizontalSrfSpeed; VerSpeed = (float)ActiveVessel.verticalSpeed; Speed = (float)Math.Sqrt(HorSpeed * HorSpeed + VerSpeed * VerSpeed); // check volume if (Util.audio.Volume != Math.Max(GameSettings.VOICE_VOLUME, GameSettings.SHIP_VOLUME) * Settings.Volume) { Util.audio.UpdateVolume(); } // check shake Util.controller.CheckResetShake(); // if vessel changed, don't update if (ActiveVessel != LastActiveVessel) { Util.audio.SetUnavailable(); return(false); } if (!gpwsFunc.PreUpdate()) { return(false); } // enable if (!gpwsFunc.EnableSystem) { Util.audio.SetUnavailable(); return(false); } return(true); }