Ejemplo n.º 1
0
        private IEnumerator registerWheel()
        {
            if (wheelRef == null)
            {
                yield break;
            }

            yield return(null);

            dischargeResources = new List <ResourceConsumer>();
            dummyRCS           = part.Modules.GetModule <MomentumDischargeThruster>();
            if (dummyRCS != null)
            {
                dischargeRate = dummyRCS.thrusterPower;
                double ISP = dummyRCS.atmosphereCurve.Evaluate(0);
                double totalPropellantMassRatio = dummyRCS.propellants.Sum(r => r.ratio * PartResourceLibrary.Instance.resourceDefinitions[r.id].density);
                double totalMassRate            = dummyRCS.thrusterPower * saturationLimit / (ISP * dummyRCS.G);
                foreach (Propellant p in dummyRCS.propellants)
                {
                    PartResourceDefinition res = PartResourceLibrary.Instance.resourceDefinitions[p.id];
                    double propellantRate      = p.ratio * totalMassRate / totalPropellantMassRatio;
                    dischargeResources.Add(new ResourceConsumer(res.id, propellantRate, res.resourceFlowMode));
                }
                if (dischargeResources.Any(rc => rc.Rate > 0))
                {
                    canForceDischarge = true;
                }
            }

            for (int i = 0; i < 10; i++)
            {
                yield return(null);
            }

            VesselInfo partVesselInfo = Window.Instance.Vessels.Find(x => x.vessel == vessel);

            if (partVesselInfo == null)
            {
                partVesselInfo = new VesselInfo(vessel, wheelRef.State == ModuleReactionWheel.WheelState.Active);
                Window.Instance.Vessels.Add(partVesselInfo);
            }

            partVesselInfo.wheels.Add(this);
        }
Ejemplo n.º 2
0
        void drawVessel(VesselInfo ves)
        {
            Color backgroundColour = GUI.backgroundColor;

            if (ves.vessel == FlightGlobals.ActiveVessel)
            {
                GUI.backgroundColor = XKCDColors.Green;
            }
            ves.displayVes      = GUILayout.Toggle(ves.displayVes, ves.vessel.vesselName, GUI.skin.button);
            GUI.backgroundColor = backgroundColour;

            if (ves.displayVes)
            {
                bool state = GUILayout.Toggle(ves.forcedActive, "Toggle Vessel Torque");
                if (state != ves.forcedActive)
                {
                    ves.forcedActive = state;
                    ModuleReactionWheel.WheelState stateToSet = state ? ModuleReactionWheel.WheelState.Active : ModuleReactionWheel.WheelState.Disabled;
                    foreach (RWSaturatable rw in ves.wheels)
                    {
                        rw.wheelRef.State = stateToSet;
                    }
                }
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.BeginVertical();

                foreach (RWSaturatable rw in ves.wheels)
                {
                    drawWheel(rw);
                }

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }