public void Serialize(DataSerializer s)
            {
                AutobudgetWater d = Singleton <AutobudgetManager> .instance.container.AutobudgetWater;

                s.WriteBool(d.Enabled);
                s.WriteInt32(d.AutobudgetBuffer);
                s.WriteInt32(d.BudgetMaxValue);
                s.WriteBool(d.PauseWhenBudgetTooHigh);

                s.WriteInt32(d.TargetWaterStorageRatio);
            }
            public void Deserialize(DataSerializer s)
            {
                AutobudgetWater d = Singleton <AutobudgetManager> .instance.container.AutobudgetWater;

                if (s.version == 0)
                {
                    d.Enabled                 = s.ReadBool();
                    d.AutobudgetBuffer        = s.ReadInt32();
                    d.BudgetMaxValue          = s.ReadInt32();
                    d.PauseWhenBudgetTooHigh  = s.ReadBool();
                    d.TargetWaterStorageRatio = s.ReadInt32();

                    if (d.TargetWaterStorageRatio == 95)
                    {
                        d.TargetWaterStorageRatio = 50; // Change the default value
                    }
                }
                else if (s.version == 1)
                {
                    d.Enabled                = s.ReadBool();
                    d.AutobudgetBuffer       = s.ReadInt32();
                    d.BudgetMaxValue         = s.ReadInt32();
                    d.PauseWhenBudgetTooHigh = s.ReadBool();

                    d.TargetWaterStorageRatio = s.ReadInt32();
                    bool tmp = s.ReadBool();
                }
                else
                {
                    // Revert to the version 0
                    d.Enabled                = s.ReadBool();
                    d.AutobudgetBuffer       = s.ReadInt32();
                    d.BudgetMaxValue         = s.ReadInt32();
                    d.PauseWhenBudgetTooHigh = s.ReadBool();

                    d.TargetWaterStorageRatio = s.ReadInt32();
                }
            }
示例#3
0
        public void InitObjects()
        {
            if (AutobudgetElectricity == null)
            {
                AutobudgetElectricity = new AutobudgetElectricity();
            }
            if (AutobudgetWater == null)
            {
                AutobudgetWater = new AutobudgetWater();
            }
            if (AutobudgetHeating == null)
            {
                AutobudgetHeating = new AutobudgetHeating();
            }
            if (AutobudgetGarbage == null)
            {
                AutobudgetGarbage = new AutobudgetGarbage();
            }
            if (AutobudgetHealthcare == null)
            {
                AutobudgetHealthcare = new AutobudgetHealthcare();
            }
            if (AutobudgetEducation == null)
            {
                AutobudgetEducation = new AutobudgetEducation();
            }
            if (AutobudgetPolice == null)
            {
                AutobudgetPolice = new AutobudgetPolice();
            }
            if (AutobudgetFire == null)
            {
                AutobudgetFire = new AutobudgetFire();
            }
            if (AutobudgetIndustry == null)
            {
                AutobudgetIndustry = new AutobudgetIndustry();
            }
            if (AutobudgetRoad == null)
            {
                AutobudgetRoad = new AutobudgetRoad();
            }
            if (AutobudgetPost == null)
            {
                AutobudgetPost = new AutobudgetPost();
            }
            if (AutobudgetTaxi == null)
            {
                AutobudgetTaxi = new AutobudgetTaxi();
            }

            AllAutobudgetObjects.Clear();
            AllAutobudgetObjects.Add(AutobudgetElectricity);
            AllAutobudgetObjects.Add(AutobudgetWater);
            AllAutobudgetObjects.Add(AutobudgetHeating);
            AllAutobudgetObjects.Add(AutobudgetGarbage);
            AllAutobudgetObjects.Add(AutobudgetHealthcare);
            AllAutobudgetObjects.Add(AutobudgetEducation);
            AllAutobudgetObjects.Add(AutobudgetPolice);
            AllAutobudgetObjects.Add(AutobudgetFire);
            AllAutobudgetObjects.Add(AutobudgetIndustry);
            AllAutobudgetObjects.Add(AutobudgetRoad);
            AllAutobudgetObjects.Add(AutobudgetPost);
            AllAutobudgetObjects.Add(AutobudgetTaxi);
        }