Exemplo n.º 1
0
        private static void Load_Plot_Upgrades(string fileName)
        {
            // LOAD PLOT UPGRADES
            if (File.Exists(fileName))
            {
                Stream strm = File.OpenRead(fileName);
                if (strm == null)
                {
                    throw new IOException("Cannot open file for reading: " + fileName);
                }

                BinaryReader br    = new BinaryReader(strm);
                int          total = br.ReadInt32();
                for (int i = 0; i < total; i++)
                {
                    Plot_Upgrades up = Plot_Upgrades.Deserialize(br);
                    Plot_Upgrades_Cache.Add(up);
                }

                // Load the upgrade data cache
                int pidTotal = br.ReadInt32();
                for (int p = 0; p < pidTotal; p++)
                {
                    PlotID pid       = PlotID.Deserialize(br);
                    int    upgrTotal = br.ReadInt32();

                    for (int u = 0; u < upgrTotal; u++)
                    {
                        string upgrade = br.ReadString();
                        int    kTotal  = br.ReadInt32();
                        // Make sure we can add keys/values without issue.
                        Setup_Upgrade_Data_Dict(pid, upgrade);

                        for (int k = 0; k < kTotal; k++)
                        {
                            string key   = br.ReadString();
                            int    blen  = br.ReadInt32();
                            byte[] value = br.ReadBytes(blen);

                            //PLog.Info("[{0}][{1}] [{2}]: ({3}){4}", pid, upgrade, key, blen, Util.FormatByteArray(value));

                            if (!Plot_Upgrade_Data[pid][upgrade].ContainsKey(key))
                            {
                                Plot_Upgrade_Data[pid][upgrade].Add(key, value);
                            }
                            else
                            {
                                Plot_Upgrade_Data[pid][upgrade][key] = value;
                            }
                        }
                    }
                }

                strm.Close();
            }
        }
Exemplo n.º 2
0
        private static Sisco_Return onPlot_Loaded_Upgrades(ref object sender, ref object[] args, ref object return_value)
        {
            LandPlot plot = (LandPlot)sender;
            PlotID   id   = new PlotID(plot);

            Plot_Upgrades cached = Plot_Upgrades_Cache.FirstOrDefault(o => o.ID.Equals(id));

            if (cached != null)
            {
                var track = plot.gameObject.AddComponent <PlotUpgradeTracker>();
                track.Load(plot, cached);

                Plot_Upgrades_Cache.Remove(cached);
            }

            return(null);
        }
Exemplo n.º 3
0
        internal void Load(LandPlot pl, Plot_Upgrades up)
        {
            this.plot = pl;
            this.ID   = new PlotID(plot);
            foreach (string upgradeName in up.upgrades)
            {
                PlotUpgrade upgrade = (PlotUpgrade)Upgrades.Get_Upgrade(Upgrade_Type.PLOT_UPGRADE, upgradeName);

                if (upgrade != null)
                {
                    this.upgrades.Add(upgrade);
                }
                else
                {
                    upgrades_missing.Add(upgradeName);
                }
            }
        }
Exemplo n.º 4
0
 internal void Serialize(BinaryWriter bw)
 {
     Plot_Upgrades.Serialize(bw, ID, allUpgrades.ToList());
 }