AddGetter() public method

public AddGetter ( String name, BindingGetDlg dlg ) : void
name String
dlg BindingGetDlg
return void
Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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());
 }
Esempio n. 3
0
        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(); });
        }
Esempio n. 4
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("TEST", delegate(CPU cpu)
     {
         return(5);  // Chosen by fair die roll, guaranteed to be random.
     });
 }
Esempio n. 5
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("TEST:RADAR", delegate(CPU cpu)
     {
         return new TimeSpan(cpu.SessionTime);
     });
 }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("TEST", delegate(CPU cpu)
     {
         return new SpecialValueTester(cpu);
     });
 }
Esempio n. 8
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("TEST", delegate(CPU cpu)
     {
         return(new SpecialValueTester());
     });
 }
Esempio n. 9
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("TEST:RADAR", delegate(CPU cpu)
     {
         return(new TimeSpan(cpu.SessionTime));
     });
 }
Esempio n. 10
0
        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; });
        }
Esempio n. 11
0
        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); });
            }
        }
Esempio n. 12
0
        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)); });
            }
        }
Esempio n. 13
0
        public override void AddTo(BindingManager manager)
        {
            manager.AddGetter("TEST", delegate(CPU cpu)
            {
                String outtext = "";

                return outtext;
            });
        }
Esempio n. 14
0
 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);
         }
     });
 }
Esempio n. 15
0
 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);
         }
     });
 }
Esempio n. 16
0
            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;
            }
Esempio n. 17
0
        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);
            });
        }
Esempio n. 18
0
        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)); });
        }
Esempio n. 19
0
        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); });
        }
Esempio n. 20
0
            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;
            }
Esempio n. 21
0
        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;
            });
        }
Esempio n. 22
0
        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); });
        }
Esempio n. 23
0
        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]);
        }
Esempio n. 24
0
            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;
            }
Esempio n. 25
0
        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]; });
        }
Esempio n. 26
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return(cpu.SessionTime); });
     manager.AddGetter("VERSION", delegate(CPU cpu) { return(Core.VersionInfo); });
 }
Esempio n. 27
0
        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("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)); });
        }
Esempio n. 28
0
        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]); });
        }
Esempio n. 29
0
        public override void AddTo(BindingManager manager)
        {
            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("ETA:TRANSITION", cpu => cpu.Vessel.orbit.EndUT);

            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("AV", delegate(CPU cpu) { return(cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity)); });
            manager.AddGetter("STAGE", delegate(CPU cpu) { return(new StageValues(cpu.Vessel)); });

            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]));
            });

            // Things like altitude, mass, maxthrust are now handled the same for other ships as the current ship
            manager.AddGetter("SHIP", delegate(CPU cpu) { return(new VesselTarget(cpu.Vessel, cpu)); });

            // These are now considered shortcuts to SHIP:suffix
            foreach (String scName in VesselTarget.ShortCuttableShipSuffixes)
            {
                manager.AddGetter(scName, delegate(CPU cpu) { return(new VesselTarget(cpu.Vessel, cpu).GetSuffix(scName)); });
            }

            manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value) { cpu.Vessel.vesselName = value.ToString(); });
        }
Esempio n. 30
0
        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]); });
        }
Esempio n. 31
0
        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); });
        }
Esempio n. 32
0
 public override void AddTo(BindingManager manager)
 {
     manager.AddGetter("SESSIONTIME", delegate(CPU cpu) { return cpu.SessionTime; });
 }
Esempio n. 33
0
        public override void AddTo(BindingManager manager)
        {
            manager.AddGetter("ALT:RADAR",      delegate(CPU cpu) { return Mathf.Min(0, cpu.Vessel.heightFromTerrain, (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("AV",             delegate(CPU cpu) { return cpu.Vessel.transform.InverseTransformDirection(cpu.Vessel.rigidbody.angularVelocity); });
            manager.AddGetter("STAGE",          delegate(CPU cpu) { return new StageValues(cpu.Vessel); });

            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]);
            });

            // Things like altitude, mass, maxthrust are now handled the same for other ships as the current ship
            manager.AddGetter("SHIP", delegate(CPU cpu) { return new VesselTarget(cpu.Vessel, cpu); });

            // These are now considered shortcuts to SHIP:suffix
            foreach (String scName in VesselTarget.ShortCuttableShipSuffixes)
            {
                manager.AddGetter(scName, delegate(CPU cpu) { return new VesselTarget(cpu.Vessel, cpu).GetSuffix(scName); });
            }

            manager.AddSetter("VESSELNAME", delegate(CPU cpu, object value) { cpu.Vessel.vesselName = value.ToString(); });
        }
Esempio n. 34
0
        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]; });
        }