public void Set(LevelData level, int levelLayer, int playerLayer, int skyLayer, string rflPath, bool pcFog) { this.levelRFLPath = rflPath; this.levelName = level.name; this.author = level.author; this.playerStart = level.playerStart; this.multiplayer = level.multiplayer; this.spawnPoints = level.spawnPoints; this.levelMask = LayerMask.GetMask(LayerMask.LayerToName(levelLayer)); this.playerLayer = playerLayer; this.skyMask = LayerMask.GetMask(LayerMask.LayerToName(skyLayer)); this.useFog = level.nearPlane <= level.farPlane && level.farPlane > 0f; this.fogStart = 0f; this.clipPlane = level.farPlane; if (this.clipPlane <= 0f) { this.clipPlane = 1000f; } if (pcFog && level.nearPlane > 0f && level.nearPlane <= level.farPlane) { Debug.LogWarning("Found non trivial value " + level.nearPlane + " for fog start (near plane). By Default RF behaviour this value was ignored. " + "Please set in the UFPlayerInfo script if you which to use the value."); } if (level.nearPlane > 0f && level.nearPlane > level.farPlane) { Debug.LogWarning("Value for fog start (near plane) was greater than the value " + "for the far clipping plane. As a result, by default RF behaviour, fog has " + "been disabled. Visit the UFPlayerInfo object if this was not intended."); } this.fogColor = level.fogColor; this.ambientColor = level.ambientColor; bool foundSkyRoom = false; Room skyRoom = default(Room); AxisAlignedBoundingBox levelBox = level.staticGeometry.rooms[0].aabb; foreach (Room room in level.staticGeometry.rooms) { levelBox = AxisAlignedBoundingBox.Join(levelBox, room.aabb); if (room.isSkyRoom) { foundSkyRoom = true; skyRoom = room; continue; } float roomRadius = .5f * room.aabb.GetSize().magnitude; MakeEAX(room.eaxEffect, room.aabb.GetCenter(), roomRadius); } BoxCollider bc = gameObject.AddComponent <BoxCollider>(); bc.isTrigger = true; bc.center = (levelBox.min + levelBox.max) / 2f; bc.size = levelBox.max - levelBox.min; if (foundSkyRoom) { GameObject camG = new GameObject("SkyCamera"); Vector3 skyPos = (skyRoom.aabb.min + skyRoom.aabb.max) / 2f; Vector3 skyDiagonal = skyRoom.aabb.max - skyRoom.aabb.min; camG.transform.SetParent(transform); camG.transform.position = skyPos; skyCamera = camG.AddComponent <Camera>(); skyCamera.depth = -10; skyCamera.clearFlags = CameraClearFlags.SolidColor; skyCamera.backgroundColor = fogColor; skyCamera.farClipPlane = skyDiagonal.magnitude / 2f; skyCamera.cullingMask = skyMask; } }