public void undo() { if (this.model == null) { if (this.objectAsset != null) { this.model = LevelObjects.addObject(this.position, this.rotation, this.scale, this.objectAsset.id, this.objectAsset.name, this.objectAsset.GUID, ELevelObjectPlacementOrigin.MANUAL); } else if (this.itemAsset != null) { this.model = LevelObjects.addBuildable(this.position, this.rotation, this.itemAsset.id); } } }
public static void load() { LevelObjects._models = new GameObject().transform; LevelObjects.models.name = "Objects"; LevelObjects.models.parent = Level.level; LevelObjects.models.tag = "Logic"; LevelObjects.models.gameObject.layer = LayerMasks.LOGIC; LevelObjects._objects = new List <LevelObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._buildables = new List <LevelBuildableObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._total = 0; LevelObjects._regions = new bool[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects._loads = new int[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE]; LevelObjects.shouldInstantlyLoad = true; LevelObjects.isHierarchyReady = false; for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { LevelObjects.loads[(int)b, (int)b2] = -1; } } for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { LevelObjects.objects[(int)b3, (int)b4] = new List <LevelObject>(); LevelObjects.buildables[(int)b3, (int)b4] = new List <LevelBuildableObject>(); } } if (Level.info.configData.Use_Legacy_Objects) { if (ReadWrite.fileExists(Level.info.path + "/Level/Objects.dat", false, false)) { River river = new River(Level.info.path + "/Level/Objects.dat", false); byte b5 = river.readByte(); bool flag = true; if (b5 > 0) { if (b5 > 1 && b5 < 3) { river.readSteamID(); } if (b5 > 8) { LevelObjects.availableInstanceID = river.readUInt32(); } else { LevelObjects.availableInstanceID = 1u; } for (byte b6 = 0; b6 < Regions.WORLD_SIZE; b6 += 1) { for (byte b7 = 0; b7 < Regions.WORLD_SIZE; b7 += 1) { ushort num = river.readUInt16(); for (ushort num2 = 0; num2 < num; num2 += 1) { Vector3 vector = river.readSingleVector3(); Quaternion newRotation = river.readSingleQuaternion(); Vector3 newScale; if (b5 > 3) { newScale = river.readSingleVector3(); } else { newScale = Vector3.one; } ushort num3 = river.readUInt16(); string newName = string.Empty; if (b5 > 5) { newName = river.readString(); } Guid newGUID = Guid.Empty; if (b5 > 7) { newGUID = river.readGUID(); } ELevelObjectPlacementOrigin newPlacementOrigin = ELevelObjectPlacementOrigin.MANUAL; if (b5 > 6) { newPlacementOrigin = (ELevelObjectPlacementOrigin)river.readByte(); } uint newInstanceID; if (b5 > 8) { newInstanceID = river.readUInt32(); } else { newInstanceID = LevelObjects.generateUniqueInstanceID(); } if (num3 != 0) { LevelObject levelObject = new LevelObject(vector, newRotation, newScale, num3, newName, newGUID, newPlacementOrigin, newInstanceID); if (levelObject.asset == null) { flag = false; } if (Level.isEditor) { byte b8; byte b9; Regions.tryGetCoordinate(vector, out b8, out b9); if (b8 != b6 || b9 != b7) { Debug.LogError(string.Concat(new object[] { num3, " should be in ", b8, ", ", b9, " but was in ", b6, ", ", b7, "!" })); } LevelObjects.objects[(int)b8, (int)b9].Add(levelObject); } else { LevelObjects.objects[(int)b6, (int)b7].Add(levelObject); } LevelObjects._total++; } } } } } if (flag) { LevelObjects._hash = river.getHash(); } else { LevelObjects._hash = new byte[20]; } river.closeRiver(); } else { for (byte b10 = 0; b10 < Regions.WORLD_SIZE; b10 += 1) { for (byte b11 = 0; b11 < Regions.WORLD_SIZE; b11 += 1) { if (ReadWrite.fileExists(string.Concat(new object[] { Level.info.path, "/Objects/Objects_", b10, "_", b11, ".dat" }), false, false)) { River river2 = new River(string.Concat(new object[] { Level.info.path, "/Objects/Objects_", b10, "_", b11, ".dat" }), false); byte b12 = river2.readByte(); if (b12 > 0) { ushort num4 = river2.readUInt16(); for (ushort num5 = 0; num5 < num4; num5 += 1) { Vector3 position = river2.readSingleVector3(); Quaternion rotation = river2.readSingleQuaternion(); ushort num6 = river2.readUInt16(); string empty = string.Empty; Guid empty2 = Guid.Empty; ELevelObjectPlacementOrigin placementOrigin = ELevelObjectPlacementOrigin.MANUAL; if (num6 != 0) { LevelObjects.addObject(position, rotation, Vector3.one, num6, empty, empty2, placementOrigin); } } } river2.closeRiver(); } } } LevelObjects._hash = new byte[20]; } } else { LevelObjects._hash = new byte[20]; } if ((Provider.isServer || Level.isEditor) && ReadWrite.fileExists(Level.info.path + "/Level/Buildables.dat", false, false)) { River river3 = new River(Level.info.path + "/Level/Buildables.dat", false); river3.readByte(); for (byte b13 = 0; b13 < Regions.WORLD_SIZE; b13 += 1) { for (byte b14 = 0; b14 < Regions.WORLD_SIZE; b14 += 1) { ushort num7 = river3.readUInt16(); for (ushort num8 = 0; num8 < num7; num8 += 1) { Vector3 vector2 = river3.readSingleVector3(); Quaternion newRotation2 = river3.readSingleQuaternion(); ushort num9 = river3.readUInt16(); if (num9 != 0) { LevelBuildableObject item = new LevelBuildableObject(vector2, newRotation2, num9); if (Level.isEditor) { byte b15; byte b16; Regions.tryGetCoordinate(vector2, out b15, out b16); if (b15 != b13 || b16 != b14) { Debug.LogError(string.Concat(new object[] { num9, " should be in ", b15, ", ", b16, " but was in ", b13, ", ", b14, "!" })); } LevelObjects.buildables[(int)b15, (int)b16].Add(item); } else { LevelObjects.buildables[(int)b13, (int)b14].Add(item); } LevelObjects._total++; } } } } river3.closeRiver(); } if (Level.info.configData.Use_Legacy_Objects && !Dedicator.isDedicated && !Level.isEditor) { for (byte b17 = 0; b17 < Regions.WORLD_SIZE; b17 += 1) { for (byte b18 = 0; b18 < Regions.WORLD_SIZE; b18 += 1) { for (int i = 0; i < LevelObjects.objects[(int)b17, (int)b18].Count; i++) { LevelObject levelObject2 = LevelObjects.objects[(int)b17, (int)b18][i]; if (levelObject2.asset != null && !(levelObject2.transform == null)) { if (levelObject2.asset.lod != EObjectLOD.NONE) { ObjectsLOD objectsLOD = levelObject2.transform.gameObject.AddComponent <ObjectsLOD>(); objectsLOD.lod = levelObject2.asset.lod; objectsLOD.bias = levelObject2.asset.lodBias; objectsLOD.center = levelObject2.asset.lodCenter; objectsLOD.size = levelObject2.asset.lodSize; objectsLOD.calculateBounds(); } } } } } } if (Level.isEditor) { LevelObjects.reun = new IReun[256]; LevelObjects.step = 0; LevelObjects.frame = 0; } }