Exemple #1
0
        protected World(Zaimoni.Serialization.DecodeObjects decode)
        {
            byte relay_b = 0;
            int  relay_i = 0;

            Zaimoni.Serialization.Formatter.Deserialize7bit(decode.src, ref m_Size);
            Zaimoni.Serialization.Formatter.Deserialize(decode.src, ref relay_b);
            Weather = (Weather)(relay_b);
            Zaimoni.Serialization.Formatter.Deserialize7bit(decode.src, ref relay_i);
            NextWeatherCheckTurn = relay_i;
            decode.LoadFrom7bit(ref m_Event_Raids);
            decode.LoadFrom(ref m_DistrictsGrid);
            m_Ready = new();

            ulong code;

            m_PlayerDistrict = decode.Load <District>(out code);
            if (0 < code && null == m_PlayerDistrict)
            {
                decode.Schedule(code, (o) => {
                    if (o is District w)
                    {
                        m_PlayerDistrict = w;
                    }
                    else
                    {
                        throw new InvalidOperationException("District object not loaded");
                    }
                });
            }

            m_SimDistrict = decode.Load <District>(out code);
            if (0 < code && null == m_SimDistrict)
            {
                decode.Schedule(code, (o) => {
                    if (o is District w)
                    {
                        m_SimDistrict = w;
                    }
                    else
                    {
                        throw new InvalidOperationException("District object not loaded");
                    }
                });
            }

            void onLoaded(District[] src)
            {
                foreach (var x in src)
                {
                    m_Ready.Enqueue(x);
                }
            }

            decode.LinearLoad <District>(onLoaded);

            m_CHAR_City = new Rectangle(CHAR_City_Origin, new Point(m_Size, m_Size));
            s_Recent    = this;
        }
Exemple #2
0
 static public void Load(Zaimoni.Serialization.DecodeObjects decode)
 {
     decode.LoadFrom7bit(ref _createdCounts);
     if ((int)Gameplay.GameActors.IDs._COUNT != _createdCounts.Length)
     {
         throw new InvalidOperationException("need upgrade path for Actor::Load");
     }
     // \todo auto-repair if the incoming count is incorrect
 }