コード例 #1
0
        public static void ImportBP(this DysonSphere _this, BinaryReader r)
        {
            int num = r.ReadInt32();

            if (num == 0)
            {
                _this.ResetNew();
                return;
            }
            _this.randSeed   = r.ReadInt32();
            _this.layerCount = r.ReadInt32();
            int num3 = r.ReadInt32();

            for (int i = 1; i < num3; i++)
            {
                int num4 = r.ReadInt32();
                if (num4 != 0)
                {
                    Assert.True(i == num4);
                    if (i != num4)
                    {
                        throw new Exception("dyson layerId doesn't match! (1)");
                    }
                    DysonSphereLayer dysonSphereLayer = new DysonSphereLayer(_this);
                    dysonSphereLayer.Init();
                    if (i < _this.layersIdBased.Length)
                    {
                        _this.layersIdBased[i]    = dysonSphereLayer;
                        _this.layersSorted[i - 1] = dysonSphereLayer;
                    }
                    dysonSphereLayer.ImportBP(r);
                    Assert.True(i == dysonSphereLayer.id);
                    if (i != dysonSphereLayer.id)
                    {
                        throw new Exception("dyson layerId doesn't match! (2)");
                    }
                }
            }
            _this.LayerSort();
            _this.autoNodeCount = r.ReadInt32();
            num3 = r.ReadInt32();
            for (int l = 0; l < num3; l++)
            {
                int num6 = r.ReadInt32();
                if (num6 > 0)
                {
                    int layerId = r.ReadInt32();
                    int nodeId  = r.ReadInt32();
                    if (l < _this.autoNodes.Length)
                    {
                        _this.autoNodes[l] = _this.FindNode(layerId, nodeId);
                    }
                }
            }
            _this.ArrangeAutoNodes();
            if (num >= 2)
            {
                Traverse.Create(_this).Method("SetNrdCapacity", r.ReadInt32()).GetValue();
                _this.nrdCursor        = r.ReadInt32();
                _this.nrdRecycleCursor = r.ReadInt32();
                for (int m = 1; m < _this.nrdCursor; m++)
                {
                    _this.nrdPool[m].Import(r);
                }
                for (int n = 0; n < _this.nrdRecycleCursor; n++)
                {
                    _this.nrdRecycle[n] = r.ReadInt32();
                }
                _this.nrdBuffer.SetData(_this.nrdPool);
            }
            else
            {
                Traverse.Create(_this).Method("SetNrdCapacity", 128).GetValue();
                for (int num7 = 0; num7 < 10; num7++)
                {
                    DysonSphereLayer dysonSphereLayer2 = _this.layersIdBased[num7];
                    if (dysonSphereLayer2 != null)
                    {
                        for (int num8 = 1; num8 < dysonSphereLayer2.nodeCursor; num8++)
                        {
                            if (dysonSphereLayer2.nodePool[num8] != null && dysonSphereLayer2.nodePool[num8].id == num8)
                            {
                                _this.AddDysonNodeRData(dysonSphereLayer2.nodePool[num8], false);
                            }
                        }
                    }
                }
                _this.nrdBuffer.SetData(_this.nrdPool);
            }
            if (_this.autoNodeCount == 0)
            {
                _this.PickAutoNode();
                _this.PickAutoNode();
                _this.PickAutoNode();
                _this.PickAutoNode();
            }
        }