public static void load() { bool flag = false; if (LevelSavedata.fileExists("/Structures.dat") && Level.info.type == ELevelType.SURVIVAL) { River river = LevelSavedata.openRiver("/Structures.dat", true); byte b = river.readByte(); if (b > 3) { StructureManager.serverActiveDate = river.readUInt32(); } else { StructureManager.serverActiveDate = Provider.time; } if (b > 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { StructureRegion region = StructureManager.regions[(int)b2, (int)b3]; StructureManager.loadRegion(b, river, region); } } } if (b < 6) { flag = true; } } else { flag = true; } if (flag && LevelObjects.buildables != null) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { for (byte b5 = 0; b5 < Regions.WORLD_SIZE; b5 += 1) { List <LevelBuildableObject> list = LevelObjects.buildables[(int)b4, (int)b5]; if (list != null && list.Count != 0) { StructureRegion structureRegion = StructureManager.regions[(int)b4, (int)b5]; for (int i = 0; i < list.Count; i++) { LevelBuildableObject levelBuildableObject = list[i]; if (levelBuildableObject != null) { ItemStructureAsset itemStructureAsset = levelBuildableObject.asset as ItemStructureAsset; if (itemStructureAsset != null) { Vector3 eulerAngles = levelBuildableObject.rotation.eulerAngles; byte newAngle_X = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2)); byte newAngle_Y = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2)); byte newAngle_Z = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2)); Structure structure = new Structure(itemStructureAsset.id, itemStructureAsset.health, itemStructureAsset); StructureData structureData = new StructureData(structure, levelBuildableObject.point, newAngle_X, newAngle_Y, newAngle_Z, 0UL, 0UL, uint.MaxValue); structureRegion.structures.Add(structureData); StructureManager.manager.spawnStructure(structureRegion, structure.id, structureData.point, structureData.angle_x, structureData.angle_y, structureData.angle_z, (byte)Mathf.RoundToInt((float)structure.health / (float)itemStructureAsset.health * 100f), 0UL, 0UL, StructureManager.instanceCount += 1u); } } } } } } } Level.isLoadingStructures = false; }