Exemplo n.º 1
0
        public void LoadBeacons(string beaconFile, bool createIfNotExists = false)
        {
            StaticBeacons.Clear();
            if (System.IO.File.Exists(beaconFile))
            {
                ConfigNode beaconsNode = ConfigNode.Load(beaconFile);
                foreach (ConfigNode beacon in beaconsNode.GetNodes("Beacon"))
                {
                    StaticBeacons.Add(new StaticBeacon(beacon));
                }
            }
            else if (createIfNotExists)
            {
                //Set the defaults and save the file
                StaticBeacon KSC = new StaticBeacon("KSC", SpaceCenter.Instance.Latitude, SpaceCenter.Instance.Longitude, 100000);
                StaticBeacons.Add(KSC);

                ConfigNode beaconsNode = new ConfigNode("Beacons");
                beaconsNode.AddNode(KSC.AsNode());

                beaconsNode.Save(beaconFile);
            }
        }
Exemplo n.º 2
0
        public void Start()
        {
            //initialize beacons
            ConfigNode NIMBYsettings = null;

            foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("NIMBY"))
            {
                NIMBYsettings = node;
            }

            if (NIMBYsettings.HasValue("MobileBeaconRange"))
            {
                double mbr;
                if (double.TryParse(NIMBYsettings.GetValue("MobileBeaconRange"), out mbr))
                {
                    MobileBeaconRange = mbr;
                }
            }

            if (NIMBYsettings.HasNode("Beacons"))
            {
                ConfigNode   node    = NIMBYsettings.GetNode("Beacons");
                ConfigNode[] beacons = node.GetNodes("Beacon");

                foreach (ConfigNode beacon in beacons)
                {
                    StaticBeacons.Add(new StaticBeacon(beacon));
                }
            }
            else
            {
                Debug.Log("[NIMBY] No Beacons node found!");
            }

            Debug.Log("[NIMBY] Loaded " + StaticBeacons.Count + " static beacons.");
        }