public void AddSnowflakes(int snowFlakesToSpawn) { if (room != null && room.BeingViewed) { if (this.camPos != null) { for (int i = 0; i < snowFlakesToSpawn; i++) { try { //Get a random position within range of the RoomCamera Vector2 cam = this.camPos; IntVector2 randomOffset = IntVector2.FromVector2(new Vector2(cam.x + UnityEngine.Random.Range(-700, 700), cam.y + UnityEngine.Random.Range(-500, 500))); Vector2 offset2 = new Vector2(UnityEngine.Random.Range(-10f, 10f), UnityEngine.Random.Range(-10f, 10f)); //If that random position has line of sight with the sky, spawn a snowflake there Vector2 spawn = randomOffset.ToVector2(); Vector2 spawnPos = spawn + offset2; if (RayTraceSky(spawnPos, new Vector2(0f, 1f))) { SnowFlake snowFlake = new SnowFlake(spawnPos, Color.Lerp(room.game.cameras[0].currentPalette.skyColor, new Color(1f, 1f, 1f), 0.1f), RainFall.rainIntensity, this); this.room.AddObject(snowFlake); //snowFlake.reset = true; for (int s = 0; s < 1000; s++) { snowFlake.Update(true); } this.snowFlakes++; } } catch { //Debug.Log("ERROR SPAWNING SNOWFLAKE"); } } } } }