Ejemplo n.º 1
0
 public override void Execute(SharedObjects shared)
 {
     if (shared.Cpu != null)
     {
         shared.Cpu.RunProgram(Program);
     }
 }
Ejemplo n.º 2
0
 public IRServoWrapper(IRWrapper.IServo init, SharedObjects shared)
 {
     servo = init;
     this.shared = shared;
     this.partValue = GetPart();
     InitializeSuffixes();
 }
Ejemplo n.º 3
0
        public StageValues(SharedObjects shared)
        {
            this.shared = shared;
            partSet = new PartSet(partHash);

            InitializeSuffixes();
        }
Ejemplo n.º 4
0
 public override void Execute(SharedObjects shared)
 {
     double degrees = GetDouble(shared.Cpu.PopValue());
     double radians = DegreesToRadians(degrees);
     double result = Math.Cos(radians);
     shared.Cpu.PushStack(result);
 }
Ejemplo n.º 5
0
        public override void AddTo(SharedObjects shared)
        {
            Shared = shared;

            if (Shared.Vessel == null)
            {
                SafeHouse.Logger.LogWarning("FlightControlManager.AddTo Skipped: shared.Vessel== null");
                return;
            }

            if (Shared.Vessel.rootPart == null)
            {
                SafeHouse.Logger.LogWarning("FlightControlManager.AddTo Skipped: shared.Vessel.rootPart == null");
                return;
            }

            SafeHouse.Logger.Log("FlightControlManager.AddTo " + Shared.Vessel.id);

            currentVessel = shared.Vessel;
            ConnectivityManager.AddAutopilotHook(currentVessel, OnFlyByWire);

            AddNewFlightParam("throttle", Shared);
            AddNewFlightParam("steering", Shared);
            AddNewFlightParam("wheelthrottle", Shared);
            AddNewFlightParam("wheelsteering", Shared);

            shared.BindingMgr.AddSetter("SASMODE", value => SelectAutopilotMode(value));
            shared.BindingMgr.AddGetter("SASMODE", () => GetAutopilotModeName());
            shared.BindingMgr.AddSetter("NAVMODE", value => SetNavMode(value));
            shared.BindingMgr.AddGetter("NAVMODE", () => GetNavModeName());
        }
Ejemplo n.º 6
0
        public override void AddTo(SharedObjects shared)
        {
            Shared = shared;

            if (Shared.Vessel == null)
            {
                SafeHouse.Logger.LogWarning("FlightControlManager.AddTo Skipped: shared.Vessel== null");
                return;
            }

            if (Shared.Vessel.rootPart == null)
            {
                SafeHouse.Logger.LogWarning("FlightControlManager.AddTo Skipped: shared.Vessel.rootPart == null");
                return;
            }

            SafeHouse.Logger.Log("FlightControlManager.AddTo " + Shared.Vessel.id);

            currentVessel = shared.Vessel;
            currentVessel.OnPreAutopilotUpdate += OnFlyByWire;

            AddNewFlightParam("throttle", Shared);
            AddNewFlightParam("steering", Shared);
            AddNewFlightParam("wheelthrottle", Shared);
            AddNewFlightParam("wheelsteering", Shared);

            shared.BindingMgr.AddSetter("SASMODE", value => SelectAutopilotMode((string)value));
            shared.BindingMgr.AddGetter("SASMODE", () => currentVessel.Autopilot.Mode.ToString().ToUpper());
        }
