Пример #1
0
        public void encodeChildren(CEncodedObjectOutputBufferI output)
        {
            output.openObject(CPlayer.TAGS);
            foreach (CPlayer cp in players_)
            {
                cp.encode(output);
            }
            output.objectEnd();

            var spotc = new List <CProducerUnit>();
            var spotu = new List <CUnit>();
            var spotp = new List <CProducerUnit>();

            foreach (CUnit cu in spots_)
            {
                if (cu.entry_.isCity())
                {
                    spotc.Add((CProducerUnit)cu);
                }
                else if (cu.entry_.isProducer())
                {
                    spotp.Add((CProducerUnit)cu);
                }
                else
                {
                    spotu.Add(cu);
                }
            }

            output.openObject(SPOTU);
            foreach (CUnit u in spotu)
            {
                CUnit.encodeCUnit(u, output);
            }
            output.objectEnd();

            output.openObject(SPOTC);
            foreach (CProducerUnit c in spotc)
            {
                CProducerUnit.encodeCProducerUnit(c, output);
            }
            output.objectEnd();

            output.openObject(SPOTP);
            foreach (CProducerUnit p in spotp)
            {
                CProducerUnit.encodeCProducerUnit(p, output);
            }
            output.objectEnd();

            output.openObject(CITIES);
            foreach (CProducerUnit c in cities_)
            {
                CProducerUnit.encodeCProducerUnit(c, output);
            }
            output.objectEnd();

            output.openObject(UNITS);
            foreach (CUnit u in units_)
            {
                if (!u.entry_.isProducer())
                {
                    CUnit.encodeCUnit(u, output);
                }
            }
            output.objectEnd();

            output.openObject(PRODUCERS);
            dlogger_.info("Prods:" + Convert.ToString(producers_.Count));
            foreach (CProducerUnit p in producers_)
            {
                CProducerUnit.encodeCProducerUnit(p, output);
            }
            output.objectEnd();

            output.openObject(CSupplyRoute.TAGS);
            foreach (CSupplyRoute csr in supplySources_.Values)
            {
                csr.encode(output);
            }
            output.objectEnd();

            map_.encode(output);

            gameRules_.encode(output);

            vc_.encode(output);

            output.openObject(CProposal.TAGS);
            foreach (CProposal p in proposals_)
            {
                p.encode(output);
            }
            output.objectEnd();

            output.openObject(CProductionReportData.TAGS);
            foreach (CProductionReportData prd in prodReport_)
            {
                prd.encode(output);
            }
            output.objectEnd();

            //random for use of AI
            random_.encode(AI_RANDOM_TAG, output);
            return;
        }