示例#1
0
        /// <summary>
        /// Load the saved TargetCommand. Open a new ITargetable object by
        /// the objects id.
        /// </summary>
        /// <param name="n">Node with the command infos</param>
        /// <param name="fc">Current flightcomputer</param>
        /// <returns>true - loaded successfull</returns>
        public override bool Load(ConfigNode n, FlightComputer fc)
        {
            if (base.Load(n, fc))
            {
                switch (TargetType)
                {
                case "Vessel":
                {
                    Guid Vesselid = new Guid(TargetId);
                    Target = RTUtil.GetVesselById(Vesselid);
                    break;
                }

                case "CelestialBody":
                {
                    Target = FlightGlobals.Bodies.ElementAt(int.Parse(TargetId));
                    break;
                }

                default:
                {
                    Target = null;
                    break;
                }
                }
                return(true);
            }
            return(false);
        }
示例#2
0
文件: API.cs 项目: jvdnbus/SSAT2
        public static bool HasLocalControl(Guid id)
        {
            var vessel = RTUtil.GetVesselById(id);

            if (vessel == null)
            {
                return(false);
            }

            RTLog.Verbose("Flight: {0} HasLocalControl: {1}", RTLogLevel.API, id, vessel.HasLocalControl());

            return(vessel.HasLocalControl());
        }
示例#3
0
        public void Draw()
        {
            if (Satellite == null)
            {
                return;
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.TextField(Satellite.Name.Truncate(25), GUILayout.ExpandWidth(true));
                RTUtil.Button(Localizer.Format("#RT_NetworkFB_NameButton"), () =>//"Name"
                {
                    var vessel = RTUtil.GetVesselById(Satellite.Guid);
                    if (vessel)
                    {
                        vessel.RenameVessel();
                    }
                }, GUILayout.ExpandWidth(false), GUILayout.Height(24));
            }
            GUILayout.EndHorizontal();

            mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, GUILayout.ExpandHeight(true));
            {
                Color      pushColor = GUI.contentColor;
                TextAnchor pushAlign = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                foreach (var a in Satellite.Antennas.Where(a => a.CanTarget))
                {
                    GUI.contentColor = (a.Powered) ? XKCDColors.ElectricLime : XKCDColors.Scarlet;
                    String text = a.Name.Truncate(25) + Environment.NewLine + Localizer.Format("#RT_NetworkFB_Target") + RTUtil.TargetName(a.Target).Truncate(18);//"Target: "
                    RTUtil.StateButton(text, Antenna, a, s =>
                    {
                        Antenna = (s > 0) ? a : null;
                    });
                }
                GUI.skin.button.alignment = pushAlign;
                GUI.contentColor          = pushColor;
            }
            GUILayout.EndScrollView();
        }