using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CustomPaintings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ed1f3e0cf050996214fefa2c4062fc7bd3a5c8e4")]
[assembly: AssemblyProduct("CustomPaintings")]
[assembly: AssemblyTitle("CustomPaintings")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CustomPaintings
{
public class CP_Config
{
internal static class Grunge
{
internal static ConfigEntry<bool> State;
internal static ConfigEntry<float> Intensity;
internal static ConfigEntry<Color> _BaseColor;
internal static ConfigEntry<Color> _MainColor;
internal static ConfigEntry<Color> _CracksColor;
internal static ConfigEntry<Color> _OutlineColor;
}
internal static class Graphics
{
internal static ConfigEntry<bool> PointFiltering;
}
public static ConfigEntry<bool> HostControl;
public static ConfigEntry<bool> SeperateImages;
public static ConfigEntry<bool> RugsAndBanners;
public static ConfigEntry<bool> ChaosMode;
public KeyCode ForceSwapKey { get; set; }
public CP_Config()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
ForceSwapKey = (KeyCode)Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("ForceSwapKey", "P"));
}
internal static void Init(ConfigFile config)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Expected O, but got Unknown
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Expected O, but got Unknown
HostControl = config.Bind<bool>("Image Settings", "Host Control", true, new ConfigDescription("choose if host controls seperate state", (AcceptableValueBase)null, Array.Empty<object>()));
SeperateImages = config.Bind<bool>("Image Settings", "Seperate paintings", false, new ConfigDescription("seperate square, landscape and portrait images on swap", (AcceptableValueBase)null, Array.Empty<object>()));
RugsAndBanners = config.Bind<bool>("Image Settings", "enable rugs and banners", false, new ConfigDescription("add rugs and banners to the swap pool", (AcceptableValueBase)null, Array.Empty<object>()));
ChaosMode = config.Bind<bool>("Image Settings", "Chaos Mode", false, new ConfigDescription("adds a bunch of materials that shouldn't be changed to the pool", (AcceptableValueBase)null, Array.Empty<object>()));
Grunge.State = config.Bind<bool>("Grunge", "Grunge state", true, new ConfigDescription("Whether the grunge effect is enabled", (AcceptableValueBase)null, Array.Empty<object>()));
Grunge.Intensity = config.Bind<float>("Grunge", "Grunge intensity", 0.5f, new ConfigDescription("change how intense the grunge is applied", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>()));
Grunge._BaseColor = config.Bind<Color>("Grunge", "_GrungeBaseColor", new Color(0f, 0f, 0f, 1f), new ConfigDescription("The base color of the grunge", (AcceptableValueBase)null, Array.Empty<object>()));
Grunge._MainColor = config.Bind<Color>("Grunge", "_GrungeMainColor", new Color(0f, 0f, 0f, 0.5f), new ConfigDescription("The color of the main overlay of grunge", (AcceptableValueBase)null, Array.Empty<object>()));
Grunge._CracksColor = config.Bind<Color>("Grunge", "_GrungeCracksColor", new Color(0.25f, 0.25f, 0.25f, 1f), new ConfigDescription("The color of the cracks in the grunge", (AcceptableValueBase)null, Array.Empty<object>()));
Grunge._OutlineColor = config.Bind<Color>("Grunge", "_GrungeOutlineColor", new Color(0f, 0f, 0f, 1f), new ConfigDescription("The color of the grunge outlining the painting", (AcceptableValueBase)null, Array.Empty<object>()));
Graphics.PointFiltering = config.Bind<bool>("Graphics", "PointFiltering", true, new ConfigDescription("Point filtering will match the pixelated effect the game has", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
public class CP_GifManager
{
private readonly CP_Logger logger;
private string exePath;
public CP_GifManager(CP_Logger logger)
{
this.logger = logger;
logger.LogInfo("CP_GifManager initialized.");
}
public void ConvertGifToMp4(string gifPath, string outputPath)
{
}
}
public class CP_GroupList
{
private readonly CP_Logger logger;
public static readonly Dictionary<string, List<string>> MaterialNameToGroup = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase)
{
{
"Painting_H_Landscape",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_H_crow",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_H_crow_0",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"PaintingMedium",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_Danish_Flag",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_Board",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting Danish Flag",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting Board",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Shop Outside Billboard Ad",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Sign",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 01",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 02",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 03",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 04",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 05",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 06",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 07",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 08",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 09",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 10",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 11",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 12",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 13",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 14",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 15",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 16",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 17",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 18",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 19",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 20",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 21",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 22",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 23",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 24",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 25",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 26",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 27",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 28",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 29",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 30",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 31",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 32",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 33",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 35",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 37",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 38",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 39",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 40",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 42",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting H 45",
new List<string> { "Landscape", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_S_Creep",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_S_Creep 2_0",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_S_Creep 2",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting Wizard Class",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Picture Frame - Picture 01",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_Aurora",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_McJannek",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting Aurora",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting McJannek",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 01",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 02",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 03",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 04",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 05",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 06",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 07",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 08",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 09",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 10",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 11",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 12",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 13",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting S 15",
new List<string> { "Square", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_V_jannk",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_V_Furman",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_V_surrealistic",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_V_surrealistic_0",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"painting teacher01",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"painting teacher02",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"painting teacher03",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"painting teacher04",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting_S_Tree",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Painting Calendar",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Magazine01",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Magazine02",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Magazine03",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Magazine04",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Magazine05",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Valuable_Painting",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 01",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 02",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 03",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 05",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 07",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 09",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 15",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 16",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 17",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 18",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 19",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 20",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 21",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 22",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 23",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 24",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 25",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 26",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 27",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 28",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 29",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 30",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 31",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 32",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 34",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 35",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Museum Painting V 36",
new List<string> { "Portrait", "Normal", "RugsAndBanners", "Chaos" }
},
{
"Rug",
new List<string> { "Square", "RugsAndBanners", "Chaos" }
},
{
"shop rug",
new List<string> { "Square", "RugsAndBanners", "Chaos" }
},
{
"Bathroom Rug",
new List<string> { "Square", "RugsAndBanners", "Chaos" }
},
{
"Rug Plain Red",
new List<string> { "Landscape", "RugsAndBanners", "Chaos" }
},
{
"Wizard Wall Flag",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Rug Optimized",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 01",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 02",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 03",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 04",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 05",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 07",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 08",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"Museum Banner 09",
new List<string> { "Portrait", "RugsAndBanners", "Chaos" }
},
{
"regular material 01",
new List<string> { "Square", "Chaos" }
},
{
"Arctic Sign Accounting",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Bathroom",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Botanical Research",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Brige 4B",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Brige 8N",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Cafeteria",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Cargo processing",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Catwalk L5",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Cooling Center",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Epsilon Station",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Exotic Materials Division",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Infirmary",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Kitchen",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Living Quarters",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Loading Dock",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Maintenance2",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Observation Platform",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Recreation",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Research Lab",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Storage Yard",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Testing Lab",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Vehicle Maintenance",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Ventilation Chamber",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign Warehouse",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Sign",
new List<string> { "Landscape", "Chaos" }
},
{
"Lobby Sign - Closed Road",
new List<string> { "Square", "Chaos" }
},
{
"Lobby Sign - No stopping",
new List<string> { "Square", "Chaos" }
},
{
"Robot Company Sign 2",
new List<string> { "Square", "Chaos" }
},
{
"Robot Company Sign 3",
new List<string> { "Landscape", "Chaos" }
},
{
"Robot Company Sign 4",
new List<string> { "Portrait", "Chaos" }
},
{
"Robot Company Sign 5",
new List<string> { "Landscape", "Chaos" }
},
{
"Robot Company Sign 6",
new List<string> { "Portrait", "Chaos" }
},
{
"Robot Company Sign 7",
new List<string> { "Square", "Chaos" }
},
{
"Robot Company Sign",
new List<string> { "Square", "Chaos" }
},
{
"Wizard Sign Cauldron Storage",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Common Room",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Courtyard",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Dark Arts",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Deathpit Corridor",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Dining Hall",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Dormatory",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Dungeon",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign East Wing Lobby",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Enchanted Lava Room",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Gnome Alley",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Headmasters Study",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Lecture Hall",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Magic Plant School",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Potions And Spells",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Relaxation Room",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Sludge Pits of Joy",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Sludge Pits",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Sorcery Class",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Storage Room",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign The Great Library",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign Thinking Chamber",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Sign West Wing Garden",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_throw",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_strength",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_speed",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_health",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_grab range",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_energy",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_tumble_launch",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_map_player_count",
new List<string> { "Landscape", "Chaos" }
},
{
"upgrade_extra_jump",
new List<string> { "Landscape", "Chaos" }
},
{
"Welcome_Flag_Front",
new List<string> { "Landscape", "Chaos" }
},
{
"Welcome_Flag_Back",
new List<string> { "Landscape", "Chaos" }
},
{
"Wizard Door Double",
new List<string> { "Portrait", "Chaos" }
},
{
"Wizard Door Double Blocked",
new List<string> { "Portrait", "Chaos" }
},
{
"Wizard Door Double Blocked Lock",
new List<string> { "Portrait", "Chaos" }
},
{
"Door Wizard",
new List<string> { "Portrait", "Chaos" }
},
{
"Shop Door",
new List<string> { "Portrait", "Chaos" }
},
{
"Door Shop WC",
new List<string> { "Portrait", "Chaos" }
},
{
"Garage Door",
new List<string> { "Landscape", "Chaos" }
},
{
"Arctic Door",
new List<string> { "Portrait", "Chaos" }
},
{
"Arctic Door Blocked",
new List<string> { "Portrait", "Chaos" }
},
{
"Museum Door",
new List<string> { "Portrait", "Chaos" }
},
{
"door base",
new List<string> { "Portrait", "Chaos" }
},
{
"Kitchen Fridge",
new List<string> { "Square", "Chaos" }
},
{
"Inflatable Hammer",
new List<string> { "Square", "Chaos" }
},
{
"Moon",
new List<string> { "Square", "Chaos" }
},
{
"Soda Machine",
new List<string> { "Landscape", "Chaos" }
},
{
"Soda Shelf Sodas",
new List<string> { "Square", "Chaos" }
},
{
"Museum valuable milk",
new List<string> { "Square", "Chaos" }
},
{
"Truck Item Shelf",
new List<string> { "Square", "Chaos" }
},
{
"Map - Truck Wall",
new List<string> { "Landscape", "Chaos" }
},
{
"Map - Truck Floor",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck Interior Front",
new List<string> { "Square", "Chaos" }
},
{
"Truck Interior Back",
new List<string> { "Square", "Chaos" }
},
{
"Truck Door",
new List<string> { "Square", "Chaos" }
},
{
"Truck",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck_0",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck Glass Not Transparent",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck Glass Not Transparent Demolished",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck Demolished",
new List<string> { "Landscape", "Chaos" }
},
{
"Truck Depot",
new List<string> { "Square", "Chaos" }
},
{
"Truck Healer",
new List<string> { "Square", "Chaos" }
},
{
"Valuable Arctic Guitar",
new List<string> { "Landscape", "Chaos" }
}
};
public CP_GroupList(CP_Logger logger)
{
this.logger = logger;
}
}
public class CP_Loader
{
private const string IMAGE_FOLDER_NAME = "CustomPaintings";
private readonly CP_Logger logger;
private readonly CP_GifManager GifManager;
public Dictionary<string, List<Material>> MaterialGroups = new Dictionary<string, List<Material>>();
private const string GRUNGE_ASSET_BUNDLE = "GrungeAssets";
private const string MATERIAL_LANDSCAPE_ASSET_NAME = "GrungeHorizontalMaterial";
private const string MATERIAL_PORTRAIT_ASSET_NAME = "GrungeVerticalMaterial";
private static Material _LandscapeMaterial;
private static Material _PortraitMaterial;
private int loadedcount = 1;
public List<Material> LoadedMaterials { get; } = new List<Material>();
public CP_Loader(CP_Logger logger, CP_GifManager GifManager)
{
this.logger = logger;
this.GifManager = GifManager;
logger.LogInfo("CP_Loader initialized.");
}
public void LoadImagesFromAllPlugins()
{
string text = Path.Combine(Paths.BepInExRootPath);
if (!Directory.Exists(text))
{
logger.LogWarning("Plugins directory not found: " + text);
return;
}
string[] directories = Directory.GetDirectories(text, "CustomPaintings", SearchOption.AllDirectories);
LoadGrungeMaterials();
BindConfigUpdates();
if (directories.Length == 0)
{
logger.LogWarning("No 'CustomPaintings' folders found in plugins.");
return;
}
string[] array = directories;
foreach (string text2 in array)
{
logger.LogInfo("Loading images from: " + text2);
LoadImagesFromDirectory(text2);
}
foreach (KeyValuePair<string, List<Material>> materialGroup in MaterialGroups)
{
LoadedMaterials.AddRange(materialGroup.Value);
}
logger.LogInfo($"Total images loaded: {LoadedMaterials.Count}");
}
private void LoadImagesFromDirectory(string directoryPath)
{
if (!Directory.Exists(directoryPath))
{
logger.LogWarning("Directory does not exist: " + directoryPath);
return;
}
string[] validExtensions = new string[6] { ".png", ".jpg", ".jpeg", ".bmp", ".gif", ".mp4" };
string[] array = (from file in Directory.EnumerateFiles(directoryPath, "*.*", SearchOption.AllDirectories)
where validExtensions.Contains(Path.GetExtension(file).ToLower())
select file).ToArray();
if (array.Length == 0)
{
logger.LogWarning("No images found in " + directoryPath);
return;
}
for (int i = 0; i < array.Length; i++)
{
string text = array[i];
string text2 = Path.GetExtension(text).ToLower();
if (text2 == ".gif" || text2 == ".mp4")
{
if (text2 == ".gif")
{
string outputPath = Path.Combine(Path.GetDirectoryName(text), Path.GetFileNameWithoutExtension(text) + "_gif.mp4");
GifManager.ConvertGifToMp4(text, outputPath);
}
continue;
}
Texture2D val = LoadTextureFromFile(text);
if ((Object)(object)val == (Object)null)
{
logger.LogWarning($"Failed to load image #{i + 1}: {text}");
continue;
}
float num = (float)((Texture)val).width / (float)((Texture)val).height;
if (num > 1.3f)
{
AddGrungeMaterial("Landscape", _LandscapeMaterial, val);
}
else if (num < 0.85714287f)
{
AddGrungeMaterial("Portrait", _PortraitMaterial, val);
}
else
{
AddGrungeMaterial("Square", _LandscapeMaterial, val);
}
logger.LogInfo($"Loaded image #{loadedcount}: {Path.GetFileName(text)}");
loadedcount++;
}
}
private Material AddGrungeMaterial(Material grungeMaterial, Texture2D texture)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if ((Object)(object)grungeMaterial == (Object)null)
{
logger.LogWarning("Falling back to default shader");
return new Material(Shader.Find("Standard"));
}
return new Material(grungeMaterial)
{
mainTexture = (Texture)(object)texture
};
}
private void AddGrungeMaterial(string paintingType, Material grungeMaterial, Texture2D texture)
{
if (!MaterialGroups.ContainsKey(paintingType))
{
MaterialGroups[paintingType] = new List<Material>();
}
Material item = AddGrungeMaterial(grungeMaterial, texture);
MaterialGroups[paintingType].Add(item);
}
private Texture2D LoadTextureFromFile(string filePath)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
byte[] array = File.ReadAllBytes(filePath);
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
SetFilterMode((Texture)(object)val);
val.Apply();
return val;
}
return null;
}
private void LoadGrungeMaterials()
{
string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = "GrungeAssets";
string text2 = Path.Combine(directoryName, text);
logger.LogInfo("Loading [" + text2 + "]");
if (File.Exists(text2))
{
logger.LogInfo("Grunge Asset Bundle exists.");
}
else
{
logger.LogWarning("Grunge Asset Bundle doesn't exist!");
}
AssetBundle val = AssetBundle.LoadFromFile(text2);
if ((Object)(object)val == (Object)null)
{
logger.LogError("Failed to load [" + text + "]!");
}
else
{
_LandscapeMaterial = val.LoadAsset<Material>("GrungeHorizontalMaterial");
if ((Object)(object)_LandscapeMaterial == (Object)null)
{
logger.LogError("Could not load landscape painting material [GrungeHorizontalMaterial]!");
}
_PortraitMaterial = val.LoadAsset<Material>("GrungeVerticalMaterial");
if ((Object)(object)_PortraitMaterial == (Object)null)
{
logger.LogError("Could not load portrait painting material [GrungeVerticalMaterial]!");
}
}
if ((Object)(object)_LandscapeMaterial != (Object)null && (Object)(object)_PortraitMaterial != (Object)null)
{
logger.LogInfo("Grunge materials successfully loaded!");
}
}
internal void BindConfigUpdates()
{
CP_Config.Grunge.State.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge.Intensity.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge._BaseColor.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge._BaseColor.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge._MainColor.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge._CracksColor.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Grunge._OutlineColor.SettingChanged += OnGrungeConfigOptionChanged;
CP_Config.Graphics.PointFiltering.SettingChanged += OnPointFilteringConfigOptionChange;
}
internal void OnPointFilteringConfigOptionChange(object sender, EventArgs e)
{
foreach (Material loadedMaterial in LoadedMaterials)
{
SetFilterMode(loadedMaterial.mainTexture);
}
}
internal void SetFilterMode(Texture texture)
{
if (CP_Config.Graphics.PointFiltering.Value)
{
texture.filterMode = (FilterMode)0;
}
else
{
texture.filterMode = (FilterMode)2;
}
}
internal void OnGrungeConfigOptionChanged(object sender, EventArgs e)
{
UpdateGrungeMaterialParameters();
}
internal void UpdateGrungeMaterialParameters()
{
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
logger.LogDebug("Updating Grunge Material Parameters...");
bool value = CP_Config.Grunge.State.Value;
float value2 = CP_Config.Grunge.Intensity.Value;
Color val = default(Color);
((Color)(ref val))..ctor(1f, 1f, 1f, value2);
logger.LogDebug($"Grunge state is [{value}]!");
logger.LogDebug($"Grunge intensity is [{value2}]!");
logger.LogDebug($"Number of loaded painting materials = [{LoadedMaterials.Count}]");
foreach (Material loadedMaterial in LoadedMaterials)
{
if ((Object)(object)loadedMaterial == (Object)null)
{
logger.LogWarning("No material found!");
}
else if (value)
{
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._BaseColor).Definition.Key, CP_Config.Grunge._BaseColor.Value);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._MainColor).Definition.Key, CP_Config.Grunge._MainColor.Value * val);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._CracksColor).Definition.Key, CP_Config.Grunge._CracksColor.Value * val);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._OutlineColor).Definition.Key, CP_Config.Grunge._OutlineColor.Value * val);
}
else
{
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._BaseColor).Definition.Key, Color.clear);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._MainColor).Definition.Key, Color.clear);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._CracksColor).Definition.Key, Color.clear);
loadedMaterial.SetColor(((ConfigEntryBase)CP_Config.Grunge._OutlineColor).Definition.Key, Color.clear);
}
}
}
}
public class CP_Logger
{
private readonly string logFilePath;
private readonly string modName;
private readonly ManualLogSource logSource;
public CP_Logger(string modName)
{
this.modName = modName;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
logFilePath = Path.Combine(directoryName, modName + "_log.txt");
if (File.Exists(logFilePath))
{
File.Delete(logFilePath);
}
logSource = Logger.CreateLogSource(modName);
}
public void LogDebug(string message)
{
WriteLog("DEBUG", message);
}
public void LogInfo(string message)
{
WriteLog("INFO", message);
}
public void LogWarning(string message)
{
WriteLog("WARNING", message);
}
public void LogError(string message)
{
WriteLog("ERROR", message);
}
private void WriteLog(string level, string message)
{
string callingClassName = GetCallingClassName();
string text = modName + "." + callingClassName;
string text2 = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [{level}] [{text}] {message}";
File.AppendAllText(logFilePath, text2 + Environment.NewLine);
ManualLogSource val = Logger.CreateLogSource(text);
switch (level)
{
case "DEBUG":
val.LogDebug((object)message);
break;
case "INFO":
val.LogInfo((object)message);
break;
case "WARNING":
val.LogWarning((object)message);
break;
case "ERROR":
val.LogError((object)message);
break;
}
}
public void LogToFileOnly(string level, string message)
{
string callingClassName = GetCallingClassName();
string text = modName + "." + callingClassName;
string text2 = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss} [{level}] [{text}] {message}";
File.AppendAllText(logFilePath, text2 + Environment.NewLine);
}
private string GetCallingClassName()
{
StackTrace stackTrace = new StackTrace();
for (int i = 2; i < stackTrace.FrameCount; i++)
{
Type declaringType = stackTrace.GetFrame(i).GetMethod().DeclaringType;
if (declaringType != typeof(CP_Logger) && declaringType != null)
{
return declaringType.Name;
}
}
return "UnknownClass";
}
public void LogMaterial(Material material)
{
if ((Object)(object)material != (Object)null && ((Object)material).name.ToLower().Contains("painting"))
{
LogInfo("Material containing 'painting': " + ((Object)material).name);
}
}
public void ClearLog()
{
if (File.Exists(logFilePath))
{
File.Delete(logFilePath);
}
}
}
public class CP_Swapper
{
public enum ModState
{
Host,
Client,
SinglePlayer
}
private readonly CP_Logger logger;
private readonly CP_Loader loader;
private readonly CP_GroupList grouper;
private static CP_Config configfile;
public static int HostSeed = 0;
public static int ReceivedSeed = 0;
public static int Seed = 0;
public static string SeperateState = "Singleplayer";
public static bool RBState = false;
public static bool ChaosState = false;
public static string ImageMode = "Normal";
private int paintingsChangedCount;
private int LandscapeChangedCount;
private int SquareChangedCount;
private int PortraitChangedCount;
private static ModState currentState = ModState.SinglePlayer;
public ModState GetModState()
{
return currentState;
}
public CP_Swapper(CP_Logger logger, CP_Loader loader, CP_GroupList grouper)
{
this.logger = logger;
this.loader = loader;
this.grouper = grouper;
logger.LogInfo("CP_Swapper initialized.");
logger.LogInfo($"Initial ModState: {currentState}");
}
public void ReplacePaintings()
{
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0405: Unknown result type (might be due to invalid IL or missing references)
if (currentState == ModState.SinglePlayer)
{
Seed = Random.Range(0, int.MaxValue);
logger.LogInfo($"Generated new random singleplayer seed: {Seed}");
}
if (currentState == ModState.Host)
{
Seed = HostSeed;
}
if (currentState == ModState.Client)
{
Seed = ReceivedSeed;
}
if ((CP_Config.ChaosMode.Value && !CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (ChaosState && CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (CP_Config.ChaosMode.Value && currentState == ModState.SinglePlayer))
{
ImageMode = "Chaos";
}
else if ((!CP_Config.ChaosMode.Value && !CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (!ChaosState && CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (!CP_Config.ChaosMode.Value && currentState == ModState.SinglePlayer))
{
if ((CP_Config.RugsAndBanners.Value && !CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (RBState && CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (CP_Config.RugsAndBanners.Value && currentState == ModState.SinglePlayer))
{
ImageMode = "RugsAndBanners";
}
else if ((!CP_Config.RugsAndBanners.Value && !CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (!RBState && CP_Config.HostControl.Value && currentState != ModState.SinglePlayer) || (!CP_Config.RugsAndBanners.Value && currentState == ModState.SinglePlayer))
{
ImageMode = "Normal";
}
}
Scene activeScene = SceneManager.GetActiveScene();
logger.LogInfo($"Applying seed {Seed} for painting swaps in scene: {((Scene)(ref activeScene)).name}");
logger.LogInfo("Replacing all paintings with custom images...");
paintingsChangedCount = 0;
int num = 0;
Scene activeScene2;
if ((!CP_Config.SeperateImages.Value && SeperateState == "Singleplayer") || (SeperateState == "off" && CP_Config.HostControl.Value) || (!CP_Config.HostControl.Value && !CP_Config.SeperateImages.Value))
{
activeScene2 = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene2)).GetRootGameObjects();
for (int i = 0; i < rootGameObjects.Length; i++)
{
MeshRenderer[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val in componentsInChildren)
{
Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
for (int k = 0; k < sharedMaterials.Length; k++)
{
num++;
string key = ((Object)sharedMaterials[k]).name.Trim();
if (CP_GroupList.MaterialNameToGroup.TryGetValue(key, out var value) && (Object)(object)sharedMaterials[k] != (Object)null && value.Contains(ImageMode) && !((Object)sharedMaterials[k]).name.Contains("Painting Frame Vertical Gold") && !((Object)sharedMaterials[k]).name.Contains("Painting Frame Horizontal Gold") && loader.LoadedMaterials.Count > 0)
{
int index = Mathf.Abs((Seed + paintingsChangedCount) % loader.LoadedMaterials.Count);
sharedMaterials[k] = loader.LoadedMaterials[index];
paintingsChangedCount++;
}
}
((Renderer)val).sharedMaterials = sharedMaterials;
}
}
}
else
{
if ((!CP_Config.SeperateImages.Value || !(SeperateState == "Singleplayer")) && (!(SeperateState == "on") || !CP_Config.HostControl.Value) && (CP_Config.HostControl.Value || !CP_Config.SeperateImages.Value))
{
return;
}
activeScene2 = SceneManager.GetActiveScene();
GameObject[] rootGameObjects = ((Scene)(ref activeScene2)).GetRootGameObjects();
for (int i = 0; i < rootGameObjects.Length; i++)
{
MeshRenderer[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<MeshRenderer>();
foreach (MeshRenderer val2 in componentsInChildren)
{
Material[] sharedMaterials2 = ((Renderer)val2).sharedMaterials;
for (int l = 0; l < sharedMaterials2.Length; l++)
{
num++;
string key2 = ((Object)sharedMaterials2[l]).name.Trim();
if (CP_GroupList.MaterialNameToGroup.TryGetValue(key2, out var value2) && (Object)(object)sharedMaterials2[l] != (Object)null && value2.Contains(ImageMode))
{
if (((Object)sharedMaterials2[l]).name.Contains("Painting Frame Vertical Gold") || ((Object)sharedMaterials2[l]).name.Contains("Painting Frame Horizontal Gold"))
{
continue;
}
if (value2.Contains("Landscape"))
{
int index2 = Mathf.Abs((Seed + LandscapeChangedCount) % loader.MaterialGroups["Landscape"].Count);
sharedMaterials2[l] = loader.MaterialGroups["Landscape"][index2];
LandscapeChangedCount++;
}
else if (value2.Contains("Square"))
{
int index3 = Mathf.Abs((Seed + SquareChangedCount) % loader.MaterialGroups["Square"].Count);
sharedMaterials2[l] = loader.MaterialGroups["Square"][index3];
SquareChangedCount++;
}
else if (value2.Contains("Portrait"))
{
int index4 = Mathf.Abs((Seed + PortraitChangedCount) % loader.MaterialGroups["Portrait"].Count);
sharedMaterials2[l] = loader.MaterialGroups["Portrait"][index4];
PortraitChangedCount++;
}
}
((Renderer)val2).sharedMaterials = sharedMaterials2;
}
}
}
logger.LogInfo($"Total materials checked: {num}");
logger.LogInfo($"Total paintings changed in this scene: {LandscapeChangedCount + SquareChangedCount + PortraitChangedCount}");
}
}
public void SetState(ModState newState)
{
currentState = newState;
logger.LogInfo($"Mod state set to: {currentState}");
}
}
public class CP_Synchroniser : MonoBehaviourPunCallbacks, IOnEventCallback
{
private readonly CP_Logger logger;
public const byte SeedEventCode = 1;
public const byte HostSettingsCode = 2;
public CP_Synchroniser(CP_Logger logger)
{
this.logger = logger;
logger.LogInfo("CP_Synchroniser initialized.");
}
public void SendSeed(int seed)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
object[] array = new object[1] { seed };
logger.LogInfo("sharing seed with other clients");
RaiseEventOptions val = new RaiseEventOptions
{
Receivers = (ReceiverGroup)1,
CachingOption = (EventCaching)4
};
PhotonNetwork.RaiseEvent((byte)1, (object)array, val, SendOptions.SendReliable);
}
public void SendHostSettings(string HostSeperateState, bool HostRBState, bool Chaosstate)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
object[] array = new object[3] { HostSeperateState, HostRBState, Chaosstate };
logger.LogInfo("sharing seperation setting");
RaiseEventOptions val = new RaiseEventOptions
{
Receivers = (ReceiverGroup)1,
CachingOption = (EventCaching)4
};
PhotonNetwork.RaiseEvent((byte)2, (object)array, val, SendOptions.SendReliable);
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == 1)
{
int num = (int)((object[])photonEvent.CustomData)[0];
logger.LogInfo($"Received seed: {num}");
CP_Swapper.ReceivedSeed = num;
}
if (photonEvent.Code == 2)
{
object[] obj = (object[])photonEvent.CustomData;
string text = (string)obj[0];
bool flag = (bool)obj[1];
bool flag2 = (bool)obj[2];
logger.LogInfo("Received seperate state: " + text);
logger.LogInfo($"Received Rug and Banner state: {flag}");
logger.LogInfo($"Received chaos state: {flag2}");
CP_Swapper.SeperateState = text;
CP_Swapper.RBState = flag;
CP_Swapper.ChaosState = flag2;
}
}
}
[BepInPlugin("UnderratedJunk.CustomPaintings", "CustomPaintings", "1.2.0")]
public class CustomPaintings : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerAvatar), "LoadingLevelAnimationCompletedRPC")]
public class PaintingSwapPatch
{
private static void Postfix()
{
Task.Run(async delegate
{
if (swapper.GetModState() == CP_Swapper.ModState.Client || swapper.GetModState() == CP_Swapper.ModState.Host)
{
int waited = 0;
int interval = 50;
while (!receivedSeed.HasValue && waited < maxWaitTimeMs)
{
await Task.Delay(interval);
waited += interval;
}
if (receivedSeed.HasValue)
{
logger.LogInfo($"[Postfix] Client using received seed: {receivedSeed.Value}");
oldreceivedSeed = CP_Swapper.ReceivedSeed;
CP_Swapper.ReceivedSeed = receivedSeed.Value;
receivedSeed = null;
}
else if (CP_Swapper.ReceivedSeed == oldreceivedSeed)
{
logger.LogWarning("[Postfix] Client did not receive seed in time. Proceeding without it.");
}
}
swapper.ReplacePaintings();
});
}
private static void Prefix()
{
if (swapper.GetModState() == CP_Swapper.ModState.Client)
{
PhotonNetwork.AddCallbackTarget((object)sync);
}
if (swapper.GetModState() == CP_Swapper.ModState.Host)
{
CP_Swapper.HostSeed = Random.Range(0, int.MaxValue);
logger.LogInfo($"Generated Hostseed: {CP_Swapper.HostSeed}");
PhotonNetwork.AddCallbackTarget((object)sync);
sync.SendSeed(CP_Swapper.HostSeed);
if (CP_Config.SeperateImages.Value)
{
sync.SendHostSettings("on", CP_Config.RugsAndBanners.Value, CP_Config.ChaosMode.Value);
}
else if (!CP_Config.SeperateImages.Value)
{
sync.SendHostSettings("off", CP_Config.RugsAndBanners.Value, CP_Config.ChaosMode.Value);
}
}
loader.UpdateGrungeMaterialParameters();
}
}
[HarmonyPatch(typeof(NetworkConnect), "TryJoiningRoom")]
public class JoinLobbyPatch
{
private static void Prefix()
{
if (swapper.GetModState() != 0)
{
swapper.SetState(CP_Swapper.ModState.Client);
}
}
}
[HarmonyPatch(typeof(SteamManager), "HostLobby")]
public class HostLobbyPatch
{
private static bool Prefix()
{
swapper.SetState(CP_Swapper.ModState.Host);
return true;
}
}
[HarmonyPatch(typeof(SteamManager), "LeaveLobby")]
public class LeaveLobbyPatch
{
private static void Postfix()
{
PhotonNetwork.RemoveCallbackTarget((object)sync);
swapper.SetState(CP_Swapper.ModState.SinglePlayer);
CP_Swapper.SeperateState = "Singleplayer";
}
}
private static CP_Logger logger;
private static CP_Loader loader;
private static CP_Swapper swapper;
private static CP_Synchroniser sync;
private static CP_GroupList grouper;
private static CP_Config configfile;
private static CP_GifManager GifManager;
public static int? receivedSeed = null;
public static int? oldreceivedSeed = null;
public static readonly int maxWaitTimeMs = 1000;
private readonly Harmony harmony = new Harmony("UnderratedJunk.CustomPaintings");
private void Awake()
{
logger = new CP_Logger("CustomPaintings");
logger.LogInfo("CustomPaintings mod initialized.");
GifManager = new CP_GifManager(logger);
CP_Config.Init(((BaseUnityPlugin)this).Config);
loader = new CP_Loader(logger, GifManager);
loader.LoadImagesFromAllPlugins();
configfile = new CP_Config();
grouper = new CP_GroupList(logger);
swapper = new CP_Swapper(logger, loader, grouper);
sync = new CP_Synchroniser(logger);
harmony.PatchAll();
}
public void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(configfile.ForceSwapKey))
{
swapper.ReplacePaintings();
}
}
}
}