Ejemplo n.º 7
0
        public EngineValue(global::Part part, MultiModeEngine engine, SharedObjects sharedObj)
            : base(part, sharedObj)
        {
            MMengine = engine;

            var moduleEngines = part.Modules.GetModules<ModuleEngines>();
            if (moduleEngines.Count == 2)
            {
                var modEngine1 = moduleEngines.Where(e => e.engineID == MMengine.primaryEngineID).FirstOrDefault();
                if (modEngine1 != null)
                    engine1 = new ModuleEngineAdapter(modEngine1);
                else
                    throw new KOSException("Attempted to build a MultiModeEngine with no engine matching Primary ID");
                var modEngine2 = moduleEngines.Where(e => e.engineID == MMengine.secondaryEngineID).FirstOrDefault();
                if (modEngine2 != null)
                    engine2 = new ModuleEngineAdapter(modEngine2);
                else
                    throw new KOSException("Attempted to build a MultiModeEngine with no engine matching Secondary ID");
            }
            else
            {
                throw new KOSException(string.Format("Attempted to build a MultiModeEngine with {0} engine modules defined instead of 2", moduleEngines.Count));
            }

            MultiMode = true;

            findGimbal();

            EngineInitializeSuffixes();
        }
Ejemplo n.º 8
0
 public override void Execute(SharedObjects shared)
 {
     string bodyName = PopValueAssert(shared).ToString();
     AssertArgBottomAndConsume(shared);
     var result = new BodyTarget(bodyName, shared);
     ReturnValue = result;
 }
Ejemplo n.º 9
0
        public static PartModuleFields Construct(PartModule mod, SharedObjects shared)
        {
            var moduleGimbal = mod as ModuleGimbal;
            if (moduleGimbal != null)
                return new GimbalFields(moduleGimbal, shared);

            var processor = mod as kOSProcessor;

            if (processor != null) {
                return new kOSProcessorFields(processor, shared);
            }

            if (mod.moduleName.Equals(RemoteTechAntennaModuleFields.RTAntennaModule)) {
                return new RemoteTechAntennaModuleFields(mod, shared);
            }

            var scienceExperimentFields = ScienceExperimentFieldsFactory.Construct(mod, shared);

            if (scienceExperimentFields != null)
            {
                return scienceExperimentFields;
            }

            return new PartModuleFields(mod, shared);
        }
Ejemplo n.º 10
0
 /// <summary>
 ///   Build a GeoCoordinates from any arbitrary lat/long pair of doubles.
 /// </summary>
 /// <param name="sharedObj">to know the current CPU's running vessel</param>
 /// <param name="lat">latitude</param>
 /// <param name="lng">longitude</param>
 public GeoCoordinates(SharedObjects sharedObj, double lat, double lng)
 {
     Lat = lat;
     Lng = lng;
     Shared = sharedObj;
     Body = Shared.Vessel.GetOrbit().referenceBody;
 }
Ejemplo n.º 11
0
        public override void Execute(SharedObjects shared)
        {
            AssertArgBottomAndConsume(shared); // no args

            // ReSharper disable SuggestUseVarKeywordEvident
            ListValue<WaypointValue> returnList = new ListValue<WaypointValue>();
            // ReSharper enable SuggestUseVarKeywordEvident

            WaypointManager wpm = WaypointManager.Instance();
            if (wpm == null)
            {
                ReturnValue = returnList; // When no waypoints exist, there isn't even a waypoint manager at all.
                return;
            }

            List<Waypoint> points = wpm.AllWaypoints();

            // If the code below gets used in more places it may be worth moving into a factory method
            // akin to how PartValueFactory makes a ListValue<PartValue> from a List<Part>.
            // But for now, this is the only place it's done:

            foreach (Waypoint point in points)
                returnList.Add(new WaypointValue(point, shared));
            ReturnValue = returnList;
        }
