private void fireVesselChanged(Vessel vessel) { if (vesselChangeEvent != null) { vesselChangeEvent(vessel); } }
public void CheckVesselMeetsCondition(Vessel vessel) { if (CanCheckVesselMeetsCondition(vessel)) { VesselMeetsCondition(vessel); } }
public static double GetThrustTorque(Part p, Vessel vessel) { var CoM = vessel.CoM; if (p.State == PartStates.ACTIVE) { if (p is LiquidEngine) { if (((LiquidEngine)p).thrustVectoringCapable) { return Math.Sin(Math.Abs(((LiquidEngine)p).gimbalRange) * Math.PI / 180) * ((LiquidEngine)p).maxThrust * (p.Rigidbody.worldCenterOfMass - CoM).magnitude; } } else if (p is LiquidFuelEngine) { if (((LiquidFuelEngine)p).thrustVectoringCapable) { return Math.Sin(Math.Abs(((LiquidFuelEngine)p).gimbalRange) * Math.PI / 180) * ((LiquidFuelEngine)p).maxThrust * (p.Rigidbody.worldCenterOfMass - CoM).magnitude; } } else if (p is AtmosphericEngine) { if (((AtmosphericEngine)p).thrustVectoringCapable) { return Math.Sin(Math.Abs(((AtmosphericEngine)p).gimbalRange) * Math.PI / 180) * ((AtmosphericEngine)p).maximumEnginePower * ((AtmosphericEngine)p).totalEfficiency * (p.Rigidbody.worldCenterOfMass - CoM).magnitude; } } } return 0; }
/// <summary> /// Find the vessel orientation at the CoM by interpolating from surrounding part transforms /// This orientation should be significantly more resistant to vessel flex/wobble than the vessel transform (root part) as a free body rotates about it's CoM /// /// Has an issue with the origin shifter causing random bounces /// </summary> public void findVesselFwdAxis(Vessel v) { Part closestPart = v.rootPart; float offset = (closestPart.transform.position - v.CurrentCoM).sqrMagnitude; // only comparing magnitude, sign and actual value don't matter foreach (Part p in v.Parts) { float partOffset = (p.partTransform.position - v.CurrentCoM).sqrMagnitude; if (partOffset < offset) { closestPart = p; offset = partOffset; } } /// /// now require two things, accounting for any rotation in part placement, and interpolating with surrounding parts (parent/children/symmetry counterparts) to "shift" the location to the CoM /// accounting for rotation is the most important, the nearby position will work for now. /// Vector3 location = closestPart.partTransform.position - v.CurrentCoM; /// vesselFacingAxis = closestPart.transform.localRotation * closestPart.orgRot.Inverse() * Vector3.up; if (closestPart.symmetryCounterparts != null) { for (int i = 0; i < closestPart.symmetryCounterparts.Count; i++) { vesselFacingAxis += closestPart.symmetryCounterparts[i].transform.localRotation * closestPart.symmetryCounterparts[i].orgRot.Inverse() * Vector3.up; } vesselFacingAxis /= (closestPart.symmetryCounterparts.Count + 1); } }
protected override List<Value> values(Vessel vessel, GameEvent events) { List<Value> values = new List<Value> (); int count = 0; if (vessel != null) { foreach (Part p in vessel.Parts) { if (p.partInfo.name.Equals (partName)) { ++count; } } } if(maxPartCount == -1) { if (vessel == null) { values.Add (new Value ("Part", partCount + "x " + partName)); } else { values.Add (new Value ("Part", partCount + "x " + partName, "" + count, count >= partCount)); } } else { if (vessel == null) { values.Add (new Value ("max part", maxPartCount + "x " + partName)); } else { values.Add (new Value ("max part", maxPartCount + "x " + partName, "" + count, count <= maxPartCount)); } } return values; }
private void OnVesselDestroy(Vessel data) { if (data.id == Vessel.id) { BindingMgr.Dispose(); } }
protected override List<Value> values(Vessel vessel, GameEvent events) { List<Value> v = new List<Value> (); double a = 0; if (vessel != null) { foreach (Part p in vessel.parts) { if (p.Resources [name] != null) { a += p.Resources [name].amount; } } } if (maxAmount != 0) { if(vessel == null) { v.Add(new Value("max. resource " + name, maxAmount)); } else { v.Add(new Value("max. resource " + name, maxAmount, a, a <= maxAmount)); } } if (minAmount != 0) { if(vessel == null) { v.Add(new Value("min. resource " + name, minAmount)); } else { v.Add(new Value("min. resource " + name, minAmount, a, a >= minAmount)); } } return v; }
public static int GetDockedVesselsCount(Vessel Vsl) { List<uint> MissionIds = new List<uint> (); ProtoPartSnapshot[] Parts = Vsl.protoVessel.protoPartSnapshots.ToArray(); for (int i = 0; i < Parts.Length; i++) { uint missionId = Parts [i].missionID; bool found = false; for (int k = 0; k < MissionIds.ToArray ().Length; k++) { uint _missionId = MissionIds.ToArray () [k]; if (missionId == _missionId) { found = true; } } if (!found) { MissionIds.Add (missionId); } } int missionCount = MissionIds.Count - 1; if (OnAstroid (Vsl)) { missionCount--; } return missionCount; }
public FlyingCamera(Part thatPart, RenderTexture screen, float aspect) { ourVessel = thatPart.vessel; ourPart = thatPart; screenTexture = screen; cameraAspect = aspect; }
public void update(Vessel vessel) { if (vessel != null) { updateHasTelemachusPart(vessel); } }
//called when un-clicking on a vessel public void endPipe(Vessel end) { if(_currentlyConnecting != null) _currentlyConnecting.setOutputVessel(end); _currentlyConnecting = null; }
public void OnVesselRecoveryRequested(Vessel v) { vesselMass = v.GetTotalMass(); //Get total ship cost KerbalGUIManager.print("[rusty] OnVesselRecoveryRequested"); }
private void OnVesselPack(Vessel vessel) { if (vessel.situation == Vessel.Situations.FLYING) { lastPackTime[vessel.id] = UnityEngine.Time.realtimeSinceStartup; } }
protected override void Start() { //Initialize the map object Visible = SCANcontroller.controller.bigMapVisible; if (v == null) v = FlightGlobals.ActiveVessel; if (b == null) b = v.mainBody; if (bigmap == null) { bigmap = new SCANmap(b, true); bigmap.setProjection((MapProjection)SCANcontroller.controller.projection); bigmap.setWidth(SCANcontroller.controller.map_width); } WindowRect.x = SCANcontroller.controller.map_x; WindowRect.y = SCANcontroller.controller.map_y; currentColor = SCANcontroller.controller.colours == 0; lastColor = currentColor; lastResource = SCANcontroller.controller.map_ResourceOverlay; WindowCaption = string.Format("Map of {0}", b.theName); data = SCANUtil.getData(b); if (data == null) { data = new SCANdata(b); SCANcontroller.controller.addToBodyData(b, data); } bigmap.setBody(b); if (SCANconfigLoader.GlobalResource) { loadedResources = SCANcontroller.setLoadedResourceList(); } TooltipsEnabled = SCANcontroller.controller.toolTips; }
private void OnVesselWasModified(Vessel data) { if (!ReferenceEquals(data, FlightGlobals.ActiveVessel)) { DebugHelper.Debug("OnVesselWasModified called on non-active vessel, skipping"); return; } DebugHelper.Debug("OnVesselWasModified, groups count {0}", Groups.Count); //_gui.ClearGroups(); foreach (var engineGroup in Groups.Values) { DebugHelper.Debug("Cleaning group {0}: {1} engine(s)", engineGroup.GroupId, engineGroup.EngineRefList.Count); engineGroup.EngineRefList.Clear(); } //Groups.Clear(); RecurseParts(data.rootPart, x => { //DebugHelper.Debug("Part {0}", x.name); //x.FindModuleImplementing<>() if (!x.Modules.Contains("EngineGroupModule")) { //DebugHelper.Debug("!x.Modules.Contains('EngineGroupModule')"); return; } var moduleRef = x.Modules["EngineGroupModule"] as EngineGroupModule; if (moduleRef == null) { //DebugHelper.Debug("moduleRef == null"); return; } var groupId = moduleRef.EngineGroupId; if (string.IsNullOrEmpty(groupId)) return; if (!Groups.ContainsKey(groupId)) { DebugHelper.Debug("Creating a group {0}", groupId); Groups.Add(groupId, new EngineGroup(groupId)); _gui.AddGroup(Groups[groupId]); } foreach (var wrapper in moduleRef.Wrappers) { Groups[groupId].EngineRefList.Add(wrapper); } }); foreach (var groupId in Groups.Keys.ToList()) { if (Groups[groupId].EngineRefList.Count == 0) { DebugHelper.Debug("Removing group {0} (no engines)", groupId); _gui.RemoveGroup(Groups[groupId]); Groups.Remove(groupId); } } if (Groups.Count == 0) { _gui.DisplayNoGroupsMessage(); } }
void Awake() { part = GetComponentInParent<Part>(); vessel = part.vessel; CamTools.OnResetCTools += OnResetCTools; }
public VesselDto(Vessel vessel) { _VesselId = vessel.ID; _OperatorId = vessel.OperatorId; _VesselCode = vessel.VesselCode; _VesselName = vessel.VesselName; }
public static EvaAction GetEvaAction(ProtoCrewMember kerbal, Vessel fromVessel) { if (fromVessel != null) { bool atmosphere = fromVessel.IsInAtmosphere(); bool oxygen = fromVessel.IsInAtmosphereWithOxygen(); if (Log.IsLogable(Log.LEVEL.DETAIL)) Log.Detail("creating EVA action for kerbal " + kerbal.name + " in atmosphere:" + atmosphere + ", oxygen:" + oxygen); if (atmosphere && oxygen) { return ActionPool.ACTION_EVA_OXYGEN; } else if (atmosphere && ! oxygen) { return ActionPool.ACTION_EVA_INATM; } else if (!atmosphere) { return ActionPool.ACTION_EVA_NOATM; } else { Log.Warning("unexpected EVA situation"); return ActionPool.ACTION_EVA_NOATM; } } else { Log.Warning("no vessel for kerbal "+kerbal.name+" on EVA"); return ActionPool.ACTION_EVA_NOATM; } }
public static void Wrap(Vessel parent, Action<BaseEvent, bool> pass) { var controller = UIPartActionController.Instance; if (!controller) return; var listFieldInfo = controller.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(List<UIPartActionWindow>)); var list = (List<UIPartActionWindow>)listFieldInfo.GetValue(controller); foreach (var window in list.Where(l => l.part.vessel == parent)) { var itemsFieldInfo = window.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(List<UIPartActionItem>)); var item = (List<UIPartActionItem>)itemsFieldInfo.GetValue(window); foreach (var it in item) { var button = it as UIPartActionEventItem; if (button != null) { var partEventFieldInfo = button.Evt.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(BaseEventDelegate)); var partEvent = (BaseEventDelegate)partEventFieldInfo.GetValue(button.Evt); if (!partEvent.Method.GetCustomAttributes(typeof(KSPEvent), true).Any(a => ((KSPEvent)a).category.Contains("skip_control"))) { bool ignore_delay = partEvent.Method.GetCustomAttributes(typeof(KSPEvent), true).Any(a => ((KSPEvent)a).category.Contains("skip_delay")); var eventField = typeof(UIPartActionEventItem).GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(BaseEvent)); eventField.SetValue(button, Wrapper.CreateWrapper(button.Evt, pass, ignore_delay)); } } } } }
public override List<Lab> getFreeLabsWithEquipment(Vessel vessel) { List<Lab> ret = new List<Lab>(); List<MPL_Module> allPhysicsLabs; if (cachedVesselID == vessel.id && partCount == vessel.parts.Count && physicsLabCache != null) { allPhysicsLabs = physicsLabCache; } else { allPhysicsLabs = new List<MPL_Module>(UnityFindObjectsOfType(typeof(MPL_Module)) as MPL_Module[]); physicsLabCache = allPhysicsLabs; cachedVesselID = vessel.id; partCount = vessel.parts.Count; NE_Helper.log("Lab Cache refresh"); } foreach (MPL_Module lab in allPhysicsLabs) { if (lab.vessel == vessel && lab.hasEquipmentInstalled(neededEquipment) && lab.hasEquipmentFreeExperimentSlot(neededEquipment)) { ret.Add(lab); } } return ret; }
public static void Wrap(Vessel parent, Action<BaseEvent> pass) { var controller = UIPartActionController.Instance; if (!controller) return; var listFieldInfo = controller.GetType() .GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(List<UIPartActionWindow>)); var list = (List<UIPartActionWindow>) listFieldInfo.GetValue(controller); foreach (var window in list.Where(l => l.part.vessel == parent)) { var itemsFieldInfo = window.GetType() .GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(List<UIPartActionItem>)); var item = (List<UIPartActionItem>) itemsFieldInfo.GetValue(window); foreach (var it in item) { var button = it as UIPartActionModuleButton; if (button != null) { var partEventFieldInfo = button.partEvent.GetType() .GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .First(fi => fi.FieldType == typeof(BaseEventDelegate)); var partEvent = (BaseEventDelegate) partEventFieldInfo.GetValue(button.partEvent); if (partEvent.Method.GetCustomAttributes( typeof(IgnoreSignalDelayAttribute), true).Length == 0) { button.partEvent = Wrapper.Wrap(button.partEvent, pass); } } } } }
/// <summary> /// Gets the vessel crew and works for EVAs as well /// </summary> /// <param name="v"></param> /// <returns></returns> protected static IEnumerable<ProtoCrewMember> GetVesselCrew(Vessel v) { if (v == null) { yield break; } // EVA vessel if (v.vesselType == VesselType.EVA) { if (v.parts == null) { yield break; } foreach (Part p in v.parts) { foreach (ProtoCrewMember pcm in p.protoModuleCrew) { yield return pcm; } } } else { // Vessel with crew foreach (ProtoCrewMember pcm in v.GetVesselCrew()) { yield return pcm; } } }
public void ForgetVessel(Vessel hackyVessel) { if (loadingFlyingVessels.ContainsKey(hackyVessel.id)) { loadingFlyingVessels.Remove(hackyVessel.id); } }
private void Startup() { //Initialize the map object Visible = false; if (HighLogic.LoadedSceneIsFlight) { v = SCANcontroller.controller.BigMap.V; b = SCANcontroller.controller.BigMap.Body; data = SCANcontroller.controller.BigMap.Data; } else if (HighLogic.LoadedSceneHasPlanetarium) { v = null; b = SCANcontroller.controller.kscMap.Body; data = SCANcontroller.controller.kscMap.Data; } if (spotmap == null) { spotmap = new SCANmap(); spotmap.setSize(320, 240); } showOrbit = SCANcontroller.controller.map_orbit; showAnomaly = SCANcontroller.controller.map_markers; if (HighLogic.LoadedScene == GameScenes.SPACECENTER) showWaypoints = false; else showWaypoints = SCANcontroller.controller.map_waypoints; TooltipsEnabled = SCANcontroller.controller.toolTips; spotmap.setBody(b); }
public static void RemoveAllManeuverNodes(Vessel vessel) { while (vessel.patchedConicSolver.maneuverNodes.Count > 0) { vessel.patchedConicSolver.RemoveManeuverNode(vessel.patchedConicSolver.maneuverNodes.Last()); } }
public static double GetThrustTorque(Part p, Vessel vessel) { if (p.State == PartStates.ACTIVE) { var gimbal = p.Modules.OfType<ModuleGimbal>().FirstOrDefault(); if (gimbal != null && !gimbal.gimbalLock) { var engine = p.Modules.OfType<ModuleEngines>().FirstOrDefault(); var fxengine = p.Modules.OfType<ModuleEnginesFX>().FirstOrDefault(); var magnitude = (p.Rigidbody.worldCenterOfMass - vessel.CoM).magnitude; var gimbalRange = Math.Sin(Math.Abs(gimbal.gimbalRange)); var engineActive = engine != null && engine.isOperational; var enginefxActive = fxengine != null && fxengine.isOperational; if (engineActive) { return gimbalRange * engine.finalThrust * magnitude; } if (enginefxActive) { return gimbalRange * fxengine.finalThrust * magnitude; } } } return 0; }
public override bool isDone(Vessel vessel, GameEvent events) { if (vessel == null) { return false; } if (doneOnce) { return true; } List<Value> values = getValues(vessel, events); foreach (Value v in values) { if (!v.done) { return false; } } // We remember that we have previously completed this goal. doneOnce = true; return true; }
public static bool ActiveControlSysIsOnVessel(Vessel v) { if (FARControlSys.ActiveControlSys != null) return FARControlSys.ActiveControlSys.vessel == v; return false; }
public static VesselAerodynamicModel GetModel(Vessel ship, CelestialBody body) { foreach (var loadedAssembly in AssemblyLoader.loadedAssemblies) { try { switch (loadedAssembly.name) { case "FerramAerospaceResearch": var FARAPIType = loadedAssembly.assembly.GetType("FerramAerospaceResearch.FARAPI"); var FARAPI_CalculateVesselAeroForces = FARAPIType.GetMethodEx("CalculateVesselAeroForces", BindingFlags.Public | BindingFlags.Static, new Type[] { typeof(Vessel), typeof(Vector3).MakeByRefType(), typeof(Vector3).MakeByRefType(), typeof(Vector3), typeof(double) }); return new FARModel(ship, body, FARAPI_CalculateVesselAeroForces); //case "MyModAssembly": // implement here your atmo mod detection // return new MyModModel(ship, body, any other parameter); } } catch (Exception e) { Debug.Log("Trajectories: failed to interface with assembly " + loadedAssembly.name); Debug.Log("Using stock model instead"); Debug.Log(e.ToString()); } } // Using stock model if no other aerodynamic is detected or if any error occured return new StockModel(ship, body); }
public void RunCalculations( Vessel vessel, Quaternion gymbal) { // Calculations thanks to Mechjeb Vector3d CoM = vessel.findWorldCenterOfMass(); Vector3d up = (CoM - vessel.mainBody.position).normalized; Vector3d velocityVesselOrbit = vessel.orbit.GetVel(); Vector3d velocityVesselOrbitUnit = velocityVesselOrbit.normalized; Vector3d radialPlus = Vector3d.Exclude(velocityVesselOrbit, up).normalized; Vector3d velocityVesselSurface = velocityVesselOrbit - vessel.mainBody.getRFrmVel(CoM); Vector3d velocityVesselSurfaceUnit = velocityVesselSurface.normalized; RadialPlus = gymbal * radialPlus; NormalPlus = gymbal * -Vector3d.Cross(radialPlus, velocityVesselOrbitUnit); ProgradeOrbit = gymbal * velocityVesselOrbitUnit; ProgradeSurface = gymbal * velocityVesselSurfaceUnit; if (vessel.patchedConicSolver.maneuverNodes.Count > 0) { Vector3d burnVector = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(vessel.orbit); ManeuverPlus = gymbal * burnVector.normalized; ManeuverPresent = true; } else { ManeuverPresent = false; } }
// Returns true if ship is it atmoshpere public static bool VesselInAtmosphere(Vessel vessel) { return(vessel.heightFromSurface < vessel.mainBody.maxAtmosphereAltitude); }
public void Init(Vessel vsl) => vessel = vsl;
public void OnVesselWasModified(Vessel v) { //if (v == part.vessel) // radiatorCount = part.symmetryCounterparts.Count + 1; }
internal void RespawnCrew() { Vessel.SpawnCrew(); SMAddon.FireEventTriggers(); }
private void Update() { safeDisplay = display; if (display) { if (((Client.realtimeSinceStartup - lastUpdateTime) > DISPLAY_UPDATE_INTERVAL) || displayFast) { lastUpdateTime = Client.realtimeSinceStartup; //Vector text if (HighLogic.LoadedScene == GameScenes.FLIGHT && FlightGlobals.ready && FlightGlobals.fetch.activeVessel != null) { Vessel ourVessel = FlightGlobals.fetch.activeVessel; vectorText = "Forward vector: " + ourVessel.GetFwdVector() + "\n"; vectorText += "Up vector: " + (Vector3)ourVessel.upAxis + "\n"; vectorText += "Srf Rotation: " + ourVessel.srfRelRotation + "\n"; vectorText += "Vessel Rotation: " + ourVessel.transform.rotation + "\n"; vectorText += "Vessel Local Rotation: " + ourVessel.transform.localRotation + "\n"; vectorText += "mainBody Rotation: " + (Quaternion)ourVessel.mainBody.rotation + "\n"; vectorText += "mainBody Transform Rotation: " + (Quaternion)ourVessel.mainBody.bodyTransform.rotation + "\n"; vectorText += "Surface Velocity: " + ourVessel.GetSrfVelocity() + ", |v|: " + ourVessel.GetSrfVelocity().magnitude + "\n"; vectorText += "Orbital Velocity: " + ourVessel.GetObtVelocity() + ", |v|: " + ourVessel.GetObtVelocity().magnitude + "\n"; if (ourVessel.orbitDriver != null && ourVessel.orbitDriver.orbit != null) { vectorText += "Frame Velocity: " + (Vector3)ourVessel.orbitDriver.orbit.GetFrameVel() + ", |v|: " + ourVessel.orbitDriver.orbit.GetFrameVel().magnitude + "\n"; } vectorText += "CoM offset vector: " + ourVessel.CoM.ToString() + "\n"; vectorText += "Angular Velocity: " + ourVessel.angularVelocity + ", |v|: " + ourVessel.angularVelocity.magnitude + "\n"; vectorText += "World Pos: " + (Vector3)ourVessel.GetWorldPos3D() + ", |pos|: " + ourVessel.GetWorldPos3D().magnitude + "\n"; } else { vectorText = "You have to be in flight"; } //NTP text ntpText = "Warp rate: " + Math.Round(Time.timeScale, 3) + "x.\n"; ntpText += "Current subspace: " + TimeSyncer.fetch.currentSubspace + ".\n"; if (TimeSyncer.fetch.locked) { ntpText += "Current subspace rate: " + Math.Round(TimeSyncer.fetch.lockedSubspace.subspaceSpeed, 3) + "x.\n"; } else { ntpText += "Current subspace rate: " + Math.Round(TimeSyncer.fetch.requestedRate, 3) + "x.\n"; } ntpText += "Current Error: " + Math.Round((TimeSyncer.fetch.GetCurrentError() * 1000), 0) + " ms.\n"; ntpText += "Current universe time: " + Math.Round(Planetarium.GetUniversalTime(), 3) + " UT\n"; ntpText += "Network latency: " + Math.Round((TimeSyncer.fetch.networkLatencyAverage / 10000f), 3) + " ms\n"; ntpText += "Server clock difference: " + Math.Round((TimeSyncer.fetch.clockOffsetAverage / 10000f), 3) + " ms\n"; ntpText += "Server lag: " + Math.Round((TimeSyncer.fetch.serverLag / 10000f), 3) + " ms\n"; //Connection queue text connectionText = "Last send time: " + NetworkWorker.fetch.GetStatistics("LastSendTime") + "ms.\n"; connectionText += "Last receive time: " + NetworkWorker.fetch.GetStatistics("LastReceiveTime") + "ms.\n"; connectionText += "Queued outgoing messages (High): " + NetworkWorker.fetch.GetStatistics("HighPriorityQueueLength") + ".\n"; connectionText += "Queued outgoing messages (Split): " + NetworkWorker.fetch.GetStatistics("SplitPriorityQueueLength") + ".\n"; connectionText += "Queued outgoing messages (Low): " + NetworkWorker.fetch.GetStatistics("LowPriorityQueueLength") + ".\n"; connectionText += "Queued out bytes: " + NetworkWorker.fetch.GetStatistics("QueuedOutBytes") + ".\n"; connectionText += "Sent bytes: " + NetworkWorker.fetch.GetStatistics("SentBytes") + ".\n"; connectionText += "Received bytes: " + NetworkWorker.fetch.GetStatistics("ReceivedBytes") + ".\n"; connectionText += "Stored future updates: " + VesselWorker.fetch.GetStatistics("StoredFutureUpdates") + "\n"; connectionText += "Stored future proto updates: " + VesselWorker.fetch.GetStatistics("StoredFutureProtoUpdates") + ".\n"; //Dynamic tick text dynamicTickText = "Current tick rate: " + DynamicTickWorker.fetch.sendTickRate + "hz.\n"; dynamicTickText += "Current max secondry vessels: " + DynamicTickWorker.fetch.maxSecondryVesselsPerTick + ".\n"; //Requested rates text requestedRateText = Settings.fetch.playerName + ": " + Math.Round(TimeSyncer.fetch.requestedRate, 3) + "x.\n"; foreach (KeyValuePair <string, float> playerEntry in WarpWorker.fetch.clientSkewList) { requestedRateText += playerEntry.Key + ": " + Math.Round(playerEntry.Value, 3) + "x.\n"; } profilerText = "Update: \n" + Profiler.updateData; profilerText += "Fixed Update: \n" + Profiler.fixedUpdateData; profilerText += "GUI: \n" + Profiler.guiData; } } }
public override Color GetCoordinateColor(Vessel vessel, double currentLatitude, double currentLongitude) { Cell cell = MapOverlay.GetCellUnder(body, currentLatitude, currentLongitude); return(MapOverlay.GetCellColor(cell, bodyResources, resource)); }
public override void OnPrecache(Vessel vessel) { body = vessel.mainBody; bodyResources = KethaneData.Current[resource.Resource][body]; }
// return living space factor in a vessel public static double Living_space(Vessel v) { // living space is the volume per-capita normalized against an 'ideal living space' and clamped in an acceptable range return(Lib.Clamp((Tot_volume(v) / Lib.CrewCount(v)) / PreferencesComfort.Instance.livingSpace, 0.1, 1.0)); }
// return moisture level in a vessel atmosphere public static double Humidity(Vessel v) { // the proportion of moisture in the atmosphere is simply the level of MoistAtmo + (0.6, base humidity of 60%) return(ResourceCache.Info(v, "MoistAtmosphere").level + 0.6); }
public new static string BackgroundUpdate(Vessel v, ProtoPartSnapshot part_snapshot, ProtoPartModuleSnapshot module_snapshot, PartModule proto_part_module, Part proto_part, Dictionary <string, double> availableResources, List <KeyValuePair <string, double> > resourceChangeRequest, double elapsed_s) => ModuleAvionics.BackgroundUpdate(v, part_snapshot, module_snapshot, proto_part_module, proto_part, availableResources, resourceChangeRequest, elapsed_s);
// return normalized pressure in a vessel public static double Pressure(Vessel v) { // the pressure is simply the atmosphere level return(ResourceCache.Info(v, "Atmosphere").level); }
// return shielding factor in a vessel public static double Shielding(Vessel v) { // the shielding factor is simply the level of shielding, scaled by the 'shielding efficiency' setting return(ResourceCache.Info(v, "Shielding").level *PreferencesStorm.Instance.shieldingEfficiency); }
// return habitat volume in a vessel in m^3 public static double Tot_volume(Vessel v) { // we use capacity: this mean that partially pressurized parts will still count, return(ResourceCache.Info(v, "Atmosphere").capacity / 1e3); }
// return waste level in a vessel atmosphere public static double Poisoning(Vessel v) { // the proportion of co2 in the atmosphere is simply the level of WasteAtmo return(ResourceCache.Info(v, "WasteAtmosphere").level); }
public static void Update(Vessel v, Vessel_info vi, VesselData vd, Resource_info ec, double elapsed_s) { if (!Lib.IsVessel(v)) { return; } // consume ec for transmitters ec.Consume(vi.connection.ec * elapsed_s, "comms"); Cache.WarpCache(v).dataCapacity = vi.connection.rate * elapsed_s; // do nothing if network is not ready if (!NetworkInitialized) { return; } // maintain and send messages // - do not send messages during/after solar storms // - do not send messages for EVA kerbals if (!v.isEVA && v.situation != Vessel.Situations.PRELAUNCH) { if (!vd.msg_signal && !vi.connection.linked) { vd.msg_signal = true; if (vd.cfg_signal) { string subtext = Localizer.Format("#KERBALISM_UI_transmissiondisabled"); switch (vi.connection.status) { case LinkStatus.plasma: subtext = Localizer.Format("#KERBALISM_UI_Plasmablackout"); break; case LinkStatus.storm: subtext = Localizer.Format("#KERBALISM_UI_Stormblackout"); break; default: if (vi.crew_count == 0) { switch (Settings.UnlinkedControl) { case UnlinkedCtrl.none: subtext = Localizer.Format("#KERBALISM_UI_noctrl"); break; case UnlinkedCtrl.limited: subtext = Localizer.Format("#KERBALISM_UI_limitedcontrol"); break; } } break; } Message.Post(Severity.warning, Lib.BuildString(Localizer.Format("#KERBALISM_UI_signallost"), " <b>", v.vesselName, "</b>"), subtext); } } else if (vd.msg_signal && vi.connection.linked) { vd.msg_signal = false; if (vd.cfg_signal) { Message.Post(Severity.relax, Lib.BuildString("<b>", v.vesselName, "</b> ", Localizer.Format("#KERBALISM_UI_signalback")), vi.connection.status == LinkStatus.direct_link ? Localizer.Format("#KERBALISM_UI_directlink") : Lib.BuildString(Localizer.Format("#KERBALISM_UI_relayby"), " <b>", vi.connection.target_name, "</b>")); } } } }
// return habitat surface in a vessel in m^2 public static double Tot_surface(Vessel v) { // we use capacity: this mean that partially pressurized parts will still count, return(ResourceCache.Info(v, "Shielding").capacity); }
public float GetBearing(Vessel vessel) { return(VesselUtils.AngleDelta(VesselUtils.GetHeading(vessel), GetHeadingFromVessel(vessel))); }
/// <summary>After switching the vessel hide the current flight computer UI.</summary> /// <param name="vessel">The **new** vessel we are changing to.</param> public void OnVesselChange(Vessel vessel) { RTLog.Notify("OnVesselChange - new vessel: " + (vessel != null ? vessel.vesselName : "N/A")); _flightComputerWindow?.Hide(); }
public static double SpeedUnitToMSec(this double speedUnit, SpeedMode mode, SpeedUnits units, Vessel vessel) { if (mode == SpeedMode.Mach) { return(speedUnit * vessel.speedOfSound); } else { double speed = speedUnit / speedUnitTransform(units, vessel.speedOfSound); switch (mode) { case SpeedMode.True: return(speed); case SpeedMode.Indicated: return(speed * Math.Sqrt(vessel.atmDensity / 1.225) * calcStagnationPres(vessel)); case SpeedMode.Equivalent: return(speed / Math.Sqrt(vessel.atmDensity / 1.225)); } return(0); } }
public double DistanceFrom(Vessel Vessel) { return(Vector3d.Distance(Vessel.GetWorldPos3D(), Body.GetWorldSurfacePosition(Lat, Lng, Vessel.altitude))); }
public static Quaternion getPlaneRotation(double heading, Vessel vessel, VesselData vdata) { Vector3 planeNormal = vecHeading(heading, vdata); return(getPlaneRotation(planeNormal, vessel)); }
public string ControllingMod(Vessel v) { if (v.name.StartsWith("Ast.")) { Log.Info("Vessel: Asteroid"); return(""); } Log.Info("ControllingMod, vessel: " + v.name); if (!v.loaded) { Log.Info("Vessel is unloaded"); foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots) { Log.Info("ProtoPartsnapshot, currentStage: " + v.currentStage.ToString() + " stageIndex: " + p.stageIndex.ToString() + " inverseStageIndex: " + p.inverseStageIndex.ToString()); if (p.inverseStageIndex >= v.currentStage - 1) { if (idUtil.IsDecoupler(p)) { ProtoPartModuleSnapshot m = p.modules.FirstOrDefault(mod => mod.moduleName == "RecoveryIDModule"); // FindModuleImplementing<RecoveryIDModule>(); if (m != null /*&& m.moduleRef != null */) { Log.Info("Part: " + p.partInfo.name + ", decoupler, Returning: " + m.moduleValues.GetValue("recoveryOwner")); return(m.moduleValues.GetValue("recoveryOwner")); //return ((RecoveryIDModule)m.moduleRef).RecoveryOwner; } } else { if (p.modules.Count > 0) { { ProtoPartModuleSnapshot m = p.modules.FirstOrDefault(mod => mod.moduleName == "ControllingRecoveryModule"); if (m != null /* && m.moduleRef != null */) { Log.Info("Part: " + p.partInfo.name + ", part, Returning: " + m.moduleValues.GetValue("recoveryOwner")); return(m.moduleValues.GetValue("recoveryOwner")); //return ((RecoveryIDModule)m.moduleRef).RecoveryOwner; } } } else { Log.Info("ControllingRecoveryModule not found"); return("ControllingRecoveryModule not found"); } } } } } else { foreach (Part p in v.Parts) { if (p.inverseStage >= v.currentStage - 1) { if (idUtil.IsDecoupler(p)) { RecoveryIDModule m = p.FindModuleImplementing <RecoveryIDModule>(); if (m != null) { Log.Info("Part: " + p.partInfo.name + ", Returning: " + m.RecoveryOwner); return(m.RecoveryOwner); } } else { ControllingRecoveryModule m = p.FindModuleImplementing <ControllingRecoveryModule>(); if (m != null) { Log.Info("Part: " + p.partInfo.name + ", Returning: " + m.RecoveryOwner); return(m.RecoveryOwner); } } } } } Log.Info("returning null"); return(null); }
private void VesselChange(Vessel v) { base.SetIncomplete(); }
public static Vector3 getPlaneNormal(Quaternion rotation, Vessel vessel) { return(rotation * vessel.mainBody.transform.right); }
public static void Purge(Vessel v) { uint vID = Lib.VesselID(v); vessels.Remove(vID); }
/// <summary> /// calculate the planet relative rotation from the plane normal vector /// </summary> public static Quaternion getPlaneRotation(Vector3 planeNormal, Vessel vessel) { return(Quaternion.FromToRotation(vessel.mainBody.transform.right, planeNormal)); }
// return true if vessel is inside the exosphere public static bool InsideExosphere(Vessel v) { var body = v.mainBody; return(body.atmosphere && v.altitude > body.atmosphereDepth * 5.0 && v.altitude <= body.atmosphereDepth * 25.0); }
public static bool HasVesselInfo(Vessel v, out Vessel_Info vi) => vessels.TryGetValue(Lib.VesselID(v), out vi);
// return true if the vessel is under water public static bool Underwater(Vessel v) { double safe_threshold = v.isEVA ? -0.5 : -2.0; return(v.mainBody.ocean && v.altitude < safe_threshold); }
public VesselSensors(Vessel target) { vessel = target; InitializeSuffixes(); }