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); }
private void RoomCamera_ApplyPositionChange(On.RoomCamera.orig_ApplyPositionChange orig, RoomCamera self) { // Cache the current screen, if needed // This is done on screen transition so each bomb won't individually cache the screen // Don't cache if the room is changing, though if (DestructionCache.IsScreenDirty(self.currentCameraPosition) && !self.AboutToSwitchRoom) { DestructionCache.CacheTexture(self.currentCameraPosition, self.room.game.rainWorld.persistentData.cameraTextures[0, 0]); } orig.Invoke(self); // Destruction must also be applied when the camera changes position bool mustApplyTexture = false; // Use a cached version of the texture, if available if (DestructionCache.HasTexture(self.currentCameraPosition) && !DestructionCache.IsScreenDirty(self.currentCameraPosition)) { DestructionCache.ApplyTexture(self.currentCameraPosition, self.room.game.rainWorld.persistentData.cameraTextures[0, 0]); } else { foreach (AbstractWorldEntity entity in self.room.abstractRoom.entities) { if (entity is AbstractDestruction ad) { mustApplyTexture = true; ad.ApplyVisual(false); } } if (mustApplyTexture) { self.room.game.rainWorld.persistentData.cameraTextures[0, 0].Apply(); } } }