public void InitializeSuffixes() { AddSuffix("CANREVERT", new Suffix <BooleanValue>(CanRevert)); AddSuffix("CANREVERTTOLAUNCH", new Suffix <BooleanValue>(CanRevertToLaunch)); AddSuffix("CANREVERTTOEDITOR", new Suffix <BooleanValue>(CanRevvertToEditor)); AddSuffix("REVERTTOLAUNCH", new NoArgsVoidSuffix(RevertToLaunch)); AddSuffix("REVERTTOEDITOR", new NoArgsVoidSuffix(RevertToEditor)); AddSuffix("REVERTTO", new OneArgsSuffix <StringValue>(RevertTo)); AddSuffix("CANQUICKSAVE", new Suffix <BooleanValue>(CanQuicksave)); AddSuffix("QUICKSAVE", new NoArgsVoidSuffix(QuickSave)); AddSuffix("QUICKLOAD", new NoArgsVoidSuffix(QuickLoad)); AddSuffix("QUICKSAVETO", new OneArgsSuffix <StringValue>(QuickSaveTo)); AddSuffix("QUICKLOADFROM", new OneArgsSuffix <StringValue>(QuickLoadFrom)); AddSuffix("QUICKSAVELIST", new Suffix <ListValue>(GetQuicksaveList)); AddSuffix("ORIGINEDITOR", new Suffix <StringValue>(OriginatingEditor)); AddSuffix("DEFAULTLOADDISTANCE", new Suffix <LoadDistanceValue>(() => new LoadDistanceValue(PhysicsGlobals.Instance.VesselRangesDefault))); AddSuffix("ACTIVEVESSEL", new SetSuffix <VesselTarget>(() => VesselTarget.CreateOrGetExisting(FlightGlobals.ActiveVessel, shared), SetActiveVessel)); AddSuffix(new string[] { "FORCESETACTIVEVESSEL", "FORCEACTIVE" }, new OneArgsSuffix <VesselTarget>(ForceSetActiveVessel)); AddSuffix("HOURSPERDAY", new Suffix <ScalarValue>(GetHoursPerDay)); AddSuffix("DEBUGLOG", new OneArgsSuffix <StringValue>(DebugLog)); AddSuffix("GETCRAFT", new TwoArgsSuffix <CraftTemplate, StringValue, StringValue>(GetCraft)); AddSuffix("LAUNCHCRAFT", new OneArgsSuffix <CraftTemplate>(LaunchShip)); AddSuffix("LAUNCHCRAFTFROM", new TwoArgsSuffix <CraftTemplate, StringValue>(LaunchShip)); AddSuffix("CRAFTLIST", new Suffix <ListValue>(CraftTemplate.GetAllTemplates)); AddSuffix("SWITCHVESSELWATCHERS", new NoArgsSuffix <UniqueSetValue <UserDelegate> >(() => shared.DispatchManager.CurrentDispatcher.GetSwitchVesselNotifyees())); AddSuffix("TIMEWARP", new Suffix <TimeWarpValue>(() => TimeWarpValue.Instance)); }
public override OrbitableVelocity GetVelocitiesAtUT(TimeSpan timeStamp) { CelestialBody parent = Body.KOSExtensionGetParentBody(); if (parent == null) // only if Body is Sun and therefore has no parent, then do more complex work instead because KSP didn't provide a way itself { Vector3d futureOrbitalVel; CelestialBody soiBody = Shared.Vessel.mainBody; if (soiBody.orbit != null) { futureOrbitalVel = soiBody.orbit.GetFrameVelAtUT(timeStamp.ToUnixStyleTime()); } else { futureOrbitalVel = -1 * VesselTarget.CreateOrGetExisting(Shared.Vessel, Shared).GetVelocitiesAtUT(timeStamp).Orbital.ToVector3D(); } Vector swappedVel = new Vector(futureOrbitalVel.x, futureOrbitalVel.z, futureOrbitalVel.y); // swap Y and Z because KSP API is weird. // Also invert directions because the above gives vel of my body rel to sun, and I want vel of sun rel to my body: return(new OrbitableVelocity(-swappedVel, -swappedVel)); } var orbVel = new Vector(Orbit.getOrbitalVelocityAtUT(timeStamp.ToUnixStyleTime())); orbVel = new Vector(orbVel.X, orbVel.Z, orbVel.Y); // swap Y and Z because KSP API is weird. var surfVel = new Vector(Body.orbit.GetVel() - parent.getRFrmVel(Body.position)); return(new OrbitableVelocity(orbVel, surfVel)); }
private void InitializeSuffixes() { AddSuffix("NAME", new SetSuffix <StringValue>(() => dockedVesselInfo.name, SetName)); AddSuffix("UID", new Suffix <StringValue>(() => dockedVesselInfo.rootPartUId.ToString())); AddSuffix("VESSEL", new Suffix <VesselTarget>(() => VesselTarget.CreateOrGetExisting(parts[0].vessel, shared))); AddSuffix("PARTS", new Suffix <ListValue>(() => PartValueFactory.Construct(parts, shared))); AddSuffix("DOCKINGPORTS", new Suffix <ListValue>(() => DockingPortValue.PartsToList(parts, shared))); AddSuffix("RESOURCES", new Suffix <ListValue>(GetResourceManifest)); }