示例#1
0
        public override bool RequestRCS(float amount, int earliestStage)
        {
            var commander = VesselCommander.GetInstance(this.vessel);

            if (!commander.ReturnRealRCS)
            {
                commander.RequestedRCS += amount;
                return(true);
            }
            return(base.RequestRCS(amount, earliestStage));
        }
示例#2
0
        public static float UpdateThrust(float mainThrottle, LiquidFuelEngine engine)
        {
            if (engine.vessel == null)
            {
                MonoBehaviour.print(String.Format("[MajiirKerbalLib] Null vessel for {0}", engine.name));
                return(mainThrottle);
            }
            var commander = VesselCommander.GetInstance(engine.vessel).EngineCommander;

            if (!commander.IsActive)
            {
                return(mainThrottle);
            }
            return(commander.Update(mainThrottle, engine));
        }
示例#3
0
        protected override void onPartFixedUpdate()
        {
            var commander = VesselCommander.GetInstance(this.vessel);

            if (this.vessel.rootPart.RequestRCS(commander.RequestedRCS, 0))
            {
                this.stackIcon.SetIconColor(XKCDColors.White);
            }
            else
            {
                this.stackIcon.SetIconColor(XKCDColors.SlateGrey);
                base.onCtrlUpd(new FlightCtrlState());
            }
            commander.RequestedRCS  = 0;
            commander.ReturnRealRCS = false;
            base.onPartFixedUpdate();
            commander.ReturnRealRCS = true;
        }
示例#4
0
        public static VesselCommander GetInstance(Vessel vessel)
        {
            foreach (var wr in commanders.Keys.ToArray())
            {
                var v = wr.Target;
                if (v == null)
                {
                    commanders.Remove(wr);
                    MonoBehaviour.print(String.Format("[MajiirKerbalLib] Removed VesselCommander for collected vessel ({0} remaining)", commanders.Count));
                    continue;
                }
                if (v == vessel)
                {
                    return commanders[wr];
                }
            }

            var commander = new VesselCommander();
            commanders[new WeakReference<Vessel>(vessel)] = commander;
            MonoBehaviour.print(String.Format("[MajiirKerbalLib] Created VesselCommander for {0} ({1} total)", vessel.name, commanders.Count));
            return commander;
        }
示例#5
0
        public override bool RequestRCS(float amount, int earliestStage)
        {
            var commander = VesselCommander.GetInstance(this.vessel);

            if (!commander.ReturnRealRCS)
            {
                commander.RequestedRCS += amount;
                return(true);
            }
            if (!allowFlow)
            {
                foreach (var part in this.children)
                {
                    if (part.RequestRCS(amount, earliestStage))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            return(base.RequestRCS(amount, earliestStage));
        }
        public static VesselCommander GetInstance(Vessel vessel)
        {
            foreach (var wr in commanders.Keys.ToArray())
            {
                var v = wr.Target;
                if (v == null)
                {
                    commanders.Remove(wr);
                    MonoBehaviour.print(String.Format("[MajiirKerbalLib] Removed VesselCommander for collected vessel ({0} remaining)", commanders.Count));
                    continue;
                }
                if (v == vessel)
                {
                    return(commanders[wr]);
                }
            }

            var commander = new VesselCommander();

            commanders[new WeakReference <Vessel>(vessel)] = commander;
            MonoBehaviour.print(String.Format("[MajiirKerbalLib] Created VesselCommander for {0} ({1} total)", vessel.name, commanders.Count));
            return(commander);
        }