Ejemplo n.º 12
0
        public static SteeringManager DeepCopy(SteeringManager oldInstance, SharedObjects shared)
        {
            SteeringManager instance = SteeringManagerProvider.GetInstance(shared);
            instance.ShowAngularVectors = oldInstance.ShowAngularVectors;
            instance.ShowFacingVectors = oldInstance.ShowFacingVectors;
            instance.ShowRCSVectors = oldInstance.ShowRCSVectors;
            instance.ShowThrustVectors = oldInstance.ShowThrustVectors;
            instance.ShowSteeringStats = oldInstance.ShowSteeringStats;
            instance.WriteCSVFiles = oldInstance.WriteCSVFiles;
            instance.MaxStoppingTime = oldInstance.MaxStoppingTime;

            instance.pitchPI.Ts = oldInstance.pitchPI.Ts;
            instance.yawPI.Ts = oldInstance.yawPI.Ts;
            instance.rollPI.Ts = oldInstance.rollPI.Ts;
            instance.pitchPI.Loop = PIDLoop.DeepCopy(oldInstance.pitchPI.Loop);
            instance.yawPI.Loop = PIDLoop.DeepCopy(oldInstance.yawPI.Loop);
            instance.rollPI.Loop = PIDLoop.DeepCopy(oldInstance.rollPI.Loop);

            instance.pitchRatePI = PIDLoop.DeepCopy(oldInstance.pitchRatePI);
            instance.yawRatePI = PIDLoop.DeepCopy(oldInstance.yawRatePI);
            instance.rollRatePI = PIDLoop.DeepCopy(oldInstance.rollRatePI);

            instance.PitchTorqueAdjust = oldInstance.PitchTorqueAdjust;
            instance.PitchTorqueFactor = oldInstance.PitchTorqueFactor;
            instance.RollTorqueAdjust = oldInstance.RollTorqueAdjust;
            instance.RollTorqueFactor = oldInstance.RollTorqueFactor;
            instance.YawTorqueAdjust = oldInstance.YawTorqueAdjust;
            instance.YawTorqueFactor = oldInstance.YawTorqueFactor;
            return instance;
        }
Ejemplo n.º 13
0
 public override void Execute(SharedObjects shared)
 {
     double ang2 = GetDouble(shared.Cpu.PopValue());
     double ang1 = GetDouble(shared.Cpu.PopValue());
     double result = kOS.Utilities.Utils.DegreeFix( ang2 - ang1, -180 );
     shared.Cpu.PushStack(result);
 }
Ejemplo n.º 14
0
        public MessageQueueStructure(MessageQueue messageQueue, SharedObjects sharedObjects)
        {
            this.messageQueue = messageQueue;
            this.sharedObjects = sharedObjects;

            InitializeSuffixes();
        }
Ejemplo n.º 15
0
        public override void Execute(SharedObjects shared)
        {
            string listType = shared.Cpu.PopValue().ToString();
            ListValue list = new ListValue();

            switch (listType)
            {
                case "bodies":
                    foreach (var body in FlightGlobals.fetch.bodies)
                    {
                        list.Add(new BodyTarget(body, shared.Vessel));
                    }
                    break;
                case "targets":
                    foreach (var vessel in FlightGlobals.Vessels)
                    {
                        if (vessel == shared.Vessel) continue;
                        list.Add(new VesselTarget(vessel, shared.Vessel));
                    }
                    break;
                case "resources":
                case "parts":
                case "engines":
                case "sensors":
                case "elements":
                    list = VesselUtils.PartList(shared.Vessel, listType);
                    break;
            }

            shared.Cpu.PushStack(list);
        }
Ejemplo n.º 16
0
 public override void Execute(SharedObjects shared)
 {
     double argument = GetDouble(PopValueAssert(shared));
     AssertArgBottomAndConsume(shared);
     double result = RadiansToDegrees(Math.Atan(argument));
     ReturnValue = result;
 }
Ejemplo n.º 17
0
        public override void AddTo(SharedObjects shared)
        {
            _shared = shared;

            _shared.BindingMgr.AddGetter("LOADDISTANCE", cpu => Vessel.loadDistance );
            _shared.BindingMgr.AddSetter("LOADDISTANCE", delegate(CPU cpu, object val)
                {
                    var distance = (float) val;
                    Vessel.loadDistance = distance;
                    Vessel.unloadDistance = distance - 250;
                });
            _shared.BindingMgr.AddGetter("WARP", cpu => TimeWarp.fetch.current_rate_index);
            _shared.BindingMgr.AddSetter("WARP", delegate(CPU cpu, object val)
                {
                    int newRate;
                    if (int.TryParse(val.ToString(), out newRate))
                    {
                        TimeWarp.SetRate(newRate, false);
                    }
                });

            foreach (var body in FlightGlobals.fetch.bodies)
            {
                var cBody = body;
                _shared.BindingMgr.AddGetter(body.name, cpu => new BodyTarget(cBody, _shared.Vessel));
            }
        }
Ejemplo n.º 18
0
Archivo: Math.cs Proyecto: KSP-KOS/KOS
 public override void Execute(SharedObjects shared)
 {
     double argument = GetDouble(PopValueAssert(shared));
     AssertArgBottomAndConsume(shared);
     double result = Math.Log(argument);
     ReturnValue = result;
 }
Ejemplo n.º 19
0
        public static ListValue PartList(this IShipconstruct vessel, string partType, SharedObjects sharedObj)
        {
            var list = new ListValue();
            var partList = vessel.Parts.ToList();

            switch (partType.ToUpper())
            {
                case "RESOURCES":
                    list = AggregateResourceValue.PartsToList(partList, sharedObj);
                    break;

                case "PARTS":
                    list = PartValueFactory.Construct(partList, sharedObj);
                    break;

                case "ENGINES":
                    list = EngineValue.PartsToList(partList, sharedObj);
                    break;

                case "SENSORS":
                    list = SensorValue.PartsToList(partList, sharedObj);
                    break;

                case "ELEMENTS":
                    list = ElementValue.PartsToList(partList, sharedObj);
                    break;

                case "DOCKINGPORTS":
                    list = DockingPortValue.PartsToList(partList, sharedObj);
                    break;
            }
            return list;
        }
Ejemplo n.º 20
0
Archivo: Math.cs Proyecto: KSP-KOS/KOS
 public override void Execute(SharedObjects shared)
 {
     double argument = GetDouble(PopValueAssert(shared));
     AssertArgBottomAndConsume(shared);
     string result = new string((char) argument, 1);
     ReturnValue = new StringValue(result);
 }
Ejemplo n.º 21
0
        public override void Execute(SharedObjects shared)
        {
            object volumeId = shared.Cpu.PopValue();
            string fileName = shared.Cpu.PopValue().ToString();

            if (shared.VolumeMgr != null)
            {
                Volume volume;

                if (volumeId != null)
                {
                    volume = shared.VolumeMgr.GetVolume(volumeId);
                }
                else
                {
                    volume = shared.VolumeMgr.CurrentVolume;
                }

                if (volume != null)
                {
                    if (!volume.DeleteByName(fileName))
                    {
                        throw new Exception(string.Format("File '{0}' not found", fileName));
                    }
                }
                else
                {
                    throw new Exception("Volume not found");
                }
            }
        }
Ejemplo n.º 22
0
 public static PartValue Construct(global::Part part, SharedObjects shared)
 {
     foreach (PartModule module in part.Modules)
     {
         ModuleEngines mEng = module as ModuleEngines;
         if (mEng != null)
             return new EngineValue(part, new ModuleEngineAdapter(mEng), shared);
         ModuleEnginesFX mEngFX = module as ModuleEnginesFX;
         if (mEngFX != null)
             return new EngineValue(part, new ModuleEngineAdapter(mEngFX), shared);
         ModuleDockingNode mDock = module as ModuleDockingNode;
         if (mDock != null)
             return new DockingPortValue(mDock, shared);
         ModuleEnviroSensor mSense = module as ModuleEnviroSensor;
         if (mSense != null)
             return new SensorValue(part, mSense, shared);
         var gimbalModule  = module as ModuleGimbal;
         if (gimbalModule != null)
             return new GimbalValue(gimbalModule,shared);
         
     }
     
     // Fallback if none of the above: then just a normal part:
     return new PartValue(part, shared);
 }
Ejemplo n.º 23
0
 public override void Execute(SharedObjects shared)
 {
     double x = GetDouble(shared.Cpu.PopValue());
     double y = GetDouble(shared.Cpu.PopValue());
     double result = RadiansToDegrees(Math.Atan2(y, x));
     shared.Cpu.PushStack(result);
 }
