public static void ApplyPositionChangeHook(On.RoomCamera.orig_ApplyPositionChange orig, RoomCamera rCam)
{
WWW www = (WWW)typeof(RoomCamera).GetField("www", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(rCam);
Texture2D texture = rCam.game.rainWorld.persistentData.cameraTextures[rCam.cameraNumber, 0];
if (ShouldScroll(rCam, GetRoomName(www.url)))
{
texture.Resize(www.texture.width, www.texture.height, TextureFormat.ARGB32, false);
}
else
{
texture.Resize(1400, 800, TextureFormat.ARGB32, false); // default
}
texture.Apply();
FAtlasManager manager = Futile.atlasManager;
List <FAtlas> atlases = (List <FAtlas>) typeof(FAtlasManager).GetField("_atlases", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(manager);
Dictionary <string, FAtlasElement> allElementsByName = (Dictionary <string, FAtlasElement>) typeof(FAtlasManager).GetField("_allElementsByName", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue(manager);
FAtlas atlas = manager.GetAtlasWithName("LevelTexture");
atlases.Remove(atlas);
allElementsByName.Remove("LevelTexture");
atlas = null;
manager.LoadAtlasFromTexture("LevelTexture", texture);
rCam.ReturnFContainer("Foreground").RemoveChild(rCam.levelGraphic);
rCam.levelGraphic = new FSprite("LevelTexture", true);
rCam.levelGraphic.anchorX = 0;
rCam.levelGraphic.anchorY = 0;
rCam.levelGraphic.isVisible = true;
rCam.levelGraphic.shader = rCam.game.rainWorld.Shaders["LevelColor"];
rCam.ReturnFContainer("Foreground").AddChild(rCam.levelGraphic);
rCam.currentCameraPosition = 0;
orig(rCam);
}