containsField() публичный статический Метод

public static containsField ( PartModule module, string fieldName ) : bool
module PartModule
fieldName string
Результат bool
Пример #1
0
 public static bool IsComsat(Vessel v)
 {
     if (v.loaded)
     {
         foreach (Part p in v.parts)
         {
             foreach (PartModule m in p.Modules)
             {
                 if (RTUtils.containsField(m, "isRemoteCommand"))
                 {
                     return(true);
                 }
             }
         }
     }
     else
     {
         foreach (ProtoPartSnapshot p in v.protoVessel.protoPartSnapshots)
         {
             foreach (ProtoPartModuleSnapshot s in p.modules)
             {
                 ConfigNode n = new ConfigNode();
                 s.Save(n);
                 if (n.HasValue("isRemoteCommand"))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #2
0
        public void SaveAndClose()
        {
            this.Close();

            try
            {
                if (FlightGlobals.ActiveVessel.isEVA ? (Vector3d.Distance(module.vessel.transform.position, FlightGlobals.ActiveVessel.transform.position) > 50) : !RTGlobals.coreList[module.vessel].InControl)
                {
                    return;
                }
            }
            catch { return; }

            if (settingNode != null && module.vessel.loaded)
            {
                if (RTUtils.containsField(module, "antennaName"))
                {
                    module.Fields.SetValue("antennaName", antennaName);
                }

                settingNode.save();

                RTGlobals.network = new RelayNetwork();
                RTGlobals.coreList[module.vessel].path = RTGlobals.network.GetCommandPath(RTGlobals.coreList[module.vessel].Rnode);
            }
        }
Пример #3
0
        public void ReloadDishRange()
        {
            if (isLoaded)
            {
                try
                {
                    if (RTUtils.containsField(partModule, "dishRange"))
                    {
                        this.dishRange = (float)partModule.Fields.GetValue("dishRange");
                    }
                    else
                    {
                        this.dishRange = 0;
                    }
                }
                catch (Exception)
                { }
            }
            else
            {
                ConfigNode n = new ConfigNode();
                protoPartModule.Save(n);

                if (n.HasValue("dishRange"))
                {
                    this.dishRange = float.Parse(n.GetValue("dishRange"));
                }
                else
                {
                    this.dishRange = 0;
                }
            }
        }
Пример #4
0
        void ConstructFromLoaded()
        {
            foreach (Part p in vessel.parts)
            {
                foreach (PartModule m in p.Modules)
                {
                    if (RTUtils.containsField(m, "isRemoteCommand") && (bool)m.Fields.GetValue("isRemoteCommand"))
                    {
                        this.hasCommand = true;
                        break;
                    }
                }
                if (hasCommand)
                {
                    break;
                }
            }

            float sumRange = 0f; // NK allow multiple antennae

            foreach (Part p in vessel.parts)
            {
                foreach (PartModule m in p.Modules)
                {
                    if (RTUtils.containsField(m, "antennaRange"))
                    {
                        float lngth = (float)m.Fields.GetValue("antennaRange");
                        if (lngth > this.antennaRange)
                        {
                            this.hasAntenna   = true;
                            this.antennaRange = lngth;
                        }
                        sumRange += lngth; // NK allow multiple antennae
                    }

                    if (RTUtils.containsField(m, "dishRange"))
                    {
                        DishData tmp = new DishData();

                        tmp.dishRange = m.Fields.GetValue("dishRange") == null ? 0 : (float)m.Fields.GetValue("dishRange");

                        tmp.pointedAt = m.Fields.GetValue("pointedAt") == null ? "None" : (string)m.Fields.GetValue("pointedAt");

                        if (tmp.dishRange > 0)
                        {
                            this.hasDish = true;
                            this.dishData.Add(tmp);
                        }
                    }
                }
            }
            // NK allow multiple antennae
            if (this.hasAntenna && RTGlobals.useMultiple)
            {
                this.antennaRange = (float)Math.Round(this.antennaRange + (sumRange - this.antennaRange) * 0.25f);
            }
        }
Пример #5
0
 void LoadFromLoaded()
 {
     foreach (Part p in node.Vessel.parts)
     {
         foreach (PartModule m in p.Modules)
         {
             if (RTUtils.containsField(m, "dishRange") && (float)m.Fields.GetValue("dishRange") > 0)
             {
                 settingNodes.Add(new SatSettingNode(m));
             }
         }
     }
     vesselName = node.Vessel.vesselName;
 }
Пример #6
0
        void ConstructFromLoaded()
        {
            foreach (Part p in vessel.parts)
            {
                foreach (PartModule m in p.Modules)
                {
                    if (RTUtils.containsField(m, "isRemoteCommand") && (bool)m.Fields.GetValue("isRemoteCommand"))
                    {
                        this.hasCommand = true;
                        break;
                    }
                }
                if (hasCommand)
                {
                    break;
                }
            }

            foreach (Part p in vessel.parts)
            {
                foreach (PartModule m in p.Modules)
                {
                    if (RTUtils.containsField(m, "antennaRange"))
                    {
                        float lngth = (float)m.Fields.GetValue("antennaRange");
                        if (lngth > this.antennaRange)
                        {
                            this.hasAntenna   = true;
                            this.antennaRange = lngth;
                        }
                    }

                    if (RTUtils.containsField(m, "dishRange"))
                    {
                        DishData tmp = new DishData();

                        tmp.dishRange = m.Fields.GetValue("dishRange") == null ? 0 : (float)m.Fields.GetValue("dishRange");

                        tmp.pointedAt = m.Fields.GetValue("pointedAt") == null ? "None" : (string)m.Fields.GetValue("pointedAt");

                        if (tmp.dishRange > 0)
                        {
                            this.hasDish = true;
                            this.dishData.Add(tmp);
                        }
                    }
                }
            }
        }
Пример #7
0
        public SatSettingNode(PartModule m)
        {
            this.partModule = m;
            isLoaded        = true;


            if (RTUtils.containsField(partModule, "pointedAt"))
            {
                this.pointedAt = new Target((string)partModule.Fields.GetValue("pointedAt"));
            }
            else
            {
                this.pointedAt = new Target();
            }

            if (RTUtils.containsField(partModule, "dishRange"))
            {
                this.dishRange = (float)partModule.Fields.GetValue("dishRange");
            }
            else
            {
                this.dishRange = 0;
            }

            if (RTUtils.containsField(partModule, "antennaName"))
            {
                this.antennaName = (string)partModule.Fields.GetValue("antennaName");
            }


            for (int i = 0; i < RTGlobals.targets.Count; i++)
            {
                if (pointedAt.Equals(RTGlobals.targets[i]))
                {
                    selectedTarget = i; break;
                }
            }
        }
Пример #8
0
        public void Open(PartModule moduleIn)
        {
            if (!moduleIn.vessel.loaded)
            {
                Close();
                return;
            }
            this.module = moduleIn;

            RTGlobals.targets = new List <Target>();

            CBOrV SortNetwork = new CBOrV(Planetarium.fetch.Sun, new RelayNode(moduleIn.vessel));

            SortNetwork.createTargets(ref RTGlobals.targets);



            RTGlobals.targets.Add(new Target());
            RTGlobals.targets[RTGlobals.targets.Count - 1].GUIListname = RTGlobals.targets[RTGlobals.targets.Count - 1].Name;
            RTGlobals.targets[RTGlobals.targets.Count - 1].color       = Color.red;


            if (RTUtils.containsField(module, "dishRange") && (float)module.Fields.GetValue("dishRange") > 0)
            {
                settingNode = new SatSettingNode(module);
                if (RTUtils.containsField(module, "antennaName"))
                {
                    antennaName = (string)module.Fields.GetValue("antennaName");
                }
                else
                {
                    antennaName = "Dish";
                }

                this.show = true;
            }
        }