Ejemplo n.º 24
0
 public OrbitInfo( Orbit orb, SharedObjects sharedObj )
 {
     shared = sharedObj;
     orbit = orb;
     name = "<unnamed>";
     InitializeSuffixes();
 }
Ejemplo n.º 25
0
 public object VesselShortcutGetter(SharedObjects shared, string name)
 {
     ISuffixResult suffix = new VesselTarget(shared).GetSuffix(name);
     if (! suffix.HasValue)
         suffix.Invoke(shared.Cpu);
     return suffix.Value;
 }
Ejemplo n.º 26
0
 public OrbitInfo(Orbitable orb, SharedObjects sharedObj)
 {
     orbit = orb.Orbit;
     shared = sharedObj;
     name = orb.GetName();
     InitializeSuffixes();
 }
Ejemplo n.º 27
0
        public override void Execute(SharedObjects shared)
        {
            var list = new ListValue();

            string alarmTypes = PopValueAssert(shared).ToString();
            AssertArgBottomAndConsume(shared);

            if (!KACWrapper.APIReady)
            {
                ReturnValue = list;
                throw new KOSUnavailableAddonException("listAlarms()", "Kerbal Alarm Clock");
            }

            //Get the list of alarms from the KAC Object
            KACWrapper.KACAPI.KACAlarmList alarms = KACWrapper.KAC.Alarms;

            foreach (KACWrapper.KACAPI.KACAlarm alarm in alarms)
            {
                // if its not my alarm or a general alarm, ignore it
                if (!string.IsNullOrEmpty(alarm.VesselID) && alarm.VesselID != shared.Vessel.id.ToString())
                {
                    continue;
                }
                
                if (alarmTypes.ToUpperInvariant() == "ALL" || alarm.AlarmTime.ToString() == alarmTypes)
                    list.Add(new KACAlarmWrapper(alarm));
            }
            ReturnValue = list;
        }
Ejemplo n.º 28
0
 public override void AddTo(SharedObjects shared)
 {
     _shared = shared;
     _shared.BindingMgr.AddGetter("SESSIONTIME", cpu => cpu.SessionTime);
     _shared.BindingMgr.AddGetter("VERSION", cpu => Core.VersionInfo);
     _shared.BindingMgr.AddGetter("VOLUME:NAME", cpu => _shared.VolumeMgr.CurrentVolume.Name);
 }
Ejemplo n.º 29
0
 public override void Execute(SharedObjects shared)
 {
     double degrees = GetDouble(PopValueAssert(shared));
     AssertArgBottomAndConsume(shared);
     double radians = DegreesToRadians(degrees);
     double result = Math.Sin(radians);
     ReturnValue = result;
 }
Ejemplo n.º 30
0
Archivo: Node.cs Proyecto: KSP-KOS/KOS
 public Node(double time, double radialOut, double normal, double prograde, SharedObjects shareObj)
     : this(shareObj)
 {
     this.time = time;
     this.prograde = prograde;
     this.radialOut = radialOut;
     this.normal = normal;
 }
Ejemplo n.º 31
0
 public GimbalFields(ModuleGimbal gimbal, SharedObjects sharedObj) : base(gimbal, sharedObj)
 {
     this.gimbal = gimbal;
     InitializeGimbalSuffixes();
 }
Ejemplo n.º 32
0
 /// <summary>
 ///   Build a GeoCoordinates from any arbitrary lat/long pair of floats.
 /// </summary>
 /// <param name="sharedObj">to know the current CPU's running vessel</param>
 /// <param name="latitude">latitude</param>
 /// <param name="longitude">longitude</param>
 public GeoCoordinates(SharedObjects sharedObj, float latitude, float longitude) :
     this(sharedObj.Vessel.GetOrbit().referenceBody, sharedObj, latitude, longitude)
 {
 }
Ejemplo n.º 33
0
 public static string WriteJson(SharedObjects sharedObjects, object input)
 {
     return(jsonWriter.Write(new Serializer(sharedObjects).Serialize(input)));
 }
Ejemplo n.º 34
0
        public override void Execute(SharedObjects shared)
        {
            var listValue = new ListValue();

            shared.Cpu.PushStack(listValue);
        }
Ejemplo n.º 35
0
 public BodyTarget(string name, SharedObjects shareObj)
     : this(VesselUtils.GetBodyByName(name), shareObj)
 {
     BodyInitializeSuffixes();
 }
Ejemplo n.º 36
0
 internal void AttachTo(SharedObjects shared)
 {
     this.shared        = shared;
     this.shared.Window = this;
 }
Ejemplo n.º 37
0
 public ConnectivityInterpreter(SharedObjects shared) : base(shared)
 {
     Shared.UpdateHandler.AddObserver(this);
     CreateProgressBarSubBuffer();
 }
Ejemplo n.º 38
0
        public StageValues(SharedObjects shared)
        {
            this.shared = shared;

            InitializeSuffixes();
        }
Ejemplo n.º 39
0
 /// <summary>
 ///   Build a GeoCoordinates from any arbitrary lat/long pair of floats.
 /// </summary>
 /// <param name="sharedObj">to know the current CPU's running vessel</param>
 /// <param name="lat">latitude</param>
 /// <param name="lng">longitude</param>
 public GeoCoordinates(SharedObjects sharedObj, float lat, float lng) :
     this(sharedObj.Vessel.GetOrbit().referenceBody, sharedObj, lat, lng)
 {
 }
Ejemplo n.º 40
0
 private void AddNewFlightParam(string name, SharedObjects shared)
 {
     flightParameters[name] = new FlightCtrlParam(name, shared);
 }
Ejemplo n.º 41
0
 public static BodyTarget CreateOrGetExisting(string bodyName, SharedObjects shared)
 {
     return(CreateOrGetExisting(VesselUtils.GetBodyByName(bodyName), shared));
 }
Ejemplo n.º 42
0
 public void SetSharedObjects(SharedObjects sharedObjects)
 {
     Shared = sharedObjects;
 }
Ejemplo n.º 43
0
 private BodyTarget(CelestialBody body, SharedObjects shareObj)
     : base(shareObj)
 {
     Body = body;
     BodyInitializeSuffixes();
 }
Ejemplo n.º 44
0
 public OrbitInfo(Orbitable orb, SharedObjects sharedObj) : this()
 {
     orbit  = orb.Orbit;
     Shared = sharedObj;
     name   = orb.GetName();
 }
Ejemplo n.º 45
0
 public Addon(SharedObjects shared) : base(shared)
 {
     InitializeSuffixes();
 }
