コード例 #1
0
        /// <summary>
        /// Load data from given object.
        /// </summary>
        /// <param name="data"></param>
        public static void LoadData(Serialization.TransferHistoryv1 data)
        {
            Logger.Log($"TransferHistory::LoadData: version {data.Id}");
            Clear();

            foreach (var e in data.TransferEvents)
            {
                // Logger.Log($"TransferHistory::LoadData: B{e.RequestBuilding} to B{e.ResponseBuilding}, {e.Material}, {e.TimeStamp}");
                Add(e.RequestBuilding, e.ResponseBuilding, e.Material, e.TimeStamp);
            }
        }
コード例 #2
0
        /// <summary>
        /// Saves a copy of the data in this object, for serialization.
        /// </summary>
        /// <returns></returns>
        public static Serialization.TransferHistoryv1 SaveData()
        {
            var data = new Serialization.TransferHistoryv1();

            foreach (var materialEvents in m_data.Values)
            {
                foreach (var events in materialEvents.Events.Values)
                {
                    data.TransferEvents.AddRange(events);
                }
            }

            return(data);
        }
コード例 #3
0
        public override void OnLoadData()
        {
            base.OnLoadData();

            if (managers.loading.currentMode == AppMode.Game)
            {
                try
                {
                    // Always try to load the latest version if possible.
                    if (TransferHistoryv1.TryLoadData(this, out TransferHistoryv1 data))
                    {
                        TransferHistory.LoadData(data);
                    }
                    else
                    {
                        TransferHistory.Clear();
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogException(ex);
                }
            }
        }
コード例 #4
0
 public static bool TryLoadData(EnhancedDistrictTransferHistorySerializableData loader, out TransferHistoryv1 data)
 {
     if (loader.TryLoadData(m_id, new TransferHistoryv1Binder(), out TransferHistoryv1 target))
     {
         if (target != null)
         {
             data = target;
             return(true);
         }
         else
         {
             data = null;
             return(false);
         }
     }
     else
     {
         data = null;
         return(false);
     }
 }