Exemplo n.º 1
0
        public override bool Pop(FlightComputer fc)
        {
            var activeHibCommand = HibernationCommand.findActiveHibernationCmd(fc);

            if (PowerMode == PowerModes.Hibernate && activeHibCommand == null) // no active hibernation
            {
                mStartHibernation = true;

                //get all activated antennas, except for probe cores' built-in comms
                AntennaIDs.Clear();
                AntennaIndices.Clear();
                var antennas = RTCore.Instance.Satellites[fc.Vessel.id].Antennas.ToList();
                for (int i = 0; i < antennas.Count; i++)
                {
                    if (antennas[i].Activated && !(antennas[i] is ModuleRTAntennaPassive))
                    {
                        var antenna = antennas[i] as PartModule;
                        AntennaIDs.Add(antenna.part.flightID);
                        AntennaIndices.Add(i);
                    }
                }

                return(true);
            }
            else if (PowerMode == PowerModes.Wake && activeHibCommand != null)
            {
                activeHibCommand.Abort();
                return(false);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Load and creates a command after saving a command. Returns null if no object
        /// has been loaded.
        /// </summary>
        /// <param name="n">Node with the command infos</param>
        /// <param name="fc">Current flightcomputer</param>
        public static ICommand LoadCommand(ConfigNode n, FlightComputer fc)
        {
            ICommand command = null;

            // switch the different commands
            switch (n.name)
            {
            case "AttitudeCommand":       { command = new AttitudeCommand(); break; }

            case "ActionGroupCommand":    { command = new ActionGroupCommand(); break; }

            case "BurnCommand":           { command = new BurnCommand(); break; }

            case "ManeuverCommand":       { command = new ManeuverCommand(); break; }

            case "CancelCommand":         { command = new CancelCommand(); break; }

            case "TargetCommand":         { command = new TargetCommand(); break; }

            case "EventCommand":          { command = new EventCommand(); break; }

            case "DriveCommand":          { command = new DriveCommand(); break; }

            case "ExternalAPICommand":    { command = new ExternalAPICommand(); break; }

            case "PartActionCommand":     { command = new PartActionCommand(); break; }

            case "StockAutopilotCommand": { command = new StockAutopilotCommand(); break; }

            case "HibernationCommand":    { command = new HibernationCommand(); break; }

            case "AxisGroupCommand":      { command = new AxisGroupCommand(); break; }

            case "PIDCommand":            { command = new PIDCommand(); break; }

            case "FlightControlCommand":  { command = new FlightControlCommand(); break; }
            }

            if (command != null)
            {
                ConfigNode.LoadObjectFromConfig(command, n);
                // additional loadings
                var result = command.Load(n, fc);
                RTLog.Verbose("Loading command {0}({1})={2}", RTLogLevel.LVL1, n.name, command.CmdGuid, result);
                // delete command if we can't load the command correctlys
                if (result == false)
                {
                    command = null;
                }
            }

            return(command);
        }
Exemplo n.º 3
0
        public override bool Pop(FlightComputer fc)
        {
            this.vesselReference = fc.Vessel;

            var activeHibCommand = HibernationCommand.findActiveHibernationCmd(fc);

            if (activeHibCommand != null) //what to do with active hibernation cmd under this new hib cmd?
            {
                if (this.PowerMode == PowerModes.Wake)
                {
                    activeHibCommand.Abort();
                    return(false);
                }
                else if (this.PowerMode == PowerModes.Hibernate && activeHibCommand.PowerMode == PowerModes.AntennaSaver)
                {
                    activeHibCommand.Abort();
                }
                else if (this.PowerMode == PowerModes.Hibernate && activeHibCommand.PowerMode == PowerModes.Hibernate)
                {
                    return(false);
                }
                else if (this.PowerMode == PowerModes.AntennaSaver && activeHibCommand.PowerMode == PowerModes.Hibernate)
                {
                    activeHibCommand.Abort();
                }
                else if (this.PowerMode == PowerModes.AntennaSaver && activeHibCommand.PowerMode == PowerModes.AntennaSaver)
                {
                    return(false);
                }
            }

            if (PowerMode == PowerModes.Hibernate)
            {
                if (AntennaIDs.Count == 0)//no saved list found
                {
                    mStartHibernation = true;
                }

                return(true);
            }
            else if (PowerMode == PowerModes.AntennaSaver)
            {
                return(true);
            }

            return(false);
        }