Ejemplo n.º 46
0
        /// <summary>
        /// Do not call! VesselTarget.ConstructPart uses this, would use `friend VesselTarget` if this was C++!
        /// </summary>
        internal EngineValue(SharedObjects shared, global::Part part, PartValue parent, DecouplerValue decoupler)
            : base(shared, part, parent, decoupler)
        {
            foreach (var module in part.Modules)
            {
                var mme = module as MultiModeEngine;
                var e   = module as ModuleEngines;
                if (mme != null)
                {
                    if (Multi == null)
                    {
                        Multi = mme;
                    }
                    else
                    {
                        SafeHouse.Logger.LogWarning("Multiple MultiModeEngine on {0}: {1}", part.name, part.partInfo.title);
                    }
                }
                else if (e != null)
                {
                    if (Engine1 == null)
                    {
                        Engine1 = e;
                    }
                    else if (Engine2 == null)
                    {
                        Engine2 = e;
                    }
                    else
                    {
                        SafeHouse.Logger.LogWarning("Third engine on {0}: {1}", part.name, part.partInfo.title);
                    }
                }
            }
            if (Engine1 == null)
            {
                throw new KOSException("Attempted to build an Engine from part with no ModuleEngines on {0}: {1}", part.name, part.partInfo.title);
            }
            if (Engine2 == null)
            {
                if (Multi != null)
                {
                    SafeHouse.Logger.LogWarning("MultiModeEngine without second engine on {0}: {1}", part.name, part.partInfo.title);
                }
            }
            else
            {
                if (Multi == null)
                {
                    Engine2 = null;
                    SafeHouse.Logger.LogWarning("Second engine without multi-mode on {0}: {1}", part.name, part.partInfo.title);
                }
                else
                {
                    if (Multi.primaryEngineID == Engine2.engineID)
                    {
                        var tmp = Engine1;
                        Engine1 = Engine2;
                        Engine2 = tmp;
                    }
                    else if (Multi.primaryEngineID != Engine1.engineID)
                    {
                        SafeHouse.Logger.LogWarning("Primary engine ID={0} does not match multi.e1={1} on {2}: {3}",
                                                    Engine1.engineID, Multi.primaryEngineID, part.name, part.partInfo.title);
                    }
                    if (Multi.secondaryEngineID != Engine2.engineID)
                    {
                        SafeHouse.Logger.LogWarning("Secondary engine ID={0} does not match multi.e2={1} on {2}: {3}",
                                                    Engine2.engineID, Multi.secondaryEngineID, part.name, part.partInfo.title);
                    }
                }
            }

            // if the part definition includes a ModuleGimbal, create GimbalFields and set HasGimbal to true
            var gimbalModule = Part.Modules.GetModules <ModuleGimbal>().FirstOrDefault();

            if (gimbalModule != null)
            {
                Gimbal = new GimbalFields(gimbalModule, Shared);
            }

            RegisterInitializer(InitializeSuffixes);
        }
Ejemplo n.º 47
0
        public override void AddTo(SharedObjects shared)
        {
            shared.BindingMgr.AddGetter("KUNIVERSE", () => new KUniverseValue(shared));

            shared.BindingMgr.AddGetter("WARPMODE", () =>
            {
                switch (TimeWarp.WarpMode)
                {
                case TimeWarp.Modes.HIGH:
                    return("RAILS");

                case TimeWarp.Modes.LOW:
                    return("PHYSICS");

                default:
                    throw new ArgumentOutOfRangeException();
                }
            });
            shared.BindingMgr.AddSetter("WARPMODE", val =>
            {
                TimeWarp.Modes toSet;

                switch (val.ToString().ToUpper())
                {
                case "PHYSICS":
                    toSet = TimeWarp.Modes.LOW;
                    break;

                case "RAILS":
                    toSet = TimeWarp.Modes.HIGH;
                    break;

                default:
                    throw new Exception(string.Format("WARPMODE '{0}' is not valid", val));
                }

                TimeWarp.fetch.Mode = toSet;
            });
            shared.BindingMgr.AddGetter("WARP", () => TimeWarp.CurrentRateIndex);
            shared.BindingMgr.AddSetter("WARP", val =>
            {
                int newRate;
                if (int.TryParse(val.ToString(), out newRate))
                {
                    switch (TimeWarp.WarpMode)
                    {
                    case TimeWarp.Modes.HIGH:
                        SetWarpRate(newRate, TimeWarp.fetch.warpRates.Length - 1);
                        break;

                    case TimeWarp.Modes.LOW:
                        SetWarpRate(newRate, TimeWarp.fetch.physicsWarpRates.Length - 1);
                        break;

                    default:
                        throw new Exception(string.Format("WARPMODE '{0}' is unknown to kOS, please contact the devs", val));
                    }
                }
            });
            shared.BindingMgr.AddGetter("MAPVIEW", () => MapView.MapIsEnabled);
            shared.BindingMgr.AddSetter("MAPVIEW", val =>
            {
                if (Convert.ToBoolean(val))
                {
                    MapView.EnterMapView();
                }
                else
                {
                    MapView.ExitMapView();
                }
            });
            shared.BindingMgr.AddGetter("CONSTANT", () => new ConstantValue());
            foreach (var body in FlightGlobals.fetch.bodies)
            {
                var cBody = body;
                shared.BindingMgr.AddGetter(body.name, () => new BodyTarget(cBody, shared));
            }

            shared.BindingMgr.AddGetter("VERSION", () => Core.VersionInfo);
            shared.BindingMgr.AddGetter("SOLARPRIMEVECTOR", () => new Vector(Planetarium.right));
            shared.BindingMgr.AddGetter("ARCHIVE", () => shared.VolumeMgr.GetVolume(Archive.ArchiveName));
        }
Ejemplo n.º 48
0
 public BindingManager(SharedObjects shared)
 {
     variables              = new Dictionary <string, BoundVariable>(StringComparer.OrdinalIgnoreCase);
     this.shared            = shared;
     this.shared.BindingMgr = this;
 }
Ejemplo n.º 49
0
 public TransferManager(SharedObjects shared)
 {
     this.shared = shared;
     transfers   = new HashSet <ResourceTransferValue>();
     shared.UpdateHandler.AddFixedObserver(this);
 }
Ejemplo n.º 50
0
 public IInterpreter CreateInterpreter(SharedObjects shared)
 {
     return(new RemoteTechInterpreter(shared));
 }
Ejemplo n.º 51
0
        public override void Execute(SharedObjects shared)
        {
            var constants = new ConstantValue();

            shared.Cpu.PushStack(constants);
        }
Ejemplo n.º 52
0
 public VolumeManager CreateVolumeManager(SharedObjects sharedObjects)
 {
     return(new RemoteTechVolumeManager(sharedObjects));
 }
Ejemplo n.º 53
0
 public static object ReadJson(SharedObjects sharedObjects, string input)
 {
     return(new Serializer(sharedObjects).Deserialize(jsonReader.Read(input)));
 }
Ejemplo n.º 54
0
 public Interpreter(SharedObjects shared)
 {
     Shared = shared;
 }
Ejemplo n.º 55
0
 public Serializer(SharedObjects sharedObjects)
 {
     SharedObjects = sharedObjects;
 }
Ejemplo n.º 56
0
 void IFlightControlParameter.EnableControl(SharedObjects shared)
 {
     controlPartId = shared.KSPPart.flightID;
     controlShared = shared;
     Enabled       = true;
 }
Ejemplo n.º 57
0
 void IFlightControlParameter.DisableControl()
 {
     controlShared = null;
     controlPartId = 0;
     Enabled       = false;
 }
Ejemplo n.º 58
0
        public static ListValue PartList(this IShipconstruct vessel, string partType, SharedObjects sharedObj)
        {
            var list     = new ListValue();
            var partList = vessel.Parts.ToList();

            switch (partType.ToUpper())
            {
            case "RESOURCES":
                list = AggregateResourceValue.PartsToList(partList, sharedObj);
                break;

            case "PARTS":
                list = PartValueFactory.Construct(partList, sharedObj);
                break;

            case "ENGINES":
                list = EngineValue.PartsToList(partList, sharedObj);
                break;

            case "SENSORS":
                list = SensorValue.PartsToList(partList, sharedObj);
                break;

            case "ELEMENTS":
                list = ElementValue.PartsToList(partList, sharedObj);
                break;

            case "DOCKINGPORTS":
                list = DockingPortValue.PartsToList(partList, sharedObj);
                break;

            case "DECOUPLERS":
            case "SEPARATORS":
                list = DecouplerValue.PartsToList(partList, sharedObj);
                break;
            }
            return(list);
        }
Ejemplo n.º 59
0
 public void AttachTo(SharedObjects sharedObj)
 {
     shared = sharedObj;
 }
Ejemplo n.º 60
0
 public OrbitInfo(Orbit orb, SharedObjects sharedObj) : this()
 {
     Shared = sharedObj;
     orbit  = orb;
     name   = "<unnamed>";
 }