Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of AlliedMonsterColors v1.0.1
AlliedMonsterColors.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; using UnityEngine.ResourceManagement.AsyncOperations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AlliedMonsterColors")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+456c560d76135f4ffece0c52409798cb373fe911")] [assembly: AssemblyProduct("AlliedMonsterColors")] [assembly: AssemblyTitle("AlliedMonsterColors")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 AlliedMonsterColors { [BepInPlugin("Alexio_Xela.AlliedMonsterColors", "AlliedMonsterColors", "1.0.1")] public class AlliedMonsterColors : BaseUnityPlugin { public const string PluginGUID = "Alexio_Xela.AlliedMonsterColors"; public const string PluginAuthor = "Alexio_Xela"; public const string PluginName = "AlliedMonsterColors"; public const string PluginVersion = "1.0.1"; public static Material colorMaterial; private static AlliedMonsterColorsConfig _config; internal static ManualLogSource log { get; set; } public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); log = ((BaseUnityPlugin)this).Logger; _config = new AlliedMonsterColorsConfig(((BaseUnityPlugin)this).Config); SetupHooks(); } public void Start() { if (Chainloader.PluginInfos.TryGetValue("com.rune580.riskofoptions", out var _)) { _config.BuildRiskOfOptionsMenu(); } } private void SetupHooks() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown CharacterModel.InitMaterials += new hook_InitMaterials(CharacterModel_InitMaterials); CharacterModel.UpdateOverlays += new hook_UpdateOverlays(CharacterModel_UpdateOverlays); } public static void config_SettingChanged(object obj, EventArgs eventArgs) { colorMaterial = setMatColorEffect(colorMaterial); } private void CharacterModel_InitMaterials(orig_InitMaterials orig) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(); AsyncOperationHandle<Material> val = LegacyResourcesAPI.LoadAsync<Material>("Materials/matGhostEffect"); val.Completed += delegate(AsyncOperationHandle<Material> x) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown colorMaterial = setMatColorEffect(new Material(x.Result)); }; } private static Material setMatColorEffect(Material material) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) material.SetColor("_TintColor", _config.RecolorTint); material.SetTexture("_RemapTex", (Texture)null); material.SetFloat("_Boost", _config.RecolorBrightness * (_config.EnableAlliedMonsterColors ? 1f : 0f)); ((Object)material).name = "matColorEffect"; return material; } private void CharacterModel_UpdateOverlays(orig_UpdateOverlays orig, CharacterModel characterModel) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 CharacterModel characterModel2 = characterModel; orig.Invoke(characterModel2); if (!_config.EnableAlliedMonsterColors || !((Object)(object)characterModel2.body != (Object)null) || !((Object)(object)characterModel2.body.master != (Object)null) || (int)characterModel2.body.master.teamIndex != 1 || characterModel2.activeOverlayCount >= CharacterModel.maxOverlays || (((Object)characterModel2.body).name.ToLower().Contains("gummy") && !_config.RecolorAlliedNonmonsters) || (characterModel2.body.isPlayerControlled && !_config.RecolorAlliedPlayers && (Object)(object)characterModel2.body.master != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedMaster)) { return; } string text = ((Object)characterModel2.body).name.ToLower(); if (!text.Contains("drone") && !text.Contains("turret")) { switch (text) { case "crosshairs": case "doc": case "chirp": break; default: goto IL_018a; } } if (!_config.RecolorAlliedNonmonsters) { return; } goto IL_018a; IL_018a: if (!text.Contains("drone") && !text.Contains("turret")) { switch (text) { default: if (!characterModel2.body.isPlayerControlled && !_config.RecolorAlliedMonsters && (text != "beetleguardallybody(clone)" || !_config.RecolorAlliedBeetles)) { return; } break; case "crosshairs": case "doc": case "chirp": break; } } if (!((Object)(object)characterModel2.body.master == (Object)(object)LocalUserManager.GetFirstLocalUser().cachedMaster) || _config.RecolorSelf) { AddOverlay(colorMaterial); } void AddOverlay(Material overlayMaterial) { Material[] currentOverlays = characterModel2.currentOverlays; CharacterModel obj = characterModel2; int activeOverlayCount = obj.activeOverlayCount; obj.activeOverlayCount = activeOverlayCount + 1; currentOverlays[activeOverlayCount] = overlayMaterial; } } } internal class AlliedMonsterColorsConfig { private readonly ConfigEntry<bool> _enableAlliedMonsterColors; private readonly ConfigEntry<Color> _recolorTint; private readonly ConfigEntry<float> _recolorBrightness; private readonly ConfigEntry<bool> _recolorAlliedBeetles; private readonly ConfigEntry<bool> _recolorAlliedMonsters; private readonly ConfigEntry<bool> _recolorAlliedNonmonsters; private readonly ConfigEntry<bool> _recolorAlliedPlayers; private readonly ConfigEntry<bool> _recolorSelf; public bool EnableAlliedMonsterColors => _enableAlliedMonsterColors.Value; public Color RecolorTint => _recolorTint.Value; public float RecolorBrightness => _recolorBrightness.Value; public bool RecolorAlliedBeetles => _recolorAlliedBeetles.Value; public bool RecolorAlliedMonsters => _recolorAlliedMonsters.Value; public bool RecolorAlliedNonmonsters => _recolorAlliedNonmonsters.Value; public bool RecolorAlliedPlayers => _recolorAlliedPlayers.Value; public bool RecolorSelf => _recolorSelf.Value; public AlliedMonsterColorsConfig(ConfigFile config) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) _enableAlliedMonsterColors = config.Bind<bool>("General", "EnableAlliedMonsterColors", true, "Enables/Disables the entire mod."); _recolorTint = config.Bind<Color>("General", "RecolorTint", Color.green, "Sets the new color for the selected entities."); _recolorBrightness = config.Bind<float>("General", "RecolorBrightness", 0.5f, "Sets the recolor brightness for the selected entities. (Setting to 0.0 makes the recolor not visible.)"); _recolorAlliedBeetles = config.Bind<bool>("General", "RecolorAlliedBeetles", true, "Maybe you think most allied monsters look fine, but just the Queen's Gland Beetle Guards look too similar? This option only colors the Queen's Gland spawns."); _recolorAlliedMonsters = config.Bind<bool>("General", "RecolorAlliedMonsters", true, "Recolors allied monsters (e.g. Happiest Mask ghosts)."); _recolorAlliedNonmonsters = config.Bind<bool>("General", "RecolorAlliedNonmonsters", false, "Recolors allied non-monsters (e.g. turrets/drones)."); _recolorAlliedPlayers = config.Bind<bool>("General", "RecolorAlliedPlayers", false, "Recolors allied players (if playing multiplayer)."); _recolorSelf = config.Bind<bool>("General", "RecolorSelf", false, "Recolors self (since you are your own ally)."); _enableAlliedMonsterColors.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorTint.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorBrightness.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorAlliedMonsters.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorAlliedNonmonsters.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorAlliedPlayers.SettingChanged += AlliedMonsterColors.config_SettingChanged; _recolorSelf.SettingChanged += AlliedMonsterColors.config_SettingChanged; } public void BuildRiskOfOptionsMenu() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //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_016e: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown byte[] array = File.ReadAllBytes(Assembly.GetExecutingAssembly().Location.Replace("AlliedMonsterColors.dll", "") + "icon.png"); Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, array); Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_enableAlliedMonsterColors, new CheckBoxConfig { description = "Enables/Disables the entire mod." })); ModSettingsManager.AddOption((BaseOption)new ColorOption(_recolorTint, new ColorOptionConfig { description = "Sets the new color for the selected entities." })); ModSettingsManager.AddOption((BaseOption)new SliderOption(_recolorBrightness, new SliderConfig { min = 0.1f, max = 20f, FormatString = "{0:0.0}", description = "Sets the recolor brightness for the selected entities." })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_recolorAlliedBeetles, new CheckBoxConfig { description = "Maybe you think most allied monsters look fine, but just the Queen's Gland Beetle Guards look too similar? This option only colors the Queen's Gland spawns." })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_recolorAlliedMonsters, new CheckBoxConfig { description = "Recolors allied monsters (e.g. Happiest Mask ghosts)." })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_recolorAlliedNonmonsters, new CheckBoxConfig { description = "Recolors allied drones/turrets." })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_recolorAlliedPlayers, new CheckBoxConfig { description = "Recolors allied players (if playing multiplayer)." })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(_recolorSelf, new CheckBoxConfig { description = "Recolors self (since you are your own ally, I suppose)." })); ModSettingsManager.SetModDescription("A Risk of Rain 2 mod to recolor allied units so they're easier to see, especially monsters so you know they're allied."); ModSettingsManager.SetModIcon(modIcon); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } }