public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); manager.AddGetter("SAS", delegate(CPU c) { return vessel.Autopilot.Mode.ToString(); }); manager.AddSetter("SAS", delegate(CPU c, object val) { if (val is bool) cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)val); else { try { Type t = typeof(VesselAutopilot.AutopilotMode); vessel.Autopilot.SetMode((VesselAutopilot.AutopilotMode)Enum.Parse(t, val.ToString(), true)); cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)true); } catch { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)false); } } }); vessel.OnFlyByWire += OnFlyByWire; }
public override void AddTo(BindingManager manager) { manager.AddGetter("TEST", delegate(CPU cpu) { return new SpecialValueTester(cpu); }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("SESSIONTIME", cpu => cpu.SessionTime); manager.AddGetter("VERSION", cpu => Core.VersionInfo); manager.AddGetter("VOLUME:NAME", cpu => cpu.SelectedVolume.Name); manager.AddSetter("VOLUME:NAME", (cpu, val) => cpu.SelectedVolume.Name = val.ToString()); }
public override void AddTo(BindingManager manager) { manager.AddGetter("TEST:RADAR", delegate(CPU cpu) { return new TimeSpan(cpu.SessionTime); }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("TEST", delegate(CPU cpu) { String outtext = ""; return outtext; }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("WARP", delegate(CPU cpu) { return TimeWarp.fetch.current_rate_index; }); manager.AddSetter("WARP", delegate(CPU cpu, object val) { int newRate; if (int.TryParse(val.ToString(), out newRate)) { TimeWarp.SetRate(newRate, false); } }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return cpu.SessionTime; }); manager.AddGetter("VOLUME:SELECTED", delegate(CPU cpu) { // if the user hasn't selected another volume, name will remain empty // return 1, as the user will still be on the default volume, 1 if (cpu.SelectedVolume.Name == null || cpu.SelectedVolume.Name.Length == 0) { return "1"; } else { return cpu.SelectedVolume.Name; } }); manager.AddGetter("VOLUME:FREESPACE", delegate(CPU cpu) { return cpu.SelectedVolume.GetFreeSpace(); }); }
public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); vessel.OnFlyByWire += OnFlyByWire; }
public CPU(object parent, string context) { this.Parent = parent; this.Context = context; bindingManager = new BindingManager(this, Context); if (context == "ksp") { archive = new Archive(Vessel); Volumes.Add(archive); } }
public CPU(object parent, string context) { this.Parent = parent; this.Context = context; bindingManager = new BindingManager(this, Context); if (context == "ksp") { archive = new Archive(Vessel); Volumes.Add(archive); } this.RegisterkOSExternalFunction(new object[] { "test2", this, "testFunction", 1 }); }
public override void AddTo(BindingManager manager) { cpu = manager.cpu; vessel = manager.cpu.Vessel; controls.Add(new LockableControl("THROTTLE", "throttle", cpu, manager)); controls.Add(new LockableControl("STEERING", "steering", cpu, manager)); controls.Add(new LockableControl("WHEELSTEERING", "wheelsteering", cpu, manager)); controls.Add(new LockableControl("WHEELTHROTTLE", "wheelthrottle", cpu, manager)); if (RTHook.Instance == null || !RTHook.Instance.HasFlightComputer(vessel.id)) { vessel.OnFlyByWire += OnFlyByWire; } }
public override void AddTo(BindingManager manager) { manager.AddGetter("WARP", delegate(CPU cpu) { return TimeWarp.fetch.current_rate_index; }); manager.AddSetter("WARP", delegate(CPU cpu, object val) { int newRate; if (int.TryParse(val.ToString(), out newRate)) { TimeWarp.SetRate(newRate, false); } }); foreach (CelestialBody body in FlightGlobals.fetch.bodies) { manager.AddGetter(body.name, delegate(CPU cpu) { return new BodyTarget(body, cpu); }); } }
public override void AddTo(BindingManager manager) { manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return cpu.SessionTime; }); manager.AddGetter("VERSION", delegate(CPU cpu) { return Core.VersionInfo; }); String buttonVarName = "BUTTON"; manager.AddGetter(buttonVarName + "1", delegate(CPU cpu) { return cpu.ButtonStates[0]; }); manager.AddGetter(buttonVarName + "2", delegate(CPU cpu) { return cpu.ButtonStates[1]; }); manager.AddGetter(buttonVarName + "3", delegate(CPU cpu) { return cpu.ButtonStates[2]; }); manager.AddGetter(buttonVarName + "4", delegate(CPU cpu) { return cpu.ButtonStates[3]; }); manager.AddGetter(buttonVarName + "5", delegate(CPU cpu) { return cpu.ButtonStates[4]; }); manager.AddGetter(buttonVarName + "6", delegate(CPU cpu) { return cpu.ButtonStates[5]; }); manager.AddGetter(buttonVarName + "7", delegate(CPU cpu) { return cpu.ButtonStates[6]; }); manager.AddGetter("INTERNALDISPLAY", delegate(CPU cpu) { return cpu.InternalDisplayEnabled; }); manager.AddSetter("INTERNALDISPLAY", delegate(CPU cpu, object val) { cpu.InternalDisplayEnabled = (bool)val; }); }
public override void AddTo(BindingManager manager) { manager.AddSetter("SAS", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool) val)); manager.AddSetter("GEAR", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Gear, (bool) val)); manager.AddSetter("LEGS", (cpu, val) => VesselUtils.LandingLegsCtrl(cpu.Vessel, (bool) val)); manager.AddSetter("CHUTES", (cpu, val) => VesselUtils.DeployParachutes(cpu.Vessel, (bool) val)); manager.AddSetter("LIGHTS", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, (bool) val)); manager.AddSetter("PANELS", (cpu, val) => VesselUtils.SolarPanelCtrl(cpu.Vessel, (bool) val)); manager.AddSetter("BRAKES", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, (bool) val)); manager.AddSetter("RCS", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, (bool) val)); manager.AddSetter("ABORT", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Abort, (bool) val)); manager.AddSetter("AG1", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom01, (bool) val)); manager.AddSetter("AG2", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom02, (bool) val)); manager.AddSetter("AG3", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom03, (bool) val)); manager.AddSetter("AG4", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom04, (bool) val)); manager.AddSetter("AG5", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom05, (bool) val)); manager.AddSetter("AG6", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom06, (bool) val)); manager.AddSetter("AG7", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom07, (bool) val)); manager.AddSetter("AG8", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom08, (bool) val)); manager.AddSetter("AG9", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom09, (bool) val)); manager.AddSetter("AG10", (cpu, val) => cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom10, (bool) val)); manager.AddGetter("SAS", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.SAS]); manager.AddGetter("GEAR", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Gear]); manager.AddGetter("LEGS", cpu => VesselUtils.GetLandingLegStatus(cpu.Vessel)); manager.AddGetter("CHUTES", cpu => VesselUtils.GetChuteStatus(cpu.Vessel)); manager.AddGetter("LIGHTS", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Light]); manager.AddGetter("PANELS", cpu => VesselUtils.GetSolarPanelStatus(cpu.Vessel)); manager.AddGetter("BRAKES", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Brakes]); manager.AddGetter("RCS", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.RCS]); manager.AddGetter("ABORT", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Abort]); manager.AddGetter("AG1", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom01]); manager.AddGetter("AG2", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom02]); manager.AddGetter("AG3", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom03]); manager.AddGetter("AG4", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom04]); manager.AddGetter("AG5", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom05]); manager.AddGetter("AG6", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom06]); manager.AddGetter("AG7", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom07]); manager.AddGetter("AG8", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom08]); manager.AddGetter("AG9", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom09]); manager.AddGetter("AG10", cpu => cpu.Vessel.ActionGroups[KSPActionGroup.Custom10]); }
public override void AddTo(BindingManager manager) { manager.AddSetter("SAS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)val); }); manager.AddSetter("GEAR", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Gear, (bool)val); }); manager.AddSetter("LEGS", delegate(CPU cpu, object val) { VesselUtils.LandingLegsCtrl(cpu.Vessel, (bool)val); }); manager.AddSetter("CHUTES", delegate(CPU cpu, object val) { VesselUtils.DeployParachutes(cpu.Vessel, (bool)val); }); manager.AddSetter("LIGHTS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, (bool)val); }); manager.AddSetter("PANELS", delegate(CPU cpu, object val) { VesselUtils.SolarPanelCtrl(cpu.Vessel, (bool)val); }); manager.AddSetter("BRAKES", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, (bool)val); }); manager.AddSetter("RCS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, (bool)val); }); manager.AddSetter("ABORT", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Abort, (bool)val); }); manager.AddSetter("AG1", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom01, (bool)val); }); manager.AddSetter("AG2", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom02, (bool)val); }); manager.AddSetter("AG3", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom03, (bool)val); }); manager.AddSetter("AG4", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom04, (bool)val); }); manager.AddSetter("AG5", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom05, (bool)val); }); manager.AddSetter("AG6", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom06, (bool)val); }); manager.AddSetter("AG7", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom07, (bool)val); }); manager.AddSetter("AG8", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom08, (bool)val); }); manager.AddSetter("AG9", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom09, (bool)val); }); manager.AddSetter("AG10", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom10, (bool)val); }); manager.AddGetter("SAS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.SAS]; }); manager.AddGetter("GEAR", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Gear]; }); manager.AddGetter("LEGS", delegate(CPU cpu) { return VesselUtils.GetLandingLegStatus(cpu.Vessel); }); manager.AddGetter("CHUTES", delegate(CPU cpu) { return VesselUtils.GetChuteStatus(cpu.Vessel); }); manager.AddGetter("LIGHTS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Light]; }); manager.AddGetter("PANELS", delegate(CPU cpu) { return VesselUtils.GetSolarPanelStatus(cpu.Vessel); }); manager.AddGetter("BRAKES", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Brakes]; }); manager.AddGetter("RCS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.RCS]; }); manager.AddGetter("ABORT", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Abort]; }); manager.AddGetter("AG1", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom01]; }); manager.AddGetter("AG2", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom02]; }); manager.AddGetter("AG3", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom03]; }); manager.AddGetter("AG4", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom04]; }); manager.AddGetter("AG5", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom05]; }); manager.AddGetter("AG6", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom06]; }); manager.AddGetter("AG7", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom07]; }); manager.AddGetter("AG8", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom08]; }); manager.AddGetter("AG9", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom09]; }); manager.AddGetter("AG10", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom10]; }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("ALT:RADAR", cpu => cpu.Vessel.heightFromTerrain > 0 ? Mathf.Min(cpu.Vessel.heightFromTerrain, (float) cpu.Vessel.altitude) : (float) cpu.Vessel.altitude); manager.AddGetter("ALT:APOAPSIS", cpu => cpu.Vessel.orbit.ApA); manager.AddGetter("ALT:PERIAPSIS", cpu => cpu.Vessel.orbit.PeA); manager.AddGetter("ETA:APOAPSIS", cpu => cpu.Vessel.orbit.timeToAp); manager.AddGetter("ETA:PERIAPSIS", cpu => cpu.Vessel.orbit.timeToPe); manager.AddGetter("ETA:TRANSITION", cpu => cpu.Vessel.orbit.EndUT - cpu.Vessel.missionTime); manager.AddGetter("MISSIONTIME", cpu => cpu.Vessel.missionTime); manager.AddGetter("TIME", cpu => new TimeSpan(Planetarium.GetUniversalTime())); manager.AddGetter("STATUS", cpu => cpu.Vessel.situation.ToString().Replace("_", " ")); manager.AddGetter("COMMRANGE", cpu => VesselUtils.GetCommRange(cpu.Vessel)); manager.AddGetter("INCOMMRANGE", cpu => Convert.ToDouble(CheckCommRange(cpu.Vessel))); manager.AddGetter("AV", cpu => cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity)); manager.AddGetter("STAGE", cpu => new StageValues(cpu.Vessel)); manager.AddGetter("ENCOUNTER", cpu => VesselUtils.TryGetEncounter(cpu.Vessel)); manager.AddGetter("NEXTNODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } return Node.FromExisting(vessel, vessel.patchedConicSolver.maneuverNodes[0]); }); // Things like altitude, mass, maxthrust are now handled the same for other ships as the current ship manager.AddGetter("SHIP", cpu => new VesselTarget(cpu.Vessel, cpu)); // These are now considered shortcuts to SHIP:suffix foreach (var scName in VesselTarget.ShortCuttableShipSuffixes) { var cName = scName; manager.AddGetter(scName, cpu => new VesselTarget(cpu.Vessel, cpu).GetSuffix(cName)); } manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value) { cpu.Vessel.vesselName = value.ToString(); }); }
public CPU(object parent, string context) { this.Parent = parent; this.Context = context; for (int i = 0; i < FUNCTION_BUTTON_COUNT; i++) ButtonStates[i] = new TerminalButton(this, i); bindingManager = new BindingManager(this, Context); if (context == "ksp") { RunType = kOSRunType.KSP; archive = new Archive(Vessel); Volumes.Add(archive); } else { RunType = kOSRunType.WINFORMS; } }
public override void AddTo(BindingManager manager) { manager.AddSetter("SAS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.SAS, (bool)val); }); manager.AddSetter("GEAR", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Gear, (bool)val); }); manager.AddSetter("LIGHTS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Light, (bool)val); }); manager.AddSetter("BRAKES", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Brakes, (bool)val); }); manager.AddSetter("RCS", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.RCS, (bool)val); }); manager.AddSetter("ABORT", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Abort, (bool)val); }); manager.AddSetter("AG1", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom01, (bool)val); }); manager.AddSetter("AG2", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom02, (bool)val); }); manager.AddSetter("AG3", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom03, (bool)val); }); manager.AddSetter("AG4", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom04, (bool)val); }); manager.AddSetter("AG5", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom05, (bool)val); }); manager.AddSetter("AG6", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom06, (bool)val); }); manager.AddSetter("AG7", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom07, (bool)val); }); manager.AddSetter("AG8", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom08, (bool)val); }); manager.AddSetter("AG9", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom09, (bool)val); }); manager.AddSetter("AG10", delegate(CPU cpu, object val) { cpu.Vessel.ActionGroups.SetGroup(KSPActionGroup.Custom10, (bool)val); }); manager.AddGetter("SAS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.SAS]; }); manager.AddGetter("GEAR", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Gear]; }); manager.AddGetter("LIGHTS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Light]; }); manager.AddGetter("BRAKES", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Brakes]; }); manager.AddGetter("RCS", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.RCS]; }); manager.AddGetter("ABORT", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Abort]; }); manager.AddGetter("AG1", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom01]; }); manager.AddGetter("AG2", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom02]; }); manager.AddGetter("AG3", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom03]; }); manager.AddGetter("AG4", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom04]; }); manager.AddGetter("AG5", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom05]; }); manager.AddGetter("AG6", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom06]; }); manager.AddGetter("AG7", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom07]; }); manager.AddGetter("AG8", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom08]; }); manager.AddGetter("AG9", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom09]; }); manager.AddGetter("AG10", delegate(CPU cpu) { return cpu.Vessel.ActionGroups[KSPActionGroup.Custom10]; }); }
public override void AddTo(BindingManager manager) { manager.AddSetter("TARGET", delegate(CPU cpu, object val) { if (val is ITargetable) { VesselUtils.SetTarget((ITargetable)val); } else if (val is VesselTarget) { VesselUtils.SetTarget(((VesselTarget)val).target); } else { var vessel = VesselUtils.GetVesselByName(val.ToString(), cpu.Vessel); VesselUtils.SetTarget(vessel); } }); manager.AddGetter("TARGET", delegate(CPU cpu) { return new VesselTarget((Vessel)FlightGlobals.fetch.VesselTarget, cpu); }); }
public LockableControl(String name, String propertyName, CPU cpu, BindingManager manager) { this.name = name; this.cpu = cpu; this.vessel = cpu.Vessel; locked = false; Value = 0; manager.AddGetter(name, delegate(CPU c) { return Value; }); manager.AddSetter(name, delegate(CPU c, object val) { }); this.propertyName = propertyName; }
public override void AddTo(BindingManager manager) { manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return(cpu.SessionTime); }); manager.AddGetter("VERSION", delegate(CPU cpu) { return(Core.VersionInfo); }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("VESSELNAME", delegate(CPU cpu) { return cpu.Vessel.vesselName; }); manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value ) { cpu.Vessel.vesselName = value.ToString(); }); manager.AddGetter("ALTITUDE", delegate(CPU cpu) { return cpu.Vessel.altitude; }); manager.AddGetter("ALT:RADAR", delegate(CPU cpu) { return cpu.Vessel.heightFromTerrain > 0 ? Mathf.Min(cpu.Vessel.heightFromTerrain, (float)cpu.Vessel.altitude) : (float)cpu.Vessel.altitude; }); manager.AddGetter("ALT:APOAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.ApA; }); manager.AddGetter("ALT:PERIAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.PeA; }); manager.AddGetter("ETA:APOAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.timeToAp; }); manager.AddGetter("ETA:PERIAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.timeToPe; }); manager.AddGetter("MISSIONTIME", delegate(CPU cpu) { return cpu.Vessel.missionTime; }); manager.AddGetter("TIME", delegate(CPU cpu) { return new kOS.TimeSpan(Planetarium.GetUniversalTime()); }); manager.AddGetter("STATUS", delegate(CPU cpu) { return cpu.Vessel.situation.ToString().Replace("_", " "); }); manager.AddGetter("COMMRANGE", delegate(CPU cpu) { return VesselUtils.GetCommRange(cpu.Vessel); }); manager.AddGetter("INCOMMRANGE", delegate(CPU cpu) { return Convert.ToDouble(CheckCommRange(cpu.Vessel)); }); manager.AddGetter("APOAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.ApA; }); manager.AddGetter("PERIAPSIS", delegate(CPU cpu) { return cpu.Vessel.orbit.PeA; }); manager.AddGetter("VELOCITY", delegate(CPU cpu) { return new VesselVelocity(cpu.Vessel); }); manager.AddGetter("ANGULARMOMENTUM",delegate(CPU cpu) { return new Direction(cpu.Vessel.angularMomentum, true); }); manager.AddGetter("ANGULARVEL", delegate(CPU cpu) { return new Direction(cpu.Vessel.angularVelocity, true); }); manager.AddGetter("MASS", delegate(CPU cpu) { return cpu.Vessel.GetTotalMass(); }); manager.AddGetter("VERTICALSPEED", delegate(CPU cpu) { return cpu.Vessel.verticalSpeed; }); manager.AddGetter("SURFACESPEED", delegate(CPU cpu) { return cpu.Vessel.horizontalSrfSpeed; }); manager.AddGetter("BODY", delegate(CPU cpu) { return cpu.Vessel.mainBody.bodyName; }); manager.AddGetter("LATITUDE", delegate(CPU cpu) { return getLattitude(cpu); }); manager.AddGetter("LONGITUDE", delegate(CPU cpu) { return getLongitude(cpu); }); manager.AddGetter("GEOPOSITION", delegate(CPU cpu) { return new GeoCoordinates(cpu.Vessel, getLattitude(cpu), getLongitude(cpu)); }); manager.AddGetter("HEADING", delegate(CPU cpu) { return VesselUtils.GetHeading(cpu.Vessel); }); manager.AddGetter("NORTH", delegate(CPU cpu) { return new Direction(VesselUtils.GetNorthVector(cpu.Vessel), false); }); manager.AddGetter("UP", delegate(CPU cpu) { return new Direction(cpu.Vessel.upAxis, false); }); manager.AddGetter("ENCOUNTER", delegate(CPU cpu) { return VesselUtils.TryGetEncounter(cpu.Vessel); }); manager.AddGetter("NEXTNODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } return Node.FromExisting(vessel, vessel.patchedConicSolver.maneuverNodes[0]); }); manager.AddGetter("PROGRADE", delegate(CPU cpu) { Debug.Log("********* Check PRO"); var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized, up); return d; }); manager.AddGetter("RETROGRADE", delegate(CPU cpu) { var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized * -1, up); return d; }); manager.AddGetter("FACING", delegate(CPU cpu) { var facing = cpu.Vessel.transform.up; return new Direction(new Vector3d(facing.x, facing.y, facing.z).normalized, false); }); manager.AddGetter("MAXTHRUST", delegate(CPU cpu) { return VesselUtils.GetMaxThrust(cpu.Vessel); }); manager.AddGetter("AV", delegate(CPU cpu) { return cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity); }); manager.AddGetter("STAGE", delegate(CPU cpu) { return new StageValues(cpu.Vessel); }); }
public virtual void AddTo(BindingManager manager) { }
public override void AddTo(BindingManager manager) { manager.AddSetter("TARGET", delegate(CPU cpu, object val) { if (val is ITargetable) { VesselUtils.SetTarget((ITargetable)val); } else if (val is VesselTarget) { VesselUtils.SetTarget(((VesselTarget)val).Target); } else if (val is BodyTarget) { VesselUtils.SetTarget(((BodyTarget)val).Target); } else { var body = VesselUtils.GetBodyByName(val.ToString()); if (body != null) { VesselUtils.SetTarget(body); return; } var vessel = VesselUtils.GetVesselByName(val.ToString(), cpu.Vessel); if (vessel != null) { VesselUtils.SetTarget(vessel); return; } } }); manager.AddGetter("TARGET", delegate(CPU cpu) { var currentTarget = FlightGlobals.fetch.VesselTarget; if (currentTarget is Vessel) { return new VesselTarget((Vessel)currentTarget, cpu); } else if (currentTarget is CelestialBody) { return new BodyTarget((CelestialBody)currentTarget, cpu); } return null; }); }
public override void AddTo(BindingManager manager) { //manager.AddGetter("TEST1", delegate(CPU cpu) { return 4; }); //manager.AddSetter("TEST1", delegate(CPU cpu, object val) { cpu.PrintLine(val.ToString()); }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("VESSELNAME", delegate(CPU cpu) { return cpu.Vessel.vesselName; }); manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value ) { cpu.Vessel.vesselName = value.ToString(); }); manager.AddGetter("ALTITUDE", delegate(CPU cpu) { return (float)cpu.Vessel.altitude; }); manager.AddGetter("ALT:RADAR", delegate(CPU cpu) { return (float)cpu.Vessel.heightFromTerrain; }); manager.AddGetter("MISSIONTIME", delegate(CPU cpu) { return (float)cpu.Vessel.missionTime; }); manager.AddGetter("STATUS", delegate(CPU cpu) { return cpu.Vessel.situation.ToString().Replace("_", " "); }); manager.AddGetter("APOAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.ApA; }); manager.AddGetter("PERIAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.PeA; }); manager.AddGetter("ALT:APOAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.ApA; }); manager.AddGetter("ALT:PERIAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.PeA; }); manager.AddGetter("ETA:APOAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.timeToAp; }); manager.AddGetter("ETA:PERIAPSIS", delegate(CPU cpu) { return (float)cpu.Vessel.orbit.timeToPe; }); manager.AddGetter("VELOCITY", delegate(CPU cpu) { return cpu.Vessel.obt_velocity; }); manager.AddGetter("ANGULARMOMENTUM",delegate(CPU cpu) { return new Direction(cpu.Vessel.angularMomentum, true); }); manager.AddGetter("ANGULARVEL", delegate(CPU cpu) { return new Direction(cpu.Vessel.angularVelocity, true); }); manager.AddGetter("MASS", delegate(CPU cpu) { return cpu.Vessel.GetTotalMass(); }); manager.AddGetter("VERTICALSPEED", delegate(CPU cpu) { return (float)cpu.Vessel.verticalSpeed; }); manager.AddGetter("SURFACESPEED", delegate(CPU cpu) { return (float)cpu.Vessel.horizontalSrfSpeed; }); manager.AddGetter("BODY", delegate(CPU cpu) { return cpu.Vessel.mainBody.bodyName; }); manager.AddGetter("LATITUDE", delegate(CPU cpu) { return (float)cpu.Vessel.latitude; }); manager.AddGetter("LONGITUDE", delegate(CPU cpu) { return (float)cpu.Vessel.longitude; }); manager.AddGetter("HEADING", delegate(CPU cpu) { return VesselUtils.GetHeading(cpu.Vessel); }); manager.AddGetter("NORTH", delegate(CPU cpu) { return new Direction(VesselUtils.GetNorthVector(cpu.Vessel), false); }); manager.AddGetter("UP", delegate(CPU cpu) { return new Direction(cpu.Vessel.upAxis, false); }); manager.AddGetter("NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; var fwd = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(cpu.Vessel.orbit); var rotRef = Quaternion.LookRotation(fwd, up); Direction d = new Direction(); d.Rotation = rotRef; return d; }); manager.AddGetter("MAG:NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; var orbit = vessel.orbit; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var mag = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(orbit).magnitude; return (float)mag; }); manager.AddGetter("ETA:NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var time = vessel.patchedConicSolver.maneuverNodes[0].UT; var currTime = Planetarium.GetUniversalTime(); return (float)(time - currTime); }); manager.AddGetter("PROGRADE", delegate(CPU cpu) { var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized, up); return d; }); manager.AddGetter("RETROGRADE", delegate(CPU cpu) { var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); var vesselRoll = cpu.Vessel.GetTransform().eulerAngles.y; d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized * -1, up); return d; }); manager.AddGetter("FACING", delegate(CPU cpu) { var facing = cpu.Vessel.transform.up; return new Direction(new Vector3d(facing.x, facing.y, facing.z).normalized, false); }); manager.AddGetter("MAXTHRUST", delegate(CPU cpu) { return VesselUtils.GetMaxThrust(cpu.Vessel); }); manager.AddGetter("AV", delegate(CPU cpu) { return cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity); }); manager.AddGetter("STAGE", delegate(CPU cpu) { return new StageValues(cpu.Vessel); }); }
public override void AddTo(BindingManager manager) { //manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return cpu.SessionTime; }); }
public LockableControl(String name, String propertyName, CPU cpu, BindingManager manager) { Name = name; Cpu = cpu; Vessel = cpu.Vessel; Locked = false; Value = 0; manager.AddGetter(name, c => Value); manager.AddSetter(name, delegate { }); this.propertyName = propertyName; }
public override void AddTo(BindingManager manager) { manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return cpu.SessionTime; }); }
public override void AddTo(BindingManager manager) { manager.AddGetter("VESSELNAME", delegate(CPU cpu) { return(cpu.Vessel.vesselName); }); manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value) { cpu.Vessel.vesselName = value.ToString(); }); manager.AddGetter("ALTITUDE", delegate(CPU cpu) { return((float)cpu.Vessel.altitude); }); manager.AddGetter("MISSIONTIME", delegate(CPU cpu) { return((float)cpu.Vessel.missionTime); }); manager.AddGetter("STATUS", delegate(CPU cpu) { return(cpu.Vessel.situation.ToString().Replace("_", " ")); }); manager.AddGetter("APOAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.ApA); }); manager.AddGetter("PERIAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.PeA); }); manager.AddGetter("ALT:APOAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.ApA); }); manager.AddGetter("ALT:PERIAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.PeA); }); manager.AddGetter("ETA:APOAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.timeToAp); }); manager.AddGetter("ETA:PERIAPSIS", delegate(CPU cpu) { return((float)cpu.Vessel.orbit.timeToPe); }); manager.AddGetter("VELOCITY", delegate(CPU cpu) { return(cpu.Vessel.obt_velocity); }); manager.AddGetter("ANGULARMOMENTUM", delegate(CPU cpu) { return(new Direction(cpu.Vessel.angularMomentum, true)); }); manager.AddGetter("ANGULARVEL", delegate(CPU cpu) { return(new Direction(cpu.Vessel.angularVelocity, true)); }); manager.AddGetter("MASS", delegate(CPU cpu) { return(cpu.Vessel.GetTotalMass()); }); manager.AddGetter("VERTICALSPEED", delegate(CPU cpu) { return((float)cpu.Vessel.verticalSpeed); }); manager.AddGetter("BODY", delegate(CPU cpu) { return(cpu.Vessel.mainBody.bodyName); }); manager.AddGetter("LATITUDE", delegate(CPU cpu) { return((float)cpu.Vessel.latitude); }); manager.AddGetter("LONGITUDE", delegate(CPU cpu) { return((float)cpu.Vessel.longitude); }); manager.AddGetter("UP", delegate(CPU cpu) { return(new Direction(cpu.Vessel.upAxis, false)); }); manager.AddGetter("NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; var fwd = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(cpu.Vessel.orbit); var rotRef = Quaternion.LookRotation(fwd, up); Direction d = new Direction(); d.Rotation = rotRef; return(d); }); manager.AddGetter("MAG:NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; var orbit = vessel.orbit; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var mag = vessel.patchedConicSolver.maneuverNodes[0].GetBurnVector(orbit).magnitude; return((float)mag); }); manager.AddGetter("ETA:NODE", delegate(CPU cpu) { var vessel = cpu.Vessel; if (!vessel.patchedConicSolver.maneuverNodes.Any()) { throw new kOSException("No maneuver nodes present!"); } var time = vessel.patchedConicSolver.maneuverNodes[0].UT; var currTime = Planetarium.GetUniversalTime(); return((float)(time - currTime)); }); manager.AddGetter("PROGRADE", delegate(CPU cpu) { var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized, up); return(d); }); manager.AddGetter("RETROGRADE", delegate(CPU cpu) { var vessel = cpu.Vessel; var up = (vessel.findLocalMOI(vessel.findWorldCenterOfMass()) - vessel.mainBody.position).normalized; Direction d = new Direction(); var vesselRoll = cpu.Vessel.GetTransform().eulerAngles.y; d.Rotation = Quaternion.LookRotation(cpu.Vessel.orbit.GetVel().normalized * -1, up); return(d); }); manager.AddGetter("FACING", delegate(CPU cpu) { var facing = cpu.Vessel.transform.up; return(new Direction(new Vector3d(facing.x, facing.y, facing.z).normalized, false)); }); manager.AddGetter("AV", delegate(CPU cpu) { return(cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity)); }); manager.AddGetter("STAGE:LIQUIDFUEL", delegate(CPU cpu) { return(GetResourceOfCurrentStage("LiquidFuel", cpu.Vessel)); }); manager.AddGetter("STAGE:SOLIDFUEL", delegate(CPU cpu) { return(GetResourceOfCurrentStage("SolidFuel", cpu.Vessel)); }); manager.AddGetter("STAGE:OXIDIZER", delegate(CPU cpu) { return(GetResourceOfCurrentStage("Oxidizer", cpu.Vessel)); }); }
public override void AddTo(BindingManager manager) { //manager.AddGetter("HEADING", delegate(CPU cpu) { return cpu.Vessel.vesselName; }); //manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value) { cpu.Vessel.vesselName = value.ToString(); }); }