public static void ImportBP(this DysonFrame _this, BinaryReader r, DysonSphere dysonSphere) { _this.SetEmpty(); r.ReadInt32(); _this.id = r.ReadInt32(); _this.protoId = r.ReadInt32(); _this.layerId = r.ReadInt32(); _this.reserved = r.ReadBoolean(); int nodeId = r.ReadInt32(); int nodeId2 = r.ReadInt32(); _this.euler = r.ReadBoolean(); _this.spMax = r.ReadInt32(); _this.nodeA = dysonSphere.FindNode(_this.layerId, nodeId); _this.nodeB = dysonSphere.FindNode(_this.layerId, nodeId2); Assert.NotNull(_this.nodeA); Assert.NotNull(_this.nodeB); if (_this.nodeA != null && !_this.nodeA.frames.Contains(_this)) { _this.nodeA.frames.Add(_this); } if (_this.nodeB != null && !_this.nodeB.frames.Contains(_this)) { _this.nodeB.frames.Add(_this); } _this.spMax = _this.segCount * 10; _this.GetSegments(); }
public static void ImportBP(this DysonShell _this, BinaryReader r, DysonSphere dysonSphere) { _this.SetEmpty(); r.ReadInt32(); _this.id = r.ReadInt32(); _this.protoId = r.ReadInt32(); _this.layerId = r.ReadInt32(); _this.randSeed = r.ReadInt32(); int num = r.ReadInt32(); for (int i = 0; i < num; i++) { Vector3 item = default(Vector3); item.x = r.ReadSingle(); item.y = r.ReadSingle(); item.z = r.ReadSingle(); _this.polygon.Add(item); } int num2 = r.ReadInt32(); for (int j = 0; j < num2; j++) { int num3 = r.ReadInt32(); DysonNode dysonNode = dysonSphere.FindNode(_this.layerId, num3); Assert.NotNull(dysonNode); if (dysonNode != null) { _this.nodeIndexMap[num3] = _this.nodes.Count; _this.nodes.Add(dysonNode); if (!dysonNode.shells.Contains(_this)) { dysonNode.shells.Add(_this); } } } Assert.True(_this.nodeIndexMap.Count == _this.nodes.Count); int count = _this.nodes.Count; for (int k = 0; k < count; k++) { int index = k; int index2 = (k + 1) % count; DysonFrame dysonFrame = DysonNode.FrameBetween(_this.nodes[index], _this.nodes[index2]); Assert.NotNull(dysonFrame); _this.frames.Add(dysonFrame); } _this.vertexCount = r.ReadInt32(); _this.triangleCount = r.ReadInt32(); int num4 = r.ReadInt32(); _this.verts = new Vector3[num4]; for (int l = 0; l < num4; l++) { _this.verts[l].x = r.ReadSingle(); _this.verts[l].y = r.ReadSingle(); _this.verts[l].z = r.ReadSingle(); } num4 = r.ReadInt32(); _this.pqArr = new IntVector2[num4]; for (int m = 0; m < num4; m++) { _this.pqArr[m].x = r.ReadInt32(); _this.pqArr[m].y = r.ReadInt32(); } num4 = r.ReadInt32(); _this.tris = new int[num4]; for (int n = 0; n < num4; n++) { _this.tris[n] = r.ReadInt32(); } num4 = r.ReadInt32(); _this.vAdjs = new int[num4]; for (int num5 = 0; num5 < num4; num5++) { _this.vAdjs[num5] = r.ReadInt32(); } num4 = r.ReadInt32(); _this.vertAttr = new int[num4]; for (int num6 = 0; num6 < num4; num6++) { _this.vertAttr[num6] = r.ReadInt32(); } Assert.True(_this.vertAttr.Length == _this.verts.Length); num4 = r.ReadInt32(); _this.vertsq = new int[num4]; for (int num7 = 0; num7 < num4; num7++) { _this.vertsq[num7] = r.ReadInt32(); } Assert.True(_this.vertsq.Length == _this.verts.Length); num4 = r.ReadInt32(); _this.vertsqOffset = new int[num4]; for (int num8 = 0; num8 < num4; num8++) { _this.vertsqOffset[num8] = r.ReadInt32(); } Assert.True(_this.vertsqOffset.Length == _this.nodes.Count + 1); num4 = r.ReadInt32(); _this.nodecps = new int[num4]; Assert.True(_this.nodecps.Length == _this.nodes.Count + 1); num4 = r.ReadInt32(); _this.vertcps = new uint[num4]; num4 = r.ReadInt32(); _this.vertRecycleCursor = r.ReadInt32(); _this.vertRecycle = new int[num4]; for (int num11 = 0; num11 < _this.vertRecycleCursor; num11++) { _this.vertRecycle[num11] = r.ReadInt32(); } Assert.True(_this.vertRecycle.Length == _this.verts.Length); _this.GenerateGeometryOnImport(); }
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(); } }
public static bool DysonShell_Import_Prefix(DysonShell __instance, BinaryReader r, DysonSphere dysonSphere) { __instance.SetEmpty(); var version = r.PeekChar(); if (version != SAVE_FIX_VERSION) { Debug.Log($"Using native import {version}"); return(true); } Debug.Log($"Using smart import {version}"); r.ReadChar(); __instance.id = r.ReadInt32(); __instance.protoId = r.ReadInt32(); __instance.layerId = r.ReadInt32(); __instance.randSeed = r.ReadInt32(); int num = r.ReadInt32(); for (int i = 0; i < num; i++) { Vector3 item = default(Vector3); item.x = r.ReadSingle(); item.y = r.ReadSingle(); item.z = r.ReadSingle(); __instance.polygon.Add(item); } int num2 = r.ReadInt32(); for (int j = 0; j < num2; j++) { int num3 = r.ReadInt32(); DysonNode dysonNode = dysonSphere.FindNode(__instance.layerId, num3); Assert.NotNull(dysonNode); if (dysonNode != null) { __instance.nodeIndexMap[num3] = __instance.nodes.Count; __instance.nodes.Add(dysonNode); if (!dysonNode.shells.Contains(__instance)) { dysonNode.shells.Add(__instance); } } } Assert.True(__instance.nodeIndexMap.Count == __instance.nodes.Count); int count = __instance.nodes.Count; for (int k = 0; k < count; k++) { int index = k; int index2 = (k + 1) % count; DysonFrame dysonFrame = DysonNode.FrameBetween(__instance.nodes[index], __instance.nodes[index2]); Assert.NotNull(dysonFrame); __instance.frames.Add(dysonFrame); } var vertexCount = r.ReadInt32(); var triangleCount = r.ReadInt32(); int vertsLength = r.ReadInt32(); var pqArrLength = r.ReadInt32(); var trisLength = r.ReadInt32(); var vAdjsLength = r.ReadInt32(); var vertAttrLength = r.ReadInt32(); var vertsqLength = r.ReadInt32(); var vertsqOffsetLength = r.ReadInt32(); __instance.GenerateGeometry(); // Verify that generated geometry is 'at least' formally correct from a counting point of view Assert.True(vertexCount == __instance.vertexCount); Assert.True(triangleCount == __instance.triangleCount); Assert.True(vertsLength == __instance.verts.Length); Assert.True(pqArrLength == __instance.pqArr.Length); Assert.True(trisLength == __instance.tris.Length); Assert.True(vAdjsLength == __instance.vAdjs.Length); Assert.True(vertAttrLength == __instance.vertAttr.Length); Assert.True(vertsqLength == __instance.vertsq.Length); Assert.True(vertsqOffsetLength == __instance.verts.Length); Assert.True(__instance.vertAttr.Length == __instance.verts.Length); Assert.True(__instance.vertsq.Length == __instance.verts.Length); Assert.True(__instance.vertsqOffset.Length == __instance.nodes.Count + 1); // Restore nodecps, vertcps and vertRecycle from save var num4 = r.ReadInt32(); __instance.nodecps = new int[num4]; for (int num9 = 0; num9 < num4; num9++) { __instance.nodecps[num9] = r.ReadInt32(); } Assert.True(__instance.nodecps.Length == __instance.nodes.Count + 1); num4 = r.ReadInt32(); __instance.vertcps = new uint[num4]; for (int num10 = 0; num10 < num4; num10++) { __instance.vertcps[num10] = r.ReadUInt32(); } num4 = r.ReadInt32(); __instance.vertRecycleCursor = r.ReadInt32(); __instance.vertRecycle = new int[num4]; for (int num11 = 0; num11 < __instance.vertRecycleCursor; num11++) { __instance.vertRecycle[num11] = r.ReadInt32(); } Assert.True(__instance.vertRecycle.Length == __instance.verts.Length); Array.Resize(ref __instance.vertcps, __instance.vertexCount); __instance.SyncCellBuffer(); return(false); }