using System;
using System.Collections;
using System.Collections.Generic;
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 DanteMod.Modules;
using GhoulMod.Survivors.Ghoul;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using UnityEngine;
[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("dteeicons")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+af88bd34a276dc1015379af23d29e3f7fdcfdffe")]
[assembly: AssemblyProduct("dteeicons")]
[assembly: AssemblyTitle("dteeicons")]
[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 dteeicons
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("DTEE.Icons", "Icons", "1.4.8")]
public class dteeicons : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass27_0
{
public CharacterBody body;
public dteeicons <>4__this;
}
private const string PluginGUID = "DTEE.Icons";
private const string PluginAuthor = "DTEE";
private const string PluginName = "Icons";
private const string PluginVersion = "1.4.8";
private static AssetBundle assetBundle;
private static Dictionary<string, string> iconOverrides;
private readonly Dictionary<string, Texture2D> loadedTextures = new Dictionary<string, Texture2D>();
private readonly Dictionary<SurvivorIconController, int> lastSeenSkin = new Dictionary<SurvivorIconController, int>();
private static readonly Dictionary<SurvivorIconController, SurvivorDef> lastSeenSurvivor = new Dictionary<SurvivorIconController, SurvivorDef>();
private BuffIndex ChirrFriend = (BuffIndex)(-1);
private BuffIndex RalseiFriend = (BuffIndex)(-1);
private Texture2D GhostTexture;
private Texture2D GooboTexture;
private Texture2D ChirrFriendTexture;
private Texture2D RalseiFriendTexture;
public static ConfigEntry<bool> RunExtras { get; set; }
public static ConfigEntry<bool> SkinSpecificIcons { get; set; }
public static ConfigEntry<bool> AggressiveLogging { get; set; }
public void Start()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
RunExtras = ((BaseUnityPlugin)this).Config.Bind<bool>("Runtime Asset Changes", "Enable Runtime Assets", true, "Enables asset changes that would occur after loading the game. This enables compatibility for items like Halcyon Seed, Happiest Mask, and Goobo Jr! This may have minor performance impacts, as I'm still working out the code.");
SkinSpecificIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("Skin-Specific Icons", "Enable Skin Icons", true, "Enables icons to be loaded in specific scenarios so that skins have their own icons. Haven't made a lot of assets for this, so this is mostly for my testing...");
AggressiveLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Aggressive Logging", "Enable Aggressive Logging", false, "Enables logging in a lot more situations. This is mostly for debugging purposes, but maybe you like watching text scroll!");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(RunExtras));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(SkinSpecificIcons));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(AggressiveLogging));
ModSettingsManager.SetModDescription("This mod replaces in-game renders with hand drawn art assets.");
assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "dteeicons.bundle"));
Sprite modIcon = assetBundle.LoadAsset<Sprite>("Assets/DevotedLemurian.png");
ModSettingsManager.SetModIcon(modIcon);
GhostTexture = assetBundle.LoadAsset<Texture2D>("Assets/HappiestMask.png");
GooboTexture = assetBundle.LoadAsset<Texture2D>("Assets/Goobo.png");
ChirrFriendTexture = assetBundle.LoadAsset<Texture2D>("Assets/BuffChirrFriend.png");
RalseiFriendTexture = assetBundle.LoadAsset<Texture2D>("Assets/RalseiEmpower.png");
SetupHooks();
SetUpImageOverrides();
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyPortraitIcons));
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
ChirrFriend = BuffCatalog.FindBuffIndex("BuffChirrFriend");
RalseiFriend = BuffCatalog.FindBuffIndex("RalseiEmpower");
});
if (RunExtras.Value)
{
CharacterBody.onBodyStartGlobal += delegate(CharacterBody body)
{
<>c__DisplayClass27_0 CS$<>8__locals0 = new <>c__DisplayClass27_0();
CS$<>8__locals0.<>4__this = this;
CS$<>8__locals0.body = body;
((MonoBehaviour)this).StartCoroutine(StupidDelayTrick());
[IteratorStateMachine(typeof(<>c__DisplayClass27_0.<<Start>g__StupidDelayTrick|2>d))]
IEnumerator StupidDelayTrick()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <>c__DisplayClass27_0.<<Start>g__StupidDelayTrick|2>d(0)
{
<>4__this = CS$<>8__locals0
};
}
};
}
if (Chainloader.PluginInfos.ContainsKey("com.rob.Dante"))
{
((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)LoadDanteAssets);
}
if (Chainloader.PluginInfos.ContainsKey("com.vcr.GhoulSurvMod"))
{
((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)LoadGhoulAssets);
}
if (RunExtras.Value)
{
CharacterBody.AddBuff_BuffIndex += new hook_AddBuff_BuffIndex(Friendship_Check);
}
}
private void SetUpImageOverrides()
{
iconOverrides = new Dictionary<string, string>
{
["Drone1BodyRemoteOp"] = "Drone1",
["Drone2BodyRemoteOp"] = "Drone2",
["Turret1BodyRemoteOp"] = "Turret1",
["EmergencyDroneBodyRemoteOp"] = "EmergencyDrone",
["JunkDroneBodyRemoteOp"] = "JunkDrone",
["HaulerDroneBodyRemoteOp"] = "HaulerDrone",
["RechargeDroneBodyRemoteOp"] = "RechargeDrone",
["JailerDroneBodyRemoteOp"] = "JailerDrone",
["MegaDroneBodyRemoteOp"] = "MegaDrone",
["FlameDroneBodyRemoteOp"] = "FlameDrone",
["MissileDroneBodyRemoteOp"] = "MissileDrone",
["BombardmentDroneBodyRemoteOp"] = "BombardmentDrone",
["CleanupDroneBodyRemoteOp"] = "CleanupDrone",
["CopycatDroneBodyRemoteOp"] = "CopycatDrone",
["ShockDroneBodyRemoteOp"] = "ShockDrone",
["VoltaicDroneBodyRemoteOp"] = "VoltaicDrone",
["InfernoDroneBodyRemoteOp"] = "InfernoDrone",
["BackupDroneBodyRemoteOp"] = "BackupDrone",
["MechanicalSpiderTurretBody"] = "MechanicalSpiderDrone",
["VoidRaidCrabBody"] = "VoidRaidCrab",
["MiniVoidRaidCrabBodyBase"] = "VoidRaidCrab",
["MiniVoidRaidCrabBodyPhase1"] = "VoidRaidCrab",
["MiniVoidRaidCrabBodyPhase2"] = "VoidRaidCrab",
["MiniVoidRaidCrabBodyPhase3"] = "VoidRaidCrab",
["FalseSonBossBody"] = "FalseSonBoss",
["FalseSonBossBodyLunarShard"] = "FalseSonBoss",
["FalseSonBossBodyBrokenLunarShard"] = "FalseSonBoss"
};
if (Chainloader.PluginInfos.ContainsKey("com.BigBadPigeon.DressUpMithrix"))
{
iconOverrides["BrotherBody"] = "BrotherClothed";
iconOverrides["BrotherGlassBody"] = "BrotherClothed";
iconOverrides["BrotherHauntBody"] = "BrotherClothed";
iconOverrides["BrotherHurtBody"] = "BrotherClothed";
iconOverrides["ITBrotherBody"] = "BrotherClothed";
}
else
{
iconOverrides["BrotherBody"] = "Brother";
iconOverrides["BrotherGlassBody"] = "Brother";
iconOverrides["BrotherHauntBody"] = "Brother";
iconOverrides["BrotherHurtBody"] = "Brother";
iconOverrides["ITBrotherBody"] = "Brother";
}
}
private void ApplyPortraitIcons()
{
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
{
if ((Object)(object)allBodyPrefab == (Object)null)
{
continue;
}
string name = ((Object)allBodyPrefab).name;
if (!iconOverrides.TryGetValue(name, out var value))
{
string text;
if (!name.EndsWith("Body"))
{
text = name;
}
else
{
string text2 = name;
text = text2.Substring(0, text2.Length - 4);
}
value = text;
}
string text3 = "Assets/" + value + ".png";
CharacterBody component = allBodyPrefab.GetComponent<CharacterBody>();
if ((Object)(object)component == (Object)null)
{
if (AggressiveLogging.Value)
{
Log.Error("CharacterBody for " + ((Object)allBodyPrefab).name + " returned null!");
}
continue;
}
Texture2D cachedTexture = GetCachedTexture(text3, null);
if ((Object)(object)cachedTexture == (Object)null)
{
if (AggressiveLogging.Value)
{
Log.Error("Failed to load texture for body " + name + " under path " + text3 + "!");
}
continue;
}
Log.Message("Successfully found texture for " + name + " under path " + text3 + "!");
if ((Object)(object)component.portraitIcon == (Object)null)
{
if (AggressiveLogging.Value)
{
Log.Debug("Pre-existing Portrait icon for " + name + " is null, and may be getting overriden at a later point.");
}
continue;
}
component.portraitIcon = (Texture)(object)cachedTexture;
if (name == "RobHunkBody")
{
string text4 = ((Language.GetString("ROB_HUNK_BODY_NAME") == "Specialist") ? "Assets/RobSpecialist.png" : "Assets/RobHunk.png");
Texture2D cachedTexture2 = GetCachedTexture(text4, null);
if (Object.op_Implicit((Object)(object)cachedTexture2))
{
component.portraitIcon = (Texture)(object)cachedTexture2;
if (AggressiveLogging.Value)
{
Log.Debug("[Startup] Set HUNK base portrait to: " + text4);
}
}
}
DroneDef val = DroneCatalog.FindDroneDefFromBody(allBodyPrefab);
if ((Object)(object)val != (Object)null)
{
Log.Debug("DroneDef found for " + name + ".");
val.iconSprite = Sprite.Create(cachedTexture, new Rect(0f, 0f, (float)((Texture)cachedTexture).width, (float)((Texture)cachedTexture).height), new Vector2(0.5f, 0.5f));
}
}
}
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
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
SurvivorIconController.Update += (hook_Update)delegate(orig_Update orig, SurvivorIconController self)
{
orig.Invoke(self);
if (SkinSpecificIcons.Value && Object.op_Implicit((Object)(object)self.survivorDef))
{
ApplyLobbyIcon(self);
}
};
CharacterSelectController.OnDisable += (hook_OnDisable)delegate(orig_OnDisable orig, CharacterSelectController self)
{
orig.Invoke(self);
lastSeenSkin.Clear();
lastSeenSurvivor.Clear();
};
CharacterBody.Start += (hook_Start)delegate(orig_Start orig, CharacterBody self)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Invalid comparison between Unknown and I4
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Invalid comparison between Unknown and I4
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Invalid comparison between Unknown and I4
orig.Invoke(self);
if ((int)self.bodyIndex != -1)
{
if (self.bodyIndex == BodyCatalog.FindBodyIndex("TitanGoldBody") || self.bodyIndex == BodyCatalog.FindBodyIndex("VerminBody"))
{
if (AggressiveLogging.Value)
{
Log.Debug("Special case found!");
}
}
else
{
if (Object.op_Implicit((Object)(object)self.master) && Object.op_Implicit((Object)(object)self.master.inventory))
{
if (self.master.inventory.GetItemCountPermanent(Items.GummyCloneIdentifier) > 0 && (int)self.teamComponent.teamIndex == 1)
{
if (AggressiveLogging.Value)
{
Log.Debug("Goo found! Skipping skin-specific icon.");
}
return;
}
if (self.master.inventory.GetItemCountPermanent(Items.Ghost) > 0 && (int)self.teamComponent.teamIndex == 1)
{
if (AggressiveLogging.Value)
{
Log.Debug("Ghost found! Skipping skin-specific icon.");
}
return;
}
}
if ((int)self.teamComponent.teamIndex == 1)
{
ApplyDynamicIcon(self.bodyIndex, (int)self.skinIndex, delegate(Texture2D tex)
{
self.portraitIcon = (Texture)(object)tex;
}, "Body Loaded!");
}
}
}
};
}
private void ApplyLobbyIcon(SurvivorIconController self)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)self.survivorDef) || !Object.op_Implicit((Object)(object)self.survivorDef.bodyPrefab))
{
return;
}
SurvivorDef value;
bool flag = !lastSeenSurvivor.TryGetValue(self, out value) || (Object)(object)value != (Object)(object)self.survivorDef;
BodyIndex val = BodyCatalog.FindBodyIndex(self.survivorDef.bodyPrefab);
LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
if (firstLocalUser == null)
{
return;
}
int skinIndex = (int)firstLocalUser.userProfile.loadout.bodyLoadoutManager.GetSkinIndex(val);
if (!flag && lastSeenSkin.TryGetValue(self, out var value2) && value2 == skinIndex)
{
return;
}
lastSeenSurvivor[self] = self.survivorDef;
lastSeenSkin[self] = skinIndex;
ApplyDynamicIcon(val, skinIndex, delegate(Texture2D tex)
{
if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.survivorIcon))
{
self.survivorIcon.texture = (Texture)(object)tex;
}
}, "Lobby changed!");
}
private void ApplyDynamicIcon(BodyIndex bIndex, int sIndex, Action<Texture2D> applyAction, string logPrefix)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
SkinDef bodySkinDef = SkinCatalog.GetBodySkinDef(bIndex, sIndex);
if (!Object.op_Implicit((Object)(object)bodySkinDef))
{
return;
}
string bodyName = BodyCatalog.GetBodyName(bIndex);
if (bodyName == "RobDanteBody" || bodyName == "VcrGhoulBody")
{
return;
}
if (!iconOverrides.TryGetValue(bodyName, out var value))
{
string text;
if (!bodyName.EndsWith("Body"))
{
text = bodyName;
}
else
{
string text2 = bodyName;
text = text2.Substring(0, text2.Length - 4);
}
value = text;
}
string text3 = "Assets/" + value + ((Object)bodySkinDef).name + ".png";
string fallbackPath = "Assets/" + value + ".png";
if (AggressiveLogging.Value)
{
Log.Debug(logPrefix + " Body: " + bodyName + " | Skin: " + ((Object)bodySkinDef).name + " | Path: " + text3);
}
if (bodyName == "RobHunkBody")
{
string path = ((Language.GetString("ROB_HUNK_BODY_NAME") == "HUNK") ? "Assets/RobHunk.png" : "Assets/RobSpecialist.png");
Texture2D cachedTexture = GetCachedTexture(path, null);
if (Object.op_Implicit((Object)(object)cachedTexture))
{
applyAction(cachedTexture);
}
}
else
{
Texture2D cachedTexture2 = GetCachedTexture(text3, fallbackPath);
if (Object.op_Implicit((Object)(object)cachedTexture2))
{
applyAction(cachedTexture2);
}
}
}
private Texture2D GetCachedTexture(string path, string fallbackPath)
{
if (loadedTextures.TryGetValue(path, out var value))
{
return value;
}
if (assetBundle.Contains(path))
{
value = assetBundle.LoadAsset<Texture2D>(path);
loadedTextures.Add(path, value);
}
else if (!string.IsNullOrEmpty(fallbackPath) && assetBundle.Contains(fallbackPath))
{
if (loadedTextures.TryGetValue(fallbackPath, out value))
{
return value;
}
value = assetBundle.LoadAsset<Texture2D>(fallbackPath);
loadedTextures.Add(fallbackPath, value);
}
return value;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private void LoadDanteAssets()
{
DanteAssets.danteIcon = assetBundle.LoadAsset<Sprite>("Assets/RobDante.png");
DanteAssets.danteDevilIcon = assetBundle.LoadAsset<Sprite>("Assets/RobDante.png");
DanteAssets.leonIcon = assetBundle.LoadAsset<Sprite>("Assets/RobSpecialist.png");
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private void LoadGhoulAssets()
{
GhoulAssets.baseIcon = (Texture)(object)assetBundle.LoadAsset<Sprite>("Assets/VcrGhoul.png").texture;
}
private void Friendship_Check(orig_AddBuff_BuffIndex orig, CharacterBody self, BuffIndex addedBuffIndex)
{
//IL_0031: 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_003f: Invalid comparison between Unknown and I4
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
bool isPlayerControlled = self.isPlayerControlled;
bool flag = Object.op_Implicit((Object)(object)self.master) && (Object)(object)self.master.minionOwnership.ownerMaster != (Object)null;
orig.Invoke(self, addedBuffIndex);
if ((int)ChirrFriend != -1 && addedBuffIndex == ChirrFriend)
{
if (AggressiveLogging.Value)
{
Log.Message("That's a friend!");
}
self.portraitIcon = (Texture)(object)ChirrFriendTexture;
}
if ((int)RalseiFriend != -1 && addedBuffIndex == RalseiFriend && !isPlayerControlled && !flag)
{
if (AggressiveLogging.Value)
{
Log.Message("That's a friend!");
}
self.portraitIcon = (Texture)(object)RalseiFriendTexture;
}
}
}
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);
}
}
}