Ejemplo n.º 1
0
        /// <summary>
        /// Unloads all data used by this class
        /// </summary>
        protected override void UnloadData()
        {
            MyPluginLog.Log("Unloading GPS manager data");

            base.UnloadData();
            SaveData();

            Static = null;
            m_globalGpss.Clear();
            m_globalGpss = null;

            m_dynamicGpss.Clear();
            m_dynamicGpss = null;

            MyPluginLog.Log("Unloading GPS manager data completed");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads persistent gps data
        /// </summary>
        public override void LoadData()
        {
            MyPluginLog.Log("Loading GPS manager data");
            Static = this;

            MyObjectBuilder_WorldGpsData ob;

            if (MyFileUtils.FileExistsInWorldStorage(FILENAME))
            {
                ob = MyFileUtils.ReadXmlFileFromWorld <MyObjectBuilder_WorldGpsData>(FILENAME);
            }
            else
            {
                ob = new MyObjectBuilder_WorldGpsData();
            }

            m_globalGpss  = new Dictionary <Guid, MyGpsData>();
            m_dynamicGpss = new Dictionary <Tuple <Guid, long>, int>();

            foreach (var item in ob.PersistentGpss)
            {
                var data = new MyGpsData(item.Name, item.Color, item.Position, item.Id, item.PlayerIds, item.Hidden);
                m_globalGpss[item.Id] = data;
            }

            MySession.Static.OnSavingCheckpoint += delegate
            {
                foreach (var key in m_dynamicGpss.Keys)
                {
                    MySession.Static.Gpss.SendDelete(key.Item2, m_dynamicGpss[key]);
                }
                ;
                m_dynamicGpss.Clear();
            };

            MyPluginLog.Log("Loading GPS manager data completed